merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 0fb8877..c7d9936 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 1d7e57b..370959c 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 bd60844..392a070 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 f7c993d..3e83fc0 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 656ba01..1120804 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="औ"
- latin:moreKeys="ऒं" />
+ latin:moreKeys="ऒं"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0910: "ऐ" DEVANAGARI LETTER AI
U+0910/U+0902: "ऐं" DEVANAGARI LETTER AI/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="ऐ"
- latin:moreKeys="ऐं" />
+ latin:moreKeys="ऐं"
+ 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="आ"
- latin:moreKeys="आं,आँ" />
+ latin:moreKeys="आं,आँ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0908: "ई" DEVANAGARI LETTER II
U+0908/U+0902: "ईं" DEVANAGARI LETTER II/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="ई"
- latin:moreKeys="ईं" />
+ latin:moreKeys="ईं"
+ 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="ऊ"
- latin:moreKeys="ऊं,ऊँ" />
+ latin:moreKeys="ऊं,ऊँ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092D: "भ" DEVANAGARI LETTER BHA -->
<Key
- latin:keyLabel="भ" />
+ latin:keyLabel="भ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0903: "ः" DEVANAGARI SIGN VISARGA -->
<Key
- latin:keyLabel="ः" />
+ latin:keyLabel="ः"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0918: "घ" DEVANAGARI LETTER GHA -->
<Key
- latin:keyLabel="घ" />
+ latin:keyLabel="घ"
+ 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="ध"
- latin:moreKeys="क्ष,श्र" />
+ latin:moreKeys="क्ष,श्र"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091D: "झ" DEVANAGARI LETTER JHA -->
<Key
- latin:keyLabel="झ" />
+ latin:keyLabel="झ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0922: "ढ" DEVANAGARI LETTER DDHA -->
<Key
- latin:keyLabel="ढ" />
+ latin:keyLabel="ढ"
+ latin:keyLabelFlags="fontNormal" />
</case>
<default>
<!-- U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
@@ -82,7 +93,8 @@
latin:keyLabel="ौ"
latin:moreKeys="ौं,%"
latin:keyHintLabel="1"
- latin:additionalMoreKeys="१,1" />
+ latin:additionalMoreKeys="१,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="ै"
latin:moreKeys="ैं,%"
latin:keyHintLabel="2"
- latin:additionalMoreKeys="२,2" />
+ latin:additionalMoreKeys="२,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="ा"
latin:moreKeys="ां,ाँ,%"
latin:keyHintLabel="3"
- latin:additionalMoreKeys="३,3" />
+ latin:additionalMoreKeys="३,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="ी"
latin:moreKeys="ीं,%"
latin:keyHintLabel="4"
- latin:additionalMoreKeys="४,4" />
+ latin:additionalMoreKeys="४,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="ू"
latin:moreKeys="ूं,ूँ,%"
latin:keyHintLabel="5"
- latin:additionalMoreKeys="५,5" />
+ latin:additionalMoreKeys="५,5"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092C: "ब" DEVANAGARI LETTER BA
U+092C/U+0952: "ब॒" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA -->
<Key
latin:keyLabel="ब"
latin:moreKeys="ब॒,%"
latin:keyHintLabel="6"
- latin:additionalMoreKeys="६,6" />
+ latin:additionalMoreKeys="६,6"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0939: "ह" DEVANAGARI LETTER HA
U+096D: "७" DEVANAGARI DIGIT SEVEN -->
<Key
latin:keyLabel="ह"
latin:keyHintLabel="7"
- latin:additionalMoreKeys="७,7" />
+ latin:additionalMoreKeys="७,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="ग"
latin:moreKeys="ज्ञ,ग़,ग॒,%"
latin:keyHintLabel="8"
- latin:additionalMoreKeys="८,8" />
+ latin:additionalMoreKeys="८,8"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0926: "द" DEVANAGARI LETTER DA
U+096F: "९" DEVANAGARI DIGIT NINE -->
<Key
latin:keyLabel="द"
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="ज"
latin:moreKeys="ज॒,ज्ञ,ज़,%"
latin:keyHintLabel="0"
- latin:additionalMoreKeys="०,0" />
+ latin:additionalMoreKeys="०,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="ड"
- latin:moreKeys="ड॒,ड़" />
+ latin:moreKeys="ड॒,ड़"
+ latin:keyLabelFlags="fontNormal" />
</default>
</switch>
</merge>
diff --git a/java/res/xml/rowkeys_hindi2.xml b/java/res/xml/rowkeys_hindi2.xml
index 05e3db2..e7c67db 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="ओ"
- latin:moreKeys="ओं,ऑ,ऒ" />
+ latin:moreKeys="ओं,ऑ,ऒ"
+ 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="ए"
- latin:moreKeys="एं,एँ,ऍ,ऎ" />
+ latin:moreKeys="एं,एँ,ऍ,ऎ"
+ 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="अ"
- latin:moreKeys="अं,अँ" />
+ latin:moreKeys="अं,अँ"
+ 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="इ"
- latin:moreKeys="इं,इँ" />
+ latin:moreKeys="इं,इँ"
+ 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="उ"
- latin:moreKeys="उं,उँ" />
+ latin:moreKeys="उं,उँ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092B: "फ" DEVANAGARI LETTER PHA
U+092B/U+093C: "फ़" DEVANAGARI LETTER PHA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="फ"
- latin:moreKeys="फ़" />
+ latin:moreKeys="फ़"
+ 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="ऱ"
- latin:moreKeys="्र,र्" />
+ latin:moreKeys="्र,र्"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0916: "ख" DEVANAGARI LETTER KHA
U+0916/U+093C: "ख़" DEVANAGARI LETTER KHA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="ख"
- latin:moreKeys="ख़" />
+ latin:moreKeys="ख़"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0925: "थ" DEVANAGARI LETTER THA -->
<Key
- latin:keyLabel="थ" />
+ latin:keyLabel="थ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091B: "छ" DEVANAGARI LETTER CHA -->
<Key
- latin:keyLabel="छ" />
+ latin:keyLabel="छ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0920: "ठ" DEVANAGARI LETTER TTHA -->
<Key
- latin:keyLabel="ठ" />
+ latin:keyLabel="ठ"
+ 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="ो"
- latin:moreKeys="ों,ॉ,ॊ" />
+ latin:moreKeys="ों,ॉ,ॊ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0947: "े" DEVANAGARI VOWEL SIGN E
U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="े"
- latin:moreKeys="ें" />
+ latin:moreKeys="ें"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+094D: "्" DEVANAGARI SIGN VIRAMA -->
<Key
- latin:keyLabel="्" />
+ latin:keyLabel="्"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+093F: "ि" DEVANAGARI VOWEL SIGN I
U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA -->
<Key
latin:keyLabel="ि"
- latin:moreKeys="िं" />
+ latin:moreKeys="िं"
+ 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="ु"
- latin:moreKeys="ुं,ुँ" />
+ latin:moreKeys="ुं,ुँ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092A: "प" DEVANAGARI LETTER PA -->
<Key
- latin:keyLabel="प" />
+ latin:keyLabel="प"
+ 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="र"
- latin:moreKeys="ऋ,ऱ,ॠ" />
+ latin:moreKeys="ऋ,ऱ,ॠ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0915: "क" DEVANAGARI LETTER KA
U+0915/U+093C: "क़" DEVANAGARI LETTER KA/DEVANAGARI SIGN NUKTA -->
<Key
latin:keyLabel="क"
- latin:moreKeys="क़" />
+ latin:moreKeys="क़"
+ 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="त"
- latin:moreKeys="त्र" />
+ latin:moreKeys="त्र"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091A: "च" DEVANAGARI LETTER CA -->
<Key
- latin:keyLabel="च" />
+ latin:keyLabel="च"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091F: "ट" DEVANAGARI LETTER TTA -->
<Key
- latin:keyLabel="ट" />
+ latin:keyLabel="ट"
+ latin:keyLabelFlags="fontNormal" />
</default>
</switch>
</merge>
diff --git a/java/res/xml/rowkeys_hindi3.xml b/java/res/xml/rowkeys_hindi3.xml
index 92bcb56..ebbff3e 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="ऑ" />
+ latin:keyLabel="ऑ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E-->
<Key
latin:keyLabel="ँ"
- latin:moreKeys="ॅ" />
+ latin:moreKeys="ॅ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0923: "ण" DEVANAGARI LETTER NNA -->
<Key
- latin:keyLabel="ण" />
+ latin:keyLabel="ण"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0929: "ऩ" DEVANAGARI LETTER NNNA -->
<Key
latin:keyLabel="ऩ" />
@@ -43,65 +46,79 @@
U+0934: "ऴ" DEVANAGARI LETTER LLLA -->
<Key
latin:keyLabel="ळ"
- latin:moreKeys="ऴ" />
+ latin:moreKeys="ऴ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0936: "श" DEVANAGARI LETTER SHA -->
<Key
- latin:keyLabel="श" />
+ latin:keyLabel="श"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0937: "ष" DEVANAGARI LETTER SSA -->
<Key
- latin:keyLabel="ष" />
+ latin:keyLabel="ष"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR -->
<Key
latin:keyLabel="ृ"
- latin:moreKeys="ॄ" />
+ latin:moreKeys="ॄ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+091E: "ञ" DEVANAGARI LETTER NYA -->
<Key
- latin:keyLabel="ञ" />
+ latin:keyLabel="ञ"
+ latin:keyLabelFlags="fontNormal" />
</case>
<default>
<!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
<Key
- latin:keyLabel="ॉ" />
+ latin:keyLabel="ॉ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
<Key
- latin:keyLabel="ं" />
+ latin:keyLabel="ं"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092E: "म" DEVANAGARI LETTER MA
U+0950: "ॐ" DEVANAGARI OM -->
<Key
latin:keyLabel="म"
- latin:moreKeys="ॐ" />
+ latin:moreKeys="ॐ"
+ 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="न"
- latin:moreKeys="ञ,ङ,ऩ" />
+ latin:moreKeys="ञ,ङ,ऩ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0935: "व" DEVANAGARI LETTER VA -->
<Key
- latin:keyLabel="व" />
+ latin:keyLabel="व"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0932: "ल" DEVANAGARI LETTER LA
U+090C: "ऌ" DEVANAGARI LETTER VOCALIC L
U+0961: "ॡ" DEVANAGARI LETTER VOCALIC LL -->
<Key
latin:keyLabel="ल"
- latin:moreKeys="ऌ,ॡ" />
+ latin:moreKeys="ऌ,ॡ"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+0938: "स" DEVANAGARI LETTER SA -->
<Key
- latin:keyLabel="स" />
+ latin:keyLabel="स"
+ latin:keyLabelFlags="fontNormal" />
<!-- U+092F: "य" DEVANAGARI LETTER YA
U+095F: "य़" DEVANAGARI LETTER YYA -->
<Key
latin:keyLabel="य"
- latin:moreKeys="य़" />
+ latin:moreKeys="य़"
+ 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="़"
- latin:moreKeys="ॽ,॰,ऽ" />
+ latin:moreKeys="ॽ,॰,ऽ"
+ 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 2bde8d2..03d610a 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -47,8 +47,6 @@
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 @@
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 093a530..f0be0ee 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 @@
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 @@
// 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,46 +77,43 @@
mYCoordinates.setLength(0);
}
- private void updateLastPoint(final int x, final int y, final int time) {
+ 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) {
+ 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;
+ }
+ if (needsSampling) {
+ mEventTimes.add(time);
+ mXCoordinates.add(x);
+ mYCoordinates.add(y);
+ }
+ if (!isHistorical) {
+ 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();
+ }
+ }
mLastPointTime = time;
mLastPointX = x;
mLastPointY = y;
}
- public void addPoint(final int x, final int y, final int time, final boolean isHistorical) {
- final int size = mEventTimes.getLength();
- if (size == 0) {
- mEventTimes.add(time);
- mXCoordinates.add(x);
- mYCoordinates.add(y);
- if (!isHistorical) {
- updateLastPoint(x, y, time);
- }
- return;
- }
-
- 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) {
- 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;
- }
- }
- updateLastPoint(x, y, time);
- }
- }
-
public void appendAllBatchPoints(final InputPointers out) {
appendBatchPoints(out, mEventTimes.getLength());
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
index 075a9bb..15170e0 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 @@
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 @@
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 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 void cancelAllMessages() {
- cancelDismissGestureFloatingPreviewText();
cancelUpdateGestureTrailPreview();
}
}
@@ -151,12 +150,13 @@
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 bf64b4f..9252b09 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1401,7 +1401,18 @@
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 c2dec25..9479a88 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.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 @@
"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 @@
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 @@
}
@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 @@
}
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 @@
}
@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 @@
}
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 @@
}
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 @@
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 d9cf270..9d8379a 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -72,7 +72,7 @@
@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 @@
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 @@
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 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 1a85e71..4060710 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 @@
}
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 @@
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 c865702..1d3e94b 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 @@
* @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 f8f13b1..adc6037 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 @@
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.
*/
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index b9fce5f..c5f2884 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -464,8 +464,8 @@
}
int ProximityInfoState::getDuration(const int index) const {
- if (mInputSize > 0 && index > 0 && index < mInputSize - 1) {
- return mTimes[index + 1] - mTimes[index - 1];
+ if (mInputSize > 0 && index >= 0 && index < mInputSize - 1) {
+ return mTimes[index + 1] - mTimes[index];
}
return 0;
}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
index 4c2d3f6..24776d5 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
@@ -19,7 +19,7 @@
import com.android.inputmethod.latin.CollectionUtils;
import com.android.inputmethod.latin.UserHistoryDictIOUtils;
import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface;
-import com.android.inputmethod.latin.makedict.FormatSpec;
+import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
@@ -475,4 +475,93 @@
Log.d(TAG, result);
}
}
+
+ // Tests for getTerminalPosition
+ private String getWordFromBinary(final FusionDictionaryBufferInterface buffer,
+ final int address) {
+ if (buffer.position() != 0) buffer.position(0);
+
+ FileHeader header = null;
+ try {
+ header = BinaryDictInputOutput.readHeader(buffer);
+ } catch (IOException e) {
+ return null;
+ } catch (UnsupportedFormatException e) {
+ return null;
+ }
+ if (header == null) return null;
+ return BinaryDictInputOutput.getWordAtAddress(buffer, header.mHeaderSize,
+ address - header.mHeaderSize, header.mFormatOptions);
+ }
+
+ private long runGetTerminalPosition(final FusionDictionaryBufferInterface buffer,
+ final String word, int index, boolean contained) {
+ final int expectedFrequency = (UNIGRAM_FREQ + index) % 255;
+ long diff = -1;
+ int position = -1;
+ try {
+ final long now = System.nanoTime();
+ position = BinaryDictIOUtils.getTerminalPosition(buffer, word);
+ diff = System.nanoTime() - now;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException while getTerminalPosition: " + e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "UnsupportedFormatException while getTermianlPosition: " + e);
+ }
+
+ assertEquals(FormatSpec.NOT_VALID_WORD != position, contained);
+ if (contained) assertEquals(getWordFromBinary(buffer, position), word);
+ return diff;
+ }
+
+ public void testGetTerminalPosition() {
+ File file = null;
+ try {
+ file = File.createTempFile("runReadUnigrams", ".dict");
+ } catch (IOException e) {
+ // do nothing
+ }
+ assertNotNull(file);
+
+ final FusionDictionary dict = new FusionDictionary(new Node(),
+ new FusionDictionary.DictionaryOptions(
+ new HashMap<String, String>(), false, false));
+ addUnigrams(sWords.size(), dict, sWords, null /* shortcutMap */);
+ timeWritingDictToFile(file, dict, VERSION3_WITH_LINKEDLIST_NODE);
+
+ final FusionDictionaryBufferInterface buffer = getBuffer(file, USE_BYTE_ARRAY);
+
+ try {
+ // too long word
+ final String longWord = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
+ assertEquals(FormatSpec.NOT_VALID_WORD,
+ BinaryDictIOUtils.getTerminalPosition(buffer, longWord));
+
+ // null
+ assertEquals(FormatSpec.NOT_VALID_WORD,
+ BinaryDictIOUtils.getTerminalPosition(buffer, null));
+
+ // empty string
+ assertEquals(FormatSpec.NOT_VALID_WORD,
+ BinaryDictIOUtils.getTerminalPosition(buffer, ""));
+ } catch (IOException e) {
+ } catch (UnsupportedFormatException e) {
+ }
+
+ // Test a word that is contained within the dictionary.
+ long sum = 0;
+ for (int i = 0; i < sWords.size(); ++i) {
+ final long time = runGetTerminalPosition(buffer, sWords.get(i), i, true);
+ sum += time == -1 ? 0 : time;
+ }
+ Log.d(TAG, "per a search : " + (((double)sum) / sWords.size() / 1000000));
+
+ // Test a word that isn't contained within the dictionary.
+ final Random random = new Random((int)System.currentTimeMillis());
+ for (int i = 0; i < 1000; ++i) {
+ final String word = generateWord(random.nextInt());
+ if (sWords.indexOf(word) != -1) continue;
+ runGetTerminalPosition(buffer, word, i, false);
+ }
+ }
}