diff options
110 files changed, 1994 insertions, 383 deletions
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml index a7e64bfaa..6f4e602ce 100644 --- a/java/AndroidManifest.xml +++ b/java/AndroidManifest.xml @@ -57,6 +57,7 @@ </service> <activity android:name=".setup.SetupActivity" + android:theme="@style/platformActivityTheme" android:label="@string/english_ime_name" android:icon="@drawable/ic_launcher_keyboard" android:launchMode="singleTask" @@ -68,6 +69,7 @@ </activity> <activity android:name=".setup.SetupWizardActivity" + android:theme="@style/platformActivityTheme" android:label="@string/english_ime_name" android:clearTaskOnLaunch="true"> <intent-filter> @@ -84,6 +86,7 @@ </receiver> <activity android:name=".settings.SettingsActivity" + android:theme="@style/platformActivityTheme" android:label="@string/english_ime_settings" android:uiOptions="splitActionBarWhenNarrow"> <intent-filter> @@ -92,6 +95,7 @@ </activity> <activity android:name=".spellcheck.SpellCheckerSettingsActivity" + android:theme="@style/platformActivityTheme" android:label="@string/android_spell_checker_settings"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -99,6 +103,7 @@ </activity> <activity android:name=".settings.DebugSettingsActivity" + android:theme="@style/platformActivityTheme" android:label="@string/english_ime_debug_settings"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -145,8 +150,8 @@ </receiver> <activity android:name="com.android.inputmethod.dictionarypack.DictionarySettingsActivity" + android:theme="@style/platformActivityTheme" android:label="@string/dictionary_settings_title" - android:theme="@android:style/Theme.Holo" android:uiOptions="splitActionBarWhenNarrow"> <intent-filter> <action android:name="android.intent.action.MAIN"/> @@ -154,8 +159,8 @@ </activity> <activity android:name="com.android.inputmethod.dictionarypack.DownloadOverMeteredDialog" - android:label="@string/dictionary_install_over_metered_network_prompt" - android:theme="@android:style/Theme.Holo"> + android:theme="@style/platformActivityTheme" + android:label="@string/dictionary_install_over_metered_network_prompt"> <intent-filter> <action android:name="android.intent.action.MAIN"/> </intent-filter> diff --git a/java/proguard.flags b/java/proguard.flags index c08a968bc..f7b7f2898 100644 --- a/java/proguard.flags +++ b/java/proguard.flags @@ -14,3 +14,10 @@ -keepclassmembers class * { native <methods>; } + +# Keep classes that are used as a parameter type of methods that are also marked as keep +# to preserve changing those methods' signature. +-keep class com.android.inputmethod.latin.utils.LanguageModelParam +-keep class com.android.inputmethod.latin.AssetFileAddress +-keep class com.android.inputmethod.latin.makedict.ProbabilityInfo +-keep class com.android.inputmethod.latin.Dictionary diff --git a/java/res/values-v20/platform-theme.xml b/java/res/values-v20/platform-theme.xml new file mode 100644 index 000000000..b8c1d9655 --- /dev/null +++ b/java/res/values-v20/platform-theme.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- TODO: This file is temporarily placed under values-v20. --> +<!-- TODO: It might be moved under values-v21. --> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- TODO: Use Theme.Quantum.Light once it is fixed. + <style name="platformActivityTheme" parent="@android:style/Theme.Quantum.Light" /> + --> + <style name="platformActivityTheme" parent="@android:style/Theme.Quantum.Light.NoActionBar.Fullscreen" /> + <style name="platformDialogTheme" parent="@android:style/Theme.Quantum.Light.Dialog" /> +</resources> diff --git a/java/res/values/platform-theme.xml b/java/res/values/platform-theme.xml new file mode 100644 index 000000000..8e131a2b0 --- /dev/null +++ b/java/res/values/platform-theme.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <style name="platformActivityTheme" parent="@android:style/Theme.Holo" /> + <style name="platformDialogTheme" parent="@android:style/Theme.Holo.Dialog" /> +</resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index e38bdd64e..937a79933 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -358,9 +358,13 @@ (US) should be an abbreviation of United Statesn to fit in the CHAR LIMIT. This should be identical to subtype_es_US aside from the trailing (%s). --> <string name="subtype_with_layout_es_US">Spanish (US) (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string> - <!-- Description for Nepali (Traditional) keyboard subtype [CHAR LIMIT=25] + <!-- Description for "LANGUAGE_NAME" (Traditional) keyboard subtype [CHAR LIMIT=25] (Traditional) can be an abbreviation to fit in the CHAR LIMIT. --> - <string name="subtype_nepali_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string> + <string name="subtype_generic_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string> + <!-- Description for "LANGUAGE_NAME" (Compact) keyboard subtype [CHAR LIMIT=25] + (Compact) can be an abbreviation to fit in the CHAR LIMIT. + TODO: Remove translatable=false once we are settled down with the naming. --> + <string name="subtype_generic_compact" translatable="false"><xliff:g id="LANGUAGE_NAME" example="Hindi">%s</xliff:g> (Compact)</string> <!-- TODO: Uncomment once we can handle IETF language tag with script name specified. Description for Serbian Cyrillic keyboard subtype [CHAR LIMIT=25] (Cyrillic) can be an abbreviation to fit in the CHAR LIMIT. diff --git a/java/res/xml-sw600dp/keys_comma_period.xml b/java/res/xml-sw600dp/keys_comma_period.xml index ab987334a..23172cf18 100644 --- a/java/res/xml-sw600dp/keys_comma_period.xml +++ b/java/res/xml-sw600dp/keys_comma_period.xml @@ -28,11 +28,26 @@ latin:moreKeys="!text/morekeys_tablet_comma" latin:backgroundType="functional" latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keySpec="!text/keyspec_tablet_period" - latin:keyHintLabel="!text/keyhintlabel_tablet_period" - latin:keyLabelFlags="hasPopupHint" - latin:moreKeys="!text/morekeys_tablet_period" - latin:backgroundType="functional" - latin:keyStyle="hasShiftedLetterHintStyle" /> + <switch> + <case + latin:languageCode="hi" + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0964: "।" DEVANAGARI DANDA --> + <Key + latin:keySpec="\u0964" + latin:keyLabelFlags="hasPopupHint" + latin:moreKeys="!autoColumnOrder!8,\\,,.,',#,),(,/,;,@,:,-,",+,\\%,&" + latin:backgroundType="functional" /> + </case> + <default> + <Key + latin:keySpec="!text/keyspec_tablet_period" + latin:keyHintLabel="!text/keyhintlabel_tablet_period" + latin:keyLabelFlags="hasPopupHint" + latin:moreKeys="!text/morekeys_tablet_period" + latin:backgroundType="functional" + latin:keyStyle="hasShiftedLetterHintStyle" /> + </default> + </switch> </merge> diff --git a/java/res/xml-sw600dp/rows_hindi_compact.xml b/java/res/xml-sw600dp/rows_hindi_compact.xml new file mode 100644 index 000000000..ac476eb3b --- /dev/null +++ b/java/res/xml-sw600dp/rows_hindi_compact.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <include + latin:keyboardLayout="@xml/key_styles_common" /> + <Row + latin:keyWidth="8.182%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact1" /> + <Key + latin:keyStyle="deleteKeyStyle" + latin:keyWidth="fillRight" /> + </Row> + <Row + latin:keyWidth="8.182%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact2" /> + <Key + latin:keyStyle="enterKeyStyle" + latin:keyWidth="fillRight" /> + </Row> + <Row + latin:keyWidth="8.182%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact3" /> + <include + latin:keyboardLayout="@xml/keys_exclamation_question" /> + </Row> + <include + latin:keyboardLayout="@xml/row_qwerty4" /> +</merge> diff --git a/java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml b/java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml new file mode 100644 index 000000000..71439d68c --- /dev/null +++ b/java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- The code point U+25CC for key label is needed because the font rendering system prior to + API version 16 can't automatically render dotted circle for incomplete combining letter + of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the + counterpart files named res/xml-v16/key_*.xml don't have this hack. --> +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0903: "ः" DEVANAGARI SIGN VISARGA + U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + U+093C: "़" DEVANAGARI SIGN NUKTA --> + <key-style + latin:styleName="moreKeysDevanagariSignAnusvara" + latin:moreKeys="ः,ँ,़" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariSignAnusvara" /> + </default> + </switch> + <!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA --> + <key-style + latin:styleName="baseKeyDevanagariSignAnusvara" + latin:parentStyle="moreKeysDevanagariSignAnusvara" + latin:keySpec="ं" + latin:keyLabelFlags="fontNormal" /> +</merge> diff --git a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml b/java/res/xml-v16/keystyle_devanagari_sign_candrabindu.xml index f24612031..6198d01a9 100644 --- a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml +++ b/java/res/xml-v16/keystyle_devanagari_sign_candrabindu.xml @@ -40,8 +40,9 @@ </default> </switch> <!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU --> - <Key - latin:keyStyle="moreKeysDevanagariSignCandrabindu" + <key-style + latin:styleName="baseKeyDevanagariSignCandrabindu" + latin:parentStyle="moreKeysDevanagariSignCandrabindu" latin:keySpec="ँ" latin:keyLabelFlags="fontNormal" /> </merge> diff --git a/java/res/xml-v16/key_devanagari_sign_nukta.xml b/java/res/xml-v16/keystyle_devanagari_sign_nukta.xml index 915779524..e0b47bb6f 100644 --- a/java/res/xml-v16/key_devanagari_sign_nukta.xml +++ b/java/res/xml-v16/keystyle_devanagari_sign_nukta.xml @@ -36,14 +36,23 @@ latin:styleName="moreKeysDevanagariSignNukta" latin:moreKeys="ॽ,॰,ऽ" /> </case> + <case + latin:keyboardLayoutSet="nepali_romanized" + > + <!-- U+093C: "़" DEVANAGARI SIGN NUKTA --> + <key-style + latin:styleName="moreKeysDevanagariSignNukta" + latin:moreKeys="़" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariSignNukta" /> </default> </switch> <!-- U+093C: "़" DEVANAGARI SIGN NUKTA --> - <Key - latin:keyStyle="moreKeysDevanagariSignNukta" + <key-style + latin:styleName="baseKeyDevanagariSignNukta" + latin:parentStyle="moreKeysDevanagariSignNukta" latin:keySpec="़" latin:keyLabelFlags="fontNormal" /> </merge> diff --git a/java/res/xml-v16/keystyle_devanagari_sign_virama.xml b/java/res/xml-v16/keystyle_devanagari_sign_virama.xml index 764fb1fbb..0c3a29b16 100644 --- a/java/res/xml-v16/keystyle_devanagari_sign_virama.xml +++ b/java/res/xml-v16/keystyle_devanagari_sign_virama.xml @@ -25,9 +25,24 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+094D: "्" DEVANAGARI SIGN VIRAMA --> + <key-style + latin:styleName="moreKeysDevanagariSignVirama" + latin:moreKeys="्" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariSignVirama" /> + </default> + </switch> <!-- U+094D: "्" DEVANAGARI SIGN VIRAMA --> <key-style latin:styleName="baseKeyDevanagariSignVirama" + latin:parentStyle="moreKeysDevanagariSignVirama" latin:keySpec="्" latin:keyLabelFlags="fontNormal" /> </merge> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml index fe9264b78..5bb0351ec 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml @@ -35,6 +35,14 @@ latin:styleName="moreKeysDevanagariVowelSignAa" latin:moreKeys="ां,ाँ,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+093E: "ा" DEVANAGARI VOWEL SIGN AA --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAa" + latin:moreKeys="ा,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignAa" /> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml index fdb53bb2c..8edf6eb1c 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml @@ -35,6 +35,14 @@ latin:moreKeys="ैं,%" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0948: "ै" DEVANAGARI VOWEL SIGN AI --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAi" + latin:moreKeys="ै,%" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA --> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml index 653e79e0f..212e058d1 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml @@ -34,6 +34,14 @@ latin:styleName="moreKeysDevanagariVowelSignAu" latin:moreKeys="ौं,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+094C: "ौ" DEVANAGARI VOWEL SIGN AU --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAu" + latin:moreKeys="ौ,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignAu" /> diff --git a/java/res/xml-v16/key_devanagari_sign_anusvara.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_e.xml index ee0f21dad..ef2c3f14b 100644 --- a/java/res/xml-v16/key_devanagari_sign_anusvara.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_e.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2013, The Android Open Source Project +** Copyright 2014, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -25,8 +25,18 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA --> - <Key - latin:keySpec="ं" - latin:keyLabelFlags="fontNormal" /> + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraE" + latin:moreKeys="ॅ" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraE" /> + </default> + </switch> </merge> diff --git a/java/res/xml-v16/key_devanagari_vowel_sign_candra_o.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_o.xml index 2f1739948..ac01d37b7 100644 --- a/java/res/xml-v16/key_devanagari_vowel_sign_candra_o.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_o.xml @@ -25,8 +25,24 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraO" + latin:moreKeys="ॉ" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraO" /> + </default> + </switch> <!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O --> - <Key + <key-style + latin:styleName="baseKeyDevanagariVowelSignCandraO" + latin:parentStyle="moreKeysDevanagariVowelSignCandraO" latin:keySpec="ॉ" latin:keyLabelFlags="fontNormal" /> </merge> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml index 7240a2ca1..77d6eb5e0 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml @@ -35,6 +35,14 @@ latin:moreKeys="ें" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0947: "े" DEVANAGARI VOWEL SIGN E --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignE" + latin:moreKeys="े" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+0903: "ः" DEVANAGARI SIGN VISARGA diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml index 5a006f033..d79447be5 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml @@ -34,6 +34,14 @@ latin:styleName="moreKeysDevanagariVowelSignI" latin:moreKeys="िं" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+093F: "ि" DEVANAGARI VOWEL SIGN I --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignI" + latin:moreKeys="ि" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignI" /> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml index a2b07fe5a..0e10f3172 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml @@ -34,6 +34,14 @@ latin:styleName="moreKeysDevanagariVowelSignIi" latin:moreKeys="ीं,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0940: "ी" DEVANAGARI VOWEL SIGN II --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignIi" + latin:moreKeys="ी,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignIi" /> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml index 4b764cdee..47ca906ce 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml @@ -29,13 +29,21 @@ <case latin:keyboardLayoutSet="hindi" > - <!-- U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA + <!-- U+094B/U+0902: "ों" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O --> <key-style latin:styleName="moreKeysDevanagariVowelSignO" latin:moreKeys="ों,ॉ,ॊ" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+094B: "ो" DEVANAGARI VOWEL SIGN O --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignO" + latin:moreKeys="ो" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignO" /> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml index 18d485afe..694e4abe7 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml @@ -35,6 +35,14 @@ latin:styleName="moreKeysDevanagariVowelSignU" latin:moreKeys="ुं,ुँ" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0941: "ु" DEVANAGARI VOWEL SIGN U --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignU" + latin:moreKeys="ु" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignU" /> diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml index d770ee6c5..f17489e3a 100644 --- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml @@ -35,6 +35,14 @@ latin:styleName="moreKeysDevanagariVowelSignUu" latin:moreKeys="ूं,ूँ,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0942: "ू" DEVANAGARI VOWEL SIGN UU --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignUu" + latin:moreKeys="ू,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignUu" /> diff --git a/java/res/xml-v16/key_devanagari_vowel_sign_vocalic_r.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_vocalic_r.xml index dc7a0e090..27098466d 100644 --- a/java/res/xml-v16/key_devanagari_vowel_sign_vocalic_r.xml +++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_vocalic_r.xml @@ -35,6 +35,15 @@ latin:moreKeys="ॄ" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignVocalicR" + latin:moreKeys="ऋ,ृ" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+0913: "ओ" DEVANAGARI LETTER O --> @@ -48,8 +57,9 @@ </default> </switch> <!-- U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R --> - <Key - latin:keyStyle="moreKeysDevanagariVowelSignVocalicR" + <key-style + latin:styleName="baseKeyDevanagariVowelSignVocalicR" + latin:parentStyle="moreKeysDevanagariVowelSignVocalicR" latin:keySpec="ृ" latin:keyLabelFlags="fontNormal" /> </merge> diff --git a/java/res/xml/kbd_hindi_compact.xml b/java/res/xml/kbd_hindi_compact.xml new file mode 100644 index 000000000..7502bba9e --- /dev/null +++ b/java/res/xml/kbd_hindi_compact.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <include + latin:keyboardLayout="@xml/rows_hindi_compact" /> +</Keyboard> diff --git a/java/res/xml/key_period.xml b/java/res/xml/key_period.xml index ce23e2256..e1d4bbdf7 100644 --- a/java/res/xml/key_period.xml +++ b/java/res/xml/key_period.xml @@ -23,6 +23,17 @@ > <switch> <case + latin:languageCode="hi" + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+0964: "।" DEVANAGARI DANDA --> + <Key + latin:keySpec="\u0964" + latin:keyLabelFlags="hasPopupHint" + latin:moreKeys="!autoColumnOrder!9,\\,,.,?,!,#,),(,/,;,',@,:,-,",+,\\%,&" + latin:backgroundType="functional" /> + </case> + <case latin:languageCode="ne" latin:keyboardLayoutSet="nepali_traditional" > diff --git a/java/res/xml/keyboard_layout_set_hindi_compact.xml b/java/res/xml/keyboard_layout_set_hindi_compact.xml new file mode 100644 index 000000000..77d02fbbc --- /dev/null +++ b/java/res/xml/keyboard_layout_set_hindi_compact.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<KeyboardLayoutSet + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Element + latin:elementName="alphabet" + latin:elementKeyboard="@xml/kbd_hindi_compact" + latin:enableProximityCharsCorrection="true" /> + <Element + latin:elementName="symbols" + latin:elementKeyboard="@xml/kbd_symbols" /> + <Element + latin:elementName="symbolsShifted" + latin:elementKeyboard="@xml/kbd_symbols_shift" /> + <Element + latin:elementName="phone" + latin:elementKeyboard="@xml/kbd_phone" /> + <Element + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> + <Element + latin:elementName="number" + latin:elementKeyboard="@xml/kbd_number" /> +</KeyboardLayoutSet> diff --git a/java/res/xml/keystyle_devanagari_sign_anusvara.xml b/java/res/xml/keystyle_devanagari_sign_anusvara.xml new file mode 100644 index 000000000..6dc9b7e3a --- /dev/null +++ b/java/res/xml/keystyle_devanagari_sign_anusvara.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- The code point U+25CC for key label is needed because the font rendering system prior to + API version 16 can't automatically render dotted circle for incomplete combining letter + of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the + counterpart files named res/xml-v16/key_*.xml don't have this hack. --> +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0903: "ः" DEVANAGARI SIGN VISARGA + U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + U+093C: "़" DEVANAGARI SIGN NUKTA --> + <key-style + latin:styleName="moreKeysDevanagariSignAnusvara" + latin:moreKeys="◌ः|ः,◌ँ|ँ,◌़|़" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariSignAnusvara" /> + </default> + </switch> + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0902: "ं" DEVANAGARI SIGN ANUSVARA --> + <key-style + latin:styleName="baseKeyDevanagariSignAnusvara" + latin:parentStyle="moreKeysDevanagariSignAnusvara" + latin:keySpec="◌ं|ं" + latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> +</merge> diff --git a/java/res/xml/key_devanagari_sign_candrabindu.xml b/java/res/xml/keystyle_devanagari_sign_candrabindu.xml index 9e9c371a7..24cb44ba8 100644 --- a/java/res/xml/key_devanagari_sign_candrabindu.xml +++ b/java/res/xml/keystyle_devanagari_sign_candrabindu.xml @@ -42,8 +42,9 @@ </switch> <!-- U+25CC: "◌" DOTTED CIRCLE U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU --> - <Key - latin:keyStyle="moreKeysDevanagariSignCandrabindu" + <key-style + latin:styleName="baseKeyDevanagariSignCandrabindu" + latin:parentStyle="moreKeysDevanagariSignCandrabindu" latin:keySpec="◌ँ|ँ" latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> </merge> diff --git a/java/res/xml/key_devanagari_sign_nukta.xml b/java/res/xml/keystyle_devanagari_sign_nukta.xml index b56eb0af3..41da555ce 100644 --- a/java/res/xml/key_devanagari_sign_nukta.xml +++ b/java/res/xml/keystyle_devanagari_sign_nukta.xml @@ -37,6 +37,15 @@ latin:styleName="moreKeysDevanagariSignNukta" latin:moreKeys="◌ॽ|ॽ,◌॰|॰,◌ऽ|ऽ" /> </case> + <case + latin:keyboardLayoutSet="nepali_romanized" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+093C: "़" DEVANAGARI SIGN NUKTA --> + <key-style + latin:styleName="moreKeysDevanagariSignNukta" + latin:moreKeys="◌़|़" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariSignNukta" /> @@ -44,8 +53,9 @@ </switch> <!-- U+25CC: "◌" DOTTED CIRCLE U+093C: "़" DEVANAGARI SIGN NUKTA --> - <Key - latin:keyStyle="moreKeysDevanagariSignNukta" + <key-style + latin:styleName="baseKeyDevanagariSignNukta" + latin:parentStyle="moreKeysDevanagariSignNukta" latin:keySpec="◌़|़" latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> </merge> diff --git a/java/res/xml/keystyle_devanagari_sign_virama.xml b/java/res/xml/keystyle_devanagari_sign_virama.xml index 5e0e10823..96506e2fc 100644 --- a/java/res/xml/keystyle_devanagari_sign_virama.xml +++ b/java/res/xml/keystyle_devanagari_sign_virama.xml @@ -25,10 +25,26 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+094D: "्" DEVANAGARI SIGN VIRAMA --> + <key-style + latin:styleName="moreKeysDevanagariSignVirama" + latin:moreKeys="◌्|्" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariSignVirama" /> + </default> + </switch> <!-- U+25CC: "◌" DOTTED CIRCLE U+094D: "्" DEVANAGARI SIGN VIRAMA --> <key-style latin:styleName="baseKeyDevanagariSignVirama" + latin:parentStyle="moreKeysDevanagariSignVirama" latin:keySpec="◌्|्" latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> </merge> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml index 97f98e328..4b876505a 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml @@ -36,6 +36,15 @@ latin:styleName="moreKeysDevanagariVowelSignAa" latin:moreKeys="◌ां|ां,◌ाँ|ाँ,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+093E: "ा" DEVANAGARI VOWEL SIGN AA --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAa" + latin:moreKeys="◌ा|ा,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignAa" /> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml index 4d1b2c514..050a7ce0e 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml @@ -36,6 +36,15 @@ latin:moreKeys="◌ैं|ैं,%" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0948: "ै" DEVANAGARI VOWEL SIGN AI --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAi" + latin:moreKeys="◌ै|ै,%" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA --> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml index 66628b5ed..49e67da38 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml @@ -30,11 +30,20 @@ latin:keyboardLayoutSet="hindi" > <!-- U+25CC: "◌" DOTTED CIRCLE - U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA --> + U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA --> <key-style latin:styleName="moreKeysDevanagariVowelSignAu" latin:moreKeys="◌ौं|ौं,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+094C: "ौ" DEVANAGARI VOWEL SIGN AU --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignAu" + latin:moreKeys="◌ौ|ौ,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignAu" /> diff --git a/java/res/xml/key_devanagari_sign_anusvara.xml b/java/res/xml/keystyle_devanagari_vowel_sign_candra_e.xml index 5d7c01890..86f68d355 100644 --- a/java/res/xml/key_devanagari_sign_anusvara.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_candra_e.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2013, The Android Open Source Project +** Copyright 2014, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -25,9 +25,19 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <!-- U+25CC: "◌" DOTTED CIRCLE - U+0902: "ं" DEVANAGARI SIGN ANUSVARA --> - <Key - latin:keySpec="◌ं|ं" - latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraE" + latin:moreKeys="◌ॅ|ॅ" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraE" /> + </default> + </switch> </merge> diff --git a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml b/java/res/xml/keystyle_devanagari_vowel_sign_candra_o.xml index 6d7d000b3..fd711e049 100644 --- a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_candra_o.xml @@ -25,9 +25,26 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + <switch> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraO" + latin:moreKeys="◌ॉ|ॉ" /> + </case> + <default> + <key-style + latin:styleName="moreKeysDevanagariVowelSignCandraO" /> + </default> + </switch> <!-- U+25CC: "◌" DOTTED CIRCLE U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O --> - <Key + <key-style + latin:styleName="baseKeyDevanagariVowelSignCandraO" + latin:parentStyle="moreKeysDevanagariVowelSignCandraO" latin:keySpec="◌ॉ|ॉ" latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> </merge> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml index de1d94974..88f6a74f4 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml @@ -36,6 +36,15 @@ latin:moreKeys="◌ें|ें" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0947: "े" DEVANAGARI VOWEL SIGN E --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignE" + latin:moreKeys="◌े|े" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+25CC: "◌" DOTTED CIRCLE diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml index d1d56c185..a84fdb4a9 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml @@ -35,6 +35,15 @@ latin:styleName="moreKeysDevanagariVowelSignI" latin:moreKeys="ि◌ं|िं" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+093F: "ि" DEVANAGARI VOWEL SIGN I --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignI" + latin:moreKeys="◌ि|ि" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignI" /> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml index fd0ce77f8..6f6eb0f15 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml @@ -29,12 +29,21 @@ <case latin:keyboardLayoutSet="hindi" > - <!-- U+0940: "ी" DEVANAGARI VOWEL SIGN II + <!-- U+25CC: "◌" DOTTED CIRCLE U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA --> <key-style latin:styleName="moreKeysDevanagariVowelSignIi" latin:moreKeys="◌ीं|ीं,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0940: "ी" DEVANAGARI VOWEL SIGN II --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignIi" + latin:moreKeys="◌ी|ी,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignIi" /> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml index edc3bef0f..68b176a43 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml @@ -30,13 +30,22 @@ latin:keyboardLayoutSet="hindi" > <!-- U+25CC: "◌" DOTTED CIRCLE - U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA + U+094B/U+0902: "ों" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O --> <key-style latin:styleName="moreKeysDevanagariVowelSignO" latin:moreKeys="◌ों|ों,◌ॉ|ॉ,◌ॊ|ॊ" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+094B: "ो" DEVANAGARI VOWEL SIGN O --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignO" + latin:moreKeys="◌ो|ो" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignO" /> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml index c7de4fdd8..7c058b174 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml @@ -36,6 +36,15 @@ latin:styleName="moreKeysDevanagariVowelSignU" latin:moreKeys="◌ुं|ुं,◌ुँ|ुँ" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0941: "ु" DEVANAGARI VOWEL SIGN U --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignU" + latin:moreKeys="◌ु|ु" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignU" /> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml index 6029d6d2b..73ab63c89 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml @@ -36,6 +36,15 @@ latin:styleName="moreKeysDevanagariVowelSignUu" latin:moreKeys="◌ूं|ूं,◌ूँ|ूँ,%" /> </case> + <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+25CC: "◌" DOTTED CIRCLE + U+0942: "ू" DEVANAGARI VOWEL SIGN UU --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignUu" + latin:moreKeys="◌ू|ू,%" /> + </case> <default> <key-style latin:styleName="moreKeysDevanagariVowelSignUu" /> diff --git a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml b/java/res/xml/keystyle_devanagari_vowel_sign_vocalic_r.xml index badea3e2c..29b083eb3 100644 --- a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_vocalic_r.xml @@ -36,6 +36,16 @@ latin:moreKeys="◌ॄ|ॄ" /> </case> <case + latin:keyboardLayoutSet="hindi_compact" + > + <!-- U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + U+25CC: "◌" DOTTED CIRCLE + U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R --> + <key-style + latin:styleName="moreKeysDevanagariVowelSignVocalicR" + latin:moreKeys="ऋ,◌ृ|ृ" /> + </case> + <case latin:keyboardLayoutSet="nepali_traditional" > <!-- U+0913: "ओ" DEVANAGARI LETTER O --> @@ -50,8 +60,9 @@ </switch> <!-- U+25CC: "◌" DOTTED CIRCLE U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R --> - <Key - latin:keyStyle="moreKeysDevanagariVowelSignVocalicR" + <key-style + latin:styleName="baseKeyDevanagariVowelSignVocalicR" + latin:parentStyle="moreKeysDevanagariVowelSignVocalicR" latin:keySpec="◌ृ|ृ" latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> </merge> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index c64b3a4e0..ee1b54b1b 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -49,6 +49,7 @@ fr_CH: French (Switzerland)/swiss gl_ES: Galician (Spain)/spanish hi: Hindi/hindi + hi: Hindi/hindi_compact hr: Croatian/qwertz hu: Hungarian/qwertz hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic @@ -321,6 +322,14 @@ android:isAsciiCapable="false" /> <subtype android:icon="@drawable/ic_ime_switcher_dark" + android:label="@string/subtype_generic_compact" + android:subtypeId="0xe49c89a1" + android:imeSubtypeLocale="hi" + android:imeSubtypeMode="keyboard" + android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi_compact,EmojiCapable" + android:isAsciiCapable="false" + /> + <subtype android:icon="@drawable/ic_ime_switcher_dark" android:label="@string/subtype_generic" android:subtypeId="0x35b7526a" android:imeSubtypeLocale="hr" @@ -485,7 +494,7 @@ android:isAsciiCapable="false" /> <subtype android:icon="@drawable/ic_ime_switcher_dark" - android:label="@string/subtype_nepali_traditional" + android:label="@string/subtype_generic_traditional" android:subtypeId="0x5fafea88" android:imeSubtypeLocale="ne_NP" android:imeSubtypeMode="keyboard" diff --git a/java/res/xml/rowkeys_hindi1.xml b/java/res/xml/rowkeys_hindi1.xml index 5d696b32c..cff9756cf 100644 --- a/java/res/xml/rowkeys_hindi1.xml +++ b/java/res/xml/rowkeys_hindi1.xml @@ -92,9 +92,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+0967: "१" DEVANAGARI DIGIT ONE --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" /> + <!-- U+0967: "१" DEVANAGARI DIGIT ONE --> <Key latin:keyStyle="baseKeyDevanagariVowelSignAu" latin:keyHintLabel="1" @@ -102,9 +102,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+0968: "२" DEVANAGARI DIGIT TWO --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ai" /> + <!-- U+0968: "२" DEVANAGARI DIGIT TWO --> <Key latin:keyStyle="baseKeyDevanagariVowelSignAi" latin:keyHintLabel="2" @@ -112,9 +112,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+0969: "३" DEVANAGARI DIGIT THREE --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_aa" /> + <!-- U+0969: "३" DEVANAGARI DIGIT THREE --> <Key latin:keyStyle="baseKeyDevanagariVowelSignAa" latin:keyHintLabel="3" @@ -122,9 +122,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+096A: "४" DEVANAGARI DIGIT FOUR --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ii" /> + <!-- U+096A: "४" DEVANAGARI DIGIT FOUR --> <Key latin:keyStyle="baseKeyDevanagariVowelSignIi" latin:keyHintLabel="4" @@ -132,9 +132,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+096B: "५" DEVANAGARI DIGIT FIVE --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_uu" /> + <!-- U+096B: "५" DEVANAGARI DIGIT FIVE --> <Key latin:keyStyle="baseKeyDevanagariVowelSignUu" latin:keyHintLabel="5" diff --git a/java/res/xml/rowkeys_hindi3.xml b/java/res/xml/rowkeys_hindi3.xml index a9be47266..cf36fc5d4 100644 --- a/java/res/xml/rowkeys_hindi3.xml +++ b/java/res/xml/rowkeys_hindi3.xml @@ -33,7 +33,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" /> + <Key + latin:keyStyle="baseKeyDevanagariSignCandrabindu" /> <!-- U+0923: "ण" DEVANAGARI LETTER NNA --> <Key latin:keySpec="ण" @@ -59,7 +61,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" /> + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" /> + <Key + latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" /> <!-- U+091E: "ञ" DEVANAGARI LETTER NYA --> <Key latin:keySpec="ञ" @@ -70,9 +74,16 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_vowel_sign_candra_o" /> + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_o" /> + <Key + latin:keyStyle="baseKeyDevanagariVowelSignCandraO" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" /> + <Key + latin:keyStyle="baseKeyDevanagariSignAnusvara" /> <!-- U+092E: "म" DEVANAGARI LETTER MA U+0950: "ॐ" DEVANAGARI OM --> <Key @@ -112,7 +123,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_nukta" /> - </default> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_nukta" /> + <Key + latin:keyStyle="baseKeyDevanagariSignNukta" /> + </default> </switch> </merge> diff --git a/java/res/xml/rowkeys_hindi_compact1.xml b/java/res/xml/rowkeys_hindi_compact1.xml new file mode 100644 index 000000000..c63de4f0b --- /dev/null +++ b/java/res/xml/rowkeys_hindi_compact1.xml @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" /> + <!-- U+0914: "औ" DEVANAGARI LETTER AU + U+0967: "१" DEVANAGARI DIGIT ONE --> + <Key + latin:keySpec="औ" + latin:keyStyle="moreKeysDevanagariVowelSignAu" + latin:keyHintLabel="1" + latin:additionalMoreKeys="१,1" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ai" /> + <!-- U+0910: "ऐ" DEVANAGARI LETTER AI + U+0968: "२" DEVANAGARI DIGIT TWO --> + <Key + latin:keySpec="ऐ" + latin:keyStyle="moreKeysDevanagariVowelSignAi" + latin:keyHintLabel="2" + latin:additionalMoreKeys="२,2" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_aa" /> + <!-- U+0906: "आ" DEVANAGARI LETTER AA + U+0969: "३" DEVANAGARI DIGIT THREE --> + <Key + latin:keySpec="आ" + latin:keyStyle="moreKeysDevanagariVowelSignAa" + latin:keyHintLabel="3" + latin:additionalMoreKeys="३,3" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ii" /> + <!-- U+0908: "ई" DEVANAGARI LETTER II + U+096A: "४" DEVANAGARI DIGIT FOUR --> + <Key + latin:keySpec="ई" + latin:keyStyle="moreKeysDevanagariVowelSignIi" + latin:keyHintLabel="4" + latin:additionalMoreKeys="४,4" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_uu" /> + <!-- U+090A: "ऊ" DEVANAGARI LETTER UU + U+096B: "५" DEVANAGARI DIGIT FIVE --> + <Key + latin:keySpec="ऊ" + latin:keyStyle="moreKeysDevanagariVowelSignUu" + latin:keyHintLabel="5" + latin:additionalMoreKeys="५,5" + latin:keyLabelFlags="fontNormal" /> + <!-- U+092C: "ब" DEVANAGARI LETTER BA + U+092D: "भ" DEVANAGARI LETTER BHA + U+096C: "६" DEVANAGARI DIGIT SIX --> + <Key + latin:keySpec="ब" + latin:moreKeys="भ,%" + latin:keyHintLabel="6" + latin:additionalMoreKeys="६,6" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0939: "ह" DEVANAGARI LETTER HA + U+096D: "७" DEVANAGARI DIGIT SEVEN --> + <Key + latin:keySpec="ह" + latin:keyHintLabel="7" + latin:additionalMoreKeys="७,7" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0917: "ग" DEVANAGARI LETTER GA + U+0918: "घ" DEVANAGARI LETTER GHA + U+096E: "८" DEVANAGARI DIGIT EIGHT --> + <Key + latin:keySpec="ग" + latin:moreKeys="घ,%" + latin:keyHintLabel="8" + latin:additionalMoreKeys="८,8" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0926: "द" DEVANAGARI LETTER DA + U+0927: "ध" DEVANAGARI LETTER DHA + U+096F: "९" DEVANAGARI DIGIT NINE --> + <Key + latin:keySpec="द" + latin:moreKeys="ध,%" + latin:keyHintLabel="9" + latin:additionalMoreKeys="९,9" + latin:keyLabelFlags="fontNormal" /> + <!-- U+091C: "ज" DEVANAGARI LETTER JA + U+091D: "झ" DEVANAGARI LETTER JHA + U+091C/U+094D/U+091E: "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + U+0966: "०" DEVANAGARI DIGIT ZERO --> + <Key + latin:keySpec="ज" + latin:moreKeys="झ,ज्ञ,%" + latin:keyHintLabel="0" + latin:additionalMoreKeys="०,0" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0921: "ड" DEVANAGARI LETTER DDA + U+0922: "ढ" DEVANAGARI LETTER DDHA --> + <Key + latin:keySpec="ड" + latin:moreKeys="ढ" + latin:keyLabelFlags="fontNormal" /> +</merge> diff --git a/java/res/xml/rowkeys_hindi_compact2.xml b/java/res/xml/rowkeys_hindi_compact2.xml new file mode 100644 index 000000000..06364c209 --- /dev/null +++ b/java/res/xml/rowkeys_hindi_compact2.xml @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_o" /> + <!-- U+0913: "ओ" DEVANAGARI LETTER O --> + <Key + latin:keySpec="ओ" + latin:keyStyle="moreKeysDevanagariVowelSignO" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_e" /> + <!-- U+090F: "ए" DEVANAGARI LETTER E --> + <Key + latin:keySpec="ए" + latin:keyStyle="moreKeysDevanagariVowelSignE" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_sign_virama" /> + <!-- U+0905: "अ" DEVANAGARI LETTER A --> + <Key + latin:keySpec="अ" + latin:keyStyle="moreKeysDevanagariSignVirama" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_i" /> + <!-- U+0907: "इ" DEVANAGARI LETTER I --> + <Key + latin:keySpec="इ" + latin:keyStyle="moreKeysDevanagariVowelSignI" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_u" /> + <!-- U+0909: "उ" DEVANAGARI LETTER U --> + <Key + latin:keySpec="उ" + latin:keyStyle="moreKeysDevanagariVowelSignU" + latin:keyLabelFlags="fontNormal" /> + <!-- U+092A: "प" DEVANAGARI LETTER PA + U+092B: "फ" DEVANAGARI LETTER PHA --> + <Key + latin:keySpec="प" + latin:moreKeys="फ" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" /> + <!-- U+0930: "र" DEVANAGARI LETTER RA --> + <Key + latin:keySpec="र" + latin:keyStyle="moreKeysDevanagariVowelSignVocalicR" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0915: "क" DEVANAGARI LETTER KA + U+0916: "ख" DEVANAGARI LETTER KHA --> + <Key + latin:keySpec="क" + latin:moreKeys="ख" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0924: "त" DEVANAGARI LETTER TA + U+0925: "थ" DEVANAGARI LETTER THA + U+0924/U+094D/U+0930: "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA --> + <Key + latin:keySpec="त" + latin:moreKeys="थ,त्र" + latin:keyLabelFlags="fontNormal" /> + <!-- U+091A: "च" DEVANAGARI LETTER CA + U+091B: "छ" DEVANAGARI LETTER CHA --> + <Key + latin:keySpec="च" + latin:moreKeys="छ" + latin:keyLabelFlags="fontNormal" /> + <!-- U+091F: "ट" DEVANAGARI LETTER TTA + U+0920: "ठ" DEVANAGARI LETTER TTHA --> + <Key + latin:keySpec="ट" + latin:moreKeys="ठ" + latin:keyLabelFlags="fontNormal" /> +</merge> diff --git a/java/res/xml/rowkeys_hindi_compact3.xml b/java/res/xml/rowkeys_hindi_compact3.xml new file mode 100644 index 000000000..0e8165ecc --- /dev/null +++ b/java/res/xml/rowkeys_hindi_compact3.xml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_o" /> + <!-- U+0911: "ऑ" DEVANAGARI LETTER CANDRA O --> + <Key + latin:keySpec="ऑ" + latin:keyStyle="moreKeysDevanagariVowelSignCandraO" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_e" /> + <!-- U+090D: "ऍ" DEVANAGARI LETTER CANDRA E --> + <Key + latin:keySpec="ऍ" + latin:keyStyle="moreKeysDevanagariVowelSignCandraE" + latin:keyLabelFlags="fontNormal" /> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" /> + <Key + latin:keyStyle="baseKeyDevanagariSignAnusvara" /> + <!-- U+092E: "म" DEVANAGARI LETTER MA + U+0950: "ॐ" DEVANAGARI OM --> + <Key + latin:keySpec="म" + latin:moreKeys="ॐ" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0928: "न" DEVANAGARI LETTER NA + U+0923: "ण" DEVANAGARI LETTER NNA + U+091E: "ञ" DEVANAGARI LETTER NYA + U+0919: "ङ" DEVANAGARI LETTER NGA --> + <Key + latin:keySpec="न" + latin:moreKeys="ण,ञ,ङ" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0935: "व" DEVANAGARI LETTER VA --> + <Key + latin:keySpec="व" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0932: "ल" DEVANAGARI LETTER LA --> + <Key + latin:keySpec="ल" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0938: "स" DEVANAGARI LETTER SA + U+0936: "श" DEVANAGARI LETTER SHA + U+0937: "ष" DEVANAGARI LETTER SSA + U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA --> + <Key + latin:keySpec="स" + latin:moreKeys="श,ष,श्र" + latin:keyLabelFlags="fontNormal" /> + <!-- U+092F: "य" DEVANAGARI LETTER YA --> + <Key + latin:keySpec="य" + latin:keyLabelFlags="fontNormal" /> + <!-- U+0915/U+094D/U+0937: "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA --> + <Key + latin:keySpec="क्ष" + latin:keyLabelFlags="fontNormal|followKeyLetterRatio" /> +</merge> diff --git a/java/res/xml/rowkeys_nepali_romanized1.xml b/java/res/xml/rowkeys_nepali_romanized1.xml index 3c082c2fe..616b259a3 100644 --- a/java/res/xml/rowkeys_nepali_romanized1.xml +++ b/java/res/xml/rowkeys_nepali_romanized1.xml @@ -44,7 +44,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" /> + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" /> + <Key + latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" /> <!-- U+0925: "थ" DEVANAGARI LETTER THA --> <Key latin:keySpec="थ" @@ -81,21 +83,25 @@ latin:keyLabelFlags="fontNormal" /> </case> <default> + <!-- Because the font rendering system prior to API version 16 can't automatically + render dotted circle for incomplete combining letter of some scripts, different + set of Key definitions are needed based on the API version. --> + <include + latin:keyboardLayout="@xml/keystyle_devanagari_sign_nukta" /> <!-- U+091F: "ट" DEVANAGARI LETTER TTA - U+0967: "१" DEVANAGARI DIGIT ONE - U+093C: "़" DEVANAGARI SIGN NUKTA --> + U+0967: "१" DEVANAGARI DIGIT ONE --> <Key latin:keySpec="ट" latin:keyHintLabel="1" latin:additionalMoreKeys="१,1" - latin:moreKeys="़" + latin:keyStyle="moreKeysDevanagariSignNukta" latin:keyLabelFlags="fontNormal" /> <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+0968: "२" DEVANAGARI DIGIT TWO --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" /> + <!-- U+0968: "२" DEVANAGARI DIGIT TWO --> <Key latin:keyStyle="baseKeyDevanagariVowelSignAu" latin:keyHintLabel="2" @@ -103,9 +109,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+0969: "३" DEVANAGARI DIGIT THREE --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_e" /> + <!-- U+0969: "३" DEVANAGARI DIGIT THREE --> <Key latin:keyStyle="baseKeyDevanagariVowelSignE" latin:keyHintLabel="3" @@ -134,9 +140,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+096D: "७" DEVANAGARI DIGIT SEVEN --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_u" /> + <!-- U+096D: "७" DEVANAGARI DIGIT SEVEN --> <Key latin:keyStyle="baseKeyDevanagariVowelSignU" latin:keyHintLabel="7" @@ -144,9 +150,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+096E: "८" DEVANAGARI DIGIT EIGHT --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_i" /> + <!-- U+096E: "८" DEVANAGARI DIGIT EIGHT --> <Key latin:keyStyle="baseKeyDevanagariVowelSignI" latin:keyHintLabel="8" @@ -154,9 +160,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+096F: "९" DEVANAGARI DIGIT NINE --> <include latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_o" /> + <!-- U+096F: "९" DEVANAGARI DIGIT NINE --> <Key latin:keyStyle="baseKeyDevanagariVowelSignO" latin:keyHintLabel="9" diff --git a/java/res/xml/rowkeys_nepali_romanized3.xml b/java/res/xml/rowkeys_nepali_romanized3.xml index 232d96e02..cc2ca8c84 100644 --- a/java/res/xml/rowkeys_nepali_romanized3.xml +++ b/java/res/xml/rowkeys_nepali_romanized3.xml @@ -41,7 +41,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" /> + <Key + latin:keyStyle="baseKeyDevanagariSignCandrabindu" /> <!-- U+092D: "भ" DEVANAGARI LETTER BHA --> <Key latin:keySpec="भ" @@ -54,7 +56,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" /> + <Key + latin:keyStyle="baseKeyDevanagariSignAnusvara" /> <!-- U+0919: "ङ" DEVANAGARI LETTER NGA --> <Key latin:keySpec="ङ" diff --git a/java/res/xml/rowkeys_nepali_traditional1.xml b/java/res/xml/rowkeys_nepali_traditional1.xml index 98a7be260..cf4bda982 100644 --- a/java/res/xml/rowkeys_nepali_traditional1.xml +++ b/java/res/xml/rowkeys_nepali_traditional1.xml @@ -91,7 +91,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" /> + latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" /> + <Key + latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" /> </case> <default> <!-- U+091F: "ट" DEVANAGARI LETTER TTA diff --git a/java/res/xml/rowkeys_nepali_traditional2.xml b/java/res/xml/rowkeys_nepali_traditional2.xml index 5ea14ea0d..58a463e71 100644 --- a/java/res/xml/rowkeys_nepali_traditional2.xml +++ b/java/res/xml/rowkeys_nepali_traditional2.xml @@ -41,7 +41,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" /> + <Key + latin:keyStyle="baseKeyDevanagariSignCandrabindu" /> <!-- U+0926/U+094D/U+0926: "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA --> <Key latin:keySpec="द्द" diff --git a/java/res/xml/rowkeys_nepali_traditional3_right3.xml b/java/res/xml/rowkeys_nepali_traditional3_right3.xml index d6a74d46a..3e6187d11 100644 --- a/java/res/xml/rowkeys_nepali_traditional3_right3.xml +++ b/java/res/xml/rowkeys_nepali_traditional3_right3.xml @@ -29,7 +29,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" /> + <Key + latin:keyStyle="baseKeyDevanagariSignAnusvara" /> <!-- U+0919: "ङ" DEVANAGARI LETTER NGA --> <Key latin:keySpec="ङ" @@ -54,8 +56,8 @@ <Key latin:keySpec="।" latin:keyLabelFlags="fontNormal" /> - <!-- U+0930: "र" DEVANAGARI LETTER RA - U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U --> + <!-- U+0930: "र" DEVANAGARI LETTER RA + U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U --> <Key latin:keySpec="र" latin:moreKeys="रु" diff --git a/java/res/xml/rowkeys_nepali_traditional3_right5.xml b/java/res/xml/rowkeys_nepali_traditional3_right5.xml index a34f40097..89d5aa469 100644 --- a/java/res/xml/rowkeys_nepali_traditional3_right5.xml +++ b/java/res/xml/rowkeys_nepali_traditional3_right5.xml @@ -29,7 +29,9 @@ render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> <include - latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" /> + latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" /> + <Key + latin:keyStyle="baseKeyDevanagariSignAnusvara" /> <!-- U+0919: "ङ" DEVANAGARI LETTER NGA --> <Key latin:keySpec="ङ" @@ -53,9 +55,9 @@ <!-- Because the font rendering system prior to API version 16 can't automatically render dotted circle for incomplete combining letter of some scripts, different set of Key definitions are needed based on the API version. --> - <!-- U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA --> <include latin:keyboardLayout="@xml/keystyle_devanagari_sign_visarga" /> + <!-- U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA --> <Key latin:keyStyle="baseKeyDevanagariSignVisarga" latin:moreKeys="ऽ" /> diff --git a/java/res/xml/rows_hindi_compact.xml b/java/res/xml/rows_hindi_compact.xml new file mode 100644 index 000000000..a60cf2b02 --- /dev/null +++ b/java/res/xml/rows_hindi_compact.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<merge + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" +> + <include + latin:keyboardLayout="@xml/key_styles_common" /> + <Row + latin:keyWidth="9.091%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact1" /> + </Row> + <Row + latin:keyWidth="9.091%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact2" /> + </Row> + <Row + latin:keyWidth="9.091%p" + > + <include + latin:keyboardLayout="@xml/rowkeys_hindi_compact3" /> + <Key + latin:keyStyle="deleteKeyStyle" + latin:keyWidth="fillRight" /> + </Row> + <include + latin:keyboardLayout="@xml/row_qwerty4" /> +</merge> diff --git a/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java b/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java index 8badaf4b9..4a8fa51ee 100644 --- a/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java +++ b/java/src/com/android/inputmethod/dictionarypack/MetadataDbHelper.java @@ -45,10 +45,8 @@ public class MetadataDbHelper extends SQLiteOpenHelper { // This is the first released version of the database that implements CLIENTID. It is // used to identify the versions for upgrades. This should never change going forward. private static final int METADATA_DATABASE_VERSION_WITH_CLIENTID = 6; - // This is the current database version. It should be updated when the database schema - // gets updated. It is passed to the framework constructor of SQLiteOpenHelper, so - // that's what the framework uses to track our database version. - private static final int METADATA_DATABASE_VERSION = 6; + // The current database version. + private static final int CURRENT_METADATA_DATABASE_VERSION = 7; private final static long NOT_A_DOWNLOAD_ID = -1; @@ -169,7 +167,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper { private MetadataDbHelper(final Context context, final String clientId) { super(context, METADATA_DATABASE_NAME_STEM + (TextUtils.isEmpty(clientId) ? "" : "." + clientId), - null, METADATA_DATABASE_VERSION); + null, CURRENT_METADATA_DATABASE_VERSION); mContext = context; mClientId = clientId; } @@ -219,22 +217,45 @@ public class MetadataDbHelper extends SQLiteOpenHelper { /** * Upgrade the database. Upgrade from version 3 is supported. + * Version 3 has a DB named METADATA_DATABASE_NAME_STEM containing a table METADATA_TABLE_NAME. + * Version 6 and above has a DB named METADATA_DATABASE_NAME_STEM containing a + * table CLIENT_TABLE_NAME, and for each client a table called METADATA_TABLE_STEM + "." + the + * name of the client and contains a table METADATA_TABLE_NAME. + * For schemas, see the above create statements. The schemas have never changed so far. + * + * This method is called by the framework. See {@link SQLiteOpenHelper#onUpgrade} + * @param db The database we are upgrading + * @param oldVersion The old database version (the one on the disk) + * @param newVersion The new database version as supplied to the constructor of SQLiteOpenHelper */ @Override public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) { if (METADATA_DATABASE_INITIAL_VERSION == oldVersion - && METADATA_DATABASE_VERSION_WITH_CLIENTID == newVersion) { + && METADATA_DATABASE_VERSION_WITH_CLIENTID <= newVersion + && CURRENT_METADATA_DATABASE_VERSION >= newVersion) { // Upgrade from version METADATA_DATABASE_INITIAL_VERSION to version // METADATA_DATABASE_VERSION_WITH_CLIENT_ID + // Only the default database should contain the client table, so we test for mClientId. if (TextUtils.isEmpty(mClientId)) { - // Only the default database should contain the client table. - // Anyway in version 3 only the default table existed so the emptyness + // Anyway in version 3 only the default table existed so the emptiness // test should always be true, but better check to be sure. createClientTable(db); } + } else if (METADATA_DATABASE_VERSION_WITH_CLIENTID < newVersion + && CURRENT_METADATA_DATABASE_VERSION >= newVersion) { + // Here we drop the client table, so that all clients send us their information again. + // The client table contains the URL to hit to update the available dictionaries list, + // but the info about the dictionaries themselves is stored in the table called + // METADATA_TABLE_NAME and we want to keep it, so we only drop the client table. + db.execSQL("DROP TABLE IF EXISTS " + CLIENT_TABLE_NAME); + // Only the default database should contain the client table, so we test for mClientId. + if (TextUtils.isEmpty(mClientId)) { + createClientTable(db); + } } else { - // Version 3 was the earliest version, so we should never come here. If we do, we - // have no idea what this database is, so we'd better wipe it off. + // If we're not in the above case, either we are upgrading from an earlier versionCode + // and we should wipe the database, or we are handling a version we never heard about + // (can only be a bug) so it's safer to wipe the database. db.execSQL("DROP TABLE IF EXISTS " + METADATA_TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + CLIENT_TABLE_NAME); onCreate(db); diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 646590948..6535d2d76 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -36,25 +36,25 @@ public class Event { // Should the types below be represented by separate classes instead? It would be cleaner // but probably a bit too much // An event we don't handle in Latin IME, for example pressing Ctrl on a hardware keyboard. - final public static int EVENT_NOT_HANDLED = 0; + final public static int EVENT_TYPE_NOT_HANDLED = 0; // A key press that is part of input, for example pressing an alphabetic character on a // hardware qwerty keyboard. It may be part of a sequence that will be re-interpreted later // through combination. - final public static int EVENT_INPUT_KEYPRESS = 1; + final public static int EVENT_TYPE_INPUT_KEYPRESS = 1; // A toggle event is triggered by a key that affects the previous character. An example would // be a numeric key on a 10-key keyboard, which would toggle between 1 - a - b - c with // repeated presses. - final public static int EVENT_TOGGLE = 2; + final public static int EVENT_TYPE_TOGGLE = 2; // A mode event instructs the combiner to change modes. The canonical example would be the // hankaku/zenkaku key on a Japanese keyboard, or even the caps lock key on a qwerty keyboard // if handled at the combiner level. - final public static int EVENT_MODE_KEY = 3; + final public static int EVENT_TYPE_MODE_KEY = 3; // An event corresponding to a gesture. - final public static int EVENT_GESTURE = 4; + final public static int EVENT_TYPE_GESTURE = 4; // An event corresponding to the manual pick of a suggestion. - final public static int EVENT_SUGGESTION_PICKED = 5; + final public static int EVENT_TYPE_SUGGESTION_PICKED = 5; // An event corresponding to a string generated by some software process. - final public static int EVENT_SOFTWARE_GENERATED_STRING = 6; + final public static int EVENT_TYPE_SOFTWARE_GENERATED_STRING = 6; // 0 is a valid code point, so we use -1 here. final public static int NOT_A_CODE_POINT = -1; @@ -66,7 +66,7 @@ public class Event { // or dead-abovering. final private static int FLAG_DEAD = 0x1; - final private int mType; // The type of event - one of the constants above + final private int mEventType; // The type of event - one of the constants above // The code point associated with the event, if relevant. This is a unicode code point, and // has nothing to do with other representations of the key. It is only relevant if this event // is of KEYPRESS type, but for a mode key like hankaku/zenkaku or ctrl, there is no code point @@ -94,7 +94,7 @@ public class Event { // Some flags that can't go into the key code. It's a bit field of FLAG_* final private int mFlags; - // If this is of type EVENT_SUGGESTION_PICKED, this must not be null (and must be null in + // If this is of type EVENT_TYPE_SUGGESTION_PICKED, this must not be null (and must be null in // other cases). final public SuggestedWordInfo mSuggestedWordInfo; @@ -105,7 +105,7 @@ public class Event { private Event(final int type, final CharSequence text, final int codePoint, final int keyCode, final int x, final int y, final SuggestedWordInfo suggestedWordInfo, final int flags, final Event next) { - mType = type; + mEventType = type; mText = text; mCodePoint = codePoint; mKeyCode = keyCode; @@ -116,7 +116,7 @@ public class Event { mNextEvent = next; // Sanity checks // mSuggestedWordInfo is non-null if and only if the type is SUGGESTION_PICKED - if (EVENT_SUGGESTION_PICKED == mType) { + if (EVENT_TYPE_SUGGESTION_PICKED == mEventType) { if (null == mSuggestedWordInfo) { throw new RuntimeException("Wrong event: SUGGESTION_PICKED event must have a " + "non-null SuggestedWordInfo"); @@ -131,13 +131,13 @@ public class Event { public static Event createSoftwareKeypressEvent(final int codePoint, final int keyCode, final int x, final int y) { - return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y, - null /* suggestedWordInfo */, FLAG_NONE, null); + return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y, + null /* suggestedWordInfo */, FLAG_NONE, null /* next */); } public static Event createHardwareKeypressEvent(final int codePoint, final int keyCode, final Event next) { - return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, + return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, next); } @@ -145,7 +145,7 @@ public class Event { // This creates an input event for a dead character. @see {@link #FLAG_DEAD} public static Event createDeadEvent(final int codePoint, final int keyCode, final Event next) { // TODO: add an argument or something if we ever create a software layout with dead keys. - return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, + return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE, null /* suggestedWordInfo */, FLAG_DEAD, next); } @@ -159,7 +159,7 @@ public class Event { */ public static Event createEventForCodePointFromUnknownSource(final int codePoint) { // TODO: should we have a different type of event for this? After all, it's not a key press. - return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE, + return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, null /* next */); } @@ -175,8 +175,8 @@ public class Event { public static Event createEventForCodePointFromAlreadyTypedText(final int codePoint, final int x, final int y) { // TODO: should we have a different type of event for this? After all, it's not a key press. - return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE, x, y, - null /* suggestedWordInfo */, FLAG_NONE, null /* next */); + return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE, + x, y, null /* suggestedWordInfo */, FLAG_NONE, null /* next */); } /** @@ -184,10 +184,10 @@ public class Event { * @return an event for this suggestion pick. */ public static Event createSuggestionPickedEvent(final SuggestedWordInfo suggestedWordInfo) { - return new Event(EVENT_SUGGESTION_PICKED, suggestedWordInfo.mWord, + return new Event(EVENT_TYPE_SUGGESTION_PICKED, suggestedWordInfo.mWord, NOT_A_CODE_POINT, NOT_A_KEY_CODE, Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE, - suggestedWordInfo, FLAG_NONE, null); + suggestedWordInfo, FLAG_NONE, null /* next */); } /** @@ -199,13 +199,26 @@ public class Event { * @return an event for this text. */ public static Event createSoftwareTextEvent(final CharSequence text, final int keyCode) { - return new Event(EVENT_SOFTWARE_GENERATED_STRING, text, NOT_A_CODE_POINT, keyCode, + return new Event(EVENT_TYPE_SOFTWARE_GENERATED_STRING, text, NOT_A_CODE_POINT, keyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, null /* next */); } + /** + * Creates an input event representing the manual pick of a punctuation suggestion. + * @return an event for this suggestion pick. + */ + public static Event createPunctuationSuggestionPickedEvent( + final SuggestedWordInfo suggestedWordInfo) { + final int primaryCode = suggestedWordInfo.mWord.charAt(0); + return new Event(EVENT_TYPE_SUGGESTION_PICKED, suggestedWordInfo.mWord, primaryCode, + NOT_A_KEY_CODE, Constants.SUGGESTION_STRIP_COORDINATE, + Constants.SUGGESTION_STRIP_COORDINATE, suggestedWordInfo, FLAG_NONE, + null /* next */); + } + public static Event createNotHandledEvent() { - return new Event(EVENT_NOT_HANDLED, null /* text */, NOT_A_CODE_POINT, NOT_A_KEY_CODE, + return new Event(EVENT_TYPE_NOT_HANDLED, null /* text */, NOT_A_CODE_POINT, NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, null); } @@ -218,25 +231,26 @@ public class Event { // Returns whether this is a fake key press from the suggestion strip. This happens with // punctuation signs selected from the suggestion strip. public boolean isSuggestionStripPress() { - return EVENT_INPUT_KEYPRESS == mType && Constants.SUGGESTION_STRIP_COORDINATE == mX; + return EVENT_TYPE_SUGGESTION_PICKED == mEventType; } public boolean isHandled() { - return EVENT_NOT_HANDLED != mType; + return EVENT_TYPE_NOT_HANDLED != mEventType; } public CharSequence getTextToCommit() { - switch (mType) { - case EVENT_MODE_KEY: - case EVENT_NOT_HANDLED: - case EVENT_TOGGLE: + switch (mEventType) { + case EVENT_TYPE_MODE_KEY: + case EVENT_TYPE_NOT_HANDLED: + case EVENT_TYPE_TOGGLE: return ""; - case EVENT_INPUT_KEYPRESS: + case EVENT_TYPE_INPUT_KEYPRESS: return StringUtils.newSingleCodePointString(mCodePoint); - case EVENT_GESTURE: - case EVENT_SOFTWARE_GENERATED_STRING: + case EVENT_TYPE_GESTURE: + case EVENT_TYPE_SOFTWARE_GENERATED_STRING: + case EVENT_TYPE_SUGGESTION_PICKED: return mText; } - throw new RuntimeException("Unknown event type: " + mType); + throw new RuntimeException("Unknown event type: " + mEventType); } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index fd0be6f92..2e4a0902d 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -219,22 +219,15 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { return null; } - /** - * Update keyboard shift state triggered by connected EditText status change. - */ - public void updateShiftState() { - mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState(), - mLatinIME.getCurrentRecapitalizeState()); - } - // TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout // when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal(). public void resetKeyboardStateToAlphabet() { mState.onResetKeyboardStateToAlphabet(); } - public void onPressKey(final int code, final boolean isSinglePointer) { - mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); + public void onPressKey(final int code, final boolean isSinglePointer, + final int currentAutoCapsState) { + mState.onPressKey(code, isSinglePointer, currentAutoCapsState); } public void onReleaseKey(final int code, final boolean withSliding) { @@ -338,8 +331,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ - public void onCodeInput(final int code) { - mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState()); + public void onCodeInput(final int code, final int currentAutoCapsState) { + mState.onCodeInput(code, currentAutoCapsState); } public boolean isShowingEmojiPalettes() { diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 60ac1ba48..30c2dfedb 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -89,6 +89,8 @@ public final class BinaryDictionary extends Dictionary { private final long mDictSize; private final String mDictFilePath; private final boolean mIsUpdatable; + private boolean mHasUpdated; + private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH]; private final int[] mOutputSuggestionCount = new int[1]; private final int[] mOutputCodePoints = new int[MAX_WORD_LENGTH * MAX_RESULTS]; @@ -97,6 +99,7 @@ public final class BinaryDictionary extends Dictionary { private final int[] mOutputTypes = new int[MAX_RESULTS]; // Only one result is ever used private final int[] mOutputAutoCommitFirstWordConfidence = new int[1]; + private final float[] mInputOutputLanguageWeight = new float[1]; private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions(); @@ -137,6 +140,7 @@ public final class BinaryDictionary extends Dictionary { mDictSize = length; mDictFilePath = filename; mIsUpdatable = isUpdatable; + mHasUpdated = false; mNativeSuggestOptions.setUseFullEditDistance(useFullEditDistance); loadDictionary(filename, offset, length, isUpdatable); } @@ -167,7 +171,7 @@ public final class BinaryDictionary extends Dictionary { int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions, int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints, int[] outputScores, int[] outputIndices, int[] outputTypes, - int[] outputAutoCommitFirstWordConfidence); + int[] outputAutoCommitFirstWordConfidence, float[] inOutLanguageWeight); private static native void addUnigramWordNative(long dict, int[] word, int probability, int[] shortcutTarget, int shortcutProbability, boolean isNotAWord, boolean isBlacklisted, int timestamp); @@ -184,6 +188,7 @@ public final class BinaryDictionary extends Dictionary { // TODO: Move native dict into session private final void loadDictionary(final String path, final long startOffset, final long length, final boolean isUpdatable) { + mHasUpdated = false; mNativeDict = openNative(path, startOffset, length, isUpdatable); } @@ -231,16 +236,17 @@ public final class BinaryDictionary extends Dictionary { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, - additionalFeaturesOptions, 0 /* sessionId */); + additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight); } @Override public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, - final int sessionId) { + final int sessionId, final float[] inOutLanguageWeight) { if (!isValidDictionary()) return null; Arrays.fill(mInputCodePoints, Constants.NOT_A_CODE); @@ -261,13 +267,22 @@ public final class BinaryDictionary extends Dictionary { final int inputSize = isGesture ? ips.getPointerSize() : composerSize; mNativeSuggestOptions.setIsGesture(isGesture); mNativeSuggestOptions.setAdditionalFeaturesOptions(additionalFeaturesOptions); + if (inOutLanguageWeight != null) { + mInputOutputLanguageWeight[0] = inOutLanguageWeight[0]; + } else { + mInputOutputLanguageWeight[0] = Dictionary.NOT_A_LANGUAGE_WEIGHT; + } // proximityInfo and/or prevWordForBigrams may not be null. getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(), getTraverseSession(sessionId).getSession(), ips.getXCoordinates(), ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints, inputSize, mNativeSuggestOptions.getOptions(), prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores, - mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence); + mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence, + mInputOutputLanguageWeight); + if (inOutLanguageWeight != null) { + inOutLanguageWeight[0] = mInputOutputLanguageWeight[0]; + } final int count = mOutputSuggestionCount[0]; final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); for (int j = 0; j < count; ++j) { @@ -390,6 +405,7 @@ public final class BinaryDictionary extends Dictionary { StringUtils.toCodePointArray(shortcutTarget) : null; addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints, shortcutProbability, isNotAWord, isBlacklisted, timestamp); + mHasUpdated = true; } // Add a bigram entry to binary dictionary with timestamp in native code. @@ -401,6 +417,7 @@ public final class BinaryDictionary extends Dictionary { final int[] codePoints0 = StringUtils.toCodePointArray(word0); final int[] codePoints1 = StringUtils.toCodePointArray(word1); addBigramWordsNative(mNativeDict, codePoints0, codePoints1, probability, timestamp); + mHasUpdated = true; } // Remove a bigram entry form binary dictionary in native code. @@ -411,6 +428,7 @@ public final class BinaryDictionary extends Dictionary { final int[] codePoints0 = StringUtils.toCodePointArray(word0); final int[] codePoints1 = StringUtils.toCodePointArray(word1); removeBigramWordsNative(mNativeDict, codePoints0, codePoints1); + mHasUpdated = true; } public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) { @@ -422,6 +440,7 @@ public final class BinaryDictionary extends Dictionary { } processedParamCount = addMultipleDictionaryEntriesNative(mNativeDict, languageModelParams, processedParamCount); + mHasUpdated = true; if (processedParamCount <= 0) { return; } @@ -440,8 +459,10 @@ public final class BinaryDictionary extends Dictionary { public void flush() { if (!isValidDictionary()) return; - flushNative(mNativeDict, mDictFilePath); - reopen(); + if (mHasUpdated) { + flushNative(mNativeDict, mDictFilePath); + reopen(); + } } public void flushWithGC() { diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index 4e17f8389..d5873d70f 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -100,10 +100,6 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { }); } - public void reopen(final Context context) { - registerObserver(context); - } - @Override public synchronized void close() { if (mObserver != null) { diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java index e04524843..0742fbde9 100644 --- a/java/src/com/android/inputmethod/latin/Dictionary.java +++ b/java/src/com/android/inputmethod/latin/Dictionary.java @@ -27,6 +27,7 @@ import java.util.ArrayList; */ public abstract class Dictionary { public static final int NOT_A_PROBABILITY = -1; + public static final float NOT_A_LANGUAGE_WEIGHT = -1.0f; // The following types do not actually come from real dictionary instances, so we create // corresponding instances. @@ -70,22 +71,26 @@ public abstract class Dictionary { * @param proximityInfo the object for key proximity. May be ignored by some implementations. * @param blockOffensiveWords whether to block potentially offensive words * @param additionalFeaturesOptions options about additional features used for the suggestion. + * @param inOutLanguageWeight the language weight used for generating suggestions. + * inOutLanguageWeight is a float array that has only one element. This can be updated when the + * different language weight is used. * @return the list of suggestions (possibly null if none) */ // TODO: pass more context than just the previous word, to enable better suggestions (n-gram // and more) abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions); + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight); // The default implementation of this method ignores sessionId. // Subclasses that want to use sessionId need to override this method. public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, - final int sessionId) { + final int sessionId, final float[] inOutLanguageWeight) { return getSuggestions(composer, prevWord, proximityInfo, blockOffensiveWords, - additionalFeaturesOptions); + additionalFeaturesOptions, inOutLanguageWeight); } /** @@ -159,7 +164,8 @@ public abstract class Dictionary { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { return null; } diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index bf075140e..16173fffc 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -58,18 +58,21 @@ public final class DictionaryCollection extends Dictionary { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries; if (dictionaries.isEmpty()) return null; // To avoid creating unnecessary objects, we get the list out of the first // dictionary and add the rest to it if not null, hence the get(0) ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer, - prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions); + prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, + inOutLanguageWeight); if (null == suggestions) suggestions = CollectionUtils.newArrayList(); final int length = dictionaries.size(); for (int i = 1; i < length; ++ i) { final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer, - prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions); + prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, + inOutLanguageWeight); if (null != sugg) suggestions.addAll(sugg); } return suggestions; diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java index 9c6aa552c..7cb218fbe 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -461,12 +461,14 @@ public class DictionaryFacilitatorForSuggest { final Map<String, Dictionary> dictMap = dictionaries.mDictMap; final SuggestionResults suggestionResults = new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS); + final float[] languageWeight = new float[] { Dictionary.NOT_A_LANGUAGE_WEIGHT }; for (final String dictType : dictTypesOrderedToGetSuggestion) { final Dictionary dictionary = dictMap.get(dictType); if (null == dictionary) continue; final ArrayList<SuggestedWordInfo> dictionarySuggestions = dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, - blockOffensiveWords, additionalFeaturesOptions, sessionId); + blockOffensiveWords, additionalFeaturesOptions, sessionId, + languageWeight); if (null == dictionarySuggestions) continue; suggestionResults.addAll(dictionarySuggestions); if (null != rawSuggestions) { diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 92b535458..64e9d2b51 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -262,6 +262,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { ExecutorUtils.getExecutor(mDictName).execute(new Runnable() { @Override public void run() { + if (mBinaryDictionary == null) { + return; + } runGCAfterAllPrioritizedTasksIfRequiredLocked(mindsBlockByGC); } }); @@ -274,9 +277,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } private void runGCAfterAllPrioritizedTasksIfRequiredLocked(final boolean mindsBlockByGC) { - if (mBinaryDictionary == null) { - return; - } // needsToRunGC() have to be called with lock. if (mBinaryDictionary.needsToRunGC(mindsBlockByGC)) { if (setProcessingLargeTaskIfNot()) { @@ -301,9 +301,13 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { protected void addWordDynamically(final String word, final int frequency, final String shortcutTarget, final int shortcutFreq, final boolean isNotAWord, final boolean isBlacklisted, final int timestamp) { + reloadDictionaryIfRequired(); ExecutorUtils.getExecutor(mDictName).execute(new Runnable() { @Override public void run() { + if (mBinaryDictionary == null) { + return; + } runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */); addWordDynamicallyLocked(word, frequency, shortcutTarget, shortcutFreq, isNotAWord, isBlacklisted, timestamp); @@ -323,9 +327,13 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { */ protected void addBigramDynamically(final String word0, final String word1, final int frequency, final int timestamp) { + reloadDictionaryIfRequired(); ExecutorUtils.getExecutor(mDictName).execute(new Runnable() { @Override public void run() { + if (mBinaryDictionary == null) { + return; + } runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */); addBigramDynamicallyLocked(word0, word1, frequency, timestamp); } @@ -341,9 +349,13 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { * Dynamically remove a word bigram in the dictionary. */ protected void removeBigramDynamically(final String word0, final String word1) { + reloadDictionaryIfRequired(); ExecutorUtils.getExecutor(mDictName).execute(new Runnable() { @Override public void run() { + if (mBinaryDictionary == null) { + return; + } runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */); mBinaryDictionary.removeBigramWords(word0, word1); } @@ -360,14 +372,15 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { protected void addMultipleDictionaryEntriesDynamically( final ArrayList<LanguageModelParam> languageModelParams, final AddMultipleDictionaryEntriesCallback callback) { + reloadDictionaryIfRequired(); ExecutorUtils.getExecutor(mDictName).execute(new Runnable() { @Override public void run() { + if (mBinaryDictionary == null) { + return; + } final boolean locked = setProcessingLargeTaskIfNot(); try { - if (mBinaryDictionary == null) { - return; - } mBinaryDictionary.addMultipleDictionaryEntries( languageModelParams.toArray( new LanguageModelParam[languageModelParams.size()])); @@ -387,7 +400,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, - final int sessionId) { + final int sessionId, final float[] inOutLanguageWeight) { reloadDictionaryIfRequired(); if (processingLargeTask()) { return null; @@ -404,7 +417,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { final ArrayList<SuggestedWordInfo> binarySuggestion = mBinaryDictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, - sessionId); + sessionId, inOutLanguageWeight); holder.set(binarySuggestion); if (mBinaryDictionary.isCorrupted()) { removeBinaryDictionaryLocked(); @@ -417,9 +430,10 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, - additionalFeaturesOptions, 0 /* sessionId */); + additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight); } @Override diff --git a/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java b/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java index 9870faa98..be54b669b 100644 --- a/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java +++ b/java/src/com/android/inputmethod/latin/ImportantNoticeDialog.java @@ -23,6 +23,7 @@ import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnShowListener; +import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.ImportantNoticeUtils; /** @@ -40,7 +41,7 @@ public final class ImportantNoticeDialog extends AlertDialog implements OnShowLi public ImportantNoticeDialog( final Context context, final ImportantNoticeDialogListener listener) { - super(context, THEME_HOLO_DARK); + super(DialogUtils.getPlatformDialogThemeContext(context)); mListener = listener; mNextImportantNoticeVersion = ImportantNoticeUtils.getNextImportantNoticeVersion(context); setMessage(ImportantNoticeUtils.getNextImportantNoticeContents(context)); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b4807b01a..ca99998e0 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -83,6 +83,7 @@ import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor; import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CoordinateUtils; +import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.ImportantNoticeUtils; import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.JniUtils; @@ -197,7 +198,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen latinIme.mSettings.getCurrent()); break; case MSG_UPDATE_SHIFT_STATE: - switcher.updateShiftState(); + switcher.requestUpdatingShiftState(); break; case MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP: if (msg.arg1 == ARG1_NOT_GESTURE_INPUT) { @@ -833,7 +834,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // we need to re-evaluate the shift state, but not the whole layout which would be // disruptive. // Space state must be updated before calling updateShiftState - switcher.updateShiftState(); + switcher.requestUpdatingShiftState(); } // This will set the punctuation suggestions if next word suggestion is off; // otherwise it will clear the suggestion strip. @@ -912,7 +913,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // TODO: find a better way to simulate actual execution. if (isInputViewShown() && mInputLogic.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd)) { - mKeyboardSwitcher.updateShiftState(); + mKeyboardSwitcher.requestUpdatingShiftState(); } mSubtypeState.currentSubtypeUsed(); @@ -1231,7 +1232,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.onCodeInput(mSettings.getCurrent(), event, mKeyboardSwitcher.getKeyboardShiftMode(), mHandler); updateStateAfterInputTransaction(completeInputTransaction); - mKeyboardSwitcher.onCodeInput(codePoint); + mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState()); } // A helper method to split the code point and the key code. Ultimately, they should not be @@ -1256,8 +1257,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // TODO: have the keyboard pass the correct key code when we need it. final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE); mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler); - mKeyboardSwitcher.updateShiftState(); - mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT); + mKeyboardSwitcher.requestUpdatingShiftState(); + mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState()); } @Override @@ -1500,7 +1501,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mHandler.postUpdateShiftState(); break; case InputTransaction.SHIFT_UPDATE_NOW: - mKeyboardSwitcher.updateShiftState(); + mKeyboardSwitcher.requestUpdatingShiftState(); break; default: // SHIFT_NO_UPDATE } @@ -1540,7 +1541,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onPressKey(final int primaryCode, final int repeatCount, final boolean isSinglePointer) { - mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer); + mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer, getCurrentAutoCapsState()); hapticAndAudioFeedback(primaryCode, repeatCount); } @@ -1662,8 +1663,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } }; - final AlertDialog.Builder builder = - new AlertDialog.Builder(this).setItems(items, listener).setTitle(title); + final AlertDialog.Builder builder = new AlertDialog.Builder( + DialogUtils.getPlatformDialogThemeContext(this)); + builder.setItems(items, listener).setTitle(title); showOptionDialog(builder.create()); } diff --git a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java index 68505ce38..9f61d6c37 100644 --- a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java @@ -51,20 +51,21 @@ public final class ReadOnlyBinaryDictionary extends Dictionary { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, - additionalFeaturesOptions, 0 /* sessionId */); + additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight); } @Override public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, - final int sessionId) { + final int sessionId, final float[] inOutLanguageWeight) { if (mLock.readLock().tryLock()) { try { return mBinaryDictionary.getSuggestions(composer, prevWord, proximityInfo, - blockOffensiveWords, additionalFeaturesOptions); + blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight); } finally { mLock.readLock().unlock(); } diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java index 9c095e4b1..c24ee4033 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java @@ -34,10 +34,11 @@ public final class SynchronouslyLoadedContactsBinaryDictionary extends ContactsB @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes, final String prevWordForBigrams, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { synchronized (mLock) { return super.getSuggestions(codes, prevWordForBigrams, proximityInfo, - blockOffensiveWords, additionalFeaturesOptions); + blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight); } } diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java index 801fb5b89..1d29d7ad0 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java @@ -39,10 +39,11 @@ public final class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDic @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes, final String prevWordForBigrams, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { synchronized (mLock) { return super.getSuggestions(codes, prevWordForBigrams, proximityInfo, - blockOffensiveWords, additionalFeaturesOptions); + blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight); } } diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index f31fb134c..5d21554ae 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -169,64 +169,63 @@ public final class WordComposer { * coordinates. */ public void add(final Event event) { + processEvent(event); + } + + private void processEvent(final Event event) { final int primaryCode = event.mCodePoint; final int keyX = event.mX; final int keyY = event.mY; final int newIndex = size(); - processEvent(event); + mCombinerChain.processEvent(mEvents, event); + mEvents.add(event); + refreshTypedWordCache(); mCursorPositionWithinWord = mCodePointSize; - if (newIndex < MAX_WORD_LENGTH) { - mPrimaryKeyCodes[newIndex] = primaryCode >= Constants.CODE_SPACE - ? Character.toLowerCase(primaryCode) : primaryCode; - // In the batch input mode, the {@code mInputPointers} holds batch input points and - // shouldn't be overridden by the "typed key" coordinates - // (See {@link #setBatchInputWord}). - if (!mIsBatchMode) { - // TODO: Set correct pointer id and time - mInputPointers.addPointerAt(newIndex, keyX, keyY, 0, 0); - } + // We may have deleted the last one. + if (0 == mCodePointSize) { + mIsFirstCharCapitalized = false; } - mIsFirstCharCapitalized = isFirstCharCapitalized( - newIndex, primaryCode, mIsFirstCharCapitalized); - if (Character.isUpperCase(primaryCode)) mCapsCount++; - if (Character.isDigit(primaryCode)) mDigitsCount++; - if (Constants.CODE_SINGLE_QUOTE == primaryCode) { - ++mTrailingSingleQuotesCount; + if (Constants.CODE_DELETE == event.mKeyCode) { + if (mTrailingSingleQuotesCount > 0) { + --mTrailingSingleQuotesCount; + } else { + // Delete, but we didn't end in a quote: must recompute mTrailingSingleQuotesCount + // We're only searching for single quotes, so no need to account for code points + for (int i = mTypedWordCache.length() - 1; i > 0; --i) { + if (Constants.CODE_SINGLE_QUOTE != mTypedWordCache.charAt(i)) { + break; + } + ++mTrailingSingleQuotesCount; + } + } } else { - mTrailingSingleQuotesCount = 0; + if (Constants.CODE_SINGLE_QUOTE == primaryCode) { + ++mTrailingSingleQuotesCount; + } else { + mTrailingSingleQuotesCount = 0; + } + if (newIndex < MAX_WORD_LENGTH) { + // In the batch input mode, the {@code mInputPointers} holds batch input points and + // shouldn't be overridden by the "typed key" coordinates + // (See {@link #setBatchInputWord}). + if (!mIsBatchMode) { + // TODO: Set correct pointer id and time + mInputPointers.addPointerAt(newIndex, keyX, keyY, 0, 0); + } + } + mIsFirstCharCapitalized = isFirstCharCapitalized( + newIndex, primaryCode, mIsFirstCharCapitalized); + if (Character.isUpperCase(primaryCode)) mCapsCount++; + if (Character.isDigit(primaryCode)) mDigitsCount++; } mAutoCorrection = null; } - private void processEvent(final Event event) { - mCombinerChain.processEvent(mEvents, event); - mEvents.add(event); - refreshTypedWordCache(); - } - /** * Delete the last composing unit as a result of hitting backspace. */ public void deleteLast(final Event event) { processEvent(event); - // We may have deleted the last one. - if (0 == size()) { - mIsFirstCharCapitalized = false; - } - if (mTrailingSingleQuotesCount > 0) { - --mTrailingSingleQuotesCount; - } else { - int i = mTypedWordCache.length(); - while (i > 0) { - i = Character.offsetByCodePoints(mTypedWordCache, i, -1); - if (Constants.CODE_SINGLE_QUOTE != Character.codePointAt(mTypedWordCache, i)) { - break; - } - ++mTrailingSingleQuotesCount; - } - } - mCursorPositionWithinWord = mCodePointSize; - mAutoCorrection = null; } public void setCursorPositionWithinWord(final int posWithinWord) { diff --git a/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java b/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java index 800f56597..139e73aa4 100644 --- a/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java +++ b/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java @@ -28,6 +28,7 @@ import com.android.inputmethod.latin.BinaryDictionaryGetter; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.utils.CollectionUtils; +import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import com.android.inputmethod.latin.utils.LocaleUtils; @@ -70,7 +71,7 @@ public class ExternalDictionaryGetterForDebug { } private static void showNoFileDialog(final Context context) { - new AlertDialog.Builder(context) + new AlertDialog.Builder(DialogUtils.getPlatformDialogThemeContext(context)) .setMessage(R.string.read_external_dictionary_no_files_message) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override @@ -81,8 +82,8 @@ public class ExternalDictionaryGetterForDebug { } private static void showChooseFileDialog(final Context context, final String[] fileNames) { - final AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.read_external_dictionary_multiple_files_title) + new AlertDialog.Builder(DialogUtils.getPlatformDialogThemeContext(context)) + .setTitle(R.string.read_external_dictionary_multiple_files_title) .setItems(fileNames, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { @@ -111,7 +112,7 @@ public class ExternalDictionaryGetterForDebug { final String title = String.format( context.getString(R.string.read_external_dictionary_confirm_install_message), languageName); - new AlertDialog.Builder(context) + new AlertDialog.Builder(DialogUtils.getPlatformDialogThemeContext(context)) .setTitle(title) .setMessage(message) .setNegativeButton(android.R.string.cancel, new OnClickListener() { @@ -167,7 +168,7 @@ public class ExternalDictionaryGetterForDebug { } } catch (IOException e) { // There was an error: show a dialog - new AlertDialog.Builder(context) + new AlertDialog.Builder(DialogUtils.getPlatformDialogThemeContext(context)) .setTitle(R.string.error) .setMessage(e.toString()) .setPositiveButton(android.R.string.ok, new OnClickListener() { diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 2fd8ace93..7ffc95697 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -210,15 +210,7 @@ public final class InputLogic { // So, LatinImeLogger logs "" as a user's input. LatinImeLogger.logOnManualSuggestion("", suggestion, index, suggestedWords); // Rely on onCodeInput to do the complicated swapping/stripping logic consistently. - final int primaryCode = suggestion.charAt(0); - // TODO: we should be using createSuggestionPickedEvent here, but for legacy reasons, - // onCodeInput is expected a software keypress event for a suggested punctuation - // because the current code is descended from a time where this information used not - // to be available. Fix this. - final Event event = Event.createSoftwareKeypressEvent(primaryCode, - Event.NOT_A_KEY_CODE /* keyCode*/, - Constants.SUGGESTION_STRIP_COORDINATE /* x */, - Constants.SUGGESTION_STRIP_COORDINATE /* y */); + final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, false /* isBatchMode */, suggestedWords.mIsPrediction); @@ -545,7 +537,7 @@ public final class InputLogic { // after typing some letters and a period, then gesturing; the keyboard is not in // caps mode yet, but since a gesture is starting, it should go in caps mode, // unless the user explictly said it should not. - keyboardSwitcher.updateShiftState(); + keyboardSwitcher.requestUpdatingShiftState(); } } mConnection.endBatchEdit(); @@ -587,7 +579,7 @@ public final class InputLogic { promotePhantomSpace(settingsValues); mConnection.commitText(commitParts[0], 0); mSpaceState = SpaceState.PHANTOM; - keyboardSwitcher.updateShiftState(); + keyboardSwitcher.requestUpdatingShiftState(); mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( getActualCapsMode(settingsValues, keyboardSwitcher.getKeyboardShiftMode()), commitParts[0]); @@ -831,13 +823,11 @@ public final class InputLogic { } if (Constants.CODE_SPACE == codePoint) { - if (inputTransaction.mSettingsValues.isSuggestionsRequested()) { - if (maybeDoubleSpacePeriod(inputTransaction)) { - inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); - mSpaceState = SpaceState.DOUBLE; - } else if (!mSuggestedWords.isPunctuationSuggestions()) { - mSpaceState = SpaceState.WEAK; - } + if (maybeDoubleSpacePeriod(inputTransaction)) { + inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); + mSpaceState = SpaceState.DOUBLE; + } else if (!mSuggestedWords.isPunctuationSuggestions()) { + mSpaceState = SpaceState.WEAK; } startDoubleSpacePeriodCountdown(inputTransaction); @@ -1829,7 +1819,7 @@ public final class InputLogic { } // Space state must be updated before calling updateShiftState mSpaceState = SpaceState.PHANTOM; - keyboardSwitcher.updateShiftState(); + keyboardSwitcher.requestUpdatingShiftState(); } /** diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java index 6f84e1f10..712e314a8 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java @@ -66,7 +66,7 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB } // Flush pending writes. flush(); - // TODO: Quit depending on finalize() and really close the dictionary file. + super.close(); } public void flush() { diff --git a/java/src/com/android/inputmethod/latin/settings/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/settings/AdditionalSubtypeSettings.java index 6dae6206c..39977e76f 100644 --- a/java/src/com/android/inputmethod/latin/settings/AdditionalSubtypeSettings.java +++ b/java/src/com/android/inputmethod/latin/settings/AdditionalSubtypeSettings.java @@ -48,6 +48,7 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.CollectionUtils; +import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; @@ -517,7 +518,8 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { private AlertDialog createDialog( @SuppressWarnings("unused") final SubtypePreference subtypePref) { - final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + final AlertDialog.Builder builder = new AlertDialog.Builder( + DialogUtils.getPlatformDialogThemeContext(getActivity())); builder.setTitle(R.string.custom_input_styles_title) .setMessage(R.string.custom_input_style_note_message) .setNegativeButton(R.string.not_now, null) diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java index 3947019ca..69d092751 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java @@ -327,7 +327,8 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { final ArrayList<SuggestedWordInfo> suggestions = dictInfo.mDictionary.getSuggestions(composer, prevWord, dictInfo.getProximityInfo(), true /* blockOffensiveWords */, - null /* additionalFeaturesOptions */); + null /* additionalFeaturesOptions */, + null /* inOutLanguageWeight */); if (suggestions != null) { for (final SuggestedWordInfo suggestion : suggestions) { final String suggestionStr = suggestion.mWord; diff --git a/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java b/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java index b7a5a4026..c99264347 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java @@ -53,7 +53,8 @@ public final class DictionaryPool extends LinkedBlockingQueue<DictAndKeyboard> { @Override public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, - final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) { + final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, + final float[] inOutLanguageWeight) { return noSuggestions; } @Override diff --git a/java/src/com/android/inputmethod/latin/utils/DialogUtils.java b/java/src/com/android/inputmethod/latin/utils/DialogUtils.java new file mode 100644 index 000000000..a05c932d0 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/utils/DialogUtils.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.utils; + +import android.content.Context; +import android.view.ContextThemeWrapper; + +import com.android.inputmethod.latin.R; + +public final class DialogUtils { + private DialogUtils() { + // This utility class is not publicly instantiable. + } + + public static Context getPlatformDialogThemeContext(final Context context) { + // Because {@link AlertDialog.Builder.create()} doesn't honor the specified theme with + // createThemeContextWrapper=false, the result dialog box has unneeded paddings around it. + return new ContextThemeWrapper(context, R.style.platformDialogTheme); + } +} diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk index 828edce61..572d36564 100644 --- a/native/jni/HostUnitTests.mk +++ b/native/jni/HostUnitTests.mk @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# HACK: Temporarily disable host tool build on Mac until the build system is ready for C++11. +LATINIME_HOST_OSNAME := $(shell uname -s) +ifneq ($(LATINIME_HOST_OSNAME), Darwin) # TODO: Remove this + LOCAL_PATH := $(call my-dir) ###################################### @@ -25,10 +29,8 @@ LATIN_IME_SRC_DIR := src LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) -LOCAL_IS_HOST_MODULE := true LOCAL_MODULE := liblatinime_host_static_for_unittests LOCAL_MODULE_TAGS := optional -LOCAL_NDK_STL_VARIANT := c++_static LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES)) include $(BUILD_HOST_STATIC_LIBRARY) @@ -39,15 +41,16 @@ LATIN_IME_TEST_SRC_DIR := tests LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) -LOCAL_IS_HOST_MODULE := true LOCAL_MODULE := liblatinime_host_unittests LOCAL_MODULE_TAGS := tests -LOCAL_NDK_STL_VARIANT := c++_static LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES)) LOCAL_STATIC_LIBRARIES += liblatinime_host_static_for_unittests libgtest_host libgtest_main_host include $(BUILD_HOST_NATIVE_TEST) +endif # Darwin - TODO: Remove this + #################### Clean up the tmp vars +LATINIME_HOST_OSNAME := LATIN_IME_SRC_DIR := LATIN_IME_TEST_SRC_DIR := include $(LOCAL_PATH)/CleanupNativeFileList.mk diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index 154ea9800..bf03fdf5c 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -146,7 +146,8 @@ static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions, jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount, jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray, - jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) { + jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray, + jfloatArray inOutLanguageWeight) { Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict); // Assign 0 to outSuggestionCount here in case of returning earlier in this method. int count = 0; @@ -209,20 +210,22 @@ static void latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, ASSERT(false); return; } - + float languageWeight; + env->GetFloatArrayRegion(inOutLanguageWeight, 0, 1 /* len */, &languageWeight); SuggestionResults suggestionResults(MAX_RESULTS); if (givenSuggestOptions.isGesture() || inputSize > 0) { // TODO: Use SuggestionResults to return suggestions. dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates, times, pointerIds, inputCodePoints, inputSize, prevWordCodePoints, - prevWordCodePointsLength, &givenSuggestOptions, &suggestionResults); + prevWordCodePointsLength, &givenSuggestOptions, languageWeight, + &suggestionResults); } else { dictionary->getPredictions(prevWordCodePoints, prevWordCodePointsLength, &suggestionResults); } suggestionResults.outputSuggestions(env, outSuggestionCount, outCodePointsArray, outScoresArray, outSpaceIndicesArray, outTypesArray, - outAutoCommitFirstWordConfidenceArray); + outAutoCommitFirstWordConfidenceArray, inOutLanguageWeight); } static jint latinime_BinaryDictionary_getProbability(JNIEnv *env, jclass clazz, jlong dict, @@ -489,7 +492,7 @@ static const JNINativeMethod sMethods[] = { }, { const_cast<char *>("getSuggestionsNative"), - const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I)V"), + const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I[F)V"), reinterpret_cast<void *>(latinime_BinaryDictionary_getSuggestions) }, { diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index 3651cd523..1719b1c60 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -118,14 +118,6 @@ static inline void dumpWordInfo(const int *word, const int length, const int ran } } -static inline void dumpResult(const int *outWords, const int *frequencies) { - AKLOGI("--- DUMP RESULT ---------"); - for (int i = 0; i < MAX_RESULTS; ++i) { - dumpWordInfo(&outWords[i * MAX_WORD_LENGTH], MAX_WORD_LENGTH, i, frequencies[i]); - } - AKLOGI("-------------------------"); -} - static AK_FORCE_INLINE void dumpWord(const int *word, const int length) { static char charBuf[50]; const int N = intArrayToCharArray(word, length, charBuf, NELEMS(charBuf)); @@ -309,6 +301,7 @@ static inline void prof_out(void) { #define NOT_A_PROBABILITY (-1) #define NOT_A_DICT_POS (S_INT_MIN) #define NOT_A_TIMESTAMP (-1) +#define NOT_A_LANGUAGE_WEIGHT (-1.0f) // A special value to mean the first word confidence makes no sense in this case, // e.g. this is not a multi-word suggestion. diff --git a/native/jni/src/suggest/core/dictionary/dictionary.cpp b/native/jni/src/suggest/core/dictionary/dictionary.cpp index ae4646d2e..ef7a0a8fe 100644 --- a/native/jni/src/suggest/core/dictionary/dictionary.cpp +++ b/native/jni/src/suggest/core/dictionary/dictionary.cpp @@ -47,7 +47,7 @@ Dictionary::Dictionary(JNIEnv *env, DictionaryStructureWithBufferPolicy::Structu void Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession, int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints, int inputSize, int *prevWordCodePoints, int prevWordLength, - const SuggestOptions *const suggestOptions, + const SuggestOptions *const suggestOptions, const float languageWeight, SuggestionResults *const outSuggestionResults) const { TimeKeeper::setCurrentTime(); DicTraverseSession::initSessionInstance( @@ -55,11 +55,11 @@ void Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession if (suggestOptions->isGesture()) { mGestureSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates, ycoordinates, times, pointerIds, inputCodePoints, inputSize, - outSuggestionResults); + languageWeight, outSuggestionResults); } else { mTypingSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates, ycoordinates, times, pointerIds, inputCodePoints, inputSize, - outSuggestionResults); + languageWeight, outSuggestionResults); } if (DEBUG_DICT) { outSuggestionResults->dumpSuggestions(); diff --git a/native/jni/src/suggest/core/dictionary/dictionary.h b/native/jni/src/suggest/core/dictionary/dictionary.h index df5fc9b7d..cd983b032 100644 --- a/native/jni/src/suggest/core/dictionary/dictionary.h +++ b/native/jni/src/suggest/core/dictionary/dictionary.h @@ -65,7 +65,7 @@ class Dictionary { void getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession, int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints, int inputSize, int *prevWordCodePoints, int prevWordLength, - const SuggestOptions *const suggestOptions, + const SuggestOptions *const suggestOptions, const float languageWeight, SuggestionResults *const outSuggestionResults) const; void getPredictions(const int *word, int length, diff --git a/native/jni/src/suggest/core/layout/normal_distribution.h b/native/jni/src/suggest/core/layout/normal_distribution.h new file mode 100644 index 000000000..5f21a59c0 --- /dev/null +++ b/native/jni/src/suggest/core/layout/normal_distribution.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LATINIME_NORMAL_DISTRIBUTION_H +#define LATINIME_NORMAL_DISTRIBUTION_H + +#include <cmath> + +#include "defines.h" + +namespace latinime { + +// Normal distribution N(u, sigma^2). +class NormalDistribution { + public: + NormalDistribution(const float u, const float sigma) + : mU(u), + mPreComputedNonExpPart(1.0f / sqrtf(2.0f * M_PI_F + * GeometryUtils::SQUARE_FLOAT(sigma))), + mPreComputedExponentPart(-1.0f / (2.0f * GeometryUtils::SQUARE_FLOAT(sigma))) {} + + float getProbabilityDensity(const float x) const { + const float shiftedX = x - mU; + return mPreComputedNonExpPart + * expf(mPreComputedExponentPart * GeometryUtils::SQUARE_FLOAT(shiftedX)); + } + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(NormalDistribution); + + const float mU; // mean value + const float mPreComputedNonExpPart; // = 1 / sqrt(2 * PI * sigma^2) + const float mPreComputedExponentPart; // = -1 / (2 * sigma^2) +}; +} // namespace latinime +#endif // LATINIME_NORMAL_DISTRIBUTION_H diff --git a/native/jni/src/suggest/core/layout/proximity_info.cpp b/native/jni/src/suggest/core/layout/proximity_info.cpp index 8b3ae4db8..c40a2bdca 100644 --- a/native/jni/src/suggest/core/layout/proximity_info.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info.cpp @@ -58,7 +58,6 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii) : GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth), MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth), - MOST_COMMON_KEY_HEIGHT(mostCommonKeyHeight), NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f + GeometryUtils::SQUARE_FLOAT(static_cast<float>(mostCommonKeyHeight) / static_cast<float>(mostCommonKeyWidth))), diff --git a/native/jni/src/suggest/core/layout/proximity_info.h b/native/jni/src/suggest/core/layout/proximity_info.h index a91b9d674..b72c29394 100644 --- a/native/jni/src/suggest/core/layout/proximity_info.h +++ b/native/jni/src/suggest/core/layout/proximity_info.h @@ -35,7 +35,6 @@ class ProximityInfo { const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii); ~ProximityInfo(); bool hasSpaceProximity(const int x, const int y) const; - int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const; float getNormalizedSquaredDistanceFromCenterFloatG( const int keyId, const int x, const int y, const bool isGeometric) const; int getCodePointOf(const int keyIndex) const; @@ -48,8 +47,6 @@ class ProximityInfo { float getSweetSpotRadiiAt(int keyIndex) const { return mSweetSpotRadii[keyIndex]; } float getSweetSpotCenterXAt(int keyIndex) const { return mSweetSpotCenterXs[keyIndex]; } float getSweetSpotCenterYAt(int keyIndex) const { return mSweetSpotCenterYs[keyIndex]; } - void calculateNearbyKeyCodes( - const int x, const int y, const int primaryKey, int *inputCodes) const; bool hasTouchPositionCorrectionData() const { return HAS_TOUCH_POSITION_CORRECTION_DATA; } int getMostCommonKeyWidth() const { return MOST_COMMON_KEY_WIDTH; } int getMostCommonKeyWidthSquare() const { return MOST_COMMON_KEY_WIDTH_SQUARE; } @@ -97,7 +94,6 @@ class ProximityInfo { const int GRID_HEIGHT; const int MOST_COMMON_KEY_WIDTH; const int MOST_COMMON_KEY_WIDTH_SQUARE; - const int MOST_COMMON_KEY_HEIGHT; const float NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE; const int CELL_WIDTH; const int CELL_HEIGHT; @@ -124,7 +120,6 @@ class ProximityInfo { int mCenterXsG[MAX_KEY_COUNT_IN_A_KEYBOARD]; int mCenterYsG[MAX_KEY_COUNT_IN_A_KEYBOARD]; int mKeyKeyDistancesG[MAX_KEY_COUNT_IN_A_KEYBOARD][MAX_KEY_COUNT_IN_A_KEYBOARD]; - // TODO: move to correction.h }; } // namespace latinime #endif // LATINIME_PROXIMITY_INFO_H diff --git a/native/jni/src/suggest/core/layout/proximity_info_params.cpp b/native/jni/src/suggest/core/layout/proximity_info_params.cpp index 49df10301..597518a4c 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_params.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_params.cpp @@ -98,7 +98,4 @@ const int ProximityInfoParams::LOOKUP_RADIUS_PERCENTILE = 50; const int ProximityInfoParams::FIRST_POINT_TIME_OFFSET_MILLIS = 150; const int ProximityInfoParams::STRONG_DOUBLE_LETTER_TIME_MILLIS = 600; -// Used by ProximityInfoStateUtils::calculateNormalizedSquaredDistance() -const int ProximityInfoParams::NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR = 1 << 10; - } // namespace latinime diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.h b/native/jni/src/suggest/core/layout/proximity_info_state.h index 9abd69a66..e253d9550 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state.h +++ b/native/jni/src/suggest/core/layout/proximity_info_state.h @@ -108,10 +108,6 @@ class ProximityInfoState { return false; } - inline const int *getPrimaryInputWord() const { - return mPrimaryInputWord; - } - inline bool touchPositionCorrectionEnabled() const { return mTouchPositionCorrectionEnabled; } @@ -156,10 +152,6 @@ class ProximityInfoState { ProximityType getProximityTypeG(const int index, const int codePoint) const; - const std::vector<int> *getSearchKeyVector(const int index) const { - return &mSampledSearchKeyVectors[index]; - } - float getSpeedRate(const int index) const { return mSpeedRates[index]; } diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp index 867f59843..5a3ff7384 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp @@ -24,6 +24,7 @@ #include "defines.h" #include "suggest/core/layout/geometry_utils.h" +#include "suggest/core/layout/normal_distribution.h" #include "suggest/core/layout/proximity_info.h" #include "suggest/core/layout/proximity_info_params.h" @@ -717,8 +718,8 @@ namespace latinime { const float sigma = speedxAngleRate + speedxNearestKeyDistanceRate + ProximityInfoParams::MIN_STANDARD_DEVIATION; - ProximityInfoUtils::NormalDistribution - distribution(ProximityInfoParams::CENTER_VALUE_OF_NORMALIZED_DISTRIBUTION, sigma); + NormalDistribution distribution( + ProximityInfoParams::CENTER_VALUE_OF_NORMALIZED_DISTRIBUTION, sigma); // Summing up probability densities of all near keys. float sumOfProbabilityDensities = 0.0f; for (int j = 0; j < keyCount; ++j) { diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h index 6de970033..ea0cd1149 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h +++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h @@ -90,10 +90,6 @@ class ProximityInfoStateUtils { std::vector<float> *sampledNormalizedSquaredLengthCache); static void initPrimaryInputWord(const int inputSize, const int *const inputProximities, int *primaryInputWord); - static void initNormalizedSquaredDistances(const ProximityInfo *const proximityInfo, - const int inputSize, const int *inputXCoordinates, const int *inputYCoordinates, - const int *const inputProximities, const std::vector<int> *const sampledInputXs, - const std::vector<int> *const sampledInputYs, int *normalizedSquaredDistances); static void dump(const bool isGeometric, const int inputSize, const int *const inputXCoordinates, const int *const inputYCoordinates, const int sampledInputSize, const std::vector<int> *const sampledInputXs, diff --git a/native/jni/src/suggest/core/layout/proximity_info_utils.h b/native/jni/src/suggest/core/layout/proximity_info_utils.h index 310bbdb62..c273ef456 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_utils.h +++ b/native/jni/src/suggest/core/layout/proximity_info_utils.h @@ -125,28 +125,6 @@ class ProximityInfoUtils { return type == MATCH_CHAR || type == PROXIMITY_CHAR || type == ADDITIONAL_PROXIMITY_CHAR; } - // Normal distribution N(u, sigma^2). - struct NormalDistribution { - public: - NormalDistribution(const float u, const float sigma) - : mU(u), - mPreComputedNonExpPart(1.0f / sqrtf(2.0f * M_PI_F - * GeometryUtils::SQUARE_FLOAT(sigma))), - mPreComputedExponentPart(-1.0f / (2.0f * GeometryUtils::SQUARE_FLOAT(sigma))) {} - - float getProbabilityDensity(const float x) const { - const float shiftedX = x - mU; - return mPreComputedNonExpPart - * expf(mPreComputedExponentPart * GeometryUtils::SQUARE_FLOAT(shiftedX)); - } - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(NormalDistribution); - const float mU; // mean value - const float mPreComputedNonExpPart; // = 1 / sqrt(2 * PI * sigma^2) - const float mPreComputedExponentPart; // = -1 / (2 * sigma^2) - }; // struct NormalDistribution - private: DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfoUtils); diff --git a/native/jni/src/suggest/core/result/suggestion_results.cpp b/native/jni/src/suggest/core/result/suggestion_results.cpp index da1c6bc72..088a55f6f 100644 --- a/native/jni/src/suggest/core/result/suggestion_results.cpp +++ b/native/jni/src/suggest/core/result/suggestion_results.cpp @@ -20,7 +20,8 @@ namespace latinime { void SuggestionResults::outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outputCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray, - jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) { + jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray, + jfloatArray outLanguageWeight) { int outputIndex = 0; while (!mSuggestedWords.empty()) { const SuggestedWord &suggestedWord = mSuggestedWords.top(); @@ -50,6 +51,7 @@ void SuggestionResults::outputSuggestions(JNIEnv *env, jintArray outSuggestionCo mSuggestedWords.pop(); } env->SetIntArrayRegion(outSuggestionCount, 0 /* start */, 1 /* len */, &outputIndex); + env->SetFloatArrayRegion(outLanguageWeight, 0 /* start */, 1 /* len */, &mLanguageWeight); } void SuggestionResults::addPrediction(const int *const codePoints, const int codePointCount, @@ -94,6 +96,7 @@ void SuggestionResults::getSortedScores(int *const outScores) const { } void SuggestionResults::dumpSuggestions() const { + AKLOGE("language weight: %f", mLanguageWeight); std::vector<SuggestedWord> suggestedWords; auto copyOfSuggestedWords = mSuggestedWords; while (!copyOfSuggestedWords.empty()) { diff --git a/native/jni/src/suggest/core/result/suggestion_results.h b/native/jni/src/suggest/core/result/suggestion_results.h index 020bab42b..8e845e2d3 100644 --- a/native/jni/src/suggest/core/result/suggestion_results.h +++ b/native/jni/src/suggest/core/result/suggestion_results.h @@ -29,12 +29,13 @@ namespace latinime { class SuggestionResults { public: explicit SuggestionResults(const int maxSuggestionCount) - : mMaxSuggestionCount(maxSuggestionCount), mSuggestedWords() {} + : mMaxSuggestionCount(maxSuggestionCount), mLanguageWeight(NOT_A_LANGUAGE_WEIGHT), + mSuggestedWords() {} // Returns suggestion count. void outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray, - jintArray outAutoCommitFirstWordConfidenceArray); + jintArray outAutoCommitFirstWordConfidenceArray, jfloatArray outLanguageWeight); void addPrediction(const int *const codePoints, const int codePointCount, const int score); void addSuggestion(const int *const codePoints, const int codePointCount, const int score, const int type, const int indexToPartialCommit, @@ -42,6 +43,10 @@ class SuggestionResults { void getSortedScores(int *const outScores) const; void dumpSuggestions() const; + void setLanguageWeight(const float languageWeight) { + mLanguageWeight = languageWeight; + } + int getSuggestionCount() const { return mSuggestedWords.size(); } @@ -50,6 +55,7 @@ class SuggestionResults { DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionResults); const int mMaxSuggestionCount; + float mLanguageWeight; std::priority_queue< SuggestedWord, std::vector<SuggestedWord>, SuggestedWord::Comparator> mSuggestedWords; }; diff --git a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp index 83140f1ab..a307cb45d 100644 --- a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp +++ b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp @@ -33,7 +33,7 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16; /* static */ void SuggestionsOutputUtils::outputSuggestions( const Scoring *const scoringPolicy, DicTraverseSession *traverseSession, - SuggestionResults *const outSuggestionResults) { + const float languageWeight, SuggestionResults *const outSuggestionResults) { #if DEBUG_EVALUATE_MOST_PROBABLE_STRING const int terminalSize = 0; #else @@ -43,9 +43,12 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16; for (int index = terminalSize - 1; index >= 0; --index) { traverseSession->getDicTraverseCache()->popTerminal(&terminals[index]); } - - const float languageWeight = scoringPolicy->getAdjustedLanguageWeight( - traverseSession, terminals.data(), terminalSize); + // Compute a language weight when an invalid language weight is passed. + // NOT_A_LANGUAGE_WEIGHT (-1) is assumed as an invalid language weight. + const float languageWeightToOutputSuggestions = (languageWeight < 0.0f) ? + scoringPolicy->getAdjustedLanguageWeight( + traverseSession, terminals.data(), terminalSize) : languageWeight; + outSuggestionResults->setLanguageWeight(languageWeightToOutputSuggestions); // Force autocorrection for obvious long multi-word suggestions when the top suggestion is // a long multiple words suggestion. // TODO: Implement a smarter auto-commit method for handling multi-word suggestions. @@ -61,10 +64,11 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16; // Output suggestion results here for (auto &terminalDicNode : terminals) { outputSuggestionsOfDicNode(scoringPolicy, traverseSession, &terminalDicNode, - languageWeight, boostExactMatches, forceCommitMultiWords, + languageWeightToOutputSuggestions, boostExactMatches, forceCommitMultiWords, outputSecondWordFirstLetterInputIndex, outSuggestionResults); } - scoringPolicy->getMostProbableString(traverseSession, languageWeight, outSuggestionResults); + scoringPolicy->getMostProbableString(traverseSession, languageWeightToOutputSuggestions, + outSuggestionResults); } /* static */ void SuggestionsOutputUtils::outputSuggestionsOfDicNode( diff --git a/native/jni/src/suggest/core/result/suggestions_output_utils.h b/native/jni/src/suggest/core/result/suggestions_output_utils.h index 73cdb9561..b099b4776 100644 --- a/native/jni/src/suggest/core/result/suggestions_output_utils.h +++ b/native/jni/src/suggest/core/result/suggestions_output_utils.h @@ -33,7 +33,8 @@ class SuggestionsOutputUtils { * Outputs the final list of suggestions (i.e., terminal nodes). */ static void outputSuggestions(const Scoring *const scoringPolicy, - DicTraverseSession *traverseSession, SuggestionResults *const outSuggestionResults); + DicTraverseSession *traverseSession, const float languageWeight, + SuggestionResults *const outSuggestionResults); private: DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionsOutputUtils); diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp index 303182cf4..433820a42 100644 --- a/native/jni/src/suggest/core/suggest.cpp +++ b/native/jni/src/suggest/core/suggest.cpp @@ -44,7 +44,8 @@ const int Suggest::MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE = 2; */ void Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, int *times, int *pointerIds, int *inputCodePoints, - int inputSize, SuggestionResults *const outSuggestionResults) const { + int inputSize, const float languageWeight, + SuggestionResults *const outSuggestionResults) const { PROF_OPEN; PROF_START(0); const float maxSpatialDistance = TRAVERSAL->getMaxSpatialDistance(); @@ -65,7 +66,8 @@ void Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession, } PROF_END(1); PROF_START(2); - SuggestionsOutputUtils::outputSuggestions(SCORING, tSession, outSuggestionResults); + SuggestionsOutputUtils::outputSuggestions( + SCORING, tSession, languageWeight, outSuggestionResults); PROF_END(2); PROF_CLOSE; } diff --git a/native/jni/src/suggest/core/suggest.h b/native/jni/src/suggest/core/suggest.h index 13ad621db..788e0314b 100644 --- a/native/jni/src/suggest/core/suggest.h +++ b/native/jni/src/suggest/core/suggest.h @@ -49,7 +49,7 @@ class Suggest : public SuggestInterface { AK_FORCE_INLINE virtual ~Suggest() {} void getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, int *times, int *pointerIds, int *inputCodePoints, int inputSize, - SuggestionResults *const outSuggestionResults) const; + const float languageWeight, SuggestionResults *const outSuggestionResults) const; private: DISALLOW_IMPLICIT_CONSTRUCTORS(Suggest); diff --git a/native/jni/src/suggest/core/suggest_interface.h b/native/jni/src/suggest/core/suggest_interface.h index c3ffea9a2..a6e5aefae 100644 --- a/native/jni/src/suggest/core/suggest_interface.h +++ b/native/jni/src/suggest/core/suggest_interface.h @@ -28,7 +28,7 @@ class SuggestInterface { public: virtual void getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, int *times, int *pointerIds, int *inputCodePoints, int inputSize, - SuggestionResults *const suggestionResults) const = 0; + const float languageWeight, SuggestionResults *const suggestionResults) const = 0; SuggestInterface() {} virtual ~SuggestInterface() {} private: diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java index bbffc8dd5..d6d12ea56 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java @@ -25,7 +25,7 @@ import java.util.ArrayList; @SmallTest public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase { - private static final int NUMBER_OF_SUBTYPES = 66; + private static final int NUMBER_OF_SUBTYPES = 67; private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 42; private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2; diff --git a/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java new file mode 100644 index 000000000..bcf06f085 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout; + +import android.os.Build; + +/** + * This class offers label strings of Devanagari letters that need the dotted circle to draw + * its glyph. + */ +class DevanagariLetterConstants { + private static final boolean NEEDS_DOTTED_CIRCLE = + Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN; + // U+25CC: "◌" DOTTED CIRCLE + private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : ""; + + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + static final String SIGN_CANDRABINDU = DOTTED_CIRCLE + "\u0901"; + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + static final String SIGN_ANUSVARA = DOTTED_CIRCLE + "\u0902"; + // U+0903: "ः" DEVANAGARI SIGN VISARGA + static final String SIGN_VISARGA = DOTTED_CIRCLE + "\u0903"; + // U+093C: "़" DEVANAGARI SIGN NUKTA + static final String SIGN_NUKTA = DOTTED_CIRCLE + "\u093C"; + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + static final String SIGN_AVAGRAHA = DOTTED_CIRCLE + "\u093D"; + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + static final String VOWEL_SIGN_AA = DOTTED_CIRCLE + "\u093E"; + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + static final String VOWEL_SIGN_I = DOTTED_CIRCLE + "\u093F"; + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + static final String VOWEL_SIGN_II = DOTTED_CIRCLE + "\u0940"; + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + static final String VOWEL_SIGN_U = DOTTED_CIRCLE + "\u0941"; + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + static final String VOWEL_SIGN_UU = DOTTED_CIRCLE + "\u0942"; + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + static final String VOWEL_SIGN_VOCALIC_R = DOTTED_CIRCLE + "\u0943"; + // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR + static final String VOWEL_SIGN_VOCALIC_RR = DOTTED_CIRCLE + "\u0944"; + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + static final String VOWEL_SIGN_CANDRA_E = DOTTED_CIRCLE + "\u0945"; + // U+0947: "े" DEVANAGARI VOWEL SIGN E + static final String VOWEL_SIGN_E = DOTTED_CIRCLE + "\u0947"; + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + static final String VOWEL_SIGN_AI = DOTTED_CIRCLE + "\u0948"; + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + static final String VOWEL_SIGN_CANDRA_O = DOTTED_CIRCLE + "\u0949"; + // U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O + static final String VOWEL_SIGN_SHORT_O = DOTTED_CIRCLE + "\u094A"; + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + static final String VOWEL_SIGN_O = DOTTED_CIRCLE + "\u094B"; + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + static final String VOWEL_SIGN_AU = DOTTED_CIRCLE + "\u094C"; + // U+094D: "्" DEVANAGARI SIGN VIRAMA + static final String SIGN_VIRAMA = DOTTED_CIRCLE + "\u094D"; + // U+0970: "॰" DEVANAGARI ABBREVIATION SIGN + static final String ABBREVIATION_SIGN = DOTTED_CIRCLE + "\u0970"; + // U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP + static final String LETTER_GLOTTAL_STOP = DOTTED_CIRCLE + "\u097D"; +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java index 7ff2dcbbc..c3f45313f 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java @@ -16,6 +16,8 @@ package com.android.inputmethod.keyboard.layout; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; @@ -96,25 +98,37 @@ public final class Hindi extends LayoutBase { // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU // U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA // U+0967: "१" DEVANAGARI DIGIT ONE - key("\u094C", joinMoreKeys("\u094C\u0902", "\u0967", "1")), + key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys( + moreKey(VOWEL_SIGN_AU + "\u0902", "\u094C\u0902"), + "\u0967", "1")), // U+0948: "ै" DEVANAGARI VOWEL SIGN AI // U+0948/U+0902: "ैं" DEVANAGARI VOWEL SIGN AI/DEVANAGARI SIGN ANUSVARA // U+0968: "२" DEVANAGARI DIGIT TWO - key("\u0948", joinMoreKeys("\u0948\u0902", "\u0968", "2")), + key(VOWEL_SIGN_AI, "\u0948", joinMoreKeys( + moreKey(VOWEL_SIGN_AI + "\u0902", "\u0948\u0902"), + "\u0968", "2")), // 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 // U+0969: "३" DEVANAGARI DIGIT THREE - key("\u093E", joinMoreKeys("\u093E\u0902", "\u093E\u0901", "\u0969", "3")), + key(VOWEL_SIGN_AA, "\u093E", joinMoreKeys( + moreKey(VOWEL_SIGN_AA + "\u0902", "\u093E\u0902"), + moreKey(VOWEL_SIGN_AA + "\u0901", "\u093E\u0901"), + "\u0969", "3")), // U+0940: "ी" DEVANAGARI VOWEL SIGN II // U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA // U+096A: "४" DEVANAGARI DIGIT FOUR - key("\u0940", joinMoreKeys("\u0940\u0902", "\u096A", "4")), + key(VOWEL_SIGN_II, "\u0940", joinMoreKeys( + moreKey(VOWEL_SIGN_II + "\u0902", "\u0940\u0902"), + "\u096A", "4")), // 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 // U+096B: "५" DEVANAGARI DIGIT FIVE - key("\u0942", joinMoreKeys("\u0942\u0902", "\u0942\u0901", "\u096B", "5")), + key(VOWEL_SIGN_UU, "\u0942", joinMoreKeys( + moreKey(VOWEL_SIGN_UU + "\u0902", "\u0942\u0902"), + moreKey(VOWEL_SIGN_UU + "\u0901", "\u0942\u0901"), + "\u096B", "5")), // U+092C: "ब" DEVANAGARI LETTER BA // U+092C/U+0952: "ब॒" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA // U+096C: "६" DEVANAGARI DIGIT SIX @@ -150,19 +164,26 @@ public final class Hindi extends LayoutBase { // U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O // U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O - key("\u094B", joinMoreKeys("\u094B\u0902", "\u0949", "\u094A")), + key(VOWEL_SIGN_O, "\u094B", joinMoreKeys( + moreKey(VOWEL_SIGN_O + "\u0902", "\u094B\u0902"), + moreKey(VOWEL_SIGN_CANDRA_O, "\u0949"), + moreKey(VOWEL_SIGN_SHORT_O, "\u094A"))), // U+0947: "े" DEVANAGARI VOWEL SIGN E // U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA - key("\u0947", moreKey("\u0947\u0902")), + key(VOWEL_SIGN_E, "\u0947", + moreKey(VOWEL_SIGN_E + "\u0902", "\u0947\u0902")), // U+094D: "्" DEVANAGARI SIGN VIRAMA - "\u094D", + key(SIGN_VIRAMA, "\u094D"), // U+093F: "ि" DEVANAGARI VOWEL SIGN I // U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA - key("\u093F", moreKey("\u093F\u0902")), + key(VOWEL_SIGN_I, "\u093F", + moreKey("\u093F" + SIGN_ANUSVARA, "\u093F\u0902")), // 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("\u0941", joinMoreKeys("\u0941\u0902", "\u0941\u0901")), + key(VOWEL_SIGN_U, "\u0941", joinMoreKeys( + moreKey(VOWEL_SIGN_U + "\u0902", "\u0941\u0902"), + moreKey(VOWEL_SIGN_U + "\u0901", "\u0941\u0901"))), // U+092A: "प" DEVANAGARI LETTER PA "\u092A", // U+0930: "र" DEVANAGARI LETTER RA @@ -182,8 +203,9 @@ public final class Hindi extends LayoutBase { "\u091A","\u091F") .setKeysOfRow(3, // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + key(VOWEL_SIGN_CANDRA_O, "\u0949"), // U+0902: "ं" DEVANAGARI SIGN ANUSVARA - "\u0949", "\u0902", + key(SIGN_ANUSVARA, "\u0902"), // U+092E: "म" DEVANAGARI LETTER MA // U+0950: "ॐ" DEVANAGARI OM key("\u092E", moreKey("\u0950")), @@ -207,7 +229,10 @@ public final class Hindi extends LayoutBase { // U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP // U+0970: "॰" DEVANAGARI ABBREVIATION SIGN // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA - key("\u093C", joinMoreKeys("\u097D", "\u0970", "\u093D"))) + key(SIGN_NUKTA, "\u093C", joinMoreKeys( + moreKey(LETTER_GLOTTAL_STOP, "\u097D"), + moreKey(ABBREVIATION_SIGN, "\u0970"), + moreKey(SIGN_AVAGRAHA, "\u093D")))) .build(); private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() @@ -232,7 +257,7 @@ public final class Hindi extends LayoutBase { // U+092D: "भ" DEVANAGARI LETTER BHA // U+0903: "ः" DEVANAGARI SIGN VISARGA // U+0918: "घ" DEVANAGARI LETTER GHA - "\u092D", "\u0903", "\u0918", + "\u092D", key(SIGN_VISARGA, "\u0903"), "\u0918", // U+0927: "ध" DEVANAGARI LETTER DHA // U+0915/U+094D/U+0937: // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA @@ -285,7 +310,7 @@ public final class Hindi extends LayoutBase { "\u0911", // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E - key("\u0901", moreKey("\u0945")), + key(SIGN_CANDRABINDU, "\u0901", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")), // U+0923: "ण" DEVANAGARI LETTER NNA // U+0929: "ऩ" DEVANAGARI LETTER NNNA "\u0923", "\u0929", @@ -297,7 +322,7 @@ public final class Hindi extends LayoutBase { "\u0936", "\u0937", // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR - key("\u0943", moreKey("\u0944")), + key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey(VOWEL_SIGN_VOCALIC_RR, "\u0944")), // U+091E: "ञ" DEVANAGARI LETTER NYA "\u091E") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java new file mode 100644 index 000000000..afd26e428 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout; + +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_ANUSVARA; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_CANDRABINDU; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_NUKTA; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VIRAMA; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VISARGA; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AA; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AI; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AU; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_E; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_O; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_E; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_I; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_II; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_O; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_U; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_UU; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_VOCALIC_R; + +import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer; +import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import com.android.inputmethod.latin.Constants; + +import java.util.Locale; + +/** + * The Hindi Compact keyboard. + */ +public final class HindiCompact extends LayoutBase { + private static final String LAYOUT_NAME = "hindi_compact"; + + public HindiCompact(final LayoutCustomizer customizer) { + super(customizer, HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class HindiCompactCustomizer extends HindiCustomizer { + public HindiCompactCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + // U+0964: "।" DEVANAGARI DANDA + final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone)); + return isPhone ? joinKeys(periodKey) : joinKeys(",", periodKey); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? HINDI_PHONE_PUNCTUATION_MORE_KEYS : HINDI_TABLET_PUNCTUATION_MORE_KEYS; + } + + // Punctuation more keys for phone form factor. + private static final ExpectedKey[] HINDI_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ",", ".", "?", "!", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + // Punctuation more keys for tablet form factor. + private static final ExpectedKey[] HINDI_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ",", ".", "'", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0914: "औ" DEVANAGARI LETTER AU + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0967: "१" DEVANAGARI DIGIT ONE + key("\u0914", joinMoreKeys(moreKey(VOWEL_SIGN_AU, "\u094C"), "\u0967", "1")), + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0968: "२" DEVANAGARI DIGIT TWO + key("\u0910", joinMoreKeys(moreKey(VOWEL_SIGN_AI, "\u0948"), "\u0968", "2")), + // U+0906: "आ" DEVANAGARI LETTER AA + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+0969: "३" DEVANAGARI DIGIT THREE + key("\u0906", joinMoreKeys(moreKey(VOWEL_SIGN_AA, "\u093E"), "\u0969", "3")), + // U+0908: "ई" DEVANAGARI LETTER II + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+096A: "४" DEVANAGARI DIGIT FOUR + key("\u0908", joinMoreKeys(moreKey(VOWEL_SIGN_II, "\u0940"), "\u096A", "4")), + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + // U+096B: "५" DEVANAGARI DIGIT FIVE + key("\u090A", joinMoreKeys(moreKey(VOWEL_SIGN_UU, "\u0942"), "\u096B", "5")), + // U+092C: "ब" DEVANAGARI LETTER BA + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")), + // U+0939: "ह" DEVANAGARI LETTER HA + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0939", joinMoreKeys("\u096D", "7")), + // U+0917: "ग" DEVANAGARI LETTER GA + // U+0918: "घ" DEVANAGARI LETTER GHA + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")), + // U+0926: "द" DEVANAGARI LETTER DA + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")), + // U+091C: "ज" DEVANAGARI LETTER JA + // U+091D: "झ" DEVANAGARI LETTER JHA + // U+091C/U+094D/U+091E: + // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")), + // U+0921: "ड" DEVANAGARI LETTER DDA + // U+0922: "ढ" DEVANAGARI LETTER DDHA + key("\u0921", moreKey("\u0922"))) + .setKeysOfRow(2, + // U+0913: "ओ" DEVANAGARI LETTER O + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + key("\u0913", moreKey(VOWEL_SIGN_O, "\u094B")), + // U+090F: "ए" DEVANAGARI LETTER E + // U+0947: "े" DEVANAGARI VOWEL SIGN E + key("\u090F", moreKey(VOWEL_SIGN_E, "\u0947")), + // U+0905: "अ" DEVANAGARI LETTER A + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key("\u0905", moreKey(SIGN_VIRAMA, "\u094D")), + // U+0907: "इ" DEVANAGARI LETTER I + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + key("\u0907", moreKey(VOWEL_SIGN_I, "\u093F")), + // U+0909: "उ" DEVANAGARI LETTER U + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + key("\u0909", moreKey(VOWEL_SIGN_U, "\u0941")), + // U+092A: "प" DEVANAGARI LETTER PA + // U+092B: "फ" DEVANAGARI LETTER PHA + key("\u092A", moreKey("\u092B")), + // U+0930: "र" DEVANAGARI LETTER RA + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + key("\u0930", joinMoreKeys("\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))), + // U+0915: "क" DEVANAGARI LETTER KA + // U+0916: "ख" DEVANAGARI LETTER KHA + key("\u0915", moreKey("\u0916")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+0925: "थ" DEVANAGARI LETTER THA + // U+0924/U+094D/U+0930: + // "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")), + // U+091A: "च" DEVANAGARI LETTER CA + // U+091B: "छ" DEVANAGARI LETTER CHA + key("\u091A", moreKey("\u091B")), + // U+091F: "ट" DEVANAGARI LETTER TTA + // U+0920: "ठ" DEVANAGARI LETTER TTHA + key("\u091F", moreKey("\u0920"))) + .setKeysOfRow(3, + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + key("\u0911", moreKey(VOWEL_SIGN_CANDRA_O, "\u0949")), + // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + key("\u090D", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")), + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+093C: "़" DEVANAGARI SIGN NUKTA + key(SIGN_ANUSVARA, "\u0902", joinMoreKeys( + moreKey(SIGN_VISARGA, "\u0903"), + moreKey(SIGN_CANDRABINDU, "\u0901"), + moreKey(SIGN_NUKTA, "\u093C"))), + // U+092E: "म" DEVANAGARI LETTER MA + // U+0950: "ॐ" DEVANAGARI OM + key("\u092E", moreKey("\u0950")), + // U+0928: "न" DEVANAGARI LETTER NA + // U+0923: "ण" DEVANAGARI LETTER NNA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+0919: "ङ" DEVANAGARI LETTER NGA + key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")), + // U+0935: "व" DEVANAGARI LETTER VA + // U+0932: "ल" DEVANAGARI LETTER LA + "\u0935", "\u0932", + // U+0938: "स" DEVANAGARI LETTER SA + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0937: "ष" DEVANAGARI LETTER SSA + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")), + // U+092F: "य" DEVANAGARI LETTER YA + // U+0915/U+094D/U+0937: + // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA + "\u092F", "\u0915\u094D\u0937") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java index 09cc8f9ca..4123a22ef 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java @@ -180,8 +180,7 @@ public abstract class LayoutBase extends AbstractLayoutBase { * @return the array of {@link ExpectedKey} that are "more keys" of the punctuation key. */ public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { - return isPhone ? PHONE_PUNCTUATION_MORE_KEYS - : TABLET_PUNCTUATION_MORE_KEYS; + return isPhone ? PHONE_PUNCTUATION_MORE_KEYS : TABLET_PUNCTUATION_MORE_KEYS; } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java index 7cfe3444c..7048dbb73 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java @@ -16,6 +16,8 @@ package com.android.inputmethod.keyboard.layout; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer; import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols; @@ -70,13 +72,13 @@ public final class NepaliRomanized extends LayoutBase { // U+091F: "ट" DEVANAGARI LETTER TTA // U+0967: "१" DEVANAGARI DIGIT ONE // U+093C: "़" DEVANAGARI SIGN NUKTA - key("\u091F", joinMoreKeys("\u0967", "1", "\u093C")), + key("\u091F", joinMoreKeys("\u0967", "1", key(SIGN_NUKTA, "\u093C"))), // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU // U+0968: "२" DEVANAGARI DIGIT TWO - key("\u094C", joinMoreKeys("\u0968", "2")), + key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0968", "2")), // U+0947: "े" DEVANAGARI VOWEL SIGN E // U+0969: "३" DEVANAGARI DIGIT THREE - key("\u0947", joinMoreKeys("\u0969", "3")), + key(VOWEL_SIGN_E, "\u0947", joinMoreKeys("\u0969", "3")), // U+0930: "र" DEVANAGARI LETTER RA // U+096A: "४" DEVANAGARI DIGIT FOUR key("\u0930", joinMoreKeys("\u096A", "4")), @@ -88,13 +90,13 @@ public final class NepaliRomanized extends LayoutBase { key("\u092F", joinMoreKeys("\u096C", "6")), // U+0941: "ु" DEVANAGARI VOWEL SIGN U // U+096D: "७" DEVANAGARI DIGIT SEVEN - key("\u0941", joinMoreKeys("\u096D", "7")), + key(VOWEL_SIGN_U, "\u0941", joinMoreKeys("\u096D", "7")), // U+093F: "ि" DEVANAGARI VOWEL SIGN I // U+096E: "८" DEVANAGARI DIGIT EIGHT - key("\u093F", joinMoreKeys("\u096E", "8")), + key(VOWEL_SIGN_I, "\u093F", joinMoreKeys("\u096E", "8")), // U+094B: "ो" DEVANAGARI VOWEL SIGN O // U+096F: "९" DEVANAGARI DIGIT NINE - key("\u094B", joinMoreKeys("\u096F", "9")), + key(VOWEL_SIGN_O, "\u094B", joinMoreKeys("\u096F", "9")), // U+092A: "प" DEVANAGARI LETTER PA // U+0966: "०" DEVANAGARI DIGIT ZERO key("\u092A", joinMoreKeys("\u0966", "0")), @@ -102,6 +104,7 @@ public final class NepaliRomanized extends LayoutBase { "\u0907") .setKeysOfRow(2, // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + key(VOWEL_SIGN_AA, "\u093E"), // U+0938: "स" DEVANAGARI LETTER SA // U+0926: "द" DEVANAGARI LETTER DA // U+0909: "उ" DEVANAGARI LETTER U @@ -112,8 +115,8 @@ public final class NepaliRomanized extends LayoutBase { // U+0932: "ल" DEVANAGARI LETTER LA // U+090F: "ए" DEVANAGARI LETTER E // U+0950: "ॐ" DEVANAGARI OM - "\u093E", "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", - "\u0932", "\u090F", "\u0950") + "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", "\u0932", + "\u090F", "\u0950") .setKeysOfRow(3, // U+0937: "ष" DEVANAGARI LETTER SSA // U+0921: "ड" DEVANAGARI LETTER DDA @@ -127,23 +130,28 @@ public final class NepaliRomanized extends LayoutBase { // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA key("\u0964", moreKey("\u093D")), // U+094D: "्" DEVANAGARI SIGN VIRAMA - "\u094D") + key(SIGN_VIRAMA, "\u094D")) .build(); private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, // U+0920: "ठ" DEVANAGARI LETTER TTHA // U+0914: "औ" DEVANAGARI LETTER AU + "\u0920", "\u0914", // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + key(VOWEL_SIGN_AI, "\u0948"), // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + key(VOWEL_SIGN_VOCALIC_R, "\u0943"), // U+0925: "थ" DEVANAGARI LETTER THA // U+091E: "ञ" DEVANAGARI LETTER NYA + "\u0925", "\u091E", // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + key(VOWEL_SIGN_UU, "\u0942"), // U+0940: "ी" DEVANAGARI VOWEL SIGN II + key(VOWEL_SIGN_II, "\u0940"), // U+0913: "ओ" DEVANAGARI LETTER O // U+092B: "फ" DEVANAGARI LETTER PHA // U+0908: "ई" DEVANAGARI LETTER II - "\u0920", "\u0914", "\u0948", "\u0943", "\u0925", "\u091E", "\u0942", "\u0940", "\u0913", "\u092B", "\u0908") .setKeysOfRow(2, // U+0906: "आ" DEVANAGARI LETTER AA @@ -158,18 +166,22 @@ public final class NepaliRomanized extends LayoutBase { // U+0910: "ऐ" DEVANAGARI LETTER AI // U+0903: "ः" DEVANAGARI SIGN VISARGA "\u0906", "\u0936", "\u0927", "\u090A", "\u0918", "\u0905", "\u091D", "\u0916", - "\u0965", "\u0910", "\u0903") + "\u0965", "\u0910", key(SIGN_VISARGA, "\u0903")) .setKeysOfRow(3, // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R // U+0922: "ढ" DEVANAGARI LETTER DDHA // U+091B: "छ" DEVANAGARI LETTER CHA + "\u090B", "\u0922", "\u091B", // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + key(SIGN_CANDRABINDU, "\u0901"), // U+092D: "भ" DEVANAGARI LETTER BHA // U+0923: "ण" DEVANAGARI LETTER NNA + "\u092D", "\u0923", // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\u0902"), // U+0919: "ङ" DEVANAGARI LETTER NGA + "\u0919", // U+094D: "्" DEVANAGARI SIGN VIRAMA - "\u090B", "\u0922", "\u091B", "\u0901", "\u092D", "\u0923", "\u0902", "\u0919", - "\u094D") + key(SIGN_VIRAMA, "\u094D")) .build(); } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java index 1599fd7a6..4d6cdedbf 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java @@ -16,6 +16,8 @@ package com.android.inputmethod.keyboard.layout; +import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols; import com.android.inputmethod.keyboard.layout.NepaliRomanized.NepaliRomanizedCustomizer; @@ -47,7 +49,7 @@ public final class NepaliTraditional extends LayoutBase { public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { if (isPhone) { // U+094D: "्" DEVANAGARI SIGN VIRAMA - return joinKeys(key("\u094D", PHONE_PUNCTUATION_MORE_KEYS)); + return joinKeys(key(SIGN_VIRAMA, "\u094D", PHONE_PUNCTUATION_MORE_KEYS)); } return super.getKeysRightToSpacebar(isPhone); } @@ -61,7 +63,8 @@ public final class NepaliTraditional extends LayoutBase { // U+0947: "े" DEVANAGARI VOWEL SIGN E // U+0903: "ः" DEVANAGARI SIGN VISARGA // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA - key("\u0947", joinMoreKeys("\u0903", "\u093D")), + key(VOWEL_SIGN_E, "\u0947", joinMoreKeys( + moreKey(SIGN_VISARGA, "\u0903"), "\u093D")), // U+0964: "।" DEVANAGARI DANDA "\u0964", // U+0930: "र" DEVANAGARI LETTER RA @@ -71,14 +74,15 @@ public final class NepaliTraditional extends LayoutBase { builder.addKeysOnTheRightOfRow(3, // U+0903: "ः" DEVANAGARI SIGN VISARGA // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA - key("\u0903", moreKey("\u093D")), + key(SIGN_VISARGA, "\u0903", moreKey("\u093D")), // U+0947: "े" DEVANAGARI VOWEL SIGN E + key(VOWEL_SIGN_E, "\u0947"), // U+0964: "।" DEVANAGARI DANDA - "\u0947", "\u0964", + "\u0964", // U+0930: "र" DEVANAGARI LETTER RA key("\u0930", moreKey("!")), // U+094D: "्" DEVANAGARI SIGN VIRAMA - key("\u094D", moreKey("?"))); + key(SIGN_VIRAMA, "\u094D", moreKey("?"))); } return builder.build(); } @@ -93,21 +97,23 @@ public final class NepaliTraditional extends LayoutBase { if (isPhone) { builder.addKeysOnTheRightOfRow(3, // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\u0902"), // U+0919: "ङ" DEVANAGARI LETTER NGA - "\u0902", "\u0919", + "\u0919", // U+0948: "ै" DEVANAGARI VOWEL SIGN AI // U+0936/U+094D/U+0930: // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA - key("\u0948", moreKey("\u0936\u094D\u0930"))); + key(VOWEL_SIGN_AI, "\u0948", moreKey("\u0936\u094D\u0930"))); } else { builder.addKeysOnTheRightOfRow(3, // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\u0902"), // U+0919: "ङ" DEVANAGARI LETTER NGA - "\u0902", "\u0919", + "\u0919", // U+0948: "ै" DEVANAGARI VOWEL SIGN AI // U+0936/U+094D/U+0930: // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA - key("\u0948", moreKey("\u0936\u094D\u0930")), + key(VOWEL_SIGN_AI, "\u0948", moreKey("\u0936\u094D\u0930")), // U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U key("\u0930\u0941", moreKey("!")), "?"); @@ -154,16 +160,20 @@ public final class NepaliTraditional extends LayoutBase { // U+092C: "ब" DEVANAGARI LETTER BA // U+0915: "क" DEVANAGARI LETTER KA // U+092E: "म" DEVANAGARI LETTER MA + "\u092C", "\u0915", "\u092E", // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + key(VOWEL_SIGN_AA, "\u093E"), // U+0928: "न" DEVANAGARI LETTER NA // U+091C: "ज" DEVANAGARI LETTER JA // U+0935: "व" DEVANAGARI LETTER VA // U+092A: "प" DEVANAGARI LETTER PA + "\u0928", "\u091C", "\u0935", "\u092A", // U+093F: "ि" DEVANAGARI VOWEL SIGN I + key(VOWEL_SIGN_I, "\u093F"), // U+0938: "स" DEVANAGARI LETTER SA + "\u0938", // U+0941: "ु" DEVANAGARI VOWEL SIGN U - "\u092C", "\u0915", "\u092E", "\u093E", "\u0928", "\u091C", "\u0935", "\u092A", - "\u093F", "\u0938", "\u0941") + key(VOWEL_SIGN_U, "\u0941")) .setKeysOfRow(3, // U+0936: "श" DEVANAGARI LETTER SHA // U+0939: "ह" DEVANAGARI LETTER HA @@ -219,34 +229,41 @@ public final class NepaliTraditional extends LayoutBase { key("\u090F", moreKey("\u0923")), // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R // U+0913: "ओ" DEVANAGARI LETTER O - key("\u0943", moreKey("\u0913"))) + key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey("\u0913"))) .setKeysOfRow(2, // U+0906: "आ" DEVANAGARI LETTER AA // U+0919/U+094D: "ङ्" DEVANAGARI LETTER NGA/DEVANAGARI SIGN VIRAMA // U+0921/U+094D/U+0921: // "ड्ड" DEVANAGARI LETTER DDA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DDA + "\u0906", "\u0919\u094D", "\u0921\u094D\u0921", // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + key(SIGN_CANDRABINDU, "\u0901"), // U+0926/U+094D/U+0926: // "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA // U+091D: "झ" DEVANAGARI LETTER JHA + "\u0926\u094D\u0926", "\u091D", // U+094B: "ो" DEVANAGARI VOWEL SIGN O + key(VOWEL_SIGN_O, "\u094B"), // U+092B: "फ" DEVANAGARI LETTER PHA + "\u092B", // U+0940: "ी" DEVANAGARI VOWEL SIGN II + key(VOWEL_SIGN_II, "\u0940"), // U+091F/U+094D/U+0920: // "ट्ठ" DEVANAGARI LETTER TTA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTHA + "\u091F\u094D\u0920", // U+0942: "ू" DEVANAGARI VOWEL SIGN UU - "\u0906", "\u0919\u094D", "\u0921\u094D\u0921", "\u0901", "\u0926\u094D\u0926", - "\u091D", "\u094B", "\u092B", "\u0940", "\u091F\u094D\u0920", "\u0942") + key(VOWEL_SIGN_UU, "\u0942")) .setKeysOfRow(3, // U+0915/U+094D: "क्" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA // U+0939/U+094D/U+092E: // "ह्म" DEVANAGARI LETTER HA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER MA // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R // U+0950: "ॐ" DEVANAGARI OM + "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950", // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + key(VOWEL_SIGN_AU, "\u094C"), // U+0926/U+094D/U+092F: // "द्य" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER YA - "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950", "\u094C", "\u0926\u094D\u092F") .build(); } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java new file mode 100644 index 000000000..2e676df26 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.keyboard.layout.HindiCompact; +import com.android.inputmethod.keyboard.layout.HindiCompact.HindiCompactCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * hi: Hindi/hindi_compact + */ +@SmallTest +public final class TestsHindiCompact extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hi"); + private static final LayoutBase LAYOUT = new HindiCompact(new HindiCompactCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index b36645289..d2dd29262 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -16,7 +16,10 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.latin.settings.Settings; + import android.test.suitebuilder.annotation.LargeTest; +import android.text.TextUtils; import android.view.inputmethod.BaseInputConnection; @LargeTest @@ -179,6 +182,8 @@ public class InputLogicTests extends InputTestsBase { } public void testDoubleSpace() { + // Set default pref just in case + setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true); // U+1F607 is an emoji final String[] STRINGS_TO_TYPE = new String[] { "this ", "a+ ", "\u1F607 ", ".. ", ") ", "( ", "% " }; @@ -200,6 +205,76 @@ public class InputLogicTests extends InputTestsBase { assertEquals("double space make a period", EXPECTED_RESULT, mEditText.getText().toString()); } + private void testDoubleSpacePeriodWithSettings(final boolean expectsPeriod, + final Object... settingsKeysValues) { + final Object[] oldSettings = new Object[settingsKeysValues.length / 2]; + final String STRING_WITHOUT_PERIOD = "this "; + final String STRING_WITH_PERIOD = "this. "; + final String EXPECTED_RESULT = expectsPeriod ? STRING_WITH_PERIOD : STRING_WITHOUT_PERIOD; + try { + for (int i = 0; i < settingsKeysValues.length; i += 2) { + if (settingsKeysValues[i + 1] instanceof String) { + oldSettings[i / 2] = setStringPreference((String)settingsKeysValues[i], + (String)settingsKeysValues[i + 1], "0"); + } else { + oldSettings[i / 2] = setBooleanPreference((String)settingsKeysValues[i], + (Boolean)settingsKeysValues[i + 1], false); + } + } + mLatinIME.loadSettings(); + mEditText.setText(""); + type(STRING_WITHOUT_PERIOD); + assertEquals("double-space-to-period with specific settings " + + TextUtils.join(" ", settingsKeysValues), + EXPECTED_RESULT, mEditText.getText().toString()); + } finally { + // Restore old settings + for (int i = 0; i < settingsKeysValues.length; i += 2) { + if (null == oldSettings[i / 2]) { + break; + } if (oldSettings[i / 2] instanceof String) { + setStringPreference((String)settingsKeysValues[i], (String)oldSettings[i / 2], + ""); + } else { + setBooleanPreference((String)settingsKeysValues[i], (Boolean)oldSettings[i / 2], + false); + } + } + } + } + + public void testDoubleSpacePeriod() { + // Reset settings to default, else these tests will go flaky. + setStringPreference(Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0", "0"); + setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, "1", "1"); + setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true); + testDoubleSpacePeriodWithSettings(true /* expectsPeriod */); + // "Suggestion visibility" to "always hide" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "2"); + // "Suggestion visibility" to "portrait only" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "1"); + // "Suggestion visibility" to "always show" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0"); + + // "Double-space period" to "off" + testDoubleSpacePeriodWithSettings(false, Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, false); + + // "Auto-correction" to "off" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0"); + // "Auto-correction" to "modest" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "1"); + // "Auto-correction" to "very aggressive" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "3"); + + // "Suggestion visibility" to "always hide" and "Auto-correction" to "off" + testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0", + Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0"); + // "Suggestion visibility" to "always hide" and "Auto-correction" to "off" + testDoubleSpacePeriodWithSettings(false, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0", + Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0", + Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, false); + } + public void testBackspaceAtStartAfterAutocorrect() { final String STRING_TO_TYPE = "tgis "; final int typedLength = STRING_TO_TYPE.length(); diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index 690c559e8..1383ff903 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -65,7 +65,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected MyEditText mEditText; protected View mInputView; protected InputConnection mInputConnection; - private boolean mPreviousDebugSetting; private boolean mPreviousBigramPredictionSettings; private String mPreviousAutoCorrectSetting; @@ -185,7 +184,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { mEditText.setEnabled(true); setupService(); mLatinIME = getService(); - mPreviousDebugSetting = setDebugMode(true); + setDebugMode(true); mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, true, true /* defaultValue */); mPreviousAutoCorrectSetting = setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, @@ -219,7 +218,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { true /* defaultValue */); setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, mPreviousAutoCorrectSetting, DEFAULT_AUTO_CORRECTION_THRESHOLD); - setDebugMode(mPreviousDebugSetting); + setDebugMode(false); super.tearDown(); } diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index f49dee70f..e12d7e0b5 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -85,7 +85,6 @@ LOCAL_JAVA_LIBRARIES := junit LOCAL_ADDITIONAL_DEPENDENCIES := $(LATINIME_HOST_NATIVE_LIBNAME) LOCAL_JAR_MANIFEST := etc/manifest.txt LOCAL_MODULE := dicttool_aosp -LOCAL_IS_HOST_MODULE := true include $(BUILD_HOST_JAVA_LIBRARY) include $(LOCAL_PATH)/etc/Android.mk diff --git a/tools/dicttool/NativeLib.mk b/tools/dicttool/NativeLib.mk index 0d3507be3..74034482b 100644 --- a/tools/dicttool/NativeLib.mk +++ b/tools/dicttool/NativeLib.mk @@ -29,13 +29,7 @@ ifeq ($(FLAG_DBG), true) LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline endif #FLAG_DBG -ifneq ($(strip $(HOST_JDK_IS_64BIT_VERSION)),) -LOCAL_CFLAGS += -m64 -LOCAL_LDFLAGS += -m64 -endif #HOST_JDK_IS_64BIT_VERSION - -LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated -LOCAL_NO_DEFAULT_COMPILER_FLAGS := true +LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated -Wno-unused-parameter -Wno-unused-function LOCAL_CLANG := true # For C++11 @@ -44,7 +38,6 @@ LOCAL_CFLAGS += -std=c++11 LATINIME_NATIVE_JNI_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni LATINIME_NATIVE_SRC_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni/src LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LATINIME_NATIVE_SRC_DIR) -# Used in jni_common.cpp to avoid registering useless methods. include $(LOCAL_PATH)/$(LATINIME_NATIVE_JNI_DIR)/NativeFileList.mk @@ -53,7 +46,6 @@ LOCAL_SRC_FILES := \ $(addprefix $(LATINIME_NATIVE_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES)) LOCAL_MODULE := $(LATINIME_HOST_NATIVE_LIBNAME) -LOCAL_IS_HOST_MODULE := true include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/tools/dicttool/etc/dicttool_aosp b/tools/dicttool/etc/dicttool_aosp index 65a1c3a1c..09d65c691 100755 --- a/tools/dicttool/etc/dicttool_aosp +++ b/tools/dicttool/etc/dicttool_aosp @@ -68,5 +68,14 @@ else libpath="$frameworkdir/$lib" fi +# Check if the host Java executable supports a 32-bit JVM. It needs to do because the JNI +# library is 32-bit. +${DICTTOOL_JAVA-java} -d32 -version > /dev/null 2>&1 +if [[ $? != 0 ]] ; then + echo Please specify a Java executable that supports a 32-bit JVM as DICTTOOL_JAVA. + exit 1 +fi + # might need more memory, e.g. -Xmx128M -exec java -ea -classpath "$libpath":"$jarpath" -Djava.library.path="$libdir" "$classname" "$@" +exec ${DICTTOOL_JAVA-java} -d32 -ea -classpath "$libpath":"$jarpath" \ + -Djava.library.path="$libdir" "$classname" "$@" |