diff options
155 files changed, 2413 insertions, 572 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-af/strings.xml b/java/res/values-af/strings.xml index 9c9f02245..720b92ec9 100644 --- a/java/res/values-af/strings.xml +++ b/java/res/values-af/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Oortjie"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Spasie"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Steminvoering"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emosiekone"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Soek"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Punt"</string> diff --git a/java/res/values-am/strings.xml b/java/res/values-am/strings.xml index 3f9b03fd7..dae334e40 100644 --- a/java/res/values-am/strings.xml +++ b/java/res/values-am/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"ትር"</string> <string name="spoken_description_space" msgid="2582521050049860859">"ባዶ ቦታ"</string> <string name="spoken_description_mic" msgid="615536748882611950">"የድምፅ ግቤ ት"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"ኢሞጂ"</string> <string name="spoken_description_return" msgid="8178083177238315647">"ተመለስ"</string> <string name="spoken_description_search" msgid="1247236163755920808">"ፍለጋ"</string> <string name="spoken_description_dot" msgid="40711082435231673">"ነጥብ"</string> diff --git a/java/res/values-az-rAZ/strings.xml b/java/res/values-az-rAZ/strings.xml index 99765a9ff..283f01fa9 100644 --- a/java/res/values-az-rAZ/strings.xml +++ b/java/res/values-az-rAZ/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Boşluq"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Səs daxiletməsi"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Qayıt"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Axtar"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Nöqtə"</string> diff --git a/java/res/values-bg/strings.xml b/java/res/values-bg/strings.xml index 03e8b8cea..88a02959c 100644 --- a/java/res/values-bg/strings.xml +++ b/java/res/values-bg/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Интервал"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Гласово въвеждане"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Емотикони"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Търсене"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Точка"</string> diff --git a/java/res/values-cs/strings.xml b/java/res/values-cs/strings.xml index b190857a0..1c4afe215 100644 --- a/java/res/values-cs/strings.xml +++ b/java/res/values-cs/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tabulátor"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Mezerník"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Hlasový vstup"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emodži"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"vyhledávací tlačítko"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Tečka"</string> diff --git a/java/res/values-da/strings.xml b/java/res/values-da/strings.xml index e87fffdee..c2894f743 100644 --- a/java/res/values-da/strings.xml +++ b/java/res/values-da/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tabulatortast"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Mellemrum"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Taleinput"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Tilbage"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Søg"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Punktum"</string> diff --git a/java/res/values-es-rUS/strings.xml b/java/res/values-es-rUS/strings.xml index 2e8dc1646..0690d5604 100644 --- a/java/res/values-es-rUS/strings.xml +++ b/java/res/values-es-rUS/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Pestaña"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Espacio"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de voz"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Volver"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Buscar"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Punto"</string> diff --git a/java/res/values-fa/strings.xml b/java/res/values-fa/strings.xml index 14957ebcf..f57a469f8 100644 --- a/java/res/values-fa/strings.xml +++ b/java/res/values-fa/strings.xml @@ -97,8 +97,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"فاصله"</string> <string name="spoken_description_mic" msgid="615536748882611950">"ورودی صدا"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string> <string name="spoken_description_search" msgid="1247236163755920808">"جستجو"</string> <string name="spoken_description_dot" msgid="40711082435231673">"نقطه"</string> diff --git a/java/res/values-fi/strings.xml b/java/res/values-fi/strings.xml index 514e07cb7..9839b395e 100644 --- a/java/res/values-fi/strings.xml +++ b/java/res/values-fi/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Sarkain"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Välilyönti"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Äänisyöte"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Takaisin"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Haku"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Piste"</string> diff --git a/java/res/values-fr-rCA/strings.xml b/java/res/values-fr-rCA/strings.xml index b0b4c0145..217211ce7 100644 --- a/java/res/values-fr-rCA/strings.xml +++ b/java/res/values-fr-rCA/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Onglet"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Espace"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Saisie vocale"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Renvoyer"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Rechercher"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Point"</string> diff --git a/java/res/values-fr/strings.xml b/java/res/values-fr/strings.xml index 1afd4af0e..6d0e43c2f 100644 --- a/java/res/values-fr/strings.xml +++ b/java/res/values-fr/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tabulation"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Espace"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Saisie vocale"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Entrée"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Rechercher"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Point"</string> diff --git a/java/res/values-hy-rAM/strings.xml b/java/res/values-hy-rAM/strings.xml index 975b7b33b..3bd55143d 100644 --- a/java/res/values-hy-rAM/strings.xml +++ b/java/res/values-hy-rAM/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Բացակ"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Ձայնային մուտքագրում"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Զմայլիկներ"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Վերադարձ"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Որոնել"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Կետ"</string> diff --git a/java/res/values-ja/strings.xml b/java/res/values-ja/strings.xml index 76ba650d4..5cdc6f4d1 100644 --- a/java/res/values-ja/strings.xml +++ b/java/res/values-ja/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Space"</string> <string name="spoken_description_mic" msgid="615536748882611950">"音声入力"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"絵文字"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"検索"</string> <string name="spoken_description_dot" msgid="40711082435231673">"中点"</string> diff --git a/java/res/values-ka-rGE/strings.xml b/java/res/values-ka-rGE/strings.xml index dcb8061e0..cc6c5bb7c 100644 --- a/java/res/values-ka-rGE/strings.xml +++ b/java/res/values-ka-rGE/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"შორისი"</string> <string name="spoken_description_mic" msgid="615536748882611950">"ხმოვანი შეყვანა"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"დაბრუნება"</string> <string name="spoken_description_search" msgid="1247236163755920808">"ძიება"</string> <string name="spoken_description_dot" msgid="40711082435231673">"წერტილი"</string> diff --git a/java/res/values-ko/strings.xml b/java/res/values-ko/strings.xml index 30907b6df..d756aa96f 100644 --- a/java/res/values-ko/strings.xml +++ b/java/res/values-ko/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"탭"</string> <string name="spoken_description_space" msgid="2582521050049860859">"스페이스"</string> <string name="spoken_description_mic" msgid="615536748882611950">"음성 입력"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"그림 이모티콘"</string> <string name="spoken_description_return" msgid="8178083177238315647">"리턴 키"</string> <string name="spoken_description_search" msgid="1247236163755920808">"검색"</string> <string name="spoken_description_dot" msgid="40711082435231673">"점"</string> diff --git a/java/res/values-mn-rMN/strings.xml b/java/res/values-mn-rMN/strings.xml index 684c03f2b..42e840895 100644 --- a/java/res/values-mn-rMN/strings.xml +++ b/java/res/values-mn-rMN/strings.xml @@ -93,7 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Таб"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Хоосон зай"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Дуугаар оруулах"</string> - <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Эможи"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Буцах"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Хайх"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Цэг"</string> diff --git a/java/res/values-ms-rMY/strings.xml b/java/res/values-ms-rMY/strings.xml index 2cbba2194..1a3b3fc57 100644 --- a/java/res/values-ms-rMY/strings.xml +++ b/java/res/values-ms-rMY/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Ruang"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Input suara"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Kembali"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Cari"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Titik"</string> diff --git a/java/res/values-ne-rNP/strings.xml b/java/res/values-ne-rNP/strings.xml index 04a2d09f4..318071c76 100644 --- a/java/res/values-ne-rNP/strings.xml +++ b/java/res/values-ne-rNP/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"ट्याब"</string> <string name="spoken_description_space" msgid="2582521050049860859">"स्पेस"</string> <string name="spoken_description_mic" msgid="615536748882611950">"आवाज इनपुट"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"इमोजी"</string> <string name="spoken_description_return" msgid="8178083177238315647">"फर्कनुहोस्"</string> <string name="spoken_description_search" msgid="1247236163755920808">"खोज्नुहोस्"</string> <string name="spoken_description_dot" msgid="40711082435231673">"डट"</string> diff --git a/java/res/values-pt-rPT/strings.xml b/java/res/values-pt-rPT/strings.xml index 8b4131c11..c9622554f 100644 --- a/java/res/values-pt-rPT/strings.xml +++ b/java/res/values-pt-rPT/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Espaço"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de voz"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Pesquisar"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Ponto"</string> diff --git a/java/res/values-pt/strings.xml b/java/res/values-pt/strings.xml index a74d24a27..96669d3da 100644 --- a/java/res/values-pt/strings.xml +++ b/java/res/values-pt/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Espaço"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de voz"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emojis"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Voltar"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Pesquisar"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Ponto"</string> diff --git a/java/res/values-ro/strings.xml b/java/res/values-ro/strings.xml index d40f4427e..ac5143bda 100644 --- a/java/res/values-ro/strings.xml +++ b/java/res/values-ro/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Spaţiu"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Intrare vocală"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Căutaţi"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Punct"</string> diff --git a/java/res/values-ru/strings.xml b/java/res/values-ru/strings.xml index 44cb0fab8..dd0657dcb 100644 --- a/java/res/values-ru/strings.xml +++ b/java/res/values-ru/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Клавиша табуляции"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Пробел"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Голосовой ввод"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Смайлики."</string> <string name="spoken_description_return" msgid="8178083177238315647">"Клавиша \"Ввод\""</string> <string name="spoken_description_search" msgid="1247236163755920808">"Поиск"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Точка"</string> diff --git a/java/res/values-sk/strings.xml b/java/res/values-sk/strings.xml index 68df7ae41..c35982caf 100644 --- a/java/res/values-sk/strings.xml +++ b/java/res/values-sk/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Karta"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Medzerník"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Hlasový vstup"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Hľadať"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Bodka"</string> diff --git a/java/res/values-sr/strings.xml b/java/res/values-sr/strings.xml index e1ead18a7..2e9fbdbf3 100644 --- a/java/res/values-sr/strings.xml +++ b/java/res/values-sr/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Размак"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Гласовни унос"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Емоџи"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Претражи"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Тачка"</string> diff --git a/java/res/values-th/strings.xml b/java/res/values-th/strings.xml index fe118bd4d..cb857075f 100644 --- a/java/res/values-th/strings.xml +++ b/java/res/values-th/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"แท็บ"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Space"</string> <string name="spoken_description_mic" msgid="615536748882611950">"การป้อนข้อมูลด้วยเสียง"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"อีโมจิ"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string> <string name="spoken_description_search" msgid="1247236163755920808">"ค้นหา"</string> <string name="spoken_description_dot" msgid="40711082435231673">"เครื่องหมายจุด"</string> diff --git a/java/res/values-tl/strings.xml b/java/res/values-tl/strings.xml index 02bc8baa1..c5621b75e 100644 --- a/java/res/values-tl/strings.xml +++ b/java/res/values-tl/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Puwang"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Input ng boses"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Bumalik"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Paghahanap"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Tuldok"</string> diff --git a/java/res/values-tr/strings.xml b/java/res/values-tr/strings.xml index ca6d66400..a5832aec9 100644 --- a/java/res/values-tr/strings.xml +++ b/java/res/values-tr/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Sekme"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Boşluk"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Ses girişi"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Emoji"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Ara"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Nokta"</string> 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-vi/strings.xml b/java/res/values-vi/strings.xml index 952444209..ed795216c 100644 --- a/java/res/values-vi/strings.xml +++ b/java/res/values-vi/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"Dấu cách"</string> <string name="spoken_description_mic" msgid="615536748882611950">"Nhập dữ liệu bằng giọng nói"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"Biểu tượng cảm xúc"</string> <string name="spoken_description_return" msgid="8178083177238315647">"Quay lại"</string> <string name="spoken_description_search" msgid="1247236163755920808">"Tìm kiếm"</string> <string name="spoken_description_dot" msgid="40711082435231673">"Dấu chấm"</string> @@ -190,7 +189,7 @@ <string name="setup_step3_action" msgid="600879797256942259">"Định cấu hình các ngôn ngữ khác"</string> <string name="setup_finish_action" msgid="276559243409465389">"Đã xong"</string> <string name="show_setup_wizard_icon" msgid="5008028590593710830">"Hiển thị biểu tượng ứng dụng"</string> - <string name="show_setup_wizard_icon_summary" msgid="4119998322536880213">"Hiển thị biểu tượng ứng dụng trong trình khởi chạy"</string> + <string name="show_setup_wizard_icon_summary" msgid="4119998322536880213">"Hiển thị biểu tượng ứng dụng trong trình chạy"</string> <string name="app_name" msgid="6320102637491234792">"Nhà cung cấp từ điển"</string> <string name="dictionary_provider_name" msgid="3027315045397363079">"Nhà cung cấp từ điển"</string> <string name="dictionary_service_name" msgid="6237472350693511448">"Dịch vụ từ điển"</string> diff --git a/java/res/values-zh-rCN/strings.xml b/java/res/values-zh-rCN/strings.xml index 603e84b76..8b605dfc4 100644 --- a/java/res/values-zh-rCN/strings.xml +++ b/java/res/values-zh-rCN/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab"</string> <string name="spoken_description_space" msgid="2582521050049860859">"空格"</string> <string name="spoken_description_mic" msgid="615536748882611950">"语音输入"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"表情符"</string> <string name="spoken_description_return" msgid="8178083177238315647">"返回"</string> <string name="spoken_description_search" msgid="1247236163755920808">"搜索"</string> <string name="spoken_description_dot" msgid="40711082435231673">"点"</string> diff --git a/java/res/values-zh-rTW/strings.xml b/java/res/values-zh-rTW/strings.xml index 2309c5c2e..412ffe978 100644 --- a/java/res/values-zh-rTW/strings.xml +++ b/java/res/values-zh-rTW/strings.xml @@ -93,8 +93,7 @@ <string name="spoken_description_tab" msgid="2667716002663482248">"Tab 鍵"</string> <string name="spoken_description_space" msgid="2582521050049860859">"空白鍵"</string> <string name="spoken_description_mic" msgid="615536748882611950">"語音輸入"</string> - <!-- no translation found for spoken_description_emoji (6934027701390427635) --> - <skip /> + <string name="spoken_description_emoji" msgid="6934027701390427635">"表情符號"</string> <string name="spoken_description_return" msgid="8178083177238315647">"返回"</string> <string name="spoken_description_search" msgid="1247236163755920808">"搜尋"</string> <string name="spoken_description_dot" msgid="40711082435231673">"點"</string> 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 37a4bf8f6..2e4a0902d 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -204,10 +204,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady()); final boolean subtypeChanged = (oldKeyboard == null) || !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale); - final boolean needsToDisplayLanguage = mSubtypeSwitcher.needsToDisplayLanguage( + final int languageOnSpacebarFormatType = mSubtypeSwitcher.getLanguageOnSpacebarFormatType( keyboard.mId.mSubtype); - keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, needsToDisplayLanguage, - RichInputMethodManager.getInstance().hasMultipleEnabledIMEsOrSubtypes(true)); + final boolean hasMultipleEnabledIMEsOrSubtypes = RichInputMethodManager.getInstance() + .hasMultipleEnabledIMEsOrSubtypes(true /* shouldIncludeAuxiliarySubtypes */); + keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, languageOnSpacebarFormatType, + hasMultipleEnabledIMEsOrSubtypes); } public Keyboard getKeyboard() { @@ -217,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) { @@ -336,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/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 03425ef1f..0f9c39a80 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -49,6 +49,7 @@ import com.android.inputmethod.keyboard.internal.GestureTrailsDrawingPreview; import com.android.inputmethod.keyboard.internal.KeyDrawParams; import com.android.inputmethod.keyboard.internal.KeyPreviewChoreographer; import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams; +import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper; import com.android.inputmethod.keyboard.internal.NonDistinctMultitouchHelper; import com.android.inputmethod.keyboard.internal.SlidingKeyInputDrawingPreview; import com.android.inputmethod.keyboard.internal.TimerHandler; @@ -123,7 +124,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack // Stuff to draw language name on spacebar. private final int mLanguageOnSpacebarFinalAlpha; private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator; - private boolean mNeedsToDisplayLanguage; + private int mLanguageOnSpacebarFormatType; private boolean mHasMultipleEnabledIMEsOrSubtypes; private int mLanguageOnSpacebarAnimAlpha = Constants.Color.ALPHA_OPAQUE; private final float mLanguageOnSpacebarTextRatio; @@ -811,14 +812,16 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack } public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged, - final boolean needsToDisplayLanguage, final boolean hasMultipleEnabledIMEsOrSubtypes) { - mNeedsToDisplayLanguage = needsToDisplayLanguage; + final int languageOnSpacebarFormatType, + final boolean hasMultipleEnabledIMEsOrSubtypes) { + mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType; mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes; final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator; if (animator == null) { - mNeedsToDisplayLanguage = false; + mLanguageOnSpacebarFormatType = LanguageOnSpacebarHelper.FORMAT_TYPE_NONE; } else { - if (subtypeChanged && needsToDisplayLanguage) { + if (subtypeChanged + && languageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) { setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE); if (animator.isStarted()) { animator.cancel(); @@ -919,9 +922,11 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype, final int width) { // Choose appropriate language name to fit into the width. - final String fullText = SpacebarLanguageUtils.getFullDisplayName(subtype); - if (fitsTextIntoWidth(width, fullText, paint)) { - return fullText; + if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) { + final String fullText = SpacebarLanguageUtils.getFullDisplayName(subtype); + if (fitsTextIntoWidth(width, fullText, paint)) { + return fullText; + } } final String middleText = SpacebarLanguageUtils.getMiddleDisplayName(subtype); @@ -937,7 +942,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack final int height = key.getHeight(); // If input language are explicitly selected. - if (mNeedsToDisplayLanguage) { + if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) { paint.setTextAlign(Align.CENTER); paint.setTypeface(Typeface.DEFAULT); paint.setTextSize(mLanguageOnSpacebarTextSize); diff --git a/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java b/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java new file mode 100644 index 000000000..6400a2440 --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java @@ -0,0 +1,68 @@ +/* + * 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.internal; + +import android.view.inputmethod.InputMethodSubtype; + +import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Collections; +import java.util.List; + +/** + * This class determines that the language name on the spacebar should be displayed in what format. + */ +public final class LanguageOnSpacebarHelper { + public static final int FORMAT_TYPE_NONE = 0; + public static final int FORMAT_TYPE_LANGUAGE_ONLY = 1; + public static final int FORMAT_TYPE_FULL_LOCALE = 2; + + private List<InputMethodSubtype> mEnabledSubtypes = Collections.emptyList(); + private boolean mIsSystemLanguageSameAsInputLanguage; + + public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) { + if (SubtypeLocaleUtils.isNoLanguage(subtype)) { + return FORMAT_TYPE_FULL_LOCALE; + } + // Only this subtype is enabled and equals to the system locale. + if (mEnabledSubtypes.size() < 2 && mIsSystemLanguageSameAsInputLanguage) { + return FORMAT_TYPE_NONE; + } + final String keyboardLanguage = SubtypeLocaleUtils.getSubtypeLocale(subtype).getLanguage(); + final String keyboardLayout = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype); + int sameLanguageAndLayoutCount = 0; + for (final InputMethodSubtype ims : mEnabledSubtypes) { + final String language = SubtypeLocaleUtils.getSubtypeLocale(ims).getLanguage(); + if (keyboardLanguage.equals(language) && keyboardLayout.equals( + SubtypeLocaleUtils.getKeyboardLayoutSetName(ims))) { + sameLanguageAndLayoutCount++; + } + } + // Display full locale name only when there are multiple subtypes that have the same + // locale and keyboard layout. Otherwise displaying language name is enough. + return sameLanguageAndLayoutCount > 1 ? FORMAT_TYPE_FULL_LOCALE + : FORMAT_TYPE_LANGUAGE_ONLY; + } + + public void updateEnabledSubtypes(final List<InputMethodSubtype> enabledSubtypes) { + mEnabledSubtypes = enabledSubtypes; + } + + public void updateIsSystemLanguageSameAsInputLanguage(final boolean isSame) { + mIsSystemLanguageSameAsInputLanguage = isSame; + } +} diff --git a/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java b/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java deleted file mode 100644 index e548de589..000000000 --- a/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.internal; - -import android.view.inputmethod.InputMethodSubtype; - -import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; - -/** - * This class determines that the language name on the spacebar should be displayed or not. - */ -public final class NeedsToDisplayLanguage { - private int mEnabledSubtypeCount; - private boolean mIsSystemLanguageSameAsInputLanguage; - - public boolean needsToDisplayLanguage(final InputMethodSubtype subtype) { - if (SubtypeLocaleUtils.isNoLanguage(subtype)) { - return true; - } - return mEnabledSubtypeCount >= 2 || !mIsSystemLanguageSameAsInputLanguage; - } - - public void updateEnabledSubtypeCount(final int count) { - mEnabledSubtypeCount = count; - } - - public void updateIsSystemLanguageSameAsInputLanguage(final boolean isSame) { - mIsSystemLanguageSameAsInputLanguage = isSame; - } -} 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 ae2d7c9c6..7cb218fbe 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -54,6 +53,15 @@ public class DictionaryFacilitatorForSuggest { // To synchronize assigning mDictionaries to ensure closing dictionaries. private Object mLock = new Object(); + private static final String[] dictTypesOrderedToGetSuggestion = + new String[] { + Dictionary.TYPE_MAIN, + Dictionary.TYPE_USER_HISTORY, + Dictionary.TYPE_PERSONALIZATION, + Dictionary.TYPE_USER, + Dictionary.TYPE_CONTACTS + }; + /** * Class contains dictionaries for a locale. */ @@ -453,11 +461,14 @@ public class DictionaryFacilitatorForSuggest { final Map<String, Dictionary> dictMap = dictionaries.mDictMap; final SuggestionResults suggestionResults = new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS); - for (final Dictionary dictionary : dictMap.values()) { + 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 53e6232b6..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; @@ -156,7 +157,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private static final int MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP = 3; private static final int MSG_RESUME_SUGGESTIONS = 4; private static final int MSG_REOPEN_DICTIONARIES = 5; - private static final int MSG_ON_END_BATCH_INPUT = 6; + private static final int MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED = 6; private static final int MSG_RESET_CACHES = 7; // Update this when adding new messages private static final int MSG_LAST = MSG_RESET_CACHES; @@ -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) { @@ -220,8 +221,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // get any suggestions. Wait one frame. postUpdateSuggestionStrip(); break; - case MSG_ON_END_BATCH_INPUT: - latinIme.mInputLogic.endBatchInputInternal(latinIme.mSettings.getCurrent(), + case MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED: + latinIme.mInputLogic.onUpdateTailBatchInputCompleted( + latinIme.mSettings.getCurrent(), (SuggestedWords) msg.obj, latinIme.mKeyboardSwitcher); break; case MSG_RESET_CACHES: @@ -304,8 +306,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ARG1_NOT_GESTURE_INPUT, ARG2_UNUSED, suggestedWords).sendToTarget(); } - public void onEndBatchInput(final SuggestedWords suggestedWords) { - obtainMessage(MSG_ON_END_BATCH_INPUT, suggestedWords).sendToTarget(); + public void showTailBatchInputResult(final SuggestedWords suggestedWords) { + obtainMessage(MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED, suggestedWords).sendToTarget(); } // Working variables for the following methods. @@ -832,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. @@ -911,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(); @@ -1230,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 @@ -1255,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 @@ -1499,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 } @@ -1539,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); } @@ -1661,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/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index d4301229c..021133945 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -34,7 +34,7 @@ import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils; import com.android.inputmethod.keyboard.KeyboardSwitcher; -import com.android.inputmethod.keyboard.internal.NeedsToDisplayLanguage; +import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper; import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; @@ -54,7 +54,8 @@ public final class SubtypeSwitcher { private /* final */ Resources mResources; private /* final */ ConnectivityManager mConnectivityManager; - private final NeedsToDisplayLanguage mNeedsToDisplayLanguage = new NeedsToDisplayLanguage(); + private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper = + new LanguageOnSpacebarHelper(); private InputMethodInfo mShortcutInputMethodInfo; private InputMethodSubtype mShortcutSubtype; private InputMethodSubtype mNoLanguageSubtype; @@ -127,7 +128,7 @@ public final class SubtypeSwitcher { public void updateParametersOnStartInputView() { final List<InputMethodSubtype> enabledSubtypesOfThisIme = mRichImm.getMyEnabledInputMethodSubtypeList(true); - mNeedsToDisplayLanguage.updateEnabledSubtypeCount(enabledSubtypesOfThisIme.size()); + mLanguageOnSpacebarHelper.updateEnabledSubtypes(enabledSubtypesOfThisIme); updateShortcutIME(); } @@ -176,7 +177,7 @@ public final class SubtypeSwitcher { final boolean sameLanguage = systemLocale.getLanguage().equals(newLocale.getLanguage()); final boolean implicitlyEnabled = mRichImm.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype); - mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage( + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage( sameLocale || (sameLanguage && implicitlyEnabled)); updateShortcutIME(); @@ -249,8 +250,8 @@ public final class SubtypeSwitcher { // Subtype Switching functions // ////////////////////////////////// - public boolean needsToDisplayLanguage(final InputMethodSubtype subtype) { - return mNeedsToDisplayLanguage.needsToDisplayLanguage(subtype); + public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) { + return mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype); } public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() { 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/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 ec6bd289a..7ffc95697 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -210,22 +210,12 @@ 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 InputTransaction completeTransaction = onCodeInput(settingsValues, event, - keyboardShiftState, handler); + final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, false /* isBatchMode */, suggestedWords.mIsPrediction); } - return completeTransaction; + return onCodeInput(settingsValues, event, keyboardShiftState, handler); } final Event event = Event.createSuggestionPickedEvent(suggestionInfo); @@ -547,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(); @@ -589,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]); @@ -601,7 +591,7 @@ public final class InputLogic { } public void onEndBatchInput(final InputPointers batchPointers) { - mInputLogicHandler.onEndBatchInput(batchPointers, mAutoCommitSequenceNumber); + mInputLogicHandler.updateTailBatchInput(batchPointers, mAutoCommitSequenceNumber); ++mAutoCommitSequenceNumber; } @@ -833,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); @@ -1794,7 +1782,7 @@ public final class InputLogic { * @param settingsValues the current values of the settings. * @param suggestedWords suggestedWords to use. */ - public void endBatchInputInternal(final SettingsValues settingsValues, + public void onUpdateTailBatchInputCompleted(final SettingsValues settingsValues, final SuggestedWords suggestedWords, // TODO: remove this argument final KeyboardSwitcher keyboardSwitcher) { @@ -1831,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/inputlogic/InputLogicHandler.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java index 42f0d7c00..e3b8ab465 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java @@ -54,7 +54,8 @@ class InputLogicHandler implements Handler.Callback { @Override public void onCancelBatchInput() {} @Override - public void onEndBatchInput(final InputPointers batchPointers, final int sequenceNumber) {} + public void updateTailBatchInput(final InputPointers batchPointers, + final int sequenceNumber) {} @Override public void getSuggestedWords(final int sessionId, final int sequenceNumber, final OnGetSuggestedWordsCallback callback) {} @@ -106,7 +107,7 @@ class InputLogicHandler implements Handler.Callback { * Fetch suggestions corresponding to an update of a batch input. * @param batchPointers the updated pointers, including the part that was passed last time. * @param sequenceNumber the sequence number associated with this batch input. - * @param forEnd true if this is the end of a batch input, false if it's an update. + * @param isTailBatchInput true if this is the end of a batch input, false if it's an update. */ // This method can be called from any thread and will see to it that the correct threads // are used for parts that require it. This method will send a message to the Non-UI handler @@ -115,7 +116,7 @@ class InputLogicHandler implements Handler.Callback { // send a message to the UI handler in LatinIME so that showing suggestions can be done on // the UI thread. private void updateBatchInput(final InputPointers batchPointers, - final int sequenceNumber, final boolean forEnd) { + final int sequenceNumber, final boolean isTailBatchInput) { synchronized (mLock) { if (!mInBatchInput) { // Batch input has ended or canceled while the message was being delivered. @@ -136,12 +137,12 @@ class InputLogicHandler implements Handler.Callback { suggestedWords = mInputLogic.mSuggestedWords; } mLatinIME.mHandler.showGesturePreviewAndSuggestionStrip(suggestedWords, - forEnd /* dismissGestureFloatingPreviewText */); - if (forEnd) { + isTailBatchInput /* dismissGestureFloatingPreviewText */); + if (isTailBatchInput) { mInBatchInput = false; // The following call schedules onEndBatchInputInternal // to be called on the UI thread. - mLatinIME.mHandler.onEndBatchInput(suggestedWords); + mLatinIME.mHandler.showTailBatchInputResult(suggestedWords); } } }); @@ -159,13 +160,13 @@ class InputLogicHandler implements Handler.Callback { // Called on the UI thread by InputLogic. public void onUpdateBatchInput(final InputPointers batchPointers, final int sequenceNumber) { - updateBatchInput(batchPointers, sequenceNumber, false /* forEnd */); + updateBatchInput(batchPointers, sequenceNumber, false /* isTailBatchInput */); } /** * Cancel a batch input. * - * Note that as opposed to onEndBatchInput, we do the UI side of this immediately on the + * Note that as opposed to updateTailBatchInput, we do the UI side of this immediately on the * same thread, rather than get this to call a method in LatinIME. This is because * canceling a batch input does not necessitate the long operation of pulling suggestions. */ @@ -177,17 +178,20 @@ class InputLogicHandler implements Handler.Callback { } /** - * Finish a batch input. + * Trigger an update for a tail batch input. * - * This fetches suggestions, updates the suggestion strip and commits the first suggestion. - * It also dismisses the floating text preview. + * A tail batch input is the last update for a gesture, the one that is triggered after the + * user lifts their finger. This method schedules fetching suggestions on the non-UI thread, + * then when the suggestions are computed it comes back on the UI thread to update the + * suggestion strip, commit the first suggestion, and dismiss the floating text preview. * * @param batchPointers the updated batch pointers. * @param sequenceNumber the sequence number associated with this batch input. */ // Called on the UI thread by InputLogic. - public void onEndBatchInput(final InputPointers batchPointers, final int sequenceNumber) { - updateBatchInput(batchPointers, sequenceNumber, true /* forEnd */); + public void updateTailBatchInput(final InputPointers batchPointers, + final int sequenceNumber) { + updateBatchInput(batchPointers, sequenceNumber, true /* isTailBatchInput */); } public void getSuggestedWords(final int sessionId, final int sequenceNumber, 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/Android.mk b/native/jni/Android.mk index c1372bd70..5c117cea9 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -87,6 +87,8 @@ LOCAL_NDK_STL_VARIANT := c++_static LOCAL_LDFLAGS += -ldl include $(BUILD_SHARED_LIBRARY) - #################### Clean up the tmp vars include $(LOCAL_PATH)/CleanupNativeFileList.mk + +#################### Unit test on host environment +include $(LOCAL_PATH)/HostUnitTests.mk diff --git a/native/jni/CleanupNativeFileList.mk b/native/jni/CleanupNativeFileList.mk index 5420f16f9..1738f8c58 100644 --- a/native/jni/CleanupNativeFileList.mk +++ b/native/jni/CleanupNativeFileList.mk @@ -13,5 +13,6 @@ # limitations under the License. LATIN_IME_CORE_SRC_FILES := +LATIN_IME_CORE_TEST_FILES := LATIN_IME_JNI_SRC_FILES := LATIN_IME_SRC_DIR := diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk new file mode 100644 index 000000000..572d36564 --- /dev/null +++ b/native/jni/HostUnitTests.mk @@ -0,0 +1,56 @@ +# 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. + +# 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) + +###################################### +include $(CLEAR_VARS) + +include $(LOCAL_PATH)/NativeFileList.mk + +#################### Host library for unit test +# TODO: Remove -std=c++11 once it is set by default on host build. +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_MODULE := liblatinime_host_static_for_unittests +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES)) +include $(BUILD_HOST_STATIC_LIBRARY) + +#################### Host native tests +include $(CLEAR_VARS) +LATIN_IME_TEST_SRC_DIR := tests +# TODO: Remove -std=c++11 once it is set by default on host build. +LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function +LOCAL_CLANG := true +LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR) +LOCAL_MODULE := liblatinime_host_unittests +LOCAL_MODULE_TAGS := tests +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/NativeFileList.mk b/native/jni/NativeFileList.mk index 2ee4caa42..3da9d5632 100644 --- a/native/jni/NativeFileList.mk +++ b/native/jni/NativeFileList.mk @@ -99,3 +99,6 @@ LATIN_IME_CORE_SRC_FILES := \ char_utils.cpp \ log_utils.cpp \ time_keeper.cpp) + +LATIN_IME_CORE_TEST_FILES := \ + utils/autocorrection_threshold_utils_test.cpp 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/run-tests.sh b/native/jni/run-tests.sh new file mode 100755 index 000000000..5b60e0d65 --- /dev/null +++ b/native/jni/run-tests.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# 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. + +if [[ $(type -t mmm) != function ]]; then +echo "Usage:" 1>&2 +echo " source $0" 1>&2 +echo " or" 1>&2 +echo " . $0" 1>&2 +if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi +fi + +pushd $PWD > /dev/null +cd $(gettop) +mmm -j16 packages/inputmethods/LatinIME/native/jni || \ + make -j16 liblatinime_host_unittests +${ANDROID_HOST_OUT}/bin/liblatinime_host_unittests +popd > /dev/null
\ No newline at end of file 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/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp index c4c57169b..fa9600c74 100644 --- a/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp +++ b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp @@ -52,8 +52,8 @@ const float ScoringParams::SUBSTITUTION_COST = 0.3806f; const float ScoringParams::COST_NEW_WORD = 0.0314f; const float ScoringParams::COST_SECOND_OR_LATER_WORD_FIRST_CHAR_UPPERCASE = 0.3224f; const float ScoringParams::DISTANCE_WEIGHT_LANGUAGE = 1.1214f; -const float ScoringParams::COST_FIRST_LOOKAHEAD = 0.4836f; -const float ScoringParams::COST_LOOKAHEAD = 0.00624f; +const float ScoringParams::COST_FIRST_COMPLETION = 0.4836f; +const float ScoringParams::COST_COMPLETION = 0.00624f; const float ScoringParams::HAS_PROXIMITY_TERMINAL_COST = 0.0683f; const float ScoringParams::HAS_EDIT_CORRECTION_TERMINAL_COST = 0.0362f; const float ScoringParams::HAS_MULTI_WORD_TERMINAL_COST = 0.4182f; diff --git a/native/jni/src/suggest/policyimpl/typing/scoring_params.h b/native/jni/src/suggest/policyimpl/typing/scoring_params.h index de7410d39..b66962019 100644 --- a/native/jni/src/suggest/policyimpl/typing/scoring_params.h +++ b/native/jni/src/suggest/policyimpl/typing/scoring_params.h @@ -59,8 +59,8 @@ class ScoringParams { static const float COST_NEW_WORD; static const float COST_SECOND_OR_LATER_WORD_FIRST_CHAR_UPPERCASE; static const float DISTANCE_WEIGHT_LANGUAGE; - static const float COST_FIRST_LOOKAHEAD; - static const float COST_LOOKAHEAD; + static const float COST_FIRST_COMPLETION; + static const float COST_COMPLETION; static const float HAS_PROXIMITY_TERMINAL_COST; static const float HAS_EDIT_CORRECTION_TERMINAL_COST; static const float HAS_MULTI_WORD_TERMINAL_COST; diff --git a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h index b36605af9..0ba439b47 100644 --- a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h +++ b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h @@ -166,8 +166,8 @@ class TypingWeighting : public Weighting { const bool firstCompletion = dicNode->getInputIndex(0) == traverseSession->getInputSize(); // TODO: Change the cost for the first completion for the gesture? - const float cost = firstCompletion ? ScoringParams::COST_FIRST_LOOKAHEAD - : ScoringParams::COST_LOOKAHEAD; + const float cost = firstCompletion ? ScoringParams::COST_FIRST_COMPLETION + : ScoringParams::COST_COMPLETION; return cost; } diff --git a/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp b/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp new file mode 100644 index 000000000..cc8db700f --- /dev/null +++ b/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp @@ -0,0 +1,39 @@ +/* + * 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. + */ + +#include "utils/autocorrection_threshold_utils.h" + +#include <gtest/gtest.h> + +#include <vector> + +namespace latinime { +namespace { + +int CalcEditDistance(const std::vector<int> &before, + const std::vector<int> &after) { + return AutocorrectionThresholdUtils::editDistance( + &before[0], before.size(), &after[0], after.size()); +} + +TEST(AutocorrectionThresholdUtilsTest, SameData) { + EXPECT_EQ(0, CalcEditDistance({1}, {1})); + EXPECT_EQ(0, CalcEditDistance({2, 2}, {2, 2})); + EXPECT_EQ(0, CalcEditDistance({3, 3, 3}, {3, 3, 3})); +} + +} // namespace +} // namespace latinime 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/internal/LanguageOnSpacebarHelperTests.java b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java new file mode 100644 index 000000000..0be1e374c --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java @@ -0,0 +1,167 @@ +/* + * 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.internal; + +import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE; +import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_LANGUAGE_ONLY; +import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_NONE; + +import android.content.Context; +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import android.view.inputmethod.InputMethodSubtype; + +import com.android.inputmethod.latin.RichInputMethodManager; +import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; +import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +@SmallTest +public class LanguageOnSpacebarHelperTests extends AndroidTestCase { + private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper = + new LanguageOnSpacebarHelper(); + + private RichInputMethodManager mRichImm; + + InputMethodSubtype EN_US_QWERTY; + InputMethodSubtype EN_GB_QWERTY; + InputMethodSubtype FR_AZERTY; + InputMethodSubtype FR_CA_QWERTY; + InputMethodSubtype FR_CH_SWISS; + InputMethodSubtype FR_CH_QWERTY; + InputMethodSubtype FR_CH_QWERTZ; + InputMethodSubtype ZZ_QWERTY; + + @Override + protected void setUp() throws Exception { + super.setUp(); + final Context context = getContext(); + RichInputMethodManager.init(context); + mRichImm = RichInputMethodManager.getInstance(); + SubtypeLocaleUtils.init(context); + + EN_US_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.US.toString(), "qwerty"); + EN_GB_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.UK.toString(), "qwerty"); + FR_AZERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.FRENCH.toString(), "azerty"); + FR_CA_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.CANADA_FRENCH.toString(), "qwerty"); + FR_CH_SWISS = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + "fr_CH", "swiss"); + FR_CH_QWERTZ = AdditionalSubtypeUtils.createAdditionalSubtype( + "fr_CH", "qwertz", null); + FR_CH_QWERTY = AdditionalSubtypeUtils.createAdditionalSubtype( + "fr_CH", "qwerty", null); + ZZ_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"); + } + + private static List<InputMethodSubtype> asList(final InputMethodSubtype ... subtypes) { + return Arrays.asList(subtypes); + } + + public void testOneSubtype() { + mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY)); + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); + assertEquals("one same English (US)", FORMAT_TYPE_NONE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("one same NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + + mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY)); + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); + assertEquals("one diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("one diff NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + } + + public void testTwoSubtypes() { + mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY, FR_AZERTY)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); + assertEquals("two same English (US)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("two same French)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY)); + assertEquals("two same NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); + assertEquals("two diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("two diff French", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY)); + assertEquals("two diff NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + } + + public void testSameLanuageSubtypes() { + mLanguageOnSpacebarHelper.updateEnabledSubtypes( + asList(EN_US_QWERTY, EN_GB_QWERTY, FR_AZERTY, ZZ_QWERTY)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); + assertEquals("two same English (US)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("two same English (UK)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_GB_QWERTY)); + assertEquals("two same NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); + assertEquals("two diff English (US)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); + assertEquals("two diff English (UK)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_GB_QWERTY)); + assertEquals("two diff NoLanguage", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); + } + + public void testMultiSameLanuageSubtypes() { + mLanguageOnSpacebarHelper.updateEnabledSubtypes( + asList(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); + assertEquals("multi same French", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY)); + assertEquals("multi same French (CA)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CA_QWERTY)); + assertEquals("multi same French (CH)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_SWISS)); + assertEquals("multi same French (CH) (QWERTY)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTY)); + assertEquals("multi same French (CH) (QWERTZ)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTZ)); + + mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); + assertEquals("multi diff French", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY)); + assertEquals("multi diff French (CA)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CA_QWERTY)); + assertEquals("multi diff French (CH)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_SWISS)); + assertEquals("multi diff French (CH) (QWERTY)", FORMAT_TYPE_FULL_LOCALE, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTY)); + assertEquals("multi diff French (CH) (QWERTZ)", FORMAT_TYPE_LANGUAGE_ONLY, + mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTZ)); + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java b/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java deleted file mode 100644 index e03bce1e0..000000000 --- a/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.internal; - -import android.content.Context; -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; -import android.view.inputmethod.InputMethodSubtype; - -import com.android.inputmethod.latin.RichInputMethodManager; -import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; - -import java.util.Locale; - -@SmallTest -public class NeedsToDisplayLanguageTests extends AndroidTestCase { - private final NeedsToDisplayLanguage mNeedsToDisplayLanguage = new NeedsToDisplayLanguage(); - - private RichInputMethodManager mRichImm; - - InputMethodSubtype EN_US; - InputMethodSubtype FR; - InputMethodSubtype ZZ; - - @Override - protected void setUp() throws Exception { - super.setUp(); - final Context context = getContext(); - RichInputMethodManager.init(context); - mRichImm = RichInputMethodManager.getInstance(); - SubtypeLocaleUtils.init(context); - - EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.US.toString(), "qwerty"); - FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.FRENCH.toString(), "azerty"); - ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"); - } - - public void testOneSubtype() { - mNeedsToDisplayLanguage.updateEnabledSubtypeCount(1); - - mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); - assertFalse("one same English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US)); - assertTrue("one same NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ)); - - mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); - assertTrue("one diff English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US)); - assertTrue("one diff NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ)); - } - - public void testTwoSubtype() { - mNeedsToDisplayLanguage.updateEnabledSubtypeCount(2); - - mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); - assertTrue("two same English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US)); - assertTrue("two same French", mNeedsToDisplayLanguage.needsToDisplayLanguage(FR)); - assertTrue("two same NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ)); - - mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); - assertTrue("two diff English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US)); - assertTrue("two diff French", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ)); - assertTrue("two diff NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(FR)); - } -} 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" "$@" diff --git a/tools/dicttool/tests/etc/test-dicttool.sh b/tools/dicttool/tests/etc/test-dicttool.sh index 5eb44fc85..f96db6816 100755 --- a/tools/dicttool/tests/etc/test-dicttool.sh +++ b/tools/dicttool/tests/etc/test-dicttool.sh @@ -18,7 +18,7 @@ echo "Usage:" 1>&2 echo " source $0" 1>&2 echo " or" 1>&2 echo " . $0" 1>&2 -exit 1 +if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi fi find out -name "dicttool_aosp*" -exec rm -rf {} \; > /dev/null 2>&1 |