aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values/dimens.xml2
-rw-r--r--java/res/values/keypress-vibration-durations.xml2
-rw-r--r--java/res/values/strings.xml6
-rw-r--r--java/res/xml/prefs.xml7
-rw-r--r--java/res/xml/rowkeys_hindi1.xml66
-rw-r--r--java/res/xml/rowkeys_hindi2.xml66
-rw-r--r--java/res/xml/rowkeys_hindi3.xml51
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java72
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java18
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java13
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java24
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java25
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java81
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java5
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/FormatSpec.java3
16 files changed, 310 insertions, 135 deletions
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 0fb8877a9..c7d993698 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -100,7 +100,7 @@
<fraction name="center_suggestion_percentile">36%</fraction>
<!-- Gesture preview trail parameters -->
- <dimen name="gesture_preview_trail_start_width">18.0dp</dimen>
+ <dimen name="gesture_preview_trail_start_width">12.6dp</dimen>
<dimen name="gesture_preview_trail_end_width">2.5dp</dimen>
<!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">24dp</dimen>
diff --git a/java/res/values/keypress-vibration-durations.xml b/java/res/values/keypress-vibration-durations.xml
index 1d7e57bce..370959c1a 100644
--- a/java/res/values/keypress-vibration-durations.xml
+++ b/java/res/values/keypress-vibration-durations.xml
@@ -22,7 +22,7 @@
<!-- Build.HARDWARE,duration_in_milliseconds -->
<item>herring,5</item>
<item>tuna,5</item>
- <item>mako,20</item>
+ <item>mako,5</item>
<item>manta,16</item>
</string-array>
</resources>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index bd60844a3..392a0705a 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -61,8 +61,10 @@
<string name="include_other_imes_in_language_switch_list">Switch to other input methods</string>
<!-- Option summary for including other IMEs in the language switch list [CHAR LIMIT=65] -->
<string name="include_other_imes_in_language_switch_list_summary">Language switch key covers other input methods too</string>
- <!-- Option to suppress language switch key [CHAR LIMIT=30] -->
- <string name="suppress_language_switch_key">Suppress language switch key</string>
+ <!-- Option to show language switch key [CHAR LIMIT=30] -->
+ <string name="show_language_switch_key">Language switch key</string>
+ <!-- Option summary for showing language switch key [CHAR LIMIT=65] -->
+ <string name="show_language_switch_key_summary">Show when multiple input languages are enabled</string>
<!-- Option for the dismiss delay of the key popup [CHAR LIMIT=25] -->
<string name="key_preview_popup_dismiss_delay">Key popup dismiss delay</string>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index f7c993d9d..3e83fc0fc 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -108,10 +108,11 @@
android:persistent="true"
android:defaultValue="true" />
<CheckBoxPreference
- android:key="pref_suppress_language_switch_key"
- android:title="@string/suppress_language_switch_key"
+ android:key="pref_show_language_switch_key"
+ android:title="@string/show_language_switch_key"
+ android:summary="@string/show_language_switch_key_summary"
android:persistent="true"
- android:defaultValue="false" />
+ android:defaultValue="true" />
<CheckBoxPreference
android:key="pref_include_other_imes_in_language_switch_list"
android:title="@string/include_other_imes_in_language_switch_list"
diff --git a/java/res/xml/rowkeys_hindi1.xml b/java/res/xml/rowkeys_hindi1.xml
index 656ba01c4..11208045c 100644
--- a/java/res/xml/rowkeys_hindi1.xml
+++ b/java/res/xml/rowkeys_hindi1.xml
@@ -29,50 +29,61 @@
U+0912/U+0902: "ऒं" DEVANAGARI LETTER SHORT O//DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="&#x0914;"
- latin:moreKeys="&#x0912;&#x0902;" />
+ latin:moreKeys="&#x0912;&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0910: "ऐ" DEVANAGARI LETTER AI
U+0910/U+0902: "ऐं" DEVANAGARI LETTER AI/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="&#x0910;"
- latin:moreKeys="&#x0910;&#x0902;" />
+ latin:moreKeys="&#x0910;&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0906: "आ" DEVANAGARI LETTER AA
U+0906/U+0902: "आं" DEVANAGARI LETTER AA/DEVANAGARI SIGN ANUSVARA
U+0906/U+0901: "आँ" DEVANAGARI LETTER AA/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x0906;"
- latin:moreKeys="&#x0906;&#x0902;,&#x0906;&#x0901;" />
+ latin:moreKeys="&#x0906;&#x0902;,&#x0906;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0908: "ई" DEVANAGARI LETTER II
U+0908/U+0902: "ईं" DEVANAGARI LETTER II/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="&#x0908;"
- latin:moreKeys="&#x0908;&#x0902;" />
+ latin:moreKeys="&#x0908;&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+090A: "ऊ" DEVANAGARI LETTER UU
U+090A/U+0902: "ऊं" DEVANAGARI LETTER UU/DEVANAGARI SIGN ANUSVARA
U+090A/U+0901: "ऊँ" DEVANAGARI LETTER UU/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x090A;"
- latin:moreKeys="&#x090A;&#x0902;,&#x090A;&#x0901;" />
+ latin:moreKeys="&#x090A;&#x0902;,&#x090A;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092D: "भ" DEVANAGARI LETTER BHA -->
<Key
- latin:keyLabel="&#x092D;" />
+ latin:keyLabel="&#x092D;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0903: "ः" DEVANAGARI SIGN VISARGA -->
<Key
- latin:keyLabel="&#x0903;" />
+ latin:keyLabel="&#x0903;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0918: "घ" DEVANAGARI LETTER GHA -->
<Key
- latin:keyLabel="&#x0918;" />
+ latin:keyLabel="&#x0918;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0927: "ध" DEVANAGARI LETTER DHA
U+0915/U+094D/U+0937: "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA
U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
<Key
latin:keyLabel="&#x0927;"
- latin:moreKeys="&#x0915;&#x094D;&#x0937;,&#x0936;&#x094D;&#x0930;" />
+ latin:moreKeys="&#x0915;&#x094D;&#x0937;,&#x0936;&#x094D;&#x0930;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091D: "झ" DEVANAGARI LETTER JHA -->
<Key
- latin:keyLabel="&#x091D;" />
+ latin:keyLabel="&#x091D;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0922: "ढ" DEVANAGARI LETTER DDHA -->
<Key
- latin:keyLabel="&#x0922;" />
+ latin:keyLabel="&#x0922;"
+ latin:keyLabelFlags="fontNormal" />
</case>
<default>
<!-- U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
@@ -82,7 +93,8 @@
latin:keyLabel="&#x094C;"
latin:moreKeys="&#x094C;&#x0902;,%"
latin:keyHintLabel="1"
- latin:additionalMoreKeys="&#x0967;,1" />
+ latin:additionalMoreKeys="&#x0967;,1"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0948: "ै" DEVANAGARI VOWEL SIGN AI
U+0948/U+0902: "ैं" DEVANAGARI VOWEL SIGN AI/DEVANAGARI SIGN ANUSVARA
U+0968: "२" DEVANAGARI DIGIT TWO -->
@@ -90,7 +102,8 @@
latin:keyLabel="&#x0948;"
latin:moreKeys="&#x0948;&#x0902;,%"
latin:keyHintLabel="2"
- latin:additionalMoreKeys="&#x0968;,2" />
+ latin:additionalMoreKeys="&#x0968;,2"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+093E: "ा" DEVANAGARI VOWEL SIGN AA
U+093E/U+0902: "ां" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN ANUSVARA
U+093E/U+0901: "ाँ" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN CANDRABINDU
@@ -99,7 +112,8 @@
latin:keyLabel="&#x093E;"
latin:moreKeys="&#x093E;&#x0902;,&#x093E;&#x0901;,%"
latin:keyHintLabel="3"
- latin:additionalMoreKeys="&#x0969;,3" />
+ latin:additionalMoreKeys="&#x0969;,3"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0940: "ी" DEVANAGARI VOWEL SIGN II
U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA
U+096A: "४" DEVANAGARI DIGIT FOUR -->
@@ -107,7 +121,8 @@
latin:keyLabel="&#x0940;"
latin:moreKeys="&#x0940;&#x0902;,%"
latin:keyHintLabel="4"
- latin:additionalMoreKeys="&#x096A;,4" />
+ latin:additionalMoreKeys="&#x096A;,4"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0942: "ू" DEVANAGARI VOWEL SIGN UU
U+0942/U+0902: "ूं" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN ANUSVARA
U+0942/U+0901: "ूँ" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN CANDRABINDU
@@ -116,20 +131,23 @@
latin:keyLabel="&#x0942;"
latin:moreKeys="&#x0942;&#x0902;,&#x0942;&#x0901;,%"
latin:keyHintLabel="5"
- latin:additionalMoreKeys="&#x096B;,5" />
+ latin:additionalMoreKeys="&#x096B;,5"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092C: "ब" DEVANAGARI LETTER BA
U+092C/U+0952: "ब॒" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA -->
<Key
latin:keyLabel="&#x092C;"
latin:moreKeys="&#x092C;&#x0952;,%"
latin:keyHintLabel="6"
- latin:additionalMoreKeys="&#x096C;,6" />
+ latin:additionalMoreKeys="&#x096C;,6"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0939: "ह" DEVANAGARI LETTER HA
U+096D: "७" DEVANAGARI DIGIT SEVEN -->
<Key
latin:keyLabel="&#x0939;"
latin:keyHintLabel="7"
- latin:additionalMoreKeys="&#x096D;,7" />
+ latin:additionalMoreKeys="&#x096D;,7"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0917: "ग" DEVANAGARI LETTER GA
U+091C/U+094D/U+091E: "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
U+0917/U+093C: "ग़" DEVANAGARI LETTER GA/DEVANAGARI SIGN NUKTA
@@ -139,13 +157,15 @@
latin:keyLabel="&#x0917;"
latin:moreKeys="&#x091C;&#x094D;&#x091E;,&#x0917;&#x093C;,&#x0917;&#x0952;,%"
latin:keyHintLabel="8"
- latin:additionalMoreKeys="&#x096E;,8" />
+ latin:additionalMoreKeys="&#x096E;,8"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0926: "द" DEVANAGARI LETTER DA
U+096F: "९" DEVANAGARI DIGIT NINE -->
<Key
latin:keyLabel="&#x0926;"
latin:keyHintLabel="9"
- latin:additionalMoreKeys="9" />
+ latin:additionalMoreKeys="9"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091C: "ज" DEVANAGARI LETTER JA
U+091C/U+0952: "ज॒" DEVANAGARI LETTER JA/DEVANAGARI STRESS SIGN ANUDATTA
U+091C/U+094D/U+091E: "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
@@ -155,13 +175,15 @@
latin:keyLabel="&#x091C;"
latin:moreKeys="&#x091C;&#x0952;,&#x091C;&#x094D;&#x091E;,&#x091C;&#x093C;,%"
latin:keyHintLabel="0"
- latin:additionalMoreKeys="&#x0966;,0" />
+ latin:additionalMoreKeys="&#x0966;,0"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0921: "ड" DEVANAGARI LETTER DDA
U+0921/U+0952: "ड॒" DEVANAGARI LETTER DDA/DEVANAGARI STRESS SIGN ANUDATTA
U+0921/U+093C: "ड़" DEVANAGARI LETTER DDA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="&#x0921;"
- latin:moreKeys="&#x0921;&#x0952;,&#x0921;&#x093C;" />
+ latin:moreKeys="&#x0921;&#x0952;,&#x0921;&#x093C;"
+ latin:keyLabelFlags="fontNormal" />
</default>
</switch>
</merge>
diff --git a/java/res/xml/rowkeys_hindi2.xml b/java/res/xml/rowkeys_hindi2.xml
index 05e3db202..e7c67dbe7 100644
--- a/java/res/xml/rowkeys_hindi2.xml
+++ b/java/res/xml/rowkeys_hindi2.xml
@@ -31,7 +31,8 @@
U+0912: "ऒ" DEVANAGARI LETTER SHORT O -->
<Key
latin:keyLabel="&#x0913;"
- latin:moreKeys="&#x0913;&#x0902;,&#x0911;,&#x0912;" />
+ latin:moreKeys="&#x0913;&#x0902;,&#x0911;,&#x0912;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+090F: "ए" DEVANAGARI LETTER E
U+090F/U+0902: "एं" DEVANAGARI LETTER E/DEVANAGARI SIGN ANUSVARA
U+090F/U+0901: "एँ" DEVANAGARI LETTER E/DEVANAGARI SIGN CANDRABINDU
@@ -39,50 +40,60 @@
U+090E: "ऎ" DEVANAGARI LETTER SHORT E -->
<Key
latin:keyLabel="&#x090F;"
- latin:moreKeys="&#x090F;&#x0902;,&#x090F;&#x0901;,&#x090D;,&#x090E;" />
+ latin:moreKeys="&#x090F;&#x0902;,&#x090F;&#x0901;,&#x090D;,&#x090E;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0905: "अ" DEVANAGARI LETTER A
U+0905/U+0902: "अं" DEVANAGARI LETTER A/DEVANAGARI SIGN ANUSVARA
U+0905/U+0901: "अँ" DEVANAGARI LETTER A/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x0905;"
- latin:moreKeys="&#x0905;&#x0902;,&#x0905;&#x0901;" />
+ latin:moreKeys="&#x0905;&#x0902;,&#x0905;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0907: "इ" DEVANAGARI LETTER I
U+0907/U+0902: "इं" DEVANAGARI LETTER I/DEVANAGARI SIGN ANUSVARA
U+0907/U+0901: "इं" DEVANAGARI LETTER I/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x0907;"
- latin:moreKeys="&#x0907;&#x0902;,&#x0907;&#x0901;" />
+ latin:moreKeys="&#x0907;&#x0902;,&#x0907;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0909: "उ" DEVANAGARI LETTER U
U+0909/U+0902: "उं" DEVANAGARI LETTER U/DEVANAGARI SIGN ANUSVARA
U+0909/U+0901: "उँ" DEVANAGARI LETTER U/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x0909;"
- latin:moreKeys="&#x0909;&#x0902;,&#x0909;&#x0901;" />
+ latin:moreKeys="&#x0909;&#x0902;,&#x0909;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092B: "फ" DEVANAGARI LETTER PHA
U+092B/U+093C: "फ़" DEVANAGARI LETTER PHA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="&#x092B;"
- latin:moreKeys="&#x092B;&#x093C;" />
+ latin:moreKeys="&#x092B;&#x093C;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0931: "ऱ" DEVANAGARI LETTER RRA
U+094D/U+0930: "्र" DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
U+0930/U+094D: "र्" DEVANAGARI LETTER RA/DEVANAGARI SIGN VIRAMA -->
<Key
latin:keyLabel="&#x0931;"
- latin:moreKeys="&#x094D;&#x0930;,&#x0930;&#x094D;" />
+ latin:moreKeys="&#x094D;&#x0930;,&#x0930;&#x094D;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0916: "ख" DEVANAGARI LETTER KHA
U+0916/U+093C: "ख़" DEVANAGARI LETTER KHA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="&#x0916;"
- latin:moreKeys="&#x0916;&#x093C;" />
+ latin:moreKeys="&#x0916;&#x093C;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0925: "थ" DEVANAGARI LETTER THA -->
<Key
- latin:keyLabel="&#x0925;" />
+ latin:keyLabel="&#x0925;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091B: "छ" DEVANAGARI LETTER CHA -->
<Key
- latin:keyLabel="&#x091B;" />
+ latin:keyLabel="&#x091B;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0920: "ठ" DEVANAGARI LETTER TTHA -->
<Key
- latin:keyLabel="&#x0920;" />
+ latin:keyLabel="&#x0920;"
+ latin:keyLabelFlags="fontNormal" />
</case>
<default>
<!-- U+094B: "ो" DEVANAGARI VOWEL SIGN O
@@ -91,52 +102,63 @@
U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O -->
<Key
latin:keyLabel="&#x094B;"
- latin:moreKeys="&#x094B;&#x0902;,&#x0949;,&#x094A;" />
+ latin:moreKeys="&#x094B;&#x0902;,&#x0949;,&#x094A;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0947: "े" DEVANAGARI VOWEL SIGN E
U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="&#x0947;"
- latin:moreKeys="&#x0947;&#x0902;" />
+ latin:moreKeys="&#x0947;&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+094D: "्" DEVANAGARI SIGN VIRAMA -->
<Key
- latin:keyLabel="&#x094D;" />
+ latin:keyLabel="&#x094D;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+093F: "ि" DEVANAGARI VOWEL SIGN I
U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="&#x093F;"
- latin:moreKeys="&#x093F;&#x0902;" />
+ latin:moreKeys="&#x093F;&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0941: "ु" DEVANAGARI VOWEL SIGN U
U+0941/U+0902: "ुं" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN ANUSVARA
U+0941/U+0901: "ुँ" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN CANDRABINDU -->
<Key
latin:keyLabel="&#x0941;"
- latin:moreKeys="&#x0941;&#x0902;,&#x0941;&#x0901;" />
+ latin:moreKeys="&#x0941;&#x0902;,&#x0941;&#x0901;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092A: "प" DEVANAGARI LETTER PA -->
<Key
- latin:keyLabel="&#x092A;" />
+ latin:keyLabel="&#x092A;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0930: "र" DEVANAGARI LETTER RA
U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
U+0930/U+093C: "ऱ" DEVANAGARI LETTER RA/DEVANAGARI SIGN NUKTA
U+0960: "ॠ" DEVANAGARI LETTER VOCALIC RR -->
<Key
latin:keyLabel="&#x0930;"
- latin:moreKeys="&#x090B;,&#x0930;&#x093C;,&#x0960;" />
+ latin:moreKeys="&#x090B;,&#x0930;&#x093C;,&#x0960;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0915: "क" DEVANAGARI LETTER KA
U+0915/U+093C: "क़" DEVANAGARI LETTER KA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="&#x0915;"
- latin:moreKeys="&#x0915;&#x093C;" />
+ latin:moreKeys="&#x0915;&#x093C;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0924: "त" DEVANAGARI LETTER TA
U+0924/U+094D/U+0930: "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
<Key
latin:keyLabel="&#x0924;"
- latin:moreKeys="&#x0924;&#x094D;&#x0930;" />
+ latin:moreKeys="&#x0924;&#x094D;&#x0930;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091A: "च" DEVANAGARI LETTER CA -->
<Key
- latin:keyLabel="&#x091A;" />
+ latin:keyLabel="&#x091A;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091F: "ट" DEVANAGARI LETTER TTA -->
<Key
- latin:keyLabel="&#x091F;" />
+ latin:keyLabel="&#x091F;"
+ latin:keyLabelFlags="fontNormal" />
</default>
</switch>
</merge>
diff --git a/java/res/xml/rowkeys_hindi3.xml b/java/res/xml/rowkeys_hindi3.xml
index 92bcb56b3..ebbff3e33 100644
--- a/java/res/xml/rowkeys_hindi3.xml
+++ b/java/res/xml/rowkeys_hindi3.xml
@@ -27,15 +27,18 @@
>
<!-- U+0911: "ऑ" DEVANAGARI LETTER CANDRA O -->
<Key
- latin:keyLabel="&#x0911;" />
+ latin:keyLabel="&#x0911;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E-->
<Key
latin:keyLabel="&#x0901;"
- latin:moreKeys="&#x0945;" />
+ latin:moreKeys="&#x0945;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0923: "ण" DEVANAGARI LETTER NNA -->
<Key
- latin:keyLabel="&#x0923;" />
+ latin:keyLabel="&#x0923;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0929: "ऩ" DEVANAGARI LETTER NNNA -->
<Key
latin:keyLabel="&#x0929;" />
@@ -43,65 +46,79 @@
U+0934: "ऴ" DEVANAGARI LETTER LLLA -->
<Key
latin:keyLabel="&#x0933;"
- latin:moreKeys="&#x0934;" />
+ latin:moreKeys="&#x0934;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0936: "श" DEVANAGARI LETTER SHA -->
<Key
- latin:keyLabel="&#x0936;" />
+ latin:keyLabel="&#x0936;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0937: "ष" DEVANAGARI LETTER SSA -->
<Key
- latin:keyLabel="&#x0937;" />
+ latin:keyLabel="&#x0937;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR -->
<Key
latin:keyLabel="&#x0943;"
- latin:moreKeys="&#x0944;" />
+ latin:moreKeys="&#x0944;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091E: "ञ" DEVANAGARI LETTER NYA -->
<Key
- latin:keyLabel="&#x091E;" />
+ latin:keyLabel="&#x091E;"
+ latin:keyLabelFlags="fontNormal" />
</case>
<default>
<!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
<Key
- latin:keyLabel="&#x0949;" />
+ latin:keyLabel="&#x0949;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
<Key
- latin:keyLabel="&#x0902;" />
+ latin:keyLabel="&#x0902;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092E: "म" DEVANAGARI LETTER MA
U+0950: "ॐ" DEVANAGARI OM -->
<Key
latin:keyLabel="&#x092E;"
- latin:moreKeys="&#x0950;" />
+ latin:moreKeys="&#x0950;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0928: "न" DEVANAGARI LETTER NA
U+091E: "ञ" DEVANAGARI LETTER NYA
U+0919: "ङ" DEVANAGARI LETTER NGA
U+0928/U+093C: "ऩ" DEVANAGARI LETTER NA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="&#x0928;"
- latin:moreKeys="&#x091E;,&#x0919;,&#x0928;&#x093C;" />
+ latin:moreKeys="&#x091E;,&#x0919;,&#x0928;&#x093C;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0935: "व" DEVANAGARI LETTER VA -->
<Key
- latin:keyLabel="&#x0935;" />
+ latin:keyLabel="&#x0935;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0932: "ल" DEVANAGARI LETTER LA
U+090C: "ऌ" DEVANAGARI LETTER VOCALIC L
U+0961: "ॡ" DEVANAGARI LETTER VOCALIC LL -->
<Key
latin:keyLabel="&#x0932;"
- latin:moreKeys="&#x090C;,&#x0961;" />
+ latin:moreKeys="&#x090C;,&#x0961;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0938: "स" DEVANAGARI LETTER SA -->
<Key
- latin:keyLabel="&#x0938;" />
+ latin:keyLabel="&#x0938;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092F: "य" DEVANAGARI LETTER YA
U+095F: "य़" DEVANAGARI LETTER YYA -->
<Key
latin:keyLabel="&#x092F;"
- latin:moreKeys="&#x095F;" />
+ latin:moreKeys="&#x095F;"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+093C: "़" DEVANAGARI SIGN NUKTA
U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP
U+0970: "॰" DEVANAGARI ABBREVIATION SIGN
U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA -->
<Key
latin:keyLabel="&#x093C;"
- latin:moreKeys="&#x097D;,&#x0970;,&#x093D;" />
+ latin:moreKeys="&#x097D;,&#x0970;,&#x093D;"
+ latin:keyLabelFlags="fontNormal" />
</default>
</switch>
</merge>
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 2bde8d2c5..03d610a39 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -47,8 +47,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
private static boolean sGestureHandlingEnabledByInputField = false;
private static boolean sGestureHandlingEnabledByUser = false;
- private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
-
public interface KeyEventHandler {
/**
* Get KeyDetector object that is used for this PointerTracker.
@@ -562,7 +560,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
mGestureStrokeWithPreviewPoints.appendIncrementalBatchPoints(sAggregratedPointers);
final int size = sAggregratedPointers.getPointerSize();
if (size > sLastRecognitionPointSize
- && eventTime > sLastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME) {
+ && GestureStroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) {
sLastRecognitionPointSize = size;
sLastRecognitionTime = eventTime;
if (DEBUG_LISTENER) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index 093a530d5..f0be0ee94 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -31,14 +31,23 @@ public class GestureStroke {
private int mLastPointX;
private int mLastPointY;
- private int mMinGestureLength;
- private int mMinGestureSampleLength;
+ private int mMinGestureLength; // pixel
+ private int mMinGestureSampleLength; // pixel
+ private int mGestureRecognitionThreshold; // pixel / sec
// TODO: Move some of these to resource.
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
- private static final int MIN_GESTURE_DURATION = 100; // msec
+ private static final int MIN_GESTURE_START_DURATION = 100; // msec
+ private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f;
- private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec
+ private static final float GESTURE_RECOGNITION_SPEED_THRESHOLD_RATIO_TO_KEY_WIDTH =
+ 5.5f; // keyWidth / sec
+ private static final int MSEC_PER_SEC = 1000;
+
+ public static final boolean hasRecognitionTimePast(
+ final long currentTime, final long lastRecognitionTime) {
+ return currentTime > lastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME;
+ }
public GestureStroke(final int pointerId) {
mPointerId = pointerId;
@@ -48,12 +57,14 @@ public class GestureStroke {
// TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH);
mMinGestureSampleLength = (int)(keyWidth * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH);
+ mGestureRecognitionThreshold =
+ (int)(keyWidth * GESTURE_RECOGNITION_SPEED_THRESHOLD_RATIO_TO_KEY_WIDTH);
}
public boolean isStartOfAGesture() {
final int size = mEventTimes.getLength();
final int downDuration = (size > 0) ? mEventTimes.get(size - 1) : 0;
- return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
+ return downDuration > MIN_GESTURE_START_DURATION && mLength > mMinGestureLength;
}
public void reset() {
@@ -66,44 +77,41 @@ public class GestureStroke {
mYCoordinates.setLength(0);
}
- private void updateLastPoint(final int x, final int y, final int time) {
- mLastPointTime = time;
- mLastPointX = x;
- mLastPointY = y;
- }
-
public void addPoint(final int x, final int y, final int time, final boolean isHistorical) {
+ final boolean needsSampling;
final int size = mEventTimes.getLength();
if (size == 0) {
- mEventTimes.add(time);
- mXCoordinates.add(x);
- mYCoordinates.add(y);
- if (!isHistorical) {
- updateLastPoint(x, y, time);
- }
- return;
+ needsSampling = true;
+ } else {
+ final int lastIndex = size - 1;
+ final int lastX = mXCoordinates.get(lastIndex);
+ final int lastY = mYCoordinates.get(lastIndex);
+ final float dist = getDistance(lastX, lastY, x, y);
+ needsSampling = dist > mMinGestureSampleLength;
+ mLength += dist;
}
-
- final int lastX = mXCoordinates.get(size - 1);
- final int lastY = mYCoordinates.get(size - 1);
- final float dist = getDistance(lastX, lastY, x, y);
- if (dist > mMinGestureSampleLength) {
+ if (needsSampling) {
mEventTimes.add(time);
mXCoordinates.add(x);
mYCoordinates.add(y);
- mLength += dist;
}
-
if (!isHistorical) {
- final int duration = (int)(time - mLastPointTime);
- if (mLastPointTime != 0 && duration > 0) {
- final float speed = getDistance(mLastPointX, mLastPointY, x, y) / duration;
- if (speed < GESTURE_RECOG_SPEED_THRESHOLD) {
- mIncrementalRecognitionSize = size;
- }
+ updateIncrementalRecognitionSize(x, y, time);
+ }
+ }
+
+ private void updateIncrementalRecognitionSize(final int x, final int y, final int time) {
+ final int msecs = (int)(time - mLastPointTime);
+ if (msecs > 0) {
+ final int pixels = (int)getDistance(mLastPointX, mLastPointY, x, y);
+ // Equivalent to (pixels / msecs < mGestureRecognitionThreshold / MSEC_PER_SEC)
+ if (pixels * MSEC_PER_SEC < mGestureRecognitionThreshold * msecs) {
+ mIncrementalRecognitionSize = mEventTimes.getLength();
}
- updateLastPoint(x, y, time);
}
+ mLastPointTime = time;
+ mLastPointX = x;
+ mLastPointY = y;
}
public void appendAllBatchPoints(final InputPointers out) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
index 075a9bb0c..15170e040 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
@@ -46,7 +46,6 @@ public class PreviewPlacerView extends RelativeLayout {
private final float mGestureFloatingPreviewHorizontalPadding;
private final float mGestureFloatingPreviewVerticalPadding;
private final float mGestureFloatingPreviewRoundRadius;
- /* package */ final int mGestureFloatingPreviewTextLingerTimeout;
private int mXOrigin;
private int mYOrigin;
@@ -78,11 +77,14 @@ public class PreviewPlacerView extends RelativeLayout {
private static final int MSG_UPDATE_GESTURE_PREVIEW_TRAIL = 1;
private final Params mGesturePreviewTrailParams;
+ private final int mGestureFloatingPreviewTextLingerTimeout;
public DrawingHandler(final PreviewPlacerView outerInstance,
- final Params gesturePreviewTrailParams) {
+ final Params gesturePreviewTrailParams,
+ final int getstureFloatinPreviewTextLinerTimeout) {
super(outerInstance);
mGesturePreviewTrailParams = gesturePreviewTrailParams;
+ mGestureFloatingPreviewTextLingerTimeout = getstureFloatinPreviewTextLinerTimeout;
}
@Override
@@ -105,10 +107,8 @@ public class PreviewPlacerView extends RelativeLayout {
public void dismissGestureFloatingPreviewText() {
cancelDismissGestureFloatingPreviewText();
- final PreviewPlacerView placerView = getOuterInstance();
- sendMessageDelayed(
- obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT),
- placerView.mGestureFloatingPreviewTextLingerTimeout);
+ sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT),
+ mGestureFloatingPreviewTextLingerTimeout);
}
private void cancelUpdateGestureTrailPreview() {
@@ -122,7 +122,6 @@ public class PreviewPlacerView extends RelativeLayout {
}
public void cancelAllMessages() {
- cancelDismissGestureFloatingPreviewText();
cancelUpdateGestureTrailPreview();
}
}
@@ -151,12 +150,13 @@ public class PreviewPlacerView extends RelativeLayout {
R.styleable.KeyboardView_gestureFloatingPreviewVerticalPadding, 0.0f);
mGestureFloatingPreviewRoundRadius = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_gestureFloatingPreviewRoundRadius, 0.0f);
- mGestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt(
+ final int gestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt(
R.styleable.KeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
mGesturePreviewTrailParams = new Params(keyboardViewAttr);
keyboardViewAttr.recycle();
- mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams);
+ mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams,
+ gestureFloatingPreviewTextLingerTimeout);
final Paint gesturePaint = new Paint();
gesturePaint.setAntiAlias(true);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index bf64b4f08..9252b0980 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1401,7 +1401,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
Stats.onAutoCorrection("", mWordComposer.getTypedWord(), " ", mWordComposer);
}
}
- commitTyped(LastComposedWord.NOT_A_SEPARATOR);
+ if (mWordComposer.size() <= 1) {
+ // We auto-correct the previous (typed, not gestured) string iff it's one character
+ // long. The reason for this is, even in the middle of gesture typing, you'll still
+ // tap one-letter words and you want them auto-corrected (typically, "i" in English
+ // should become "I"). However for any longer word, we assume that the reason for
+ // tapping probably is that the word you intend to type is not in the dictionary,
+ // so we do not attempt to correct, on the assumption that if that was a dictionary
+ // word, the user would probably have gestured instead.
+ commitCurrentAutoCorrection(LastComposedWord.NOT_A_SEPARATOR);
+ } else {
+ commitTyped(LastComposedWord.NOT_A_SEPARATOR);
+ }
mExpectingUpdateSelection = true;
// The following is necessary for the case where the user typed something but didn't
// manual pick it and didn't input any separator.
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index c2dec2593..9479a88a7 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -42,7 +42,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.research.ResearchLogger;
import com.android.inputmethodcommon.InputMethodSettingsFragment;
-public class Settings extends InputMethodSettingsFragment
+public final class Settings extends InputMethodSettingsFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final boolean ENABLE_INTERNAL_SETTINGS = ProductionFlag.IS_INTERNAL;
@@ -63,8 +63,8 @@ public class Settings extends InputMethodSettingsFragment
"last_user_dictionary_write_time";
public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings";
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
- public static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
- "pref_suppress_language_switch_key";
+ public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
+ "pref_show_language_switch_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
"pref_include_other_imes_in_language_switch_list";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
@@ -97,7 +97,7 @@ public class Settings extends InputMethodSettingsFragment
private TextView mKeypressVibrationDurationSettingsTextView;
private TextView mKeypressSoundVolumeSettingsTextView;
- private static void setPreferenceEnabled(Preference preference, boolean enabled) {
+ private static void setPreferenceEnabled(final Preference preference, final boolean enabled) {
if (preference != null) {
preference.setEnabled(enabled);
}
@@ -111,7 +111,7 @@ public class Settings extends InputMethodSettingsFragment
}
@Override
- public void onCreate(Bundle icicle) {
+ public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
setSubtypeEnablerTitle(R.string.select_language);
@@ -192,7 +192,7 @@ public class Settings extends InputMethodSettingsFragment
}
setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST),
- !SettingsValues.isLanguageSwitchKeySupressed(prefs));
+ SettingsValues.showsLanguageSwitchKey(prefs));
final PreferenceScreen dictionaryLink =
(PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
@@ -288,14 +288,14 @@ public class Settings extends InputMethodSettingsFragment
}
@Override
- public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
+ public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
(new BackupManager(getActivity())).dataChanged();
if (key.equals(PREF_POPUP_ON)) {
setPreferenceEnabled(findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY),
prefs.getBoolean(PREF_POPUP_ON, true));
- } else if (key.equals(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) {
+ } else if (key.equals(PREF_SHOW_LANGUAGE_SWITCH_KEY)) {
setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST),
- !SettingsValues.isLanguageSwitchKeySupressed(prefs));
+ SettingsValues.showsLanguageSwitchKey(prefs));
} else if (key.equals(PREF_GESTURE_INPUT)) {
final boolean gestureInputEnabledByConfig = getResources().getBoolean(
R.bool.config_gesture_input_enabled_by_build_config);
@@ -352,7 +352,7 @@ public class Settings extends InputMethodSettingsFragment
}
private void refreshEnablingsOfKeypressSoundAndVibrationSettings(
- SharedPreferences sp, Resources res) {
+ final SharedPreferences sp, final Resources res) {
if (mKeypressVibrationDurationSettingsPref != null) {
final boolean hasVibratorHardware = VibratorUtils.getInstance(getActivity())
.hasVibrator();
@@ -370,7 +370,7 @@ public class Settings extends InputMethodSettingsFragment
}
private void updateKeypressVibrationDurationSettingsSummary(
- SharedPreferences sp, Resources res) {
+ final SharedPreferences sp, final Resources res) {
if (mKeypressVibrationDurationSettingsPref != null) {
mKeypressVibrationDurationSettingsPref.setSummary(
SettingsValues.getCurrentVibrationDuration(sp, res)
@@ -428,7 +428,7 @@ public class Settings extends InputMethodSettingsFragment
builder.create().show();
}
- private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) {
+ private void updateKeypressSoundVolumeSummary(final SharedPreferences sp, final Resources res) {
if (mKeypressSoundVolumeSettingsPref != null) {
mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf(
(int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100)));
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index d9cf2700b..9d8379a7a 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -72,7 +72,7 @@ public final class SettingsValues {
@SuppressWarnings("unused") // TODO: Use this
private final boolean mUsabilityStudyMode;
public final boolean mIncludesOtherImesInLanguageSwitchList;
- public final boolean mIsLanguageSwitchKeySuppressed;
+ public final boolean mShowsLanguageSwitchKey;
@SuppressWarnings("unused") // TODO: Use this
private final String mKeyPreviewPopupDismissDelayRawValue;
public final boolean mUseContactsDict;
@@ -151,7 +151,7 @@ public final class SettingsValues {
mUsabilityStudyMode = getUsabilityStudyMode(prefs);
mIncludesOtherImesInLanguageSwitchList = prefs.getBoolean(
Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false);
- mIsLanguageSwitchKeySuppressed = isLanguageSwitchKeySupressed(prefs);
+ mShowsLanguageSwitchKey = showsLanguageSwitchKey(prefs);
mKeyPreviewPopupDismissDelayRawValue = prefs.getString(
Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout)));
@@ -336,12 +336,25 @@ public final class SettingsValues {
return mVoiceKeyOnMain;
}
- public static boolean isLanguageSwitchKeySupressed(final SharedPreferences prefs) {
- return prefs.getBoolean(Settings.PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
+ // This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
+ // This is being used only for the backward compatibility.
+ private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
+ "pref_suppress_language_switch_key";
+
+ public static boolean showsLanguageSwitchKey(final SharedPreferences prefs) {
+ if (prefs.contains(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) {
+ final boolean suppressLanguageSwitchKey = prefs.getBoolean(
+ PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
+ final SharedPreferences.Editor editor = prefs.edit();
+ editor.remove(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY);
+ editor.putBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, !suppressLanguageSwitchKey);
+ editor.apply();
+ }
+ return prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, true);
}
public boolean isLanguageSwitchKeyEnabled(final Context context) {
- if (mIsLanguageSwitchKeySuppressed) {
+ if (!mShowsLanguageSwitchKey) {
return false;
}
if (mIncludesOtherImesInLanguageSwitchList) {
@@ -353,7 +366,7 @@ public final class SettingsValues {
}
}
- public boolean isFullscreenModeAllowed(final Resources res) {
+ public static boolean isFullscreenModeAllowed(final Resources res) {
return res.getBoolean(R.bool.config_use_fullscreen_mode);
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
index 1a85e71ce..406071071 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
@@ -16,10 +16,11 @@
package com.android.inputmethod.latin.makedict;
-import com.android.inputmethod.latin.makedict.BinaryDictInputOutput;
+import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
+import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import java.io.IOException;
import java.util.ArrayList;
@@ -91,7 +92,18 @@ public class BinaryDictIOUtils {
}
if (p.mPosition == p.mNumOfCharGroup) {
- stack.pop();
+ if (formatOptions.mHasLinkedListNode) {
+ final int forwardLinkAddress = buffer.readUnsignedInt24();
+ if (forwardLinkAddress != FormatSpec.NO_FORWARD_LINK_ADDRESS) {
+ // the node has a forward link.
+ p.mNumOfCharGroup = Position.NOT_READ_GROUPCOUNT;
+ p.mAddress = forwardLinkAddress;
+ } else {
+ stack.pop();
+ }
+ } else {
+ stack.pop();
+ }
} else {
// the node has more groups.
p.mAddress = buffer.position();
@@ -124,4 +136,69 @@ public class BinaryDictIOUtils {
readUnigramsAndBigramsBinaryInner(buffer, header.mHeaderSize, words, frequencies, bigrams,
header.mFormatOptions);
}
+
+ /**
+ * Gets the address of the last CharGroup of the exact matching word in the dictionary.
+ * If no match is found, returns NOT_VALID_WORD.
+ *
+ * @param buffer the buffer to read.
+ * @param word the word we search for.
+ * @return the address of the terminal node.
+ * @throws IOException
+ * @throws UnsupportedFormatException
+ */
+ public static int getTerminalPosition(final FusionDictionaryBufferInterface buffer,
+ final String word) throws IOException, UnsupportedFormatException {
+ if (word == null) return FormatSpec.NOT_VALID_WORD;
+ if (buffer.position() != 0) buffer.position(0);
+
+ final FileHeader header = BinaryDictInputOutput.readHeader(buffer);
+ int wordPos = 0;
+ final int wordLen = word.codePointCount(0, word.length());
+ for (int depth = 0; depth < Constants.Dictionary.MAX_WORD_LENGTH; ++depth) {
+ if (wordPos >= wordLen) return FormatSpec.NOT_VALID_WORD;
+ int groupOffset = buffer.position() - header.mHeaderSize;
+ final int charGroupCount = BinaryDictInputOutput.readCharGroupCount(buffer);
+ groupOffset += BinaryDictInputOutput.getGroupCountSize(charGroupCount);
+
+ for (int i = 0; i < charGroupCount; ++i) {
+ final int charGroupPos = buffer.position();
+ final CharGroupInfo currentInfo = BinaryDictInputOutput.readCharGroup(buffer,
+ buffer.position(), header.mFormatOptions);
+ boolean same = true;
+ for (int p = 0, j = word.offsetByCodePoints(0, wordPos);
+ p < currentInfo.mCharacters.length;
+ ++p, j = word.offsetByCodePoints(j, 1)) {
+ if (wordPos + p >= wordLen
+ || word.codePointAt(j) != currentInfo.mCharacters[p]) {
+ same = false;
+ break;
+ }
+ }
+
+ if (same) {
+ if (wordPos + currentInfo.mCharacters.length == wordLen) {
+ if (currentInfo.mFrequency == CharGroup.NOT_A_TERMINAL) {
+ return FormatSpec.NOT_VALID_WORD;
+ } else {
+ return charGroupPos;
+ }
+ }
+ wordPos += currentInfo.mCharacters.length;
+ if (currentInfo.mChildrenAddress == FormatSpec.NO_CHILDREN_ADDRESS) {
+ return FormatSpec.NOT_VALID_WORD;
+ }
+ buffer.position(currentInfo.mChildrenAddress);
+ break;
+ }
+ groupOffset = currentInfo.mEndAddress;
+
+ // not found
+ if (i >= charGroupCount - 1) {
+ return FormatSpec.NOT_VALID_WORD;
+ }
+ }
+ }
+ return FormatSpec.NOT_VALID_WORD;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index c865702d6..1d3e94bb7 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -1242,8 +1242,9 @@ public class BinaryDictInputOutput {
* @param formatOptions file format options.
* @return the word, as a string.
*/
- private static String getWordAtAddress(final FusionDictionaryBufferInterface buffer,
- final int headerSize, final int address, final FormatOptions formatOptions) {
+ /* packages for tests */ static String getWordAtAddress(
+ final FusionDictionaryBufferInterface buffer, final int headerSize, final int address,
+ final FormatOptions formatOptions) {
final String cachedString = wordCache.get(address);
if (null != cachedString) return cachedString;
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index f8f13b197..adc6037bb 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -207,6 +207,9 @@ public final class FormatSpec {
static final int MAX_TERMINAL_FREQUENCY = 255;
static final int MAX_BIGRAM_FREQUENCY = 15;
+ // This option needs to be the same numeric value as the one in binary_format.h.
+ static final int NOT_VALID_WORD = -99;
+
/**
* Options about file format.
*/