diff options
80 files changed, 1066 insertions, 604 deletions
diff --git a/common/src/com/android/inputmethod/latin/common/LocaleUtils.java b/common/src/com/android/inputmethod/latin/common/LocaleUtils.java index 7f2333be5..d5878c024 100644 --- a/common/src/com/android/inputmethod/latin/common/LocaleUtils.java +++ b/common/src/com/android/inputmethod/latin/common/LocaleUtils.java @@ -104,7 +104,8 @@ public final class LocaleUtils { * @param testedLocale the locale to test. * @return a constant that measures how well the tested locale matches the reference locale. */ - public static int getMatchLevel(final String referenceLocale, final String testedLocale) { + public static int getMatchLevel(@Nullable final String referenceLocale, + @Nullable final String testedLocale) { if (StringUtils.isEmpty(referenceLocale)) { return StringUtils.isEmpty(testedLocale) ? LOCALE_FULL_MATCH : LOCALE_ANY_MATCH; } @@ -167,11 +168,8 @@ public final class LocaleUtils { * @param localeString a string specification of a locale, in a format of "ll_cc_variant" where * "ll" is a language code, "cc" is a country code. */ - @Nullable - public static Locale constructLocaleFromString(@Nullable final String localeString) { - if (localeString == null) { - return null; - } + @Nonnull + public static Locale constructLocaleFromString(@Nonnull final String localeString) { synchronized (sLocaleCache) { if (sLocaleCache.containsKey(localeString)) { return sLocaleCache.get(localeString); diff --git a/java/res/layout/additional_subtype_dialog.xml b/java/res/layout/additional_subtype_dialog.xml index b7804f5df..2de7d07a8 100644 --- a/java/res/layout/additional_subtype_dialog.xml +++ b/java/res/layout/additional_subtype_dialog.xml @@ -38,7 +38,6 @@ android:text="@string/subtype_locale" /> <Spinner android:id="@+id/subtype_locale_spinner" - android:spinnerMode="dialog" android:layout_width="0dp" android:layout_weight="70" android:layout_height="wrap_content" @@ -47,7 +46,8 @@ android:layout_marginTop="8dip" android:layout_gravity="fill_horizontal|center_vertical" android:gravity="start|left" - android:prompt="@string/subtype_locale" /> + android:prompt="@string/subtype_locale" + style="@style/additionalSubtypeSpinnerStyle" /> </LinearLayout> <LinearLayout android:orientation="horizontal" @@ -63,7 +63,6 @@ android:text="@string/keyboard_layout_set" /> <Spinner android:id="@+id/keyboard_layout_set_spinner" - android:spinnerMode="dialog" android:layout_width="0dp" android:layout_weight="70" android:layout_height="wrap_content" @@ -72,6 +71,7 @@ android:layout_marginTop="8dip" android:layout_gravity="fill_horizontal|center_vertical" android:gravity="start|left" - android:prompt="@string/keyboard_layout_set" /> + android:prompt="@string/keyboard_layout_set" + style="@style/additionalSubtypeSpinnerStyle" /> </LinearLayout> </LinearLayout> diff --git a/java/res/values-eu-rES/strings-emoji-descriptions.xml b/java/res/values-eu-rES/strings-emoji-descriptions.xml index c774ae1b8..50c692423 100644 --- a/java/res/values-eu-rES/strings-emoji-descriptions.xml +++ b/java/res/values-eu-rES/strings-emoji-descriptions.xml @@ -288,7 +288,7 @@ <string name="spoken_emoji_1F382" msgid="4720497171946687501">"Urtebetetze-pastela"</string> <string name="spoken_emoji_1F383" msgid="3536505941578757623">"Halloween-eko kuia-lanpara"</string> <string name="spoken_emoji_1F384" msgid="1797870204479059004">"Gabonetako zuhaitza"</string> - <string name="spoken_emoji_1F385" msgid="1754174063483626367">"Aita Noel"</string> + <string name="spoken_emoji_1F385" msgid="1754174063483626367">"Bizarzuri"</string> <string name="spoken_emoji_1F386" msgid="2130445450758114746">"Su artifizialak"</string> <string name="spoken_emoji_1F387" msgid="3403182563117999933">"Bengala"</string> <string name="spoken_emoji_1F388" msgid="2903047203723251804">"Puxika"</string> diff --git a/java/res/values-km-rKH/strings-emoji-descriptions.xml b/java/res/values-km-rKH/strings-emoji-descriptions.xml index e9b8780a5..aca04fc4d 100644 --- a/java/res/values-km-rKH/strings-emoji-descriptions.xml +++ b/java/res/values-km-rKH/strings-emoji-descriptions.xml @@ -25,16 +25,16 @@ <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="spoken_emoji_00A9" msgid="2859822817116803638">"សញ្ញារក្សាសិទ្ធ"</string> + <string name="spoken_emoji_00A9" msgid="2859822817116803638">"សញ្ញារក្សាសិទ្ធ"</string> <string name="spoken_emoji_00AE" msgid="7708335454134589027">"សញ្ញាចុះបញ្ជី"</string> <string name="spoken_emoji_203C" msgid="153340916701508663">"សញ្ញាឧទានពីរ"</string> - <string name="spoken_emoji_2049" msgid="4877256448299555371">"សញ្ញាឧទានសញ្ញាសួរ"</string> + <string name="spoken_emoji_2049" msgid="4877256448299555371">"សញ្ញាឧទានសញ្ញាសួរ"</string> <string name="spoken_emoji_2122" msgid="9188440722954720429">"សញ្ញានិក្ខិត្តសញ្ញា"</string> <string name="spoken_emoji_2139" msgid="9114342638917304327">"ប្រភពព័ត៌មាន"</string> <string name="spoken_emoji_2194" msgid="8055202727034946680">"ព្រួញឆ្វេងស្ដាំ"</string> <string name="spoken_emoji_2195" msgid="8028122253301087407">"ព្រួញឡើងលើចុះក្រោម"</string> <string name="spoken_emoji_2196" msgid="4019164898967854363">"ព្រួញទិសពាយព្យ"</string> - <string name="spoken_emoji_2197" msgid="4255723717709017801">"ព្រួញទិសឥសាន្តឦសាន្ត"</string> + <string name="spoken_emoji_2197" msgid="4255723717709017801">"ព្រួញទិសឥសាន្តឦសាន្ត"</string> <string name="spoken_emoji_2198" msgid="1452063451313622090">"ព្រួញទិសអាគ្នេយ៍"</string> <string name="spoken_emoji_2199" msgid="6942722693368807849">"ព្រួញទិសនិរតី"</string> <string name="spoken_emoji_21A9" msgid="5204750172335111188">"ព្រួញទៅឆ្វេងមានទំពក់"</string> @@ -45,7 +45,7 @@ <string name="spoken_emoji_23EA" msgid="2251396938087774944">"ត្រីកោណខ្មៅពីរចង្អុលទៅឆ្វេង"</string> <string name="spoken_emoji_23EB" msgid="3746885195641491865">"ត្រីកោណខ្មៅពីរចង្អុលឡើងលើ"</string> <string name="spoken_emoji_23EC" msgid="7852372752901163416">"ត្រីកោណខ្មៅពីរចង្អុលចុះក្រោម"</string> - <string name="spoken_emoji_23F0" msgid="8474219588750627870">"នាឡិការោទ៍"</string> + <string name="spoken_emoji_23F0" msgid="8474219588750627870">"នាឡិការោទ៍"</string> <string name="spoken_emoji_23F3" msgid="166900119581024371">"កែវពិសោធន៍មានខ្សាច់ហូរ"</string> <string name="spoken_emoji_24C2" msgid="3948348737566038470">"អក្សរអឹមធំក្នុងរង្វង់"</string> <string name="spoken_emoji_25AA" msgid="7865181015100227349">"ការ៉េតូចពណ៌ខ្មៅ"</string> @@ -195,7 +195,7 @@ <string name="spoken_emoji_1F312" msgid="4458575672576125401">"ព្រះចន្ទមួយចំណិតស្ដាំ"</string> <string name="spoken_emoji_1F313" msgid="7599181787989497294">"ព្រះចន្ទពាក់កណ្ដាល"</string> <string name="spoken_emoji_1F314" msgid="4898293184964365413">"ព្រះចន្ទមួយចំណិតឆ្វេង"</string> - <string name="spoken_emoji_1F315" msgid="3218117051779496309">"ព្រះចន្ទពេញវង់"</string> + <string name="spoken_emoji_1F315" msgid="3218117051779496309">"ព្រះចន្ទពេញវង់"</string> <string name="spoken_emoji_1F316" msgid="2061317145777689569">"ព្រះចន្ទភ្លឺមួយចំហៀង"</string> <string name="spoken_emoji_1F317" msgid="2721090687319539049">"ព្រះចន្ទភ្លឺពាក់កណ្ដាល"</string> <string name="spoken_emoji_1F318" msgid="3814091755648887570">"ព្រះចន្ទភ្លឺមួយចំណិតឆ្វេង"</string> @@ -262,7 +262,7 @@ <string name="spoken_emoji_1F365" msgid="4963815540953316307">"នំត្រីរាងមូល"</string> <string name="spoken_emoji_1F366" msgid="7862401745277049404">"ការ៉េមបំពង់"</string> <string name="spoken_emoji_1F367" msgid="7447972978281980414">"ការ៉េមកែវ"</string> - <string name="spoken_emoji_1F368" msgid="7790003146142724913">"ការ៉េម"</string> + <string name="spoken_emoji_1F368" msgid="7790003146142724913">"ការ៉េម"</string> <string name="spoken_emoji_1F369" msgid="7383712944084857350">"ដូណាត់"</string> <string name="spoken_emoji_1F36A" msgid="2726271795913042295">"ខូគី"</string> <string name="spoken_emoji_1F36B" msgid="6342163604299875931">"សូកូឡា"</string> @@ -280,7 +280,7 @@ <string name="spoken_emoji_1F377" msgid="1762398562314172075">"កែវស្រា"</string> <string name="spoken_emoji_1F378" msgid="5528234560590117516">"កែវស្រាក្រឡុក"</string> <string name="spoken_emoji_1F379" msgid="790581290787943325">"ភេសជ្ជៈត្រូពិក"</string> - <string name="spoken_emoji_1F37A" msgid="391966822450619516">"កែវស្រាបៀ"</string> + <string name="spoken_emoji_1F37A" msgid="391966822450619516">"កែវស្រាបៀ"</string> <string name="spoken_emoji_1F37B" msgid="9015043286465670662">"ជល់កែវស្រាបៀ"</string> <string name="spoken_emoji_1F37C" msgid="2532113819464508894">"ដបទឹកដោះគោ"</string> <string name="spoken_emoji_1F380" msgid="3487363857092458827">"ខ្សែបូ"</string> @@ -313,7 +313,7 @@ <string name="spoken_emoji_1F3A7" msgid="837856608794094105">"កាស"</string> <string name="spoken_emoji_1F3A8" msgid="2332260356509244587">"ក្ដារលាយពណ៌វិចិត្រករ"</string> <string name="spoken_emoji_1F3A9" msgid="9045869366525115256">"មួកសម្ដែងសិល្បៈ"</string> - <string name="spoken_emoji_1F3AA" msgid="5728760354237132">"តង់សៀក"</string> + <string name="spoken_emoji_1F3AA" msgid="5728760354237132">"តង់សៀក"</string> <string name="spoken_emoji_1F3AB" msgid="1657997517193216284">"សំបុត្រ"</string> <string name="spoken_emoji_1F3AC" msgid="4317366554314492152">"បន្ទះកណ្ដឹង"</string> <string name="spoken_emoji_1F3AD" msgid="607157286336130470">"សម្ដែងសិល្បៈ"</string> @@ -334,10 +334,10 @@ <string name="spoken_emoji_1F3BC" msgid="1608424748821446230">"និមិត្តសញ្ញាតន្ត្រី"</string> <string name="spoken_emoji_1F3BD" msgid="5490786111375627777">"អាវកីឡាមានខ្សែឆៀង"</string> <string name="spoken_emoji_1F3BE" msgid="1851613105691627931">"រ៉ាកែត និងបាល់"</string> - <string name="spoken_emoji_1F3BF" msgid="6862405997423247921">"ជិះស្គី និងក្ដារស្គី"</string> + <string name="spoken_emoji_1F3BF" msgid="6862405997423247921">"ជិះស្គី និងក្ដារស្គី"</string> <string name="spoken_emoji_1F3C0" msgid="7421420756115104085">"បាល់បោះ និងវណ្ណមូល"</string> <string name="spoken_emoji_1F3C1" msgid="6926537251677319922">"ទង់ជាតិប្រណាំងម៉ូតូ"</string> - <string name="spoken_emoji_1F3C2" msgid="5708596929237987082">"អ្នកជិះក្ដាររំអិលលើព្រិល"</string> + <string name="spoken_emoji_1F3C2" msgid="5708596929237987082">"អ្នកជិះក្ដាររំអិលលើព្រិល"</string> <string name="spoken_emoji_1F3C3" msgid="5850982999510115824">"អ្នករត់"</string> <string name="spoken_emoji_1F3C4" msgid="8468355585994639838">"អ្នកជិះទូករអិលលើទឹក"</string> <string name="spoken_emoji_1F3C6" msgid="9094474706847545409">"ពានរង្វាន់"</string> @@ -354,7 +354,7 @@ <string name="spoken_emoji_1F3E6" msgid="342132788513806214">"ធនាគារ"</string> <string name="spoken_emoji_1F3E7" msgid="6322352038284944265">"ម៉ាស៊ីនអេធីអឹម"</string> <string name="spoken_emoji_1F3E8" msgid="5864918444350599907">"សណ្ឋាគារ"</string> - <string name="spoken_emoji_1F3E9" msgid="7830416185375326938">"សណ្ឋាគារក្ដីស្រឡាញ់"</string> + <string name="spoken_emoji_1F3E9" msgid="7830416185375326938">"សណ្ឋាគារក្ដីស្រឡាញ់"</string> <string name="spoken_emoji_1F3EA" msgid="5081084413084360479">"ហាងទំនិញ ២៤ម៉ោង"</string> <string name="spoken_emoji_1F3EB" msgid="7010966528205150525">"សាលារៀន"</string> <string name="spoken_emoji_1F3EC" msgid="4845978861878295154">"ហាងទំនិញធំៗ"</string> @@ -439,12 +439,12 @@ <string name="spoken_emoji_1F44D" msgid="6182553970602667815">"មេដៃឡើងលើ"</string> <string name="spoken_emoji_1F44E" msgid="8030851867365111809">"មេដៃចុះក្រោម"</string> <string name="spoken_emoji_1F44F" msgid="5148753662268213389">"ទះដៃ"</string> - <string name="spoken_emoji_1F450" msgid="1012021072085157054">"លាដៃ"</string> + <string name="spoken_emoji_1F450" msgid="1012021072085157054">"លាដៃ"</string> <string name="spoken_emoji_1F451" msgid="8257466714629051320">"មកុដ"</string> <string name="spoken_emoji_1F452" msgid="4567394011149905466">"មួកស្ត្រី"</string> <string name="spoken_emoji_1F453" msgid="5978410551173163010">"វ៉ែនតា"</string> - <string name="spoken_emoji_1F454" msgid="348469036193323252">"ក្រវ៉ាត់ករ"</string> - <string name="spoken_emoji_1F455" msgid="5665118831861433578">"អាវយឺត"</string> + <string name="spoken_emoji_1F454" msgid="348469036193323252">"ក្រវ៉ាត់ករ"</string> + <string name="spoken_emoji_1F455" msgid="5665118831861433578">"អាវយឺត"</string> <string name="spoken_emoji_1F456" msgid="1890991330923356408">"ខោខោវប៊យ"</string> <string name="spoken_emoji_1F457" msgid="3904310482655702620">"សំលៀកបំពាក់"</string> <string name="spoken_emoji_1F458" msgid="5704243858031107692">"គីម៉ូណូ"</string> @@ -463,8 +463,8 @@ <string name="spoken_emoji_1F465" msgid="4461307702499679879">"គណនី"</string> <string name="spoken_emoji_1F466" msgid="1938873085514108889">"ក្មេងប្រុស"</string> <string name="spoken_emoji_1F467" msgid="8237080594860144998">"ក្មេងស្រី"</string> - <string name="spoken_emoji_1F468" msgid="6081300722526675382">"បុរស"</string> - <string name="spoken_emoji_1F469" msgid="1090140923076108158">"ស្ត្រី"</string> + <string name="spoken_emoji_1F468" msgid="6081300722526675382">"បុរស"</string> + <string name="spoken_emoji_1F469" msgid="1090140923076108158">"ស្ត្រី"</string> <string name="spoken_emoji_1F46A" msgid="5063570981942606595">"គ្រួសារ"</string> <string name="spoken_emoji_1F46B" msgid="6795882374287327952">"បុរស និងស្ត្រីកាន់ដៃគ្នា"</string> <string name="spoken_emoji_1F46C" msgid="6844464165783964495">"បុរសពីរនាក់កាន់ដៃគ្នា"</string> @@ -490,16 +490,16 @@ <string name="spoken_emoji_1F480" msgid="3696253485164878739">"លលាដ៍ក្បាល"</string> <string name="spoken_emoji_1F481" msgid="320408708521966893">"អ្នកផ្ដល់ព័ត៌មាន"</string> <string name="spoken_emoji_1F482" msgid="3424354860245608949">"អ្នកយាម"</string> - <string name="spoken_emoji_1F483" msgid="3221113594843849083">"អ្នករាំ"</string> + <string name="spoken_emoji_1F483" msgid="3221113594843849083">"អ្នករាំ"</string> <string name="spoken_emoji_1F484" msgid="7348014979080444885">"ក្រេមលាបបបូរមាត់"</string> <string name="spoken_emoji_1F485" msgid="6133507975565116339">"ថ្នាំលាបក្រចក"</string> <string name="spoken_emoji_1F486" msgid="9085459968247394155">"ម៉ាស្សាមុខ"</string> <string name="spoken_emoji_1F487" msgid="1479113637259592150">"កាត់សក់"</string> <string name="spoken_emoji_1F488" msgid="6922559285234100252">"ស្លាកសញ្ញាកាត់សក់"</string> <string name="spoken_emoji_1F489" msgid="8114863680950147305">"ស៊ីរ៉ាំង"</string> - <string name="spoken_emoji_1F48A" msgid="8526843630145963032">"ថ្នាំគ្រាប់"</string> + <string name="spoken_emoji_1F48A" msgid="8526843630145963032">"ថ្នាំគ្រាប់"</string> <string name="spoken_emoji_1F48B" msgid="2538528967897640292">"ស្នាមថើប"</string> - <string name="spoken_emoji_1F48C" msgid="1681173271652890232">"លិខិតស្នេហា"</string> + <string name="spoken_emoji_1F48C" msgid="1681173271652890232">"លិខិតស្នេហា"</string> <string name="spoken_emoji_1F48D" msgid="8259886164999042373">"រោទ៍"</string> <string name="spoken_emoji_1F48E" msgid="8777981696011111101">"ត្បូងថ្ម"</string> <string name="spoken_emoji_1F48F" msgid="741593675183677907">"ថើប"</string> @@ -525,7 +525,7 @@ <string name="spoken_emoji_1F4A3" msgid="6378351742957821735">"គ្រាប់បែក"</string> <string name="spoken_emoji_1F4A4" msgid="7217736258870346625">"និមិត្តសញ្ញាដេក"</string> <string name="spoken_emoji_1F4A5" msgid="5401995723541239858">"និមិត្តសញ្ញាប៉ះទង្គិចគ្នា"</string> - <string name="spoken_emoji_1F4A6" msgid="3837802182716483848">"និមិត្តសញ្ញាស្រក់ញើស"</string> + <string name="spoken_emoji_1F4A6" msgid="3837802182716483848">"និមិត្តសញ្ញាស្រក់ញើស"</string> <string name="spoken_emoji_1F4A7" msgid="5718438987757885141">"ដំណក់ទឹក"</string> <string name="spoken_emoji_1F4A8" msgid="4472108229720006377">"និមិត្តសញ្ញាដកឃ្លា"</string> <string name="spoken_emoji_1F4A9" msgid="1240958472788430032">"គំនរធូលី"</string> @@ -539,7 +539,7 @@ <string name="spoken_emoji_1F4B1" msgid="8339494003418572905">"ប្ដូររូបិយប័ណ្ណ"</string> <string name="spoken_emoji_1F4B2" msgid="3179159430187243132">"សញ្ញាដុល្លារ"</string> <string name="spoken_emoji_1F4B3" msgid="5375412518221759596">"កាតឥណទាន"</string> - <string name="spoken_emoji_1F4B4" msgid="1068592463669453204">"ក្រដាសប្រាក់ធនាគារមានសញ្ញាយ៉េន"</string> + <string name="spoken_emoji_1F4B4" msgid="1068592463669453204">"ក្រដាសប្រាក់ធនាគារមានសញ្ញាយ៉េន"</string> <string name="spoken_emoji_1F4B5" msgid="1426708699891832564">"លុយដុល្លារ"</string> <string name="spoken_emoji_1F4B6" msgid="8289249930736444837">"ក្រដាសប្រាក់ធនាគារមានសញ្ញាអឺរ៉ូ"</string> <string name="spoken_emoji_1F4B7" msgid="5245100496860739429">"ក្រដាសប្រាក់ធនាគារមានសញ្ញាផោន"</string> @@ -547,7 +547,7 @@ <string name="spoken_emoji_1F4B9" msgid="647509393536679903">"ក្រាហ្វិកនិន្នាការឡើងមានសញ្ញាយ៉េន"</string> <string name="spoken_emoji_1F4BA" msgid="1269737854891046321">"កៅអី"</string> <string name="spoken_emoji_1F4BB" msgid="6252883563347816451">"កុំព្យូទ័រផ្ទាល់ខ្លួន"</string> - <string name="spoken_emoji_1F4BC" msgid="6182597732218446206">"វ៉ាលី"</string> + <string name="spoken_emoji_1F4BC" msgid="6182597732218446206">"វ៉ាលី"</string> <string name="spoken_emoji_1F4BD" msgid="5820961044768829176">"ឌីសតូច"</string> <string name="spoken_emoji_1F4BE" msgid="4754542485835379808">"ថាសទន់"</string> <string name="spoken_emoji_1F4BF" msgid="2237481756984721795">"ថាស"</string> @@ -557,7 +557,7 @@ <string name="spoken_emoji_1F4C3" msgid="3727274466173970142">"ទំព័រកោង"</string> <string name="spoken_emoji_1F4C4" msgid="4382570710795501612">"ទំព័របញ្ឈរ"</string> <string name="spoken_emoji_1F4C5" msgid="8693944622627762487">"ប្រតិទិន"</string> - <string name="spoken_emoji_1F4C6" msgid="8469908708708424640">"ហែកប្រតិទិន"</string> + <string name="spoken_emoji_1F4C6" msgid="8469908708708424640">"ហែកប្រតិទិន"</string> <string name="spoken_emoji_1F4C7" msgid="2665313547987324495">"កាតរៀបតាមអក្សរ"</string> <string name="spoken_emoji_1F4C8" msgid="8007686702282833600">"ក្រាហ្វិកមាននិន្នាការឡើង"</string> <string name="spoken_emoji_1F4C9" msgid="2271951411192893684">"ក្រាហ្វិកមាននិន្នាការចុះ"</string> @@ -573,11 +573,11 @@ <string name="spoken_emoji_1F4D3" msgid="5873386492793610808">"សៀវភៅ"</string> <string name="spoken_emoji_1F4D4" msgid="4754469936418776360">"សៀវភៅមានក្របពណ៌"</string> <string name="spoken_emoji_1F4D5" msgid="4642713351802778905">"សៀវភៅបិទ"</string> - <string name="spoken_emoji_1F4D6" msgid="6987347918381807186">"សៀវភៅបើក"</string> + <string name="spoken_emoji_1F4D6" msgid="6987347918381807186">"សៀវភៅបើក"</string> <string name="spoken_emoji_1F4D7" msgid="7813394163241379223">"សៀវភៅពណ៌បៃតង"</string> <string name="spoken_emoji_1F4D8" msgid="7189799718984979521">"សៀវភៅពណ៌ខៀវ"</string> <string name="spoken_emoji_1F4D9" msgid="3874664073186440225">"សៀវភៅពណ៌ទឹកក្រូច"</string> - <string name="spoken_emoji_1F4DA" msgid="872212072924287762">"សៀវភៅ"</string> + <string name="spoken_emoji_1F4DA" msgid="872212072924287762">"សៀវភៅ"</string> <string name="spoken_emoji_1F4DB" msgid="2015183603583392969">"ស្លាកឈ្មោះ"</string> <string name="spoken_emoji_1F4DC" msgid="5075845110932456783">"ក្រដាសរមូរ"</string> <string name="spoken_emoji_1F4DD" msgid="2494006707147586786">"កំណត់ចំណាំ"</string> @@ -589,7 +589,7 @@ <string name="spoken_emoji_1F4E3" msgid="5588916572878599224">"ឧបករណ៍បំពងសំឡេង"</string> <string name="spoken_emoji_1F4E4" msgid="2063561529097749707">"ថាសចេញ"</string> <string name="spoken_emoji_1F4E5" msgid="3232462702926143576">"ថាសចូល"</string> - <string name="spoken_emoji_1F4E6" msgid="3399454337197561635">"កញ្ចប់"</string> + <string name="spoken_emoji_1F4E6" msgid="3399454337197561635">"កញ្ចប់"</string> <string name="spoken_emoji_1F4E7" msgid="5557136988503873238">"និមិត្តសញ្ញាអ៊ីមែល"</string> <string name="spoken_emoji_1F4E8" msgid="30698793974124123">"ស្រោមសំបុត្រចូល"</string> <string name="spoken_emoji_1F4E9" msgid="5947550337678643166">"ស្រោមសំបុត្រមានសញ្ញាព្រួញពីលើ"</string> @@ -626,7 +626,7 @@ <string name="spoken_emoji_1F50C" msgid="7793219132036431680">"ដុយអគ្គិសនី"</string> <string name="spoken_emoji_1F50D" msgid="8140244710637926780">"កែវពង្រីកចង្អុលខាងឆ្វេង"</string> <string name="spoken_emoji_1F50E" msgid="4751821352839693365">"កែវពង្រីកចង្អុលខាងស្ដាំ"</string> - <string name="spoken_emoji_1F50F" msgid="915079280472199605">"ចាក់សោដោយប្រើប៊ិច"</string> + <string name="spoken_emoji_1F50F" msgid="915079280472199605">"ចាក់សោដោយប្រើប៊ិច"</string> <string name="spoken_emoji_1F510" msgid="7658381761691758318">"បិទសោដោយប្រើកូនសោ"</string> <string name="spoken_emoji_1F511" msgid="262319867774655688">"សោ"</string> <string name="spoken_emoji_1F512" msgid="5628688337255115175">"ចាក់សោ"</string> @@ -645,15 +645,15 @@ <string name="spoken_emoji_1F51F" msgid="8673370823728653973">"គ្រាប់ចុច ១០"</string> <string name="spoken_emoji_1F520" msgid="7335109890337048900">"និមិត្តសញ្ញាបញ្ចូលសម្រាប់អក្សរឡាតាំងធំ"</string> <string name="spoken_emoji_1F521" msgid="2693185864450925778">"និមិត្តសញ្ញាបញ្ចូលសម្រាប់អក្សរឡាតាំងតូច"</string> - <string name="spoken_emoji_1F522" msgid="8419130286280673347">"និមិត្តសញ្ញាបញ្ចូលសម្រាប់លេខ"</string> + <string name="spoken_emoji_1F522" msgid="8419130286280673347">"និមិត្តសញ្ញាបញ្ចូលសម្រាប់លេខ"</string> <string name="spoken_emoji_1F523" msgid="3318053476401719421">"ការបញ្ចូលនិមិត្តសញ្ញា"</string> <string name="spoken_emoji_1F524" msgid="1625073997522316331">"និមិត្តសញ្ញាបញ្ចូលសម្រាប់អក្សរឡាតាំង"</string> <string name="spoken_emoji_1F525" msgid="4083884189172963790">"ភ្លើង"</string> <string name="spoken_emoji_1F526" msgid="2035494936742643580">"ពិលអគ្គិសនី"</string> <string name="spoken_emoji_1F527" msgid="134257142354034271">"ម៉ាឡេត"</string> <string name="spoken_emoji_1F528" msgid="700627429570609375">"ញញួរ"</string> - <string name="spoken_emoji_1F529" msgid="7480548235904988573">"ឡោស៊ី"</string> - <string name="spoken_emoji_1F52A" msgid="7613580031502317893">"កាំបិត"</string> + <string name="spoken_emoji_1F529" msgid="7480548235904988573">"ឡោស៊ី"</string> + <string name="spoken_emoji_1F52A" msgid="7613580031502317893">"កាំបិត"</string> <string name="spoken_emoji_1F52B" msgid="4554906608328118613">"កាំភ្លើងខ្លី"</string> <string name="spoken_emoji_1F52C" msgid="1330294501371770790">"មីក្រូទស្សន៍"</string> <string name="spoken_emoji_1F52D" msgid="7549551775445177140">"កែវយឹត"</string> @@ -662,7 +662,7 @@ <string name="spoken_emoji_1F530" msgid="3572898444281774023">"និមិត្តសញ្ញាជប៉ុនសម្រាប់អ្នកចាប់ផ្ដើម"</string> <string name="spoken_emoji_1F531" msgid="5225633376450025396">"លំពែងមុខបី"</string> <string name="spoken_emoji_1F532" msgid="9169568490485180779">"ប៊ូតុងការេពណ៌ខ្មៅ"</string> - <string name="spoken_emoji_1F533" msgid="6554193837201918598">"ប៊ូតុងការ៉េពណ៌ស"</string> + <string name="spoken_emoji_1F533" msgid="6554193837201918598">"ប៊ូតុងការ៉េពណ៌ស"</string> <string name="spoken_emoji_1F534" msgid="8339298801331865340">"រង្វង់ពណ៌ក្រហមធំ"</string> <string name="spoken_emoji_1F535" msgid="1227403104835533512">"រង្វង់ពណ៌ខៀវធំ"</string> <string name="spoken_emoji_1F536" msgid="5477372445510469331">"ពេជ្រពណ៌ទឹកក្រូចធំ"</string> @@ -745,8 +745,8 @@ <string name="spoken_emoji_1F628" msgid="8875777401624904224">"មុខភ័យខ្លាច"</string> <string name="spoken_emoji_1F629" msgid="1411538490319190118">"មុខនឿយហត់"</string> <string name="spoken_emoji_1F62A" msgid="4726686726690289969">"មុខងងុយគេង"</string> - <string name="spoken_emoji_1F62B" msgid="3221980473921623613">"មុខអស់កម្លាំង"</string> - <string name="spoken_emoji_1F62C" msgid="4616356691941225182">"មុខក្រញេវក្រញូវ"</string> + <string name="spoken_emoji_1F62B" msgid="3221980473921623613">"មុខអស់កម្លាំង"</string> + <string name="spoken_emoji_1F62C" msgid="4616356691941225182">"មុខក្រញេវក្រញូវ"</string> <string name="spoken_emoji_1F62D" msgid="4283677508698812232">"មុខយំលឺៗ"</string> <string name="spoken_emoji_1F62E" msgid="726083405284353894">"មុខបើកមាត់"</string> <string name="spoken_emoji_1F62F" msgid="7746620088234710962">"មុខស្ងៀមស្ងាត់"</string> @@ -784,7 +784,7 @@ <string name="spoken_emoji_1F683" msgid="8772750354339223092">"ទូររថភ្លើង"</string> <string name="spoken_emoji_1F684" msgid="346396777356203608">"រថភ្លើងល្បឿនលឿន"</string> <string name="spoken_emoji_1F685" msgid="1237059817190832730">"រថភ្លើងល្បឿនលឿនមានច្រមុះ"</string> - <string name="spoken_emoji_1F686" msgid="3525197227223620343">"រថភ្លើង"</string> + <string name="spoken_emoji_1F686" msgid="3525197227223620343">"រថភ្លើង"</string> <string name="spoken_emoji_1F687" msgid="5110143437960392837">"មេត្រូ"</string> <string name="spoken_emoji_1F688" msgid="4702085029871797965">"រថភ្លើងប្រើពន្លឺ"</string> <string name="spoken_emoji_1F689" msgid="2375851019798817094">"ស្ថានីយ"</string> @@ -803,7 +803,7 @@ <string name="spoken_emoji_1F696" msgid="6391604457418285404">"តាក់ស៊ីខាងមុខ"</string> <string name="spoken_emoji_1F697" msgid="7978399334396733790">"រថយន្ត"</string> <string name="spoken_emoji_1F698" msgid="7006050861129732018">"រថយន្តខាងមុខ"</string> - <string name="spoken_emoji_1F699" msgid="630317052666590607">"រថយន្តសម្រាប់កម្សាន្ត"</string> + <string name="spoken_emoji_1F699" msgid="630317052666590607">"រថយន្តសម្រាប់កម្សាន្ត"</string> <string name="spoken_emoji_1F69A" msgid="4739797891735823577">"រថយន្តចែកចាយ"</string> <string name="spoken_emoji_1F69B" msgid="4715997280786620649">"ឡានកាមីយ៉ុង"</string> <string name="spoken_emoji_1F69C" msgid="5557395610750818161">"ត្រាក់ទ័រ"</string> @@ -819,7 +819,7 @@ <string name="spoken_emoji_1F6A6" msgid="485575967773793454">"ភ្លើងចរាចរណ៍បញ្ឈរ"</string> <string name="spoken_emoji_1F6A7" msgid="6411048933816976794">"សញ្ញាសំណង់"</string> <string name="spoken_emoji_1F6A8" msgid="6345717218374788364">"រថយន្តប៉ូលិសបើកសារ៉ែនវិល"</string> - <string name="spoken_emoji_1F6A9" msgid="6586380356807600412">"បង្គោលទង់ជាតិរាងត្រីកោណ"</string> + <string name="spoken_emoji_1F6A9" msgid="6586380356807600412">"បង្គោលទង់ជាតិរាងត្រីកោណ"</string> <string name="spoken_emoji_1F6AA" msgid="8954448167261738885">"ទ្វារ"</string> <string name="spoken_emoji_1F6AB" msgid="5313946262888343544">"សញ្ញាហាមចូល"</string> <string name="spoken_emoji_1F6AC" msgid="6946858177965948288">"សញ្ញាជក់បារី"</string> diff --git a/java/res/values-km-rKH/strings-talkback-descriptions.xml b/java/res/values-km-rKH/strings-talkback-descriptions.xml index f9078323d..29d3b959f 100644 --- a/java/res/values-km-rKH/strings-talkback-descriptions.xml +++ b/java/res/values-km-rKH/strings-talkback-descriptions.xml @@ -78,7 +78,7 @@ <string name="spoken_emoji_unknown" msgid="5981009928135394306">"មិនស្គាល់សញ្ញាអារម្មណ៍"</string> <string name="spoken_emoticon_3A_2D_21_20" msgid="2410905667389534573">"មុខអផ្សុក"</string> <string name="spoken_emoticon_3A_2D_24_20" msgid="2481260475945560438">"មុខខ្មាសអៀន"</string> - <string name="spoken_emoticon_42_2D_29_20" msgid="1063205250387128068">"ពាក់វ៉ែនតា"</string> + <string name="spoken_emoticon_42_2D_29_20" msgid="1063205250387128068">"ពាក់វ៉ែនតា"</string> <string name="spoken_emoticon_3A_4F_20" msgid="532695091593447238">"មុខភ្ញាក់ផ្អើល"</string> <string name="spoken_emoticon_3A_2D_2A_20" msgid="5612342617244114291">"មុខថើប"</string> <string name="spoken_emoticon_3A_2D_5B_20" msgid="2223507987759905920">"មុខចងចិញ្ចើម"</string> diff --git a/java/res/values-km-rKH/strings.xml b/java/res/values-km-rKH/strings.xml index 8aea853a2..86fdf2957 100644 --- a/java/res/values-km-rKH/strings.xml +++ b/java/res/values-km-rKH/strings.xml @@ -39,7 +39,7 @@ <string name="include_other_imes_in_language_switch_list_summary" msgid="840637129103317635">"គ្រាប់ចុចប្ដូរភាសាតាមវិធីសាស្ត្របញ្ចូលផ្សេងទៀត"</string> <string name="show_language_switch_key" msgid="5915478828318774384">"គ្រាប់ចុចប្ដូរភាសា"</string> <string name="show_language_switch_key_summary" msgid="7343403647474265713">"បង្ហាញនៅពេលដែលបើកភាសាបញ្ចូលច្រើន"</string> - <string name="key_preview_popup_dismiss_delay" msgid="6213164897443068248">"សោលេចឡើងបោះបង់ការពន្យារពេល"</string> + <string name="key_preview_popup_dismiss_delay" msgid="6213164897443068248">"សោលេចឡើងបោះបង់ការពន្យារពេល"</string> <string name="key_preview_popup_dismiss_no_delay" msgid="2096123151571458064">"គ្មានការពន្យារពេល"</string> <string name="key_preview_popup_dismiss_default_delay" msgid="2166964333903906734">"លំនាំដើម"</string> <string name="abbreviation_unit_milliseconds" msgid="8700286094028323363">"<xliff:g id="MILLISECONDS">%s</xliff:g> មិល្លីវិនាទី"</string> @@ -50,7 +50,7 @@ <string name="enable_metrics_logging" msgid="5506372337118822837">"ធ្វើឲ្យ <xliff:g id="APPLICATION_NAME">%s</xliff:g> ប្រសើរឡើង"</string> <string name="use_double_space_period" msgid="8781529969425082860">"រយៈពេលចុចដកឃ្លាពីរដង"</string> <string name="use_double_space_period_summary" msgid="6532892187247952799">"ប៉ះដកឃ្លាពីរដងបញ្ចូលរយៈពេលដែលអនុវត្តតាមដកឃ្លា"</string> - <string name="auto_cap" msgid="1719746674854628252">"ការសរសេរជាអក្សរធំស្វ័យប្រវត្តិ"</string> + <string name="auto_cap" msgid="1719746674854628252">"ការសរសេរជាអក្សរធំស្វ័យប្រវត្តិ"</string> <string name="auto_cap_summary" msgid="7934452761022946874">"សរសេរពាក្យដំបូងជាអក្សរធំនៃប្រយោគនីមួយៗ"</string> <string name="edit_personal_dictionary" msgid="3996910038952940420">"វចនានុក្រមផ្ទាល់ខ្លួន"</string> <string name="configure_dictionaries_title" msgid="4238652338556902049">"ផ្នែកបន្ថែមវចនានុក្រម"</string> @@ -58,7 +58,7 @@ <string name="prefs_show_suggestions" msgid="8026799663445531637">"បង្ហាញការស្នើកែ"</string> <string name="prefs_show_suggestions_summary" msgid="1583132279498502825">"បង្ហាញពាក្យបានផ្ដល់ស្នើខណៈពេលវាយបញ្ចូល"</string> <string name="prefs_block_potentially_offensive_title" msgid="5078480071057408934">"ទប់ស្កាត់ពាក្យបំពាន"</string> - <string name="prefs_block_potentially_offensive_summary" msgid="2371835479734991364">"កុំស្នើឲ្យពាក្យបំពានមានសក្ដានុពល"</string> + <string name="prefs_block_potentially_offensive_summary" msgid="2371835479734991364">"កុំស្នើឲ្យពាក្យបំពានមានសក្ដានុពល"</string> <string name="auto_correction" msgid="7630720885194996950">"ការកែស្វ័យប្រវត្តិ"</string> <string name="auto_correction_summary" msgid="5625751551134658006">"ចន្លោះមិនឃើញ និងសញ្ញាវណ្ណយុត្តកែពាក្យដែលបានវាយខុសស្វ័យប្រវត្តិ"</string> <string name="auto_correction_threshold_mode_off" msgid="8470882665417944026">"បិទ"</string> @@ -149,7 +149,7 @@ <string name="dictionary_provider_name" msgid="3027315045397363079">"កម្មវិធីផ្ដល់វចនានុក្រម"</string> <string name="dictionary_service_name" msgid="6237472350693511448">"សេវាកម្មវចនានុក្រម"</string> <string name="download_description" msgid="6014835283119198591">"ព័ត៌មានបច្ចុប្បន្នភាពវចនានុក្រម"</string> - <string name="dictionary_settings_title" msgid="8091417676045693313">"ផ្នែកបន្ថែមវចនានុក្រម"</string> + <string name="dictionary_settings_title" msgid="8091417676045693313">"ផ្នែកបន្ថែមវចនានុក្រម"</string> <string name="dictionary_install_over_metered_network_prompt" msgid="3587517870006332980">"វចនានុក្រមអាចប្រើបាន"</string> <string name="dictionary_settings_summary" msgid="5305694987799824349">"ការកំណត់សម្រាប់វចនានុក្រម"</string> <string name="user_dictionaries" msgid="3582332055892252845">"វចនានុក្រមអ្នកប្រើ"</string> @@ -165,10 +165,10 @@ <string name="message_updating" msgid="4457761393932375219">"ពិនិត្យមើលបច្ចុប្បន្នភាព"</string> <string name="message_loading" msgid="5638680861387748936">"កំពុងផ្ទុក..."</string> <string name="main_dict_description" msgid="3072821352793492143">"វចនានុក្រមចម្បង"</string> - <string name="cancel" msgid="6830980399865683324">"បោះបង់"</string> + <string name="cancel" msgid="6830980399865683324">"បោះបង់"</string> <string name="go_to_settings" msgid="3876892339342569259">"ការកំណត់"</string> <string name="install_dict" msgid="180852772562189365">"ដំឡើង"</string> - <string name="cancel_download_dict" msgid="7843340278507019303">"បោះបង់"</string> + <string name="cancel_download_dict" msgid="7843340278507019303">"បោះបង់"</string> <string name="delete_dict" msgid="756853268088330054">"លុប"</string> <string name="should_download_over_metered_prompt" msgid="1583881200688185508">"ភាសាដែលបានជ្រើសនៅលើឧបករណ៍ចល័តមានវចនានុក្រមអាចប្រើបាន។<br/> យើងផ្ដល់អនុសាសន៍ឲ្យ <b>ទាញយក</b> វចនានុក្រមភាសា <xliff:g id="LANGUAGE_NAME">%1$s</xliff:g> ដើម្បីបង្កើនបទពិសោធន៍វាយបញ្ចូលរបស់អ្នក។<br/> <br/> ការទាញយកអាចចំណាយពេលប្រហែលពីរនាទីនៅតាម 3G។ ការគិតថ្លៃអាចអនុវត្តប្រសិនបើអ្នកមិនប្រើ <b>ផែនការទិន្នន័យគ្មានដែនកំណត់</b>.<br/> បើអ្នកមិនប្រាកដថាផែនការណាមួយដែលអ្នកមាន យើងផ្ដល់អនុសាសន៍ឲ្យភ្ជាប់វ៉ាយហ្វាយ ដើម្បីចាប់ផ្ដើមទាញយកដោយស្វ័យប្រវត្តិ។<br/> <br/> ជំនួយ៖ អ្នកអាចទាញយក និងលុបវចនានុក្រមដោយចូលទៅ <b>ភាសា & ការបញ្ចូល</b> នៅក្នុងម៉ឺនុយ <b>ការកំណត់</b> សម្រាប់ឧបករណ៍ចល័ត។"</string> <string name="download_over_metered" msgid="1643065851159409546">"ទាញយកឥឡូវនេះ (<xliff:g id="SIZE_IN_MEGABYTES">%1$.1f</xliff:g> មេកាបៃ)"</string> @@ -186,7 +186,7 @@ <string name="user_dict_settings_add_word_option_name" msgid="6665558053408962865">"ពាក្យ៖"</string> <string name="user_dict_settings_add_shortcut_option_name" msgid="3094731590655523777">"ផ្លូវកាត់៖"</string> <string name="user_dict_settings_add_locale_option_name" msgid="4738643440987277705">"ភាសា៖"</string> - <string name="user_dict_settings_add_word_hint" msgid="4902434148985906707">"វាយបញ្ចូលពាក្យ"</string> + <string name="user_dict_settings_add_word_hint" msgid="4902434148985906707">"វាយបញ្ចូលពាក្យ"</string> <string name="user_dict_settings_add_shortcut_hint" msgid="2265453012555060178">"ផ្លូវកាត់ជាជម្រើស"</string> <string name="user_dict_settings_edit_dialog_title" msgid="3765774633869590352">"កែពាក្យ"</string> <string name="user_dict_settings_context_menu_edit_title" msgid="6812255903472456302">"កែ"</string> diff --git a/java/res/values-lo-rLA/strings-emoji-descriptions.xml b/java/res/values-lo-rLA/strings-emoji-descriptions.xml index 335fc19f9..61845dafe 100644 --- a/java/res/values-lo-rLA/strings-emoji-descriptions.xml +++ b/java/res/values-lo-rLA/strings-emoji-descriptions.xml @@ -210,7 +210,7 @@ <string name="spoken_emoji_1F330" msgid="3115760035618051575">"ລູກເກົາລັດ"</string> <string name="spoken_emoji_1F331" msgid="5658888205290008691">"ກ້າໄມ້"</string> <string name="spoken_emoji_1F332" msgid="2935650450421165938">"ຕົ້ນໄມ້ບໍ່ຜັດໃບ"</string> - <string name="spoken_emoji_1F333" msgid="5898847427062482675">"ຕົ້ນໄມ້ຜັດໃບ"</string> + <string name="spoken_emoji_1F333" msgid="5898847427062482675">"ຕົ້ນໄມ້ຜັດໃບ"</string> <string name="spoken_emoji_1F334" msgid="6183375224678417894">"ຕົ້ນປາມ"</string> <string name="spoken_emoji_1F335" msgid="5352418412103584941">"ກະບອງເພັດ"</string> <string name="spoken_emoji_1F337" msgid="3839107352363566289">"ທິວລິບ"</string> @@ -450,7 +450,7 @@ <string name="spoken_emoji_1F458" msgid="5704243858031107692">"ກິໂມໂນ"</string> <string name="spoken_emoji_1F459" msgid="3553148747050035251">"ບິກີນີ"</string> <string name="spoken_emoji_1F45A" msgid="1389654639484716101">"ເສື້ອຜ້າຜູ່ຍິງ"</string> - <string name="spoken_emoji_1F45B" msgid="1113293170254222904">"ກະເປົາ"</string> + <string name="spoken_emoji_1F45B" msgid="1113293170254222904">"ກະເປົາ"</string> <string name="spoken_emoji_1F45C" msgid="3410257778598006936">"ກະເປົາ"</string> <string name="spoken_emoji_1F45D" msgid="812176504300064819">"ກະເປົາ"</string> <string name="spoken_emoji_1F45E" msgid="2901741399934723562">"ເກີບຜູ່ຊາຍ"</string> diff --git a/java/res/values-lo-rLA/strings-letter-descriptions.xml b/java/res/values-lo-rLA/strings-letter-descriptions.xml index ecc0b7a71..47f7cbc81 100644 --- a/java/res/values-lo-rLA/strings-letter-descriptions.xml +++ b/java/res/values-lo-rLA/strings-letter-descriptions.xml @@ -186,7 +186,7 @@ <string name="spoken_symbol_2019" msgid="8892530161598134083">"Right single quotation mark"</string> <string name="spoken_symbol_201A" msgid="2072987157683446644">"Single low-9 quotation mark"</string> <string name="spoken_symbol_201C" msgid="4588048378803665427">"ເຄື່ອງໝາຍວົງຢືມຊ້າຍ"</string> - <string name="spoken_symbol_201D" msgid="1642776849495925895">"ເຄື່ອງໝາຍວົງຢືມຂວາ"</string> + <string name="spoken_symbol_201D" msgid="1642776849495925895">"ເຄື່ອງໝາຍວົງຢືມຂວາ"</string> <string name="spoken_symbol_2020" msgid="9084628638189344431">"Dagger"</string> <string name="spoken_symbol_2021" msgid="5081396468559426475">"Double dagger"</string> <string name="spoken_symbol_2030" msgid="9068837172419431755">"ເຄື່ອງໝາຍຕໍ່ໄມລ໌"</string> diff --git a/java/res/values-mn-rMN/strings-emoji-descriptions.xml b/java/res/values-mn-rMN/strings-emoji-descriptions.xml index f09a51dd9..5014b2ff8 100644 --- a/java/res/values-mn-rMN/strings-emoji-descriptions.xml +++ b/java/res/values-mn-rMN/strings-emoji-descriptions.xml @@ -267,7 +267,7 @@ <string name="spoken_emoji_1F36A" msgid="2726271795913042295">"Печень"</string> <string name="spoken_emoji_1F36B" msgid="6342163604299875931">"Шоколад"</string> <string name="spoken_emoji_1F36C" msgid="2168934753998218790">"Чихэр"</string> - <string name="spoken_emoji_1F36D" msgid="3671507903799975792">"Иштэй чихэр"</string> + <string name="spoken_emoji_1F36D" msgid="3671507903799975792">"Lollipop"</string> <string name="spoken_emoji_1F36E" msgid="4630541402785165902">"Шар тос"</string> <string name="spoken_emoji_1F36F" msgid="5577915387425169439">"Зөгийн бал"</string> <string name="spoken_emoji_1F370" msgid="7243244547866114951">"Үелсэн бялуу"</string> diff --git a/java/res/values-my-rMM/strings-action-keys.xml b/java/res/values-my-rMM/strings-action-keys.xml index d15c9e55e..f7a2ca9e1 100644 --- a/java/res/values-my-rMM/strings-action-keys.xml +++ b/java/res/values-my-rMM/strings-action-keys.xml @@ -27,5 +27,5 @@ <string name="label_send_key" msgid="482252074224462163">"ပို့ရန်"</string> <string name="label_search_key" msgid="7965186050435796642">"ရှာဖွေရန်"</string> <string name="label_pause_key" msgid="2225922926459730642">"ဆိုင်းငံ့ရန်"</string> - <string name="label_wait_key" msgid="5891247853595466039">"စောင့်ဆိုင်းရန်"</string> + <string name="label_wait_key" msgid="5891247853595466039">"စောင့်ဆိုင်းရန်"</string> </resources> diff --git a/java/res/values-my-rMM/strings-letter-descriptions.xml b/java/res/values-my-rMM/strings-letter-descriptions.xml index 2d5338b86..d904f53f6 100644 --- a/java/res/values-my-rMM/strings-letter-descriptions.xml +++ b/java/res/values-my-rMM/strings-letter-descriptions.xml @@ -29,7 +29,7 @@ <string name="spoken_accented_letter_00AA" msgid="4374325261868451570">"ဣထိလိင် အစဉ်ပြ အညွှန်း"</string> <string name="spoken_accented_letter_00B5" msgid="9031387673828823891">"မိုက်ခရို သင်္ကေတ"</string> <string name="spoken_accented_letter_00BA" msgid="5045198452071207437">"ပုလိင် အစဉ်ပြ အညွှန်း"</string> - <string name="spoken_accented_letter_00DF" msgid="2260098367028134281">"ပြတ်သားသည့် S"</string> + <string name="spoken_accented_letter_00DF" msgid="2260098367028134281">"ပြတ်သားသည့် S"</string> <string name="spoken_accented_letter_00E0" msgid="2234515772182387086">"A၊ တည်ငြိမ်သော"</string> <string name="spoken_accented_letter_00E1" msgid="7780174500802535063">"A၊ စူးရှသော"</string> <string name="spoken_accented_letter_00E2" msgid="7054108480488102631">"A၊ သရသံသင်္ကေတ"</string> @@ -133,45 +133,45 @@ <string name="spoken_accented_letter_0259" msgid="2464085263158415898">"Schwa"</string> <string name="spoken_accented_letter_1EA1" msgid="688124877202887630">"A၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EA3" msgid="327960130366386256">"A အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EA5" msgid="637406363453769610">"A၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1EA7" msgid="1419591804181615409">"A၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1EA9" msgid="6068887382734896756">"A၊ သရသံသင်္ကေတ နှင့် အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EAB" msgid="7236523151662538333">"A၊ သရသံသင်္ကေတ နှင့် tilde"</string> - <string name="spoken_accented_letter_1EAD" msgid="2363364864106332076">"A,၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> - <string name="spoken_accented_letter_1EAF" msgid="1576329511464272935">"A၊ တည်ငြိမ်သော နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1EB1" msgid="4634735072816076592">"A၊ breve နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1EB3" msgid="2325245849038771534">"A၊ breve နှင့် အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EB5" msgid="3720427596242746295">"A၊ breve နှင့် tilde"</string> - <string name="spoken_accented_letter_1EB7" msgid="700415535653646695">"A၊ breve နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1EA5" msgid="637406363453769610">"A၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1EA7" msgid="1419591804181615409">"A၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1EA9" msgid="6068887382734896756">"A၊ သရသံသင်္ကေတ နှင့် အပေါ်မှာ ချိတ်"</string> + <string name="spoken_accented_letter_1EAB" msgid="7236523151662538333">"A၊ သရသံသင်္ကေတ နှင့် tilde"</string> + <string name="spoken_accented_letter_1EAD" msgid="2363364864106332076">"A,၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1EAF" msgid="1576329511464272935">"A၊ တည်ငြိမ်သော နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1EB1" msgid="4634735072816076592">"A၊ breve နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1EB3" msgid="2325245849038771534">"A၊ breve နှင့် အပေါ်မှာ ချိတ်"</string> + <string name="spoken_accented_letter_1EB5" msgid="3720427596242746295">"A၊ breve နှင့် tilde"</string> + <string name="spoken_accented_letter_1EB7" msgid="700415535653646695">"A၊ breve နှင့် အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EB9" msgid="3901338692305890487">"E၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EBB" msgid="4028688699415417302">"E၊ အပေါ်မှာ ချိတ်"</string> <string name="spoken_accented_letter_1EBD" msgid="181253633045931897">"E၊ tilde"</string> - <string name="spoken_accented_letter_1EBF" msgid="3309618845007944963">"E၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1EC1" msgid="8139046749226332542">"E၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1EC3" msgid="3239674223053133383">"E၊ သရသံသင်္ကေတ နှင့် ချိတ် အပေါ်မှာ"</string> - <string name="spoken_accented_letter_1EC5" msgid="2216559244705714587">"E၊ သရသံသင်္ကေတ နှင့် tilde"</string> - <string name="spoken_accented_letter_1EC7" msgid="9012731468253986792">"E၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1EBF" msgid="3309618845007944963">"E၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1EC1" msgid="8139046749226332542">"E၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1EC3" msgid="3239674223053133383">"E၊ သရသံသင်္ကေတ နှင့် ချိတ် အပေါ်မှာ"</string> + <string name="spoken_accented_letter_1EC5" msgid="2216559244705714587">"E၊ သရသံသင်္ကေတ နှင့် tilde"</string> + <string name="spoken_accented_letter_1EC7" msgid="9012731468253986792">"E၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EC9" msgid="2901917620195717034">"I၊ အပေါ်မှာ ချိတ်"</string> <string name="spoken_accented_letter_1ECB" msgid="5470387489820034621">"I၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1ECD" msgid="1340122876914839806">"O၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1ECF" msgid="2326921263882559755">"O၊ အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1ED1" msgid="2885683296042774958">"O၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1ED3" msgid="6857664926477376178">"O၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1ED5" msgid="2015209467290624062">"O၊ သရသံသင်္ကေတ နှင့် အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1ED7" msgid="7924481354960306389">"O၊ သရသံသင်္ကေတ နှင့် tilde"</string> - <string name="spoken_accented_letter_1ED9" msgid="7023315590332365554">"O၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> - <string name="spoken_accented_letter_1EDB" msgid="2379438944917634496">"O၊ horn နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1EDD" msgid="8107077534204404085">"O၊ horn နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1EDF" msgid="1846880105528347966">"O၊ horn နှင့် အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EE1" msgid="1520037313389776718">"O၊ horn နှင့် tilde"</string> - <string name="spoken_accented_letter_1EE3" msgid="907964027171008963">"O၊ horn နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1ED1" msgid="2885683296042774958">"O၊ သရသံသင်္ကေတ နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1ED3" msgid="6857664926477376178">"O၊ သရသံသင်္ကေတ နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1ED5" msgid="2015209467290624062">"O၊ သရသံသင်္ကေတ နှင့် အပေါ်မှာ ချိတ်"</string> + <string name="spoken_accented_letter_1ED7" msgid="7924481354960306389">"O၊ သရသံသင်္ကေတ နှင့် tilde"</string> + <string name="spoken_accented_letter_1ED9" msgid="7023315590332365554">"O၊ သရသံသင်္ကေတ နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1EDB" msgid="2379438944917634496">"O၊ horn နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1EDD" msgid="8107077534204404085">"O၊ horn နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1EDF" msgid="1846880105528347966">"O၊ horn နှင့် အပေါ်မှာ ချိတ်"</string> + <string name="spoken_accented_letter_1EE1" msgid="1520037313389776718">"O၊ horn နှင့် tilde"</string> + <string name="spoken_accented_letter_1EE3" msgid="907964027171008963">"O၊ horn နှင့် အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EE5" msgid="1522024630360038700">"U၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EE7" msgid="7815412228302952637">"U၊ အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EE9" msgid="4219119671251485651">"U၊ horn နှင့် စူးရှသော"</string> - <string name="spoken_accented_letter_1EEB" msgid="4086009841269002231">"U၊ horn နှင့် တည်ငြိမ်သော"</string> - <string name="spoken_accented_letter_1EED" msgid="3528151733528719847">"U၊ horn နှင့် အပေါ်မှာ ချိတ်"</string> - <string name="spoken_accented_letter_1EEF" msgid="3508548229409072119">"U၊ horn နှင့် tilde"</string> - <string name="spoken_accented_letter_1EF1" msgid="1912816350401931115">"U၊ horn နှင့် အောက်မှာ အစက်"</string> + <string name="spoken_accented_letter_1EE9" msgid="4219119671251485651">"U၊ horn နှင့် စူးရှသော"</string> + <string name="spoken_accented_letter_1EEB" msgid="4086009841269002231">"U၊ horn နှင့် တည်ငြိမ်သော"</string> + <string name="spoken_accented_letter_1EED" msgid="3528151733528719847">"U၊ horn နှင့် အပေါ်မှာ ချိတ်"</string> + <string name="spoken_accented_letter_1EEF" msgid="3508548229409072119">"U၊ horn နှင့် tilde"</string> + <string name="spoken_accented_letter_1EF1" msgid="1912816350401931115">"U၊ horn နှင့် အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EF3" msgid="7211760439435946494">"Y၊ တည်ငြိမ်သော"</string> <string name="spoken_accented_letter_1EF5" msgid="8998864482764007384">"Y၊ အောက်မှာ အစက်"</string> <string name="spoken_accented_letter_1EF7" msgid="922043627252869200">"Y၊ အပေါ်မှာ ချိတ်"</string> diff --git a/java/res/values-my-rMM/strings-talkback-descriptions.xml b/java/res/values-my-rMM/strings-talkback-descriptions.xml index 08fd19014..a4f84a27a 100644 --- a/java/res/values-my-rMM/strings-talkback-descriptions.xml +++ b/java/res/values-my-rMM/strings-talkback-descriptions.xml @@ -79,7 +79,7 @@ <string name="spoken_emoticon_3A_2D_21_20" msgid="2410905667389534573">"စိတ်ကုန်နေသော မျက်နှာ"</string> <string name="spoken_emoticon_3A_2D_24_20" msgid="2481260475945560438">"ကသိကအောက် မျက်နှာ"</string> <string name="spoken_emoticon_42_2D_29_20" msgid="1063205250387128068">"နေကာမျက်မှန်တပ် မျက်နှာ"</string> - <string name="spoken_emoticon_3A_4F_20" msgid="532695091593447238">"အံ့အားသင့်နေသော မျက်နှာ"</string> + <string name="spoken_emoticon_3A_4F_20" msgid="532695091593447238">"အံ့အားသင့်နေသော မျက်နှာ"</string> <string name="spoken_emoticon_3A_2D_2A_20" msgid="5612342617244114291">"နမ်းနေသော မျက်နှာ"</string> <string name="spoken_emoticon_3A_2D_5B_20" msgid="2223507987759905920">"မှုန်ကုပ်ကုပ် မျက်နှာ"</string> <string name="spoken_open_more_keys_keyboard" msgid="6832897688371903747">"အစားထိုးစရာ စာလုံးများ ရှိနိုင်"</string> diff --git a/java/res/values-my-rMM/strings.xml b/java/res/values-my-rMM/strings.xml index ab4037861..281004670 100644 --- a/java/res/values-my-rMM/strings.xml +++ b/java/res/values-my-rMM/strings.xml @@ -30,11 +30,11 @@ <string name="settings_screen_accounts" msgid="7570397912370223287">"အကောင့်များ & ကိုယ်ပိုင်ကိစ္စ"</string> <string name="settings_screen_appearance" msgid="9153102634339912029">"အပြင်ပန်း & အပြင်အဆင်များ"</string> <string name="settings_screen_multilingual" msgid="1391301621464509659">"ဘာသာစကားစုံ ရွေးချယ်စရာများ"</string> - <string name="settings_screen_gesture" msgid="8826372746901183556">"လှုပ်ရှားမှုဖြင့်စာရိုက်ခြင်း"</string> + <string name="settings_screen_gesture" msgid="8826372746901183556">"လှုပ်ရှားမှုဖြင့်စာရိုက်ခြင်း"</string> <string name="settings_screen_correction" msgid="1616818407747682955">"စာအမှားပြပြင်ခြင်း"</string> - <string name="settings_screen_advanced" msgid="7472408607625972994">"အဆင့်မြင့်"</string> + <string name="settings_screen_advanced" msgid="7472408607625972994">"အဆင့်မြင့်"</string> <string name="settings_screen_theme" msgid="2137262503543943871">"အပြင်အဆင်"</string> - <string name="enable_split_keyboard" msgid="4177264923999493614">"ကီးဘုတ် ခွဲခြမ်းမှု ဖွင့်ထားရန်"</string> + <string name="enable_split_keyboard" msgid="4177264923999493614">"ကီးဘုတ် ခွဲခြမ်းမှု ဖွင့်ထားရန်"</string> <string name="include_other_imes_in_language_switch_list" msgid="4533689960308565519">"အခြားထည့်သွင်းမည့် နည်းလမ်းများသို့ ပြောင်းရန်"</string> <string name="include_other_imes_in_language_switch_list_summary" msgid="840637129103317635">"ဘာသာပြောင်းသည့် ကီးသည် အခြားထည့်သွင်းရန် နည်းလမ်းများလည်း ပါဝင်သည်"</string> <string name="show_language_switch_key" msgid="5915478828318774384">"ဘာသာစကား ပြောင်းခလုတ်"</string> @@ -47,7 +47,7 @@ <string name="use_contacts_dict" msgid="4435317977804180815">"အဆယ်ကသွယ်အမည်များ အကြံပြုမည်"</string> <string name="use_contacts_dict_summary" msgid="6599983334507879959">"အကြံပြုချက်များနှင့် အမှားပြင်ခြင်းများအတွက် အဆက်သွယ်မှ အမည်များ အသုံးပြုမည်"</string> <string name="use_personalized_dicts" msgid="5167396352105467626">"ကိုယ်ရေးကိုယ်တာ အကြံပြုချက်များ"</string> - <string name="enable_metrics_logging" msgid="5506372337118822837">"မြှင့်တင်ပါ <xliff:g id="APPLICATION_NAME">%s</xliff:g>"</string> + <string name="enable_metrics_logging" msgid="5506372337118822837">"မြှင့်တင်ပါ <xliff:g id="APPLICATION_NAME">%s</xliff:g>"</string> <string name="use_double_space_period" msgid="8781529969425082860">"နှစ်နေရာခြား အဆုံးသတ်"</string> <string name="use_double_space_period_summary" msgid="6532892187247952799">"အချိန်ကာလ"</string> <string name="auto_cap" msgid="1719746674854628252">"အော်တိုစာလုံးကြီးပြောင်း"</string> @@ -84,7 +84,7 @@ <string name="hint_add_to_dictionary_without_word" msgid="3040385779511255101">"သိမ်းရန် ဤနေရာကို ထိပါ"</string> <string name="has_dictionary" msgid="6071847973466625007">"အဘိဓါန်ရနိုင်"</string> <string name="keyboard_layout" msgid="8451164783510487501">"ကီးဘုတ်အရောင်"</string> - <string name="switch_accounts" msgid="3321216593719006162">"အကောင့်များကို ပြောင်းရန်"</string> + <string name="switch_accounts" msgid="3321216593719006162">"အကောင့်များကို ပြောင်းရန်"</string> <string name="no_accounts_selected" msgid="2073821619103904330">"အကောင့်များ မရွေးရသေးပါ"</string> <string name="account_selected" msgid="2846876462199625974">"<xliff:g id="EMAIL_ADDRESS">%1$s</xliff:g>အား လတ်တလော သုံးနေ၏"</string> <string name="account_select_ok" msgid="9141195141763227797">"အိုကေ"</string> @@ -156,7 +156,7 @@ <string name="default_user_dict_pref_name" msgid="1625055720489280530">"သုံးစွဲသူ၏ အဘိဓာန်"</string> <string name="dictionary_available" msgid="4728975345815214218">"အဘိဓါန်ရရှိနိုင်"</string> <string name="dictionary_downloading" msgid="2982650524622620983">"လက်ရှိ ဒေါင်းလုပ်လုပ်နေသည်"</string> - <string name="dictionary_installed" msgid="8081558343559342962">"ထည့်သွင်းပြီး"</string> + <string name="dictionary_installed" msgid="8081558343559342962">"ထည့်သွင်းပြီး"</string> <string name="dictionary_disabled" msgid="8950383219564621762">"ထည့်သွင်းထားပြီး၊ ပိတ်ထားသည်"</string> <string name="cannot_connect_to_dict_service" msgid="9216933695765732398">"အဘိဓါန်ဝန်ဆောင်မှုသို့ ချိတ်ဆက်ရန် ပြဿနာရှိနေသည်"</string> <string name="no_dictionaries_available" msgid="8039920716566132611">"အဘိဓါန်မရှိ"</string> @@ -170,7 +170,7 @@ <string name="install_dict" msgid="180852772562189365">"တပ်ဆင်ပါ"</string> <string name="cancel_download_dict" msgid="7843340278507019303">"ထားတော့"</string> <string name="delete_dict" msgid="756853268088330054">"ဖျက်ရန်"</string> - <string name="should_download_over_metered_prompt" msgid="1583881200688185508">"သင့်ဖုန်းရှိ ရွေးချယ်ထားသည့် ဘာသာအတွက် အဘိဓါန်ရှိပါသည်။ <br/> အဘိဓါန်အား <b>ဒေါင်းလုပ်လုပ်ကာ</b> the <xliff:g id="LANGUAGE_NAME">%1$s</xliff:g> သင့်စာရိုက် အတွေ့အကြုံတိုးတက်စေရန် ကျွန်ုပ်တို့အကြံပြုပါသည်။ <br/> <br/> ဒေါင်းလုပ်လုပ်ရန် 3G ပေါ်တွင် ၁ မှ ၂ မိနစ်ခန့်ကြာနိုင်သည်။ သင့်တွင် <b>အကန့်သတ်မှရိ အချက်လက် သုံးစွဲမှု</b>မရှိလျှင် ငွေကျသင့်နိုင်ပါသည်။ <br/> သင့်တွင် မည်သည့်အချက်လက်သုံးစွဲမှု ရှိနေသည်ကိုမသိလျှင်၊ အလိုအလျောက် ဒေါင်းလုပ်လုပ်ရန် Wi-Fi ကွန်ရက်တစ်ခု ရှာဖွေရန် တိုက်တွန်းပါသည်။ <br/> <br/> နည်းလမ်း: သင့်ဖုန်းကိရိယာရှိ <b>ဆက်တင်ထဲတွင်</b> <b>ဘာသာ & စာရိုက်ထည့်မှု</b> သို့သွားကာ အဘိဓါန်များကို ဒေါင်းလုပ်လုပ်နိုင် ဖယ်ရှားနိုင်ပါသည်။"</string> + <string name="should_download_over_metered_prompt" msgid="1583881200688185508">"သင့်ဖုန်းရှိ ရွေးချယ်ထားသည့် ဘာသာအတွက် အဘိဓါန်ရှိပါသည်။ <br/> အဘိဓါန်အား <b>ဒေါင်းလုပ်လုပ်ကာ</b> the <xliff:g id="LANGUAGE_NAME">%1$s</xliff:g> သင့်စာရိုက် အတွေ့အကြုံတိုးတက်စေရန် ကျွန်ုပ်တို့အကြံပြုပါသည်။ <br/> <br/> ဒေါင်းလုပ်လုပ်ရန် 3G ပေါ်တွင် ၁ မှ ၂ မိနစ်ခန့်ကြာနိုင်သည်။ သင့်တွင် <b>အကန့်သတ်မှရိ အချက်လက် သုံးစွဲမှု</b>မရှိလျှင် ငွေကျသင့်နိုင်ပါသည်။ <br/> သင့်တွင် မည်သည့်အချက်လက်သုံးစွဲမှု ရှိနေသည်ကိုမသိလျှင်၊ အလိုအလျောက် ဒေါင်းလုပ်လုပ်ရန် Wi-Fi ကွန်ရက်တစ်ခု ရှာဖွေရန် တိုက်တွန်းပါသည်။ <br/> <br/> နည်းလမ်း: သင့်ဖုန်းကိရိယာရှိ <b>ဆက်တင်ထဲတွင်</b> <b>ဘာသာ & စာရိုက်ထည့်မှု</b> သို့သွားကာ အဘိဓါန်များကို ဒေါင်းလုပ်လုပ်နိုင် ဖယ်ရှားနိုင်ပါသည်။"</string> <string name="download_over_metered" msgid="1643065851159409546">"ယခုဒေါင်းလုပ်လုပ်မည် (<xliff:g id="SIZE_IN_MEGABYTES">%1$.1f</xliff:g>MB)"</string> <string name="do_not_download_over_metered" msgid="2176209579313941583">"Wi-Fi အသုံးပြု၍ ဒေါင်းလုပ်လုပ်ရန်"</string> <string name="dict_available_notification_title" msgid="4583842811218581658">"<xliff:g id="LANGUAGE_NAME">%1$s</xliff:g> အတွက် အဘိဓါန် ရနိုင်ပါသည်"</string> @@ -191,7 +191,7 @@ <string name="user_dict_settings_edit_dialog_title" msgid="3765774633869590352">"စာလုံးကို ပြင်ဆင်မည်"</string> <string name="user_dict_settings_context_menu_edit_title" msgid="6812255903472456302">"တည်းဖြတ်ရန်"</string> <string name="user_dict_settings_context_menu_delete_title" msgid="8142932447689461181">"ဖျက်ရန်"</string> - <string name="user_dict_settings_empty_text" msgid="558499587532668203">"သင့်အဘိဓာန်ထဲတွင် မည်သည့်စာလုံးမှမရှိပါ။ ထပ်ထည့်ခြင်း(+)ခလုတ်ကို ထိ၍ စာလုံးထည့်ပါ။"</string> + <string name="user_dict_settings_empty_text" msgid="558499587532668203">"သင့်အဘိဓာန်ထဲတွင် မည်သည့်စာလုံးမှမရှိပါ။ ထပ်ထည့်ခြင်း(+)ခလုတ်ကို ထိ၍ စာလုံးထည့်ပါ။"</string> <string name="user_dict_settings_all_languages" msgid="8276126583216298886">"ဘာသာစကားအားလုံးအတွက်"</string> <string name="user_dict_settings_more_languages" msgid="7131268499685180461">"ဘာသာစကားပိုများများ…"</string> <string name="user_dict_settings_delete" msgid="110413335187193859">"ဖျက်သိမ်းရန်"</string> diff --git a/java/res/values-v19/spinner-style.xml b/java/res/values-v19/spinner-style.xml new file mode 100644 index 000000000..7de59edf3 --- /dev/null +++ b/java/res/values-v19/spinner-style.xml @@ -0,0 +1,28 @@ +<?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"> + <!-- Until KitKat (API 19), {@link android.widget.Spinner} of dialog mode in a Dialog can't + handle orientation change correctly. Using dropdown mode avoids the issue. + This file overrides values/spinner-style.xml on KitKat and newer device. --> + <style name="additionalSubtypeSpinnerStyle"> + <item name="android:spinnerMode">dialog</item> + </style> +</resources> diff --git a/java/res/values/config-auto-correction-thresholds.xml b/java/res/values/config-auto-correction-thresholds.xml index 7d94a42a4..fc701c7ff 100644 --- a/java/res/values/config-auto-correction-thresholds.xml +++ b/java/res/values/config-auto-correction-thresholds.xml @@ -34,6 +34,12 @@ <item>floatNegativeInfinity</item> </string-array> + <!-- Chosen to be slightly less than the "aggressive" threshold. This is the threshold for + a mildly plausible suggestion given the input; if no "plausible" suggestion is present + for a language, it's a strong indicator the user is not typing in this language, so we + may be more forgiving of whitelist entries in another language. --> + <string name="plausibility_threshold" translatable="false">0.065</string> + <!-- The index of the auto correction threshold values array. --> <string name="auto_correction_threshold_mode_index_off" translatable="false">0</string> <string name="auto_correction_threshold_mode_index_modest" translatable="false">1</string> diff --git a/java/res/values/spinner-style.xml b/java/res/values/spinner-style.xml new file mode 100644 index 000000000..4043ad49c --- /dev/null +++ b/java/res/values/spinner-style.xml @@ -0,0 +1,28 @@ +<?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"> + <!-- Until KitKat (API 19), {@link android.widget.Spinner} of dialog mode in a Dialog can't + handle orientation change correctly. Using dropdown mode avoids the issue. + This file is overridden by values-v19/spinner-style.xml on KitKat and newer device. --> + <style name="additionalSubtypeSpinnerStyle"> + <item name="android:spinnerMode">dropdown</item> + </style> +</resources> diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index 006cda370..ea8f29250 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -35,10 +35,6 @@ latin:keyLabelFlags="hasShiftedLetterHint" /> </default> </switch> - <!-- Base key style for the key which may have settings key as more keys. --> - <key-style - latin:styleName="baseSettingsMoreKeysStyle" - latin:parentStyle="hasShiftedLetterHintStyle" /> <include latin:keyboardLayout="@xml/key_styles_settings" /> <!-- Functional key styles --> diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index b36ddf236..d85438d99 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -35,9 +35,6 @@ latin:keyLabelFlags="hasShiftedLetterHint" /> </default> </switch> - <!-- Base key style for the key which may have settings key as more keys. --> - <key-style - latin:styleName="baseSettingsMoreKeysStyle" /> <include latin:keyboardLayout="@xml/key_styles_settings" /> <!-- Functional key styles --> diff --git a/java/res/xml/key_styles_settings.xml b/java/res/xml/key_styles_settings.xml index a504bed78..43ee601e6 100644 --- a/java/res/xml/key_styles_settings.xml +++ b/java/res/xml/key_styles_settings.xml @@ -21,16 +21,14 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <!-- Base key style for the key which may have settings key as more keys. --> - <!-- Kept as a separate file for cleaner overriding by an overlay. --> + <!-- Key style for the key which may have settings key as more keys. --> <switch> <case latin:clobberSettingsKey="true" > <key-style latin:styleName="settingsMoreKeysStyle" - latin:backgroundType="functional" - latin:parentStyle="baseSettingsMoreKeysStyle" /> + latin:backgroundType="functional" /> </case> <!-- clobberSettingsKey="false" --> <default> @@ -38,8 +36,7 @@ latin:styleName="settingsMoreKeysStyle" latin:keyLabelFlags="hasPopupHint" latin:additionalMoreKeys="!text/keyspec_settings" - latin:backgroundType="functional" - latin:parentStyle="baseSettingsMoreKeysStyle" /> + latin:backgroundType="functional" /> </default> </switch> </merge> diff --git a/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java index 94a1ee6eb..e80982fc7 100644 --- a/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java @@ -269,13 +269,9 @@ public final class MainKeyboardAccessibilityDelegate eventTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0 /* metaState */); // Inject a fake down event to {@link PointerTracker} to handle a long press correctly. tracker.processMotionEvent(downEvent, mKeyDetector); - // The above fake down event triggers an unnecessary long press timer that should be - // canceled. - tracker.cancelLongPressTimer(); downEvent.recycle(); - // Invoke {@link MainKeyboardView#onLongPress(PointerTracker)} as if a long press timeout - // has passed. - mKeyboardView.onLongPress(tracker); + // Invoke {@link PointerTracker#onLongPressed()} as if a long press timeout has passed. + tracker.onLongPressed(); // If {@link Key#hasNoPanelAutoMoreKeys()} is true (such as "0 +" key on the phone layout) // or a key invokes IME switcher dialog, we should just ignore the next // {@link #onRegisterHoverKey(Key,MotionEvent)}. It can be determined by whether diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java index be0744393..c38ea0037 100644 --- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java +++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java @@ -118,11 +118,7 @@ public final class SuggestionSpanUtils { if (TextUtils.isEmpty(localeString)) { continue; } - final Locale locale = LocaleUtils.constructLocaleFromString(localeString); - if (locale == null) { - continue; - } - return locale; + return LocaleUtils.constructLocaleFromString(localeString); } return null; } diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java index e6acb8f36..c678f081d 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java @@ -22,6 +22,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; +import android.util.Log; import android.widget.Toast; import com.android.inputmethod.latin.R; @@ -33,6 +34,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; + /** * Service that handles background tasks for the dictionary provider. * @@ -51,6 +54,8 @@ import java.util.concurrent.TimeUnit; * to access, and mark the current state as such. */ public final class DictionaryService extends Service { + private static final String TAG = DictionaryService.class.getSimpleName(); + /** * The package name, to use in the intent actions. */ @@ -156,9 +161,14 @@ public final class DictionaryService extends Service { final int startId) { final DictionaryService self = this; if (SHOW_DOWNLOAD_TOAST_INTENT_ACTION.equals(intent.getAction())) { - // This is a UI action, it can't be run in another thread - showStartDownloadingToast(this, LocaleUtils.constructLocaleFromString( - intent.getStringExtra(LOCALE_INTENT_ARGUMENT))); + final String localeString = intent.getStringExtra(LOCALE_INTENT_ARGUMENT); + if (localeString == null) { + Log.e(TAG, "Received " + intent.getAction() + " without locale; skipped"); + } else { + // This is a UI action, it can't be run in another thread + showStartDownloadingToast( + this, LocaleUtils.constructLocaleFromString(localeString)); + } } else { // If it's a command that does not require UI, arrange for the work to be done on a // separate thread, so that we can return right away. The executor will spawn a thread @@ -245,7 +255,8 @@ public final class DictionaryService extends Service { /** * Shows a toast informing the user that an automatic dictionary download is starting. */ - private static void showStartDownloadingToast(final Context context, final Locale locale) { + private static void showStartDownloadingToast(final Context context, + @Nonnull final Locale locale) { final String toastText = String.format( context.getString(R.string.toast_downloading_suggestions), locale.getDisplayName()); diff --git a/java/src/com/android/inputmethod/dictionarypack/DownloadOverMeteredDialog.java b/java/src/com/android/inputmethod/dictionarypack/DownloadOverMeteredDialog.java index 50b3c72f3..91ed673ae 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DownloadOverMeteredDialog.java +++ b/java/src/com/android/inputmethod/dictionarypack/DownloadOverMeteredDialog.java @@ -28,7 +28,7 @@ import com.android.inputmethod.annotations.ExternallyReferenced; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.common.LocaleUtils; -import java.util.Locale; +import javax.annotation.Nullable; /** * This implements the dialog for asking the user whether it's okay to download dictionaries over @@ -54,11 +54,11 @@ public final class DownloadOverMeteredDialog extends Activity { setTexts(localeString, size); } - private void setTexts(final String localeString, final long size) { + private void setTexts(@Nullable final String localeString, final long size) { final String promptFormat = getString(R.string.should_download_over_metered_prompt); final String allowButtonFormat = getString(R.string.download_over_metered); - final Locale locale = LocaleUtils.constructLocaleFromString(localeString); - final String language = (null == locale ? "" : locale.getDisplayLanguage()); + final String language = (null == localeString) ? "" + : LocaleUtils.constructLocaleFromString(localeString).getDisplayLanguage(); final TextView prompt = (TextView)findViewById(R.id.download_over_metered_prompt); prompt.setText(Html.fromHtml(String.format(promptFormat, language))); final Button allowButton = (Button)findViewById(R.id.allow_button); diff --git a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java index aeb666704..f05db9dab 100644 --- a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java +++ b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java @@ -57,7 +57,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.Locale; import java.util.Set; import java.util.TreeSet; @@ -880,8 +879,8 @@ public final class UpdateHandler { // None of those are expected to happen, but just in case... if (null == notificationIntent || null == notificationManager) return; - final Locale locale = LocaleUtils.constructLocaleFromString(localeString); - final String language = (null == locale ? "" : locale.getDisplayLanguage()); + final String language = (null == localeString) ? "" + : LocaleUtils.constructLocaleFromString(localeString).getDisplayLanguage(); final String titleFormat = context.getString(R.string.dict_available_notification_title); final String notificationTitle = String.format(titleFormat, language); final Notification.Builder builder = new Notification.Builder(context) diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 06e552e3d..d1db3d4c5 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -43,6 +43,9 @@ import com.android.inputmethod.latin.common.StringUtils; import java.util.Arrays; import java.util.Locale; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Class for describing the position and characteristics of a single key in the keyboard. */ @@ -113,9 +116,11 @@ public class Key implements Comparable<Key> { /** Y coordinate of the top-left corner of the key in the keyboard layout, excluding the gap. */ private final int mY; /** Hit bounding box of the key */ + @Nonnull private final Rect mHitBox = new Rect(); /** More keys. It is guaranteed that this is null or an array of one or more elements */ + @Nullable private final MoreKeySpec[] mMoreKeys; /** More keys column number and flags */ private final int mMoreKeysColumnAndFlags; @@ -158,8 +163,9 @@ public class Key implements Comparable<Key> { private static final int ACTION_FLAGS_ALT_CODE_WHILE_TYPING = 0x04; private static final int ACTION_FLAGS_ENABLE_LONG_PRESS = 0x08; + @Nullable private final KeyVisualAttributes mKeyVisualAttributes; - + @Nullable private final OptionalAttributes mOptionalAttributes; private static final class OptionalAttributes { @@ -181,6 +187,7 @@ public class Key implements Comparable<Key> { mVisualInsetsRight = visualInsetsRight; } + @Nullable public static OptionalAttributes newInstance(final String outputText, final int altCode, final int disabledIconId, final int visualInsetsLeft, final int visualInsetsRight) { if (outputText == null && altCode == CODE_UNSPECIFIED @@ -204,10 +211,10 @@ public class Key implements Comparable<Key> { * Constructor for a key on <code>MoreKeyKeyboard</code>, on <code>MoreSuggestions</code>, * and in a <GridRows/>. */ - public Key(final String label, final int iconId, final int code, final String outputText, - final String hintLabel, final int labelFlags, final int backgroundType, final int x, - final int y, final int width, final int height, final int horizontalGap, - final int verticalGap) { + public Key(@Nullable final String label, final int iconId, final int code, + @Nullable final String outputText, @Nullable final String hintLabel, + final int labelFlags, final int backgroundType, final int x, final int y, + final int width, final int height, final int horizontalGap, final int verticalGap) { mWidth = width - horizontalGap; mHeight = height - verticalGap; mHorizontalGap = horizontalGap; @@ -245,8 +252,9 @@ public class Key implements Comparable<Key> { * @param row the row that this key belongs to. row's x-coordinate will be the right edge of * this key. */ - public Key(final String keySpec, final TypedArray keyAttr, final KeyStyle style, - final KeyboardParams params, final KeyboardRow row) { + public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr, + @Nonnull final KeyStyle style, @Nonnull final KeyboardParams params, + @Nonnull final KeyboardRow row) { mHorizontalGap = isSpacer() ? 0 : params.mHorizontalGap; mVerticalGap = params.mVerticalGap; @@ -403,11 +411,11 @@ public class Key implements Comparable<Key> { * * @param key the original key. */ - protected Key(final Key key) { + protected Key(@Nonnull final Key key) { this(key, key.mMoreKeys); } - private Key(final Key key, final MoreKeySpec[] moreKeys) { + private Key(@Nonnull final Key key, @Nullable final MoreKeySpec[] moreKeys) { // Final attributes. mCode = key.mCode; mLabel = key.mLabel; @@ -433,8 +441,9 @@ public class Key implements Comparable<Key> { mEnabled = key.mEnabled; } - public static Key removeRedundantMoreKeys(final Key key, - final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout) { + @Nonnull + public static Key removeRedundantMoreKeys(@Nonnull final Key key, + @Nonnull final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout) { final MoreKeySpec[] moreKeys = key.getMoreKeys(); final MoreKeySpec[] filteredMoreKeys = MoreKeySpec.removeRedundantMoreKeys( moreKeys, lettersOnBaseLayout); @@ -554,14 +563,17 @@ public class Key implements Comparable<Key> { return mCode; } + @Nullable public String getLabel() { return mLabel; } + @Nullable public String getHintLabel() { return mHintLabel; } + @Nullable public MoreKeySpec[] getMoreKeys() { return mMoreKeys; } @@ -620,6 +632,7 @@ public class Key implements Comparable<Key> { return mKeyVisualAttributes; } + @Nonnull public final Typeface selectTypeface(final KeyDrawParams params) { switch (mLabelFlags & LABEL_FLAGS_FONT_MASK) { case LABEL_FLAGS_FONT_NORMAL: @@ -696,6 +709,7 @@ public class Key implements Comparable<Key> { return params.mLetterSize; } + @Nonnull public Typeface selectPreviewTypeface(final KeyDrawParams params) { if (previewHasLetterSize()) { return selectTypeface(params); @@ -780,6 +794,7 @@ public class Key implements Comparable<Key> { return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY) != 0; } + @Nullable public final String getOutputText() { final OptionalAttributes attrs = mOptionalAttributes; return (attrs != null) ? attrs.mOutputText : null; @@ -794,6 +809,7 @@ public class Key implements Comparable<Key> { return mIconId; } + @Nullable public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) { final OptionalAttributes attrs = mOptionalAttributes; final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED; @@ -805,6 +821,7 @@ public class Key implements Comparable<Key> { return icon; } + @Nullable public Drawable getPreviewIcon(final KeyboardIconsSet iconSet) { return iconSet.getIconDrawable(getIconId()); } @@ -897,6 +914,7 @@ public class Key implements Comparable<Key> { mEnabled = enabled; } + @Nonnull public Rect getHitBox() { return mHitBox; } @@ -968,8 +986,10 @@ public class Key implements Comparable<Key> { * @return the background drawable of the key. * @see android.graphics.drawable.StateListDrawable#setState(int[]) */ - public final Drawable selectBackgroundDrawable(final Drawable keyBackground, - final Drawable functionalKeyBackground, final Drawable spacebarBackground) { + @Nonnull + public final Drawable selectBackgroundDrawable(@Nonnull final Drawable keyBackground, + @Nonnull final Drawable functionalKeyBackground, + @Nonnull final Drawable spacebarBackground) { final Drawable background; if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) { background = functionalKeyBackground; diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 619b801f4..2055a59bb 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -28,6 +28,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard * consists of rows of keys. @@ -47,6 +50,7 @@ import java.util.List; * </pre> */ public class Keyboard { + @Nonnull public final KeyboardId mId; public final int mThemeId; @@ -78,17 +82,22 @@ public class Keyboard { public final int mMaxMoreKeysKeyboardColumn; /** List of keys in this keyboard */ + @Nonnull private final List<Key> mSortedKeys; + @Nonnull public final List<Key> mShiftKeys; + @Nonnull public final List<Key> mAltCodeKeysWhileTyping; + @Nonnull public final KeyboardIconsSet mIconsSet; private final SparseArray<Key> mKeyCache = new SparseArray<>(); + @Nonnull private final ProximityInfo mProximityInfo; private final boolean mProximityCharsCorrectionEnabled; - public Keyboard(final KeyboardParams params) { + public Keyboard(@Nonnull final KeyboardParams params) { mId = params.mId; mThemeId = params.mThemeId; mOccupiedHeight = params.mOccupiedHeight; @@ -114,7 +123,7 @@ public class Keyboard { mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled; } - protected Keyboard(final Keyboard keyboard) { + protected Keyboard(@Nonnull final Keyboard keyboard) { mId = keyboard.mId; mThemeId = keyboard.mThemeId; mOccupiedHeight = keyboard.mOccupiedHeight; @@ -150,6 +159,7 @@ public class Keyboard { return canAssumeNativeHasProximityCharsInfoOfAllKeys || Character.isLetter(code); } + @Nonnull public ProximityInfo getProximityInfo() { return mProximityInfo; } @@ -160,10 +170,12 @@ public class Keyboard { * The list may contain {@link Key.Spacer} object as well. * @return the sorted unmodifiable list of {@link Key}s of this keyboard. */ + @Nonnull public List<Key> getSortedKeys() { return mSortedKeys; } + @Nullable public Key getKey(final int code) { if (code == Constants.CODE_UNSPECIFIED) { return null; @@ -185,7 +197,7 @@ public class Keyboard { } } - public boolean hasKey(final Key aKey) { + public boolean hasKey(@Nonnull final Key aKey) { if (mKeyCache.indexOfValue(aKey) >= 0) { return true; } @@ -211,6 +223,7 @@ public class Keyboard { * @return the list of the nearest keys to the given point. If the given * point is out of range, then an array of size zero is returned. */ + @Nonnull public List<Key> getNearestKeys(final int x, final int y) { // Avoid dead pixels at edges of the keyboard final int adjustedX = Math.max(0, Math.min(x, mOccupiedWidth - 1)); @@ -218,7 +231,8 @@ public class Keyboard { return mProximityInfo.getNearestKeys(adjustedX, adjustedY); } - public int[] getCoordinates(final int[] codePoints) { + @Nonnull + public int[] getCoordinates(@Nonnull final int[] codePoints) { final int length = codePoints.length; final int[] coordinates = CoordinateUtils.newCoordinateArray(length); for (int i = 0; i < length; ++i) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index b1051385d..5d9b8a712 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -72,6 +72,7 @@ public final class KeyboardLayoutSet { private static final String KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX = "keyboard_layout_set_"; private final Context mContext; + @Nonnull private final Params mParams; // How many layouts we forcibly keep in cache. This only includes ALPHABET (default) and @@ -84,6 +85,7 @@ public final class KeyboardLayoutSet { private static final Keyboard[] sForcibleKeyboardCache = new Keyboard[FORCIBLE_CACHE_SIZE]; private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache = new HashMap<>(); + @Nonnull private static final KeysCache sKeysCache = new KeysCache(); private final static HashMap<InputMethodSubtype, Integer> sScriptIdsForSubtypes = new HashMap<>(); @@ -145,7 +147,8 @@ public final class KeyboardLayoutSet { sKeysCache.clear(); } - public static int getScriptId(final Resources resources, final InputMethodSubtype subtype) { + public static int getScriptId(final Resources resources, + @Nonnull final InputMethodSubtype subtype) { final Integer value = sScriptIdsForSubtypes.get(subtype); if (null == value) { final int scriptId = Builder.readScriptId(resources, subtype); @@ -155,11 +158,12 @@ public final class KeyboardLayoutSet { return value; } - KeyboardLayoutSet(final Context context, final Params params) { + KeyboardLayoutSet(final Context context, @Nonnull final Params params) { mContext = context; mParams = params; } + @Nonnull public Keyboard getKeyboard(final int baseKeyboardLayoutSetElementId) { final int keyboardLayoutSetElementId; switch (mParams.mMode) { @@ -203,6 +207,7 @@ public final class KeyboardLayoutSet { } } + @Nonnull private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) { final SoftReference<Keyboard> ref = sKeyboardCache.get(id); final Keyboard cachedKeyboard = (ref == null) ? null : ref.get(); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 01980ea6e..27e538cb7 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -103,7 +103,8 @@ public class KeyboardView extends View { // TODO: Consider having a dummy keyboard object to make this @Nonnull @Nullable private Keyboard mKeyboard; - protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams(); + @Nonnull + private final KeyDrawParams mKeyDrawParams = new KeyDrawParams(); // Drawing /** True if all keys should be drawn */ @@ -120,6 +121,7 @@ public class KeyboardView extends View { @Nonnull private final Paint mPaint = new Paint(); private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); + public KeyboardView(final Context context, final AttributeSet attrs) { this(context, attrs, R.attr.keyboardViewStyle); } @@ -210,6 +212,11 @@ public class KeyboardView extends View { return mVerticalCorrection; } + @Nonnull + protected KeyDrawParams getKeyDrawParams() { + return mKeyDrawParams; + } + protected void updateKeyDrawParams(final int keyHeight) { mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes); } diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 06b87bd9a..eeac4755d 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -461,12 +461,17 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy windowContentView.addView(mDrawingPreviewPlacerView); } + // Implements {@link DrawingProxy#onKeyPressed(Key,boolean)}. @Override - public void showKeyPreview(@Nonnull final Key key) { - // If the key is invalid or has no key preview, we must not show key preview. - if (key.noKeyPreview()) { - return; + public void onKeyPressed(@Nonnull final Key key, final boolean withPreview) { + key.onPressed(); + invalidateKey(key); + if (withPreview && !key.noKeyPreview()) { + showKeyPreview(key); } + } + + private void showKeyPreview(@Nonnull final Key key) { final Keyboard keyboard = getKeyboard(); if (keyboard == null) { return; @@ -479,19 +484,30 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy locatePreviewPlacerView(); getLocationInWindow(mOriginCoords); - mKeyPreviewChoreographer.placeAndShowKeyPreview(key, keyboard.mIconsSet, mKeyDrawParams, + mKeyPreviewChoreographer.placeAndShowKeyPreview(key, keyboard.mIconsSet, getKeyDrawParams(), getWidth(), mOriginCoords, mDrawingPreviewPlacerView, isHardwareAccelerated()); } - // Implements {@link DrawingProxy#dismissKeyPreviewWithoutDelay(Key)}. - @Override - public void dismissKeyPreviewWithoutDelay(@Nonnull final Key key) { + private void dismissKeyPreviewWithoutDelay(@Nonnull final Key key) { mKeyPreviewChoreographer.dismissKeyPreview(key, false /* withAnimation */); invalidateKey(key); } + // Implements {@link DrawingProxy#onKeyReleased(Key,boolean)}. @Override - public void dismissKeyPreview(@Nonnull final Key key) { + public void onKeyReleased(@Nonnull final Key key, final boolean withAnimation) { + key.onReleased(); + invalidateKey(key); + if (!key.noKeyPreview()) { + if (withAnimation) { + dismissKeyPreview(key); + } else { + dismissKeyPreviewWithoutDelay(key); + } + } + } + + private void dismissKeyPreview(@Nonnull final Key key) { if (isHardwareAccelerated()) { mKeyPreviewChoreographer.dismissKeyPreview(key, true /* withAnimation */); return; @@ -574,7 +590,11 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy mDrawingPreviewPlacerView.removeAllViews(); } - private MoreKeysPanel onCreateMoreKeysPanel(final Key key, final Context context) { + // Implements {@link DrawingProxy@showMoreKeysKeyboard(Key,PointerTracker)}. + @Override + @Nullable + public MoreKeysPanel showMoreKeysKeyboard(@Nonnull final Key key, + @Nonnull final PointerTracker tracker) { final MoreKeySpec[] moreKeys = key.getMoreKeys(); if (moreKeys == null) { return null; @@ -590,7 +610,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy && !key.noKeyPreview() && moreKeys.length == 1 && mKeyPreviewDrawParams.getVisibleWidth() > 0; final MoreKeysKeyboard.Builder builder = new MoreKeysKeyboard.Builder( - context, key, getKeyboard(), isSingleMoreKeyWithPreview, + getContext(), key, getKeyboard(), isSingleMoreKeyWithPreview, mKeyPreviewDrawParams.getVisibleWidth(), mKeyPreviewDrawParams.getVisibleHeight(), newLabelPaint(key)); moreKeysKeyboard = builder.build(); @@ -603,50 +623,6 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy (MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view); moreKeysKeyboardView.setKeyboard(moreKeysKeyboard); container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - return moreKeysKeyboardView; - } - - // Implements {@link DrawingProxy@onLongPress(PointerTracker)}. - /** - * Called when a key is long pressed. - * @param tracker the pointer tracker which pressed the parent key - */ - @Override - public void onLongPress(@Nonnull final PointerTracker tracker) { - if (isShowingMoreKeysPanel()) { - return; - } - final Key key = tracker.getKey(); - if (key == null) { - return; - } - final KeyboardActionListener listener = mKeyboardActionListener; - if (key.hasNoPanelAutoMoreKey()) { - final int moreKeyCode = key.getMoreKeys()[0].mCode; - tracker.onLongPressed(); - listener.onPressKey(moreKeyCode, 0 /* repeatCount */, true /* isSinglePointer */); - listener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, - Constants.NOT_A_COORDINATE, false /* isKeyRepeat */); - listener.onReleaseKey(moreKeyCode, false /* withSliding */); - return; - } - final int code = key.getCode(); - if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) { - // Long pressing the space key invokes IME switcher dialog. - if (listener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) { - tracker.onLongPressed(); - listener.onReleaseKey(code, false /* withSliding */); - return; - } - } - openMoreKeysPanel(key, tracker); - } - - private void openMoreKeysPanel(final Key key, final PointerTracker tracker) { - final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext()); - if (moreKeysPanel == null) { - return; - } final int[] lastCoords = CoordinateUtils.newInstance(); tracker.getLastCoordinates(lastCoords); @@ -664,10 +640,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy // {@code mPreviewVisibleOffset} has been set appropriately in // {@link KeyboardView#showKeyPreview(PointerTracker)}. final int pointY = key.getY() + mKeyPreviewDrawParams.getVisibleOffset(); - moreKeysPanel.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener); - tracker.onShowMoreKeysPanel(moreKeysPanel); - // TODO: Implement zoom in animation of more keys panel. - mKeyPreviewChoreographer.dismissKeyPreview(key, false /* withAnimation */); + moreKeysKeyboardView.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener); + return moreKeysKeyboardView; } public boolean isInDraggingFinger() { @@ -895,13 +869,16 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy } private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) { + final Keyboard keyboard = getKeyboard(); + if (keyboard == null) { + return; + } final int width = key.getWidth(); final int height = key.getHeight(); paint.setTextAlign(Align.CENTER); paint.setTypeface(Typeface.DEFAULT); paint.setTextSize(mLanguageOnSpacebarTextSize); - final RichInputMethodSubtype subtype = getKeyboard().mId.mSubtype; - final String language = layoutLanguageOnSpacebar(paint, subtype, width); + final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width); // Draw language text with shadow final float descent = paint.descent(); final float textHeight = -paint.ascent() + descent; diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java index f0de86ff9..a021e5e2d 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java @@ -27,6 +27,8 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.utils.TypefaceUtils; +import javax.annotation.Nonnull; + public final class MoreKeysKeyboard extends Keyboard { private final int mDefaultKeyCoordX; @@ -328,6 +330,7 @@ public final class MoreKeysKeyboard extends Keyboard { } @Override + @Nonnull public MoreKeysKeyboard build() { final MoreKeysKeyboardParams params = mParams; final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags(); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 7902ce852..9764cb389 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -222,7 +222,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, final int trackersSize = sTrackers.size(); for (int i = 0; i < trackersSize; ++i) { final PointerTracker tracker = sTrackers.get(i); - tracker.setReleasedKeyGraphics(tracker.getKey()); + tracker.setReleasedKeyGraphics(tracker.getKey(), true /* withAnimation */); } } @@ -382,19 +382,17 @@ public final class PointerTracker implements PointerTrackerQueue.Element, return mKeyDetector.detectHitKey(x, y); } - private void setReleasedKeyGraphics(@Nullable final Key key) { + private void setReleasedKeyGraphics(@Nullable final Key key, final boolean withAnimation) { if (key == null) { return; } - sDrawingProxy.dismissKeyPreview(key); - // Even if the key is disabled, update the key release graphics just in case. - updateReleaseKeyGraphics(key); + sDrawingProxy.onKeyReleased(key, withAnimation); if (key.isShift()) { for (final Key shiftKey : mKeyboard.mShiftKeys) { if (shiftKey != key) { - updateReleaseKeyGraphics(shiftKey); + sDrawingProxy.onKeyReleased(shiftKey, false /* withAnimation */); } } } @@ -403,11 +401,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element, final int altCode = key.getAltCode(); final Key altKey = mKeyboard.getKey(altCode); if (altKey != null) { - updateReleaseKeyGraphics(altKey); + sDrawingProxy.onKeyReleased(altKey, false /* withAnimation */); } for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) { if (k != key && k.getAltCode() == altCode) { - updateReleaseKeyGraphics(k); + sDrawingProxy.onKeyReleased(k, false /* withAnimation */); } } } @@ -418,7 +416,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, return sTypingTimeRecorder.needsToSuppressKeyPreviewPopup(eventTime); } - private void setPressedKeyGraphics(final Key key, final long eventTime) { + private void setPressedKeyGraphics(@Nullable final Key key, final long eventTime) { if (key == null) { return; } @@ -430,15 +428,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element, return; } - if (!key.noKeyPreview() && !sInGesture && !needsToSuppressKeyPreviewPopup(eventTime)) { - sDrawingProxy.showKeyPreview(key); - } - updatePressKeyGraphics(key); + final boolean noKeyPreview = sInGesture || needsToSuppressKeyPreviewPopup(eventTime); + sDrawingProxy.onKeyPressed(key, !noKeyPreview); if (key.isShift()) { for (final Key shiftKey : mKeyboard.mShiftKeys) { if (shiftKey != key) { - updatePressKeyGraphics(shiftKey); + sDrawingProxy.onKeyPressed(shiftKey, false /* withPreview */); } } } @@ -447,26 +443,16 @@ public final class PointerTracker implements PointerTrackerQueue.Element, final int altCode = key.getAltCode(); final Key altKey = mKeyboard.getKey(altCode); if (altKey != null) { - updatePressKeyGraphics(altKey); + sDrawingProxy.onKeyPressed(altKey, false /* withPreview */); } for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) { if (k != key && k.getAltCode() == altCode) { - updatePressKeyGraphics(k); + sDrawingProxy.onKeyPressed(k, false /* withPreview */); } } } } - private static void updateReleaseKeyGraphics(final Key key) { - key.onReleased(); - sDrawingProxy.invalidateKey(key); - } - - private static void updatePressKeyGraphics(final Key key) { - key.onPressed(); - sDrawingProxy.invalidateKey(key); - } - public GestureStrokeDrawingPoints getGestureStrokeDrawingPoints() { return mGestureStrokeDrawingPoints; } @@ -837,7 +823,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, } private void processDraggingFingerOutFromOldKey(final Key oldKey) { - setReleasedKeyGraphics(oldKey); + setReleasedKeyGraphics(oldKey, true /* withAnimation */); callListenerOnRelease(oldKey, oldKey.getCode(), true /* withSliding */); startKeySelectionByDraggingFinger(oldKey); sTimerProxy.cancelKeyTimersOf(this); @@ -880,12 +866,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element, } onUpEvent(x, y, eventTime); cancelTrackingForAction(); - setReleasedKeyGraphics(oldKey); + setReleasedKeyGraphics(oldKey, true /* withAnimation */); } else { if (!mIsDetectingGesture) { cancelTrackingForAction(); } - setReleasedKeyGraphics(oldKey); + setReleasedKeyGraphics(oldKey, true /* withAnimation */); } } @@ -913,7 +899,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, onGestureMoveEvent(x, y, eventTime, true /* isMajorEvent */, newKey); if (sInGesture) { mCurrentKey = null; - setReleasedKeyGraphics(oldKey); + setReleasedKeyGraphics(oldKey, true /* withAnimation */); return; } } @@ -978,7 +964,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, final int currentRepeatingKeyCode = mCurrentRepeatingKeyCode; mCurrentRepeatingKeyCode = Constants.NOT_A_CODE; // Release the last pressed key. - setReleasedKeyGraphics(currentKey); + setReleasedKeyGraphics(currentKey, true /* withAnimation */); if (isShowingMoreKeysPanel()) { if (!mIsTrackingForActionDisabled) { @@ -1015,14 +1001,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element, } } - public void onShowMoreKeysPanel(final MoreKeysPanel panel) { - setReleasedKeyGraphics(mCurrentKey); - final int translatedX = panel.translateX(mLastX); - final int translatedY = panel.translateY(mLastY); - panel.onDownEvent(translatedX, translatedY, mPointerId, SystemClock.uptimeMillis()); - mMoreKeysPanel = panel; - } - @Override public void cancelTrackingForAction() { if (isShowingMoreKeysPanel()) { @@ -1035,14 +1013,49 @@ public final class PointerTracker implements PointerTrackerQueue.Element, return !mIsTrackingForActionDisabled; } - public void cancelLongPressTimer() { + public void onLongPressed() { sTimerProxy.cancelLongPressTimersOf(this); + if (isShowingMoreKeysPanel()) { + return; + } + final Key key = getKey(); + if (key == null) { + return; + } + if (key.hasNoPanelAutoMoreKey()) { + cancelKeyTracking(); + final int moreKeyCode = key.getMoreKeys()[0].mCode; + sListener.onPressKey(moreKeyCode, 0 /* repeatCont */, true /* isSinglePointer */); + sListener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, + Constants.NOT_A_COORDINATE, false /* isKeyRepeat */); + sListener.onReleaseKey(moreKeyCode, false /* withSliding */); + return; + } + final int code = key.getCode(); + if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) { + // Long pressing the space key invokes IME switcher dialog. + if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) { + cancelKeyTracking(); + sListener.onReleaseKey(code, false /* withSliding */); + return; + } + } + + setReleasedKeyGraphics(key, false /* withAnimation */); + final MoreKeysPanel moreKeysPanel = sDrawingProxy.showMoreKeysKeyboard(key, this); + if (moreKeysPanel == null) { + return; + } + final int translatedX = moreKeysPanel.translateX(mLastX); + final int translatedY = moreKeysPanel.translateY(mLastY); + moreKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, SystemClock.uptimeMillis()); + mMoreKeysPanel = moreKeysPanel; } - public void onLongPressed() { + private void cancelKeyTracking() { resetKeySelectionByDraggingFinger(); cancelTrackingForAction(); - setReleasedKeyGraphics(mCurrentKey); + setReleasedKeyGraphics(mCurrentKey, true /* withAnimation */); sPointerTrackerQueue.remove(this); } @@ -1059,7 +1072,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, private void onCancelEventInternal() { sTimerProxy.cancelKeyTimersOf(this); - setReleasedKeyGraphics(mCurrentKey); + setReleasedKeyGraphics(mCurrentKey, true /* withAnimation */); resetKeySelectionByDraggingFinger(); dismissMoreKeysPanel(); } diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index ab2323b06..228b964ea 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -28,6 +28,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import javax.annotation.Nonnull; + public class ProximityInfo { private static final String TAG = ProximityInfo.class.getSimpleName(); private static final boolean DEBUG = false; @@ -36,6 +38,7 @@ public class ProximityInfo { public static final int MAX_PROXIMITY_CHARS_SIZE = 16; /** Number of key widths from current touch point to search for nearest keys. */ private static final float SEARCH_DISTANCE = 1.2f; + @Nonnull private static final List<Key> EMPTY_KEY_LIST = Collections.emptyList(); private static final float DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS = 0.15f; @@ -49,13 +52,16 @@ public class ProximityInfo { private final int mKeyboardHeight; private final int mMostCommonKeyWidth; private final int mMostCommonKeyHeight; + @Nonnull private final List<Key> mSortedKeys; + @Nonnull private final List<Key>[] mGridNeighbors; @SuppressWarnings("unchecked") ProximityInfo(final int gridWidth, final int gridHeight, final int minWidth, final int height, - final int mostCommonKeyWidth, final int mostCommonKeyHeight, final List<Key> sortedKeys, - final TouchPositionCorrection touchPositionCorrection) { + final int mostCommonKeyWidth, final int mostCommonKeyHeight, + @Nonnull final List<Key> sortedKeys, + @Nonnull final TouchPositionCorrection touchPositionCorrection) { mGridWidth = gridWidth; mGridHeight = gridHeight; mGridSize = mGridWidth * mGridHeight; @@ -104,7 +110,8 @@ public class ProximityInfo { return count; } - private long createNativeProximityInfo(final TouchPositionCorrection touchPositionCorrection) { + private long createNativeProximityInfo( + @Nonnull final TouchPositionCorrection touchPositionCorrection) { final List<Key>[] gridNeighborKeys = mGridNeighbors; final int[] proximityCharsArray = new int[mGridSize * MAX_PROXIMITY_CHARS_SIZE]; Arrays.fill(proximityCharsArray, Constants.NOT_A_CODE); @@ -163,7 +170,7 @@ public class ProximityInfo { infoIndex++; } - if (touchPositionCorrection != null && touchPositionCorrection.isValid()) { + if (touchPositionCorrection.isValid()) { if (DEBUG) { Log.d(TAG, "touchPositionCorrection: ON"); } @@ -385,10 +392,8 @@ y |---+---+---+---+-v-+-|-+---+---+---+---+---| | thresholdBase and get } } + @Nonnull public List<Key> getNearestKeys(final int x, final int y) { - if (mGridNeighbors == null) { - return EMPTY_KEY_LIST; - } if (x >= 0 && x < mKeyboardMinWidth && y >= 0 && y < mKeyboardHeight) { int index = (y / mCellHeight) * mGridWidth + (x / mCellWidth); if (index < mGridSize) { diff --git a/java/src/com/android/inputmethod/keyboard/internal/DrawingProxy.java b/java/src/com/android/inputmethod/keyboard/internal/DrawingProxy.java index 7fc586a0f..06bdfc41b 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/DrawingProxy.java +++ b/java/src/com/android/inputmethod/keyboard/internal/DrawingProxy.java @@ -17,29 +17,36 @@ package com.android.inputmethod.keyboard.internal; import com.android.inputmethod.keyboard.Key; +import com.android.inputmethod.keyboard.MoreKeysPanel; import com.android.inputmethod.keyboard.PointerTracker; import javax.annotation.Nonnull; import javax.annotation.Nullable; public interface DrawingProxy { - // TODO: Remove this method. - public void invalidateKey(@Nullable Key key); - - // TODO: Rename this method to onKeyPressed. - public void showKeyPreview(@Nonnull Key key); - - // TODO: Rename this method to onKeyReleased. - public void dismissKeyPreview(@Nonnull Key key); + /** + * Called when a key is being pressed. + * @param key the {@link Key} that is being pressed. + * @param withPreview true if key popup preview should be displayed. + */ + public void onKeyPressed(@Nonnull Key key, boolean withPreview); /** - * Dismiss a key preview visual without delay. - * @param key the key whose preview visual should be dismissed. + * Called when a key is being released. + * @param key the {@link Key} that is being released. + * @param withAnimation when true, key popup preview should be dismissed with animation. */ - public void dismissKeyPreviewWithoutDelay(@Nonnull Key key); + public void onKeyReleased(@Nonnull Key key, boolean withAnimation); - // TODO: Rename this method to onKeyLongPressed. - public void onLongPress(@Nonnull PointerTracker tracker); + /** + * Start showing more keys keyboard of a key that is being long pressed. + * @param key the {@link Key} that is being long pressed and showing more keys keyboard. + * @param tracker the {@link PointerTracker} that detects this long pressing. + * @return {@link MoreKeysPanel} that is being shown. null if there is no need to show more keys + * keyboard. + */ + @Nullable + public MoreKeysPanel showMoreKeysKeyboard(@Nonnull Key key, @Nonnull PointerTracker tracker); /** * Start a while-typing-animation. diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java index df50efdc1..3ef9ea1dc 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java @@ -20,8 +20,12 @@ import android.graphics.Typeface; import com.android.inputmethod.latin.utils.ResourceUtils; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + public final class KeyDrawParams { - public Typeface mTypeface; + @Nonnull + public Typeface mTypeface = Typeface.DEFAULT; public int mLetterSize; public int mLabelSize; @@ -49,7 +53,7 @@ public final class KeyDrawParams { public KeyDrawParams() {} - private KeyDrawParams(final KeyDrawParams copyFrom) { + private KeyDrawParams(@Nonnull final KeyDrawParams copyFrom) { mTypeface = copyFrom.mTypeface; mLetterSize = copyFrom.mLetterSize; @@ -77,7 +81,7 @@ public final class KeyDrawParams { mAnimAlpha = copyFrom.mAnimAlpha; } - public void updateParams(final int keyHeight, final KeyVisualAttributes attr) { + public void updateParams(final int keyHeight, @Nullable final KeyVisualAttributes attr) { if (attr == null) { return; } @@ -117,8 +121,9 @@ public final class KeyDrawParams { attr.mHintLabelOffCenterRatio, mHintLabelOffCenterRatio); } + @Nonnull public KeyDrawParams mayCloneAndUpdateParams(final int keyHeight, - final KeyVisualAttributes attr) { + @Nullable final KeyVisualAttributes attr) { if (attr == null) { return this; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index 63aab968b..3eb62e7a6 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -22,6 +22,9 @@ import static com.android.inputmethod.latin.common.Constants.CODE_UNSPECIFIED; import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.StringUtils; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * The string parser of the key specification. * @@ -53,11 +56,11 @@ public final class KeySpecParser { // Intentional empty constructor for utility class. } - private static boolean hasIcon(final String keySpec) { + private static boolean hasIcon(@Nonnull final String keySpec) { return keySpec.startsWith(KeyboardIconsSet.PREFIX_ICON); } - private static boolean hasCode(final String keySpec, final int labelEnd) { + private static boolean hasCode(@Nonnull final String keySpec, final int labelEnd) { if (labelEnd <= 0 || labelEnd + 1 >= keySpec.length()) { return false; } @@ -72,7 +75,8 @@ public final class KeySpecParser { return false; } - private static String parseEscape(final String text) { + @Nonnull + private static String parseEscape(@Nonnull final String text) { if (text.indexOf(BACKSLASH) < 0) { return text; } @@ -91,7 +95,7 @@ public final class KeySpecParser { return sb.toString(); } - private static int indexOfLabelEnd(final String keySpec) { + private static int indexOfLabelEnd(@Nonnull final String keySpec) { final int length = keySpec.length(); if (keySpec.indexOf(BACKSLASH) < 0) { final int labelEnd = keySpec.indexOf(VERTICAL_BAR); @@ -116,22 +120,25 @@ public final class KeySpecParser { return -1; } - private static String getBeforeLabelEnd(final String keySpec, final int labelEnd) { + @Nonnull + private static String getBeforeLabelEnd(@Nonnull final String keySpec, final int labelEnd) { return (labelEnd < 0) ? keySpec : keySpec.substring(0, labelEnd); } - private static String getAfterLabelEnd(final String keySpec, final int labelEnd) { + @Nonnull + private static String getAfterLabelEnd(@Nonnull final String keySpec, final int labelEnd) { return keySpec.substring(labelEnd + /* VERTICAL_BAR */1); } - private static void checkDoubleLabelEnd(final String keySpec, final int labelEnd) { + private static void checkDoubleLabelEnd(@Nonnull final String keySpec, final int labelEnd) { if (indexOfLabelEnd(getAfterLabelEnd(keySpec, labelEnd)) < 0) { return; } throw new KeySpecParserError("Multiple " + VERTICAL_BAR + ": " + keySpec); } - public static String getLabel(final String keySpec) { + @Nullable + public static String getLabel(@Nullable final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; @@ -147,7 +154,8 @@ public final class KeySpecParser { return label; } - private static String getOutputTextInternal(final String keySpec, final int labelEnd) { + @Nullable + private static String getOutputTextInternal(@Nonnull final String keySpec, final int labelEnd) { if (labelEnd <= 0) { return null; } @@ -155,7 +163,8 @@ public final class KeySpecParser { return parseEscape(getAfterLabelEnd(keySpec, labelEnd)); } - public static String getOutputText(final String keySpec) { + @Nullable + public static String getOutputText(@Nullable final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; @@ -184,7 +193,7 @@ public final class KeySpecParser { return (StringUtils.codePointCount(label) == 1) ? null : label; } - public static int getCode(final String keySpec) { + public static int getCode(@Nullable final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return CODE_UNSPECIFIED; @@ -211,7 +220,7 @@ public final class KeySpecParser { return (StringUtils.codePointCount(label) == 1) ? label.codePointAt(0) : CODE_OUTPUT_TEXT; } - public static int parseCode(final String text, final int defaultCode) { + public static int parseCode(@Nullable final String text, final int defaultCode) { if (text == null) { return defaultCode; } @@ -226,7 +235,7 @@ public final class KeySpecParser { return defaultCode; } - public static int getIconId(final String keySpec) { + public static int getIconId(@Nullable final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return KeyboardIconsSet.ICON_UNDEFINED; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyle.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyle.java index 7941ddd41..28aa22c16 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyle.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyle.java @@ -18,18 +18,22 @@ package com.android.inputmethod.keyboard.internal; import android.content.res.TypedArray; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + public abstract class KeyStyle { private final KeyboardTextsSet mTextsSet; - public abstract String[] getStringArray(TypedArray a, int index); - public abstract String getString(TypedArray a, int index); + public abstract @Nullable String[] getStringArray(TypedArray a, int index); + public abstract @Nullable String getString(TypedArray a, int index); public abstract int getInt(TypedArray a, int index, int defaultValue); public abstract int getFlags(TypedArray a, int index); - protected KeyStyle(final KeyboardTextsSet textsSet) { + protected KeyStyle(@Nonnull final KeyboardTextsSet textsSet) { mTextsSet = textsSet; } + @Nullable protected String parseString(final TypedArray a, final int index) { if (a.hasValue(index)) { return mTextsSet.resolveTextReference(a.getString(index)); @@ -37,6 +41,7 @@ public abstract class KeyStyle { return null; } + @Nullable protected String[] parseStringArray(final TypedArray a, final int index) { if (a.hasValue(index)) { final String text = mTextsSet.resolveTextReference(a.getString(index)); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java index 5cbb34119..61f98c8ff 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java @@ -29,33 +29,42 @@ import org.xmlpull.v1.XmlPullParserException; import java.util.Arrays; import java.util.HashMap; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + public final class KeyStylesSet { private static final String TAG = KeyStylesSet.class.getSimpleName(); private static final boolean DEBUG = false; + @Nonnull private final HashMap<String, KeyStyle> mStyles = new HashMap<>(); + @Nonnull private final KeyboardTextsSet mTextsSet; + @Nonnull private final KeyStyle mEmptyKeyStyle; + @Nonnull private static final String EMPTY_STYLE_NAME = "<empty>"; - public KeyStylesSet(final KeyboardTextsSet textsSet) { + public KeyStylesSet(@Nonnull final KeyboardTextsSet textsSet) { mTextsSet = textsSet; mEmptyKeyStyle = new EmptyKeyStyle(textsSet); mStyles.put(EMPTY_STYLE_NAME, mEmptyKeyStyle); } private static final class EmptyKeyStyle extends KeyStyle { - EmptyKeyStyle(final KeyboardTextsSet textsSet) { + EmptyKeyStyle(@Nonnull final KeyboardTextsSet textsSet) { super(textsSet); } @Override + @Nullable public String[] getStringArray(final TypedArray a, final int index) { return parseStringArray(a, index); } @Override + @Nullable public String getString(final TypedArray a, final int index) { return parseString(a, index); } @@ -76,14 +85,16 @@ public final class KeyStylesSet { private final String mParentStyleName; private final SparseArray<Object> mStyleAttributes = new SparseArray<>(); - public DeclaredKeyStyle(final String parentStyleName, final KeyboardTextsSet textsSet, - final HashMap<String, KeyStyle> styles) { + public DeclaredKeyStyle(@Nonnull final String parentStyleName, + @Nonnull final KeyboardTextsSet textsSet, + @Nonnull final HashMap<String, KeyStyle> styles) { super(textsSet); mParentStyleName = parentStyleName; mStyles = styles; } @Override + @Nullable public String[] getStringArray(final TypedArray a, final int index) { if (a.hasValue(index)) { return parseStringArray(a, index); @@ -98,6 +109,7 @@ public final class KeyStylesSet { } @Override + @Nullable public String getString(final TypedArray a, final int index) { if (a.hasValue(index)) { return parseString(a, index); @@ -176,37 +188,43 @@ public final class KeyStylesSet { public void parseKeyStyleAttributes(final TypedArray keyStyleAttr, final TypedArray keyAttrs, final XmlPullParser parser) throws XmlPullParserException { final String styleName = keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName); + if (styleName == null) { + throw new XmlParseUtils.ParseException( + KeyboardBuilder.TAG_KEY_STYLE + " has no styleName attribute", parser); + } if (DEBUG) { Log.d(TAG, String.format("<%s styleName=%s />", KeyboardBuilder.TAG_KEY_STYLE, styleName)); if (mStyles.containsKey(styleName)) { - Log.d(TAG, "key-style " + styleName + " is overridden at " + Log.d(TAG, KeyboardBuilder.TAG_KEY_STYLE + " " + styleName + " is overridden at " + parser.getPositionDescription()); } } - String parentStyleName = EMPTY_STYLE_NAME; - if (keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_parentStyle)) { - parentStyleName = keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_parentStyle); - if (!mStyles.containsKey(parentStyleName)) { - throw new XmlParseUtils.ParseException( - "Unknown parentStyle " + parentStyleName, parser); - } + final String parentStyleInAttr = keyStyleAttr.getString( + R.styleable.Keyboard_KeyStyle_parentStyle); + if (parentStyleInAttr != null && !mStyles.containsKey(parentStyleInAttr)) { + throw new XmlParseUtils.ParseException( + "Unknown parentStyle " + parentStyleInAttr, parser); } + final String parentStyleName = (parentStyleInAttr == null) ? EMPTY_STYLE_NAME + : parentStyleInAttr; final DeclaredKeyStyle style = new DeclaredKeyStyle(parentStyleName, mTextsSet, mStyles); style.readKeyAttributes(keyAttrs); mStyles.put(styleName, style); } + @Nonnull public KeyStyle getKeyStyle(final TypedArray keyAttr, final XmlPullParser parser) throws XmlParseUtils.ParseException { - if (!keyAttr.hasValue(R.styleable.Keyboard_Key_keyStyle)) { + final String styleName = keyAttr.getString(R.styleable.Keyboard_Key_keyStyle); + if (styleName == null) { return mEmptyKeyStyle; } - final String styleName = keyAttr.getString(R.styleable.Keyboard_Key_keyStyle); - if (!mStyles.containsKey(styleName)) { + final KeyStyle style = mStyles.get(styleName); + if (style == null) { throw new XmlParseUtils.ParseException("Unknown key style: " + styleName, parser); } - return mStyles.get(styleName); + return style; } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java index c60d587db..6f000d294 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java @@ -23,7 +23,11 @@ import android.util.SparseIntArray; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.utils.ResourceUtils; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + public final class KeyVisualAttributes { + @Nullable public final Typeface mTypeface; public final float mLetterRatio; @@ -81,7 +85,8 @@ public final class KeyVisualAttributes { } } - public static KeyVisualAttributes newInstance(final TypedArray keyAttr) { + @Nullable + public static KeyVisualAttributes newInstance(@Nonnull final TypedArray keyAttr) { final int indexCount = keyAttr.getIndexCount(); for (int i = 0; i < indexCount; i++) { final int attrId = keyAttr.getIndex(i); @@ -93,7 +98,7 @@ public final class KeyVisualAttributes { return null; } - private KeyVisualAttributes(final TypedArray keyAttr) { + private KeyVisualAttributes(@Nonnull final TypedArray keyAttr) { if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyTypeface)) { mTypeface = Typeface.defaultFromStyle( keyAttr.getInt(R.styleable.Keyboard_Key_keyTypeface, Typeface.NORMAL)); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index 51f89c122..5743ef967 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -139,6 +139,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> { private static final int DEFAULT_KEYBOARD_COLUMNS = 10; private static final int DEFAULT_KEYBOARD_ROWS = 4; + @Nonnull protected final KP mParams; protected final Context mContext; protected final Resources mResources; @@ -149,7 +150,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> { private boolean mTopEdge; private Key mRightEdgeKey = null; - public KeyboardBuilder(final Context context, final KP params) { + public KeyboardBuilder(final Context context, @Nonnull final KP params) { mContext = context; final Resources res = context.getResources(); mResources = res; @@ -194,6 +195,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> { mParams.mProximityCharsCorrectionEnabled = enabled; } + @Nonnull public Keyboard build() { return new Keyboard(mParams); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index e1f302c1e..15a5bd456 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -26,6 +26,9 @@ import com.android.inputmethod.latin.R; import java.util.HashMap; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + public final class KeyboardIconsSet { private static final String TAG = KeyboardIconsSet.class.getSimpleName(); @@ -127,6 +130,7 @@ public final class KeyboardIconsSet { return iconId >= 0 && iconId < ICON_NAMES.length; } + @Nonnull public static String getIconName(final int iconId) { return isValidIconId(iconId) ? ICON_NAMES[iconId] : "unknown<" + iconId + ">"; } @@ -147,6 +151,7 @@ public final class KeyboardIconsSet { throw new RuntimeException("unknown icon name: " + name); } + @Nullable public Drawable getIconDrawable(final int iconId) { if (isValidIconId(iconId)) { return mIcons[iconId]; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java index fb5e97757..432687635 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java @@ -49,6 +49,7 @@ public class KeyboardParams { public int mLeftPadding; public int mRightPadding; + @Nullable public KeyVisualAttributes mKeyVisualAttributes; public int mDefaultRowHeight; @@ -63,14 +64,22 @@ public class KeyboardParams { public int GRID_HEIGHT; // Keys are sorted from top-left to bottom-right order. + @Nonnull public final SortedSet<Key> mSortedKeys = new TreeSet<>(ROW_COLUMN_COMPARATOR); + @Nonnull public final ArrayList<Key> mShiftKeys = new ArrayList<>(); + @Nonnull public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<>(); + @Nonnull public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet(); + @Nonnull public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); + @Nonnull public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet); - @Nullable public KeysCache mKeysCache; + // TODO: Make this @Nonnull + @Nullable + public KeysCache mKeysCache; public boolean mAllowRedundantMoreKeys; public int mMostCommonKeyHeight = 0; @@ -78,6 +87,7 @@ public class KeyboardParams { public boolean mProximityCharsCorrectionEnabled; + @Nonnull public final TouchPositionCorrection mTouchPositionCorrection = new TouchPositionCorrection(); @@ -100,7 +110,9 @@ public class KeyboardParams { } public void onAddKey(@Nonnull final Key newKey) { - final Key key = (mKeysCache != null) ? mKeysCache.get(newKey) : newKey; + // To avoid possible null pointer access. + final KeysCache keysCache = mKeysCache; + final Key key = (keysCache != null) ? keysCache.get(newKey) : newKey; final boolean isSpacer = key.isSpacer(); if (isSpacer && key.getWidth() == 0) { // Ignore zero width {@link Spacer}. @@ -128,12 +140,14 @@ public class KeyboardParams { for (final Key key : mSortedKeys) { lettersOnBaseLayout.addLetter(key); } + // To avoid possible null pointer access. + final KeysCache keysCache = mKeysCache; final ArrayList<Key> allKeys = new ArrayList<>(mSortedKeys); mSortedKeys.clear(); for (final Key key : allKeys) { final Key filteredKey = Key.removeRedundantMoreKeys(key, lettersOnBaseLayout); - if (mKeysCache != null) { - mKeysCache.replace(key, filteredKey); + if (keysCache != null) { + keysCache.replace(key, filteredKey); } mSortedKeys.add(filteredKey); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java b/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java index e8678637b..6ad450c29 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java @@ -20,6 +20,7 @@ import com.android.inputmethod.keyboard.Key; import java.util.HashMap; +// TODO: Rename more appropriate name. public final class KeysCache { private final HashMap<Key, Key> mMap = new HashMap<>(); @@ -27,6 +28,7 @@ public final class KeysCache { mMap.clear(); } + // TODO: Rename more descriptive name. public Key get(final Key key) { final Key existingKey = mMap.get(key); if (existingKey != null) { @@ -37,6 +39,7 @@ public final class KeysCache { return key; } + // TODO: Rename more descriptive name. public Key replace(final Key oldKey, final Key newKey) { if (oldKey.equals(newKey)) { return oldKey; diff --git a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java index 87c96cc0d..0bd42fc13 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +++ b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java @@ -24,14 +24,13 @@ import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.latin.common.CollectionUtils; import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.StringUtils; -import com.android.inputmethod.latin.define.DebugFlags; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.Locale; import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * The more key specification object. The more keys are an array of {@link MoreKeySpec}. @@ -47,12 +46,15 @@ import javax.annotation.Nonnull; // TODO: Should extend the key specification object. public final class MoreKeySpec { public final int mCode; + @Nullable public final String mLabel; + @Nullable public final String mOutputText; public final int mIconId; - public MoreKeySpec(final String moreKeySpec, boolean needsToUpperCase, final Locale locale) { - if (TextUtils.isEmpty(moreKeySpec)) { + public MoreKeySpec(@Nonnull final String moreKeySpec, boolean needsToUpperCase, + @Nonnull final Locale locale) { + if (moreKeySpec.isEmpty()) { throw new KeySpecParser.KeySpecParserError("Empty more key spec"); } final String label = KeySpecParser.getLabel(moreKeySpec); @@ -76,7 +78,7 @@ public final class MoreKeySpec { @Nonnull public Key buildKey(final int x, final int y, final int labelFlags, - final KeyboardParams params) { + @Nonnull final KeyboardParams params) { return new Key(mLabel, mIconId, mCode, mOutputText, null /* hintLabel */, labelFlags, Key.BACKGROUND_TYPE_NORMAL, x, y, params.mDefaultKeyWidth, params.mDefaultRowHeight, params.mHorizontalGap, params.mVerticalGap); @@ -87,14 +89,18 @@ public final class MoreKeySpec { int hashCode = 1; hashCode = 31 + mCode; hashCode = hashCode * 31 + mIconId; - hashCode = hashCode * 31 + (mLabel == null ? 0 : mLabel.hashCode()); - hashCode = hashCode * 31 + (mOutputText == null ? 0 : mOutputText.hashCode()); + final String label = mLabel; + hashCode = hashCode * 31 + (label == null ? 0 : label.hashCode()); + final String outputText = mOutputText; + hashCode = hashCode * 31 + (outputText == null ? 0 : outputText.hashCode()); return hashCode; } @Override public boolean equals(final Object o) { - if (this == o) return true; + if (this == o) { + return true; + } if (o instanceof MoreKeySpec) { final MoreKeySpec other = (MoreKeySpec)o; return mCode == other.mCode @@ -121,7 +127,7 @@ public final class MoreKeySpec { private final SparseIntArray mCodes = new SparseIntArray(); private final HashSet<String> mTexts = new HashSet<>(); - public void addLetter(final Key key) { + public void addLetter(@Nonnull final Key key) { final int code = key.getCode(); if (CharacterCompat.isAlphabetic(code)) { mCodes.put(code, 0); @@ -130,7 +136,7 @@ public final class MoreKeySpec { } } - public boolean contains(final MoreKeySpec moreKey) { + public boolean contains(@Nonnull final MoreKeySpec moreKey) { final int code = moreKey.mCode; if (CharacterCompat.isAlphabetic(code) && mCodes.indexOfKey(code) >= 0) { return true; @@ -141,8 +147,9 @@ public final class MoreKeySpec { } } - public static MoreKeySpec[] removeRedundantMoreKeys(final MoreKeySpec[] moreKeys, - final LettersOnBaseLayout lettersOnBaseLayout) { + @Nullable + public static MoreKeySpec[] removeRedundantMoreKeys(@Nullable final MoreKeySpec[] moreKeys, + @Nonnull final LettersOnBaseLayout lettersOnBaseLayout) { if (moreKeys == null) { return null; } @@ -162,7 +169,6 @@ public final class MoreKeySpec { return filteredMoreKeys.toArray(new MoreKeySpec[size]); } - private static final boolean DEBUG = DebugFlags.DEBUG_ENABLED; // Constants for parsing. private static final char COMMA = Constants.CODE_COMMA; private static final char BACKSLASH = Constants.CODE_BACKSLASH; @@ -180,7 +186,8 @@ public final class MoreKeySpec { * @return an array of key specification text. Null if the specified <code>text</code> is empty * or has no key specifications. */ - public static String[] splitKeySpecs(final String text) { + @Nullable + public static String[] splitKeySpecs(@Nullable final String text) { if (TextUtils.isEmpty(text)) { return null; } @@ -222,9 +229,11 @@ public final class MoreKeySpec { return list.toArray(new String[list.size()]); } + @Nonnull private static final String[] EMPTY_STRING_ARRAY = new String[0]; - private static String[] filterOutEmptyString(final String[] array) { + @Nonnull + private static String[] filterOutEmptyString(@Nullable final String[] array) { if (array == null) { return EMPTY_STRING_ARRAY; } @@ -245,8 +254,8 @@ public final class MoreKeySpec { return out.toArray(new String[out.size()]); } - public static String[] insertAdditionalMoreKeys(final String[] moreKeySpecs, - final String[] additionalMoreKeySpecs) { + public static String[] insertAdditionalMoreKeys(@Nullable final String[] moreKeySpecs, + @Nullable final String[] additionalMoreKeySpecs) { final String[] moreKeys = filterOutEmptyString(moreKeySpecs); final String[] additionalMoreKeys = filterOutEmptyString(additionalMoreKeySpecs); final int moreKeysCount = moreKeys.length; @@ -280,11 +289,6 @@ public final class MoreKeySpec { if (additionalCount > 0 && additionalIndex == 0) { // No '%' marker is found in more keys. // Insert all additional more keys to the head of more keys. - if (DEBUG && out != null) { - throw new RuntimeException("Internal logic error:" - + " moreKeys=" + Arrays.toString(moreKeys) - + " additionalMoreKeys=" + Arrays.toString(additionalMoreKeys)); - } out = CollectionUtils.arrayAsList(additionalMoreKeys, additionalIndex, additionalCount); for (int i = 0; i < moreKeysCount; i++) { out.add(moreKeys[i]); @@ -292,11 +296,6 @@ public final class MoreKeySpec { } else if (additionalIndex < additionalCount) { // The number of '%' markers are less than additional more keys. // Append remained additional more keys to the tail of more keys. - if (DEBUG && out != null) { - throw new RuntimeException("Internal logic error:" - + " moreKeys=" + Arrays.toString(moreKeys) - + " additionalMoreKeys=" + Arrays.toString(additionalMoreKeys)); - } out = CollectionUtils.arrayAsList(moreKeys, 0, moreKeysCount); for (int i = additionalIndex; i < additionalCount; i++) { out.add(additionalMoreKeys[additionalIndex]); @@ -311,7 +310,7 @@ public final class MoreKeySpec { } } - public static int getIntValue(final String[] moreKeys, final String key, + public static int getIntValue(@Nullable final String[] moreKeys, final String key, final int defaultValue) { if (moreKeys == null) { return defaultValue; @@ -338,7 +337,7 @@ public final class MoreKeySpec { return value; } - public static boolean getBooleanValue(final String[] moreKeys, final String key) { + public static boolean getBooleanValue(@Nullable final String[] moreKeys, final String key) { if (moreKeys == null) { return false; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/TimerHandler.java b/java/src/com/android/inputmethod/keyboard/internal/TimerHandler.java index 8068427bc..91f3558eb 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/TimerHandler.java +++ b/java/src/com/android/inputmethod/keyboard/internal/TimerHandler.java @@ -66,7 +66,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy> case MSG_LONGPRESS_SHIFT_KEY: cancelLongPressTimers(); final PointerTracker tracker2 = (PointerTracker) msg.obj; - drawingProxy.onLongPress(tracker2); + tracker2.onLongPressed(); break; case MSG_UPDATE_BATCH_INPUT: final PointerTracker tracker3 = (PointerTracker) msg.obj; @@ -74,8 +74,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy> startUpdateBatchInputTimer(tracker3); break; case MSG_DISMISS_KEY_PREVIEW: - final Key key = (Key) msg.obj; - drawingProxy.dismissKeyPreviewWithoutDelay(key); + drawingProxy.onKeyReleased((Key) msg.obj, false /* withAnimation */); break; case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT: drawingProxy.dismissGestureFloatingPreviewTextWithoutDelay(); diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index 5afb62b69..9c70cad0a 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -263,7 +263,8 @@ final public class BinaryDictionaryGetter { public static ArrayList<AssetFileAddress> getDictionaryFiles(final Locale locale, final Context context) { - final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale); + final boolean hasDefaultWordList = DictionaryInfoUtils.isDictionaryAvailable( + context, locale); BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context, hasDefaultWordList); final File[] cachedWordLists = getCachedWordLists(locale.toString(), context); diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java index b24fdea55..acf9cf10c 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java @@ -63,6 +63,9 @@ public class DictionaryFacilitator { // HACK: This threshold is being used when adding a capitalized entry in the User History // dictionary. private static final int CAPITALIZED_FORM_MAX_PROBABILITY_FOR_INSERT = 140; + // How many words we need to type in a row ({@see mConfidenceInMostProbableLanguage}) to + // declare we are confident the user is typing in the most probable language. + private static final int CONFIDENCE_THRESHOLD = 3; private DictionaryGroup[] mDictionaryGroups = new DictionaryGroup[] { new DictionaryGroup() }; private DictionaryGroup mMostProbableDictionaryGroup = mDictionaryGroups[0]; @@ -138,6 +141,10 @@ public class DictionaryFacilitator { public final Locale mLocale; private Dictionary mMainDict; + // Confidence that the most probable language is actually the language the user is + // typing in. For now, this is simply the number of times a word from this language + // has been committed in a row. + private int mConfidence = 0; public float mWeightForTypingInLocale = WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; public float mWeightForGesturingInLocale = WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; public final ConcurrentHashMap<String, ExpandableBinaryDictionary> mSubDictMap = @@ -257,11 +264,12 @@ public class DictionaryFacilitator { return mMostProbableDictionaryGroup; } - public void switchMostProbableLanguage(final Locale locale) { + public void switchMostProbableLanguage(@Nullable final Locale locale) { if (null == locale) { // In many cases, there is no locale to a committed word. For example, a typed word - // that does not auto-correct has no locale. In this case we simply do not change - // the most probable language. + // that is in none of the currently active dictionaries but still does not + // auto-correct to anything has no locale. In this case we simply do not change + // the most probable language and do not touch confidence. return; } final DictionaryGroup newMostProbableDictionaryGroup = @@ -272,15 +280,31 @@ public class DictionaryFacilitator { // facilitator any more. In this case, just not changing things is fine. return; } - mMostProbableDictionaryGroup.mWeightForTypingInLocale = - DictionaryGroup.WEIGHT_FOR_TYPING_IN_NOT_MOST_PROBABLE_LANGUAGE; - mMostProbableDictionaryGroup.mWeightForGesturingInLocale = - DictionaryGroup.WEIGHT_FOR_GESTURING_IN_NOT_MOST_PROBABLE_LANGUAGE; - newMostProbableDictionaryGroup.mWeightForTypingInLocale = - DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; - newMostProbableDictionaryGroup.mWeightForGesturingInLocale = - DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; - mMostProbableDictionaryGroup = newMostProbableDictionaryGroup; + if (newMostProbableDictionaryGroup == mMostProbableDictionaryGroup) { + ++newMostProbableDictionaryGroup.mConfidence; + } else { + mMostProbableDictionaryGroup.mWeightForTypingInLocale = + DictionaryGroup.WEIGHT_FOR_TYPING_IN_NOT_MOST_PROBABLE_LANGUAGE; + mMostProbableDictionaryGroup.mWeightForGesturingInLocale = + DictionaryGroup.WEIGHT_FOR_GESTURING_IN_NOT_MOST_PROBABLE_LANGUAGE; + mMostProbableDictionaryGroup.mConfidence = 0; + newMostProbableDictionaryGroup.mWeightForTypingInLocale = + DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; + newMostProbableDictionaryGroup.mWeightForGesturingInLocale = + DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE; + mMostProbableDictionaryGroup = newMostProbableDictionaryGroup; + } + } + + public boolean isConfidentAboutCurrentLanguageBeing(final Locale mLocale) { + final DictionaryGroup mostProbableDictionaryGroup = mMostProbableDictionaryGroup; + if (!mostProbableDictionaryGroup.mLocale.equals(mLocale)) { + return false; + } + if (mDictionaryGroups.length <= 1) { + return true; + } + return mostProbableDictionaryGroup.mConfidence >= CONFIDENCE_THRESHOLD; } @Nullable @@ -624,7 +648,8 @@ public class DictionaryFacilitator { final int timeStampInSeconds, final boolean blockPotentiallyOffensive) { final ExpandableBinaryDictionary userHistoryDictionary = dictionaryGroup.getSubDict(Dictionary.TYPE_USER_HISTORY); - if (userHistoryDictionary == null) { + if (userHistoryDictionary == null + || !isConfidentAboutCurrentLanguageBeing(userHistoryDictionary.mLocale)) { return; } final int maxFreq = getFrequency(word); diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index 3459b426d..781ab06c5 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -19,10 +19,8 @@ package com.android.inputmethod.latin; import android.content.ContentProviderClient; import android.content.Context; import android.content.res.AssetFileDescriptor; -import android.content.res.Resources; import android.util.Log; -import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import java.io.File; @@ -43,11 +41,10 @@ public final class DictionaryFactory { * locale. If none is found, it falls back to the built-in dictionary - if any. * @param context application context for reading resources * @param locale the locale for which to create the dictionary - * @param useFullEditDistance whether to use the full edit distance in suggestions * @return an initialized instance of DictionaryCollection */ public static DictionaryCollection createMainDictionaryFromManager(final Context context, - final Locale locale, final boolean useFullEditDistance) { + final Locale locale) { if (null == locale) { Log.e(TAG, "No locale defined for dictionary"); return new DictionaryCollection(Dictionary.TYPE_MAIN, locale, @@ -61,7 +58,7 @@ public final class DictionaryFactory { for (final AssetFileAddress f : assetFileList) { final ReadOnlyBinaryDictionary readOnlyBinaryDictionary = new ReadOnlyBinaryDictionary(f.mFilename, f.mOffset, f.mLength, - useFullEditDistance, locale, Dictionary.TYPE_MAIN); + false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN); if (readOnlyBinaryDictionary.isValidDictionary()) { dictList.add(readOnlyBinaryDictionary); } else { @@ -101,49 +98,33 @@ public final class DictionaryFactory { } final String wordlistId = DictionaryInfoUtils.getWordListIdFromFileName(new File(f.mFilename).getName()); - if (null != wordlistId) { - // TODO: this is a reasonable last resort, but it is suboptimal. - // The following will remove the entry for this dictionary with the dictionary - // provider. When the metadata is downloaded again, we will try downloading it - // again. - // However, in the practice that will mean the user will find themselves without - // the new dictionary. That's fine for languages where it's included in the APK, - // but for other languages it will leave the user without a dictionary at all until - // the next update, which may be a few days away. - // Ideally, we would trigger a new download right away, and use increasing retry - // delays for this particular id/version combination. - // Then again, this is expected to only ever happen in case of human mistake. If - // the wrong file is on the server, the following is still doing the right thing. - // If it's a file left over from the last version however, it's not great. - BinaryDictionaryFileDumper.reportBrokenFileToDictionaryProvider( - providerClient, - context.getString(R.string.dictionary_pack_client_id), - wordlistId); - } + // TODO: this is a reasonable last resort, but it is suboptimal. + // The following will remove the entry for this dictionary with the dictionary + // provider. When the metadata is downloaded again, we will try downloading it + // again. + // However, in the practice that will mean the user will find themselves without + // the new dictionary. That's fine for languages where it's included in the APK, + // but for other languages it will leave the user without a dictionary at all until + // the next update, which may be a few days away. + // Ideally, we would trigger a new download right away, and use increasing retry + // delays for this particular id/version combination. + // Then again, this is expected to only ever happen in case of human mistake. If + // the wrong file is on the server, the following is still doing the right thing. + // If it's a file left over from the last version however, it's not great. + BinaryDictionaryFileDumper.reportBrokenFileToDictionaryProvider( + providerClient, + context.getString(R.string.dictionary_pack_client_id), + wordlistId); } } /** - * Initializes a main dictionary collection from a dictionary pack, with default flags. - * - * This searches for a content provider providing a dictionary pack for the specified - * locale. If none is found, it falls back to the built-in dictionary, if any. - * @param context application context for reading resources - * @param locale the locale for which to create the dictionary - * @return an initialized instance of DictionaryCollection - */ - public static DictionaryCollection createMainDictionaryFromManager(final Context context, - final Locale locale) { - return createMainDictionaryFromManager(context, locale, false /* useFullEditDistance */); - } - - /** * Initializes a read-only binary dictionary from a raw resource file * @param context application context for reading resources * @param locale the locale to use for the resource * @return an initialized instance of ReadOnlyBinaryDictionary */ - protected static ReadOnlyBinaryDictionary createReadOnlyBinaryDictionary(final Context context, + private static ReadOnlyBinaryDictionary createReadOnlyBinaryDictionary(final Context context, final Locale locale) { AssetFileDescriptor afd = null; try { @@ -177,36 +158,4 @@ public final class DictionaryFactory { } } } - - /** - * Create a dictionary from passed data. This is intended for unit tests only. - * @param dictionaryList the list of files to read, with their offsets and lengths - * @param useFullEditDistance whether to use the full edit distance in suggestions - * @return the created dictionary, or null. - */ - @UsedForTesting - public static Dictionary createDictionaryForTest(final AssetFileAddress[] dictionaryList, - final boolean useFullEditDistance, Locale locale) { - final DictionaryCollection dictionaryCollection = - new DictionaryCollection(Dictionary.TYPE_MAIN, locale); - for (final AssetFileAddress address : dictionaryList) { - final ReadOnlyBinaryDictionary readOnlyBinaryDictionary = new ReadOnlyBinaryDictionary( - address.mFilename, address.mOffset, address.mLength, useFullEditDistance, - locale, Dictionary.TYPE_MAIN); - dictionaryCollection.addDictionary(readOnlyBinaryDictionary); - } - return dictionaryCollection; - } - - /** - * Find out whether a dictionary is available for this locale. - * @param context the context on which to check resources. - * @param locale the locale to check for. - * @return whether a (non-placeholder) dictionary is available or not. - */ - public static boolean isDictionaryAvailable(Context context, Locale locale) { - final Resources res = context.getResources(); - return 0 != DictionaryInfoUtils.getMainDictionaryResourceIdIfAvailableForLocale( - res, locale); - } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7b7b6d35e..44dffa44e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -708,6 +708,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.mSuggest.setAutoCorrectionThreshold( settingsValues.mAutoCorrectionThreshold); } + mInputLogic.mSuggest.setPlausibilityThreshold(settingsValues.mPlausibilityThreshold); } /** @@ -730,6 +731,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen unregisterReceiver(mDictionaryPackInstallReceiver); unregisterReceiver(mDictionaryDumpBroadcastReceiver); mStatsUtilsManager.onDestroy(); + DictionaryDecayBroadcastReciever.cancelIntervalAlarmForDictionaryDecaying(this); super.onDestroy(); } @@ -1007,6 +1009,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen suggest.setAutoCorrectionThreshold( currentSettingsValues.mAutoCorrectionThreshold); } + suggest.setPlausibilityThreshold(currentSettingsValues.mPlausibilityThreshold); switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(), getCurrentRecapitalizeState()); diff --git a/java/src/com/android/inputmethod/latin/NgramContext.java b/java/src/com/android/inputmethod/latin/NgramContext.java index 82a13274d..b47731229 100644 --- a/java/src/com/android/inputmethod/latin/NgramContext.java +++ b/java/src/com/android/inputmethod/latin/NgramContext.java @@ -133,7 +133,7 @@ public class NgramContext { // n is 1-indexed. @UsedForTesting - public boolean isNthPrevWordBeginningOfSontence(final int n) { + public boolean isNthPrevWordBeginningOfSentence(final int n) { if (n <= 0 || n > mPrevWordsCount) { return false; } diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java index a1ac55a20..686c3a4b2 100644 --- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java +++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java @@ -110,7 +110,7 @@ public class RichInputMethodManager { // Initialize additional subtypes. SubtypeLocaleUtils.init(context); - final InputMethodSubtype[] additionalSubtypes = getAdditionalSubtypes(context); + final InputMethodSubtype[] additionalSubtypes = getAdditionalSubtypes(); setAdditionalInputMethodSubtypes(additionalSubtypes); final ConnectivityManager connectivityManager = @@ -119,11 +119,10 @@ public class RichInputMethodManager { mIsNetworkConnected = (info != null && info.isConnected()); } - public InputMethodSubtype[] getAdditionalSubtypes(final Context context) { - SubtypeLocaleUtils.init(context); - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + public InputMethodSubtype[] getAdditionalSubtypes() { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); final String prefAdditionalSubtypes = Settings.readPrefAdditionalSubtypes( - prefs, context.getResources()); + prefs, mContext.getResources()); return AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefAdditionalSubtypes); } diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 4df1d6505..0bf0f687a 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -32,6 +32,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * This class loads a dictionary and provides a list of suggestions for a given sequence of * characters. This includes corrections and completions. @@ -62,15 +65,30 @@ public final class Suggest { } private float mAutoCorrectionThreshold; + private float mPlausibilityThreshold; public Suggest(final DictionaryFacilitator dictionaryFacilitator) { mDictionaryFacilitator = dictionaryFacilitator; } + /** + * Set the normalized-score threshold for a suggestion to be considered strong enough that we + * will auto-correct to this. + * @param threshold the threshold + */ public void setAutoCorrectionThreshold(final float threshold) { mAutoCorrectionThreshold = threshold; } + /** + * Set the normalized-score threshold for what we consider a "plausible" suggestion, in + * the same dimension as the auto-correction threshold. + * @param threshold the threshold + */ + public void setPlausibilityThreshold(final float threshold) { + mPlausibilityThreshold = threshold; + } + public interface OnGetSuggestedWordsCallback { public void onGetSuggestedWords(final SuggestedWords suggestedWords); } @@ -115,7 +133,8 @@ public final class Suggest { return suggestionsContainer; } - private static String getWhitelistedWordOrNull(final ArrayList<SuggestedWordInfo> suggestions) { + private static SuggestedWordInfo getWhitelistedWordInfoOrNull( + @Nonnull final ArrayList<SuggestedWordInfo> suggestions) { if (suggestions.isEmpty()) { return null; } @@ -123,9 +142,21 @@ public final class Suggest { if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { return null; } - return firstSuggestedWordInfo.mWord; + return firstSuggestedWordInfo; } + // Quality constants for dictionary match + // In increasing order of quality + // This source dictionary does not match the typed word. + private static final int QUALITY_NO_MATCH = 0; + // This source dictionary has a null locale, and the preferred locale is also null. + private static final int QUALITY_MATCH_NULL = 1; + // This source dictionary has a non-null locale different from the preferred locale. The + // preferred locale may be null : this is still better than MATCH_NULL. + private static final int QUALITY_MATCH_OTHER_LOCALE = 2; + // This source dictionary matches the preferred locale. + private static final int QUALITY_MATCH_PREFERRED_LOCALE = 3; + // Retrieves suggestions for non-batch input (typing, recorrection, predictions...) // and calls the callback function with the suggestions. private void getSuggestedWordsForNonBatchInput(final WordComposer wordComposer, @@ -143,22 +174,67 @@ public final class Suggest { final SuggestionResults suggestionResults = mDictionaryFacilitator.getSuggestionResults( wordComposer, ngramContext, proximityInfo.getNativeProximityInfo(), settingsValuesForSuggestion, SESSION_ID_TYPING); + final Locale mostProbableLocale = mDictionaryFacilitator.getMostProbableLocale(); final ArrayList<SuggestedWordInfo> suggestionsContainer = getTransformedSuggestedWordInfoList(wordComposer, suggestionResults, trailingSingleQuotesCount, // For transforming suggestions that don't come for any dictionary, we // use the currently most probable locale as it's our best bet. - mDictionaryFacilitator.getMostProbableLocale()); - final boolean didRemoveTypedWord = - SuggestedWordInfo.removeDups(wordComposer.getTypedWord(), suggestionsContainer); + mostProbableLocale); + + boolean typedWordExistsInAnotherLanguage = false; + int qualityOfFoundSourceDictionary = QUALITY_NO_MATCH; + @Nullable Dictionary sourceDictionaryOfRemovedWord = null; + for (final SuggestedWordInfo info : suggestionsContainer) { + // Search for the best dictionary, defined as the first one with the highest match + // quality we can find. + if (typedWordString.equals(info.mWord)) { + if (mostProbableLocale.equals(info.mSourceDict.mLocale)) { + if (qualityOfFoundSourceDictionary < QUALITY_MATCH_PREFERRED_LOCALE) { + // Use this source if the old match had lower quality than this match + sourceDictionaryOfRemovedWord = info.mSourceDict; + qualityOfFoundSourceDictionary = QUALITY_MATCH_PREFERRED_LOCALE; + } + } else { + final int matchQuality = (null == info.mSourceDict.mLocale) + ? QUALITY_MATCH_NULL : QUALITY_MATCH_OTHER_LOCALE; + if (qualityOfFoundSourceDictionary < matchQuality) { + // Use this source if the old match had lower quality than this match + sourceDictionaryOfRemovedWord = info.mSourceDict; + qualityOfFoundSourceDictionary = matchQuality; + } + typedWordExistsInAnotherLanguage = true; + } + } + } - final String whitelistedWord = getWhitelistedWordOrNull(suggestionsContainer); + SuggestedWordInfo.removeDups(typedWordString, suggestionsContainer); + + final SuggestedWordInfo whitelistedWordInfo = + getWhitelistedWordInfoOrNull(suggestionsContainer); + final String whitelistedWord; + if (null != whitelistedWordInfo && + (mDictionaryFacilitator.isConfidentAboutCurrentLanguageBeing( + whitelistedWordInfo.mSourceDict.mLocale) + || (!typedWordExistsInAnotherLanguage + && !hasPlausibleCandidateInAnyOtherLanguage(suggestionsContainer, + consideredWord, whitelistedWordInfo)))) { + // We'll use the whitelist candidate if we are confident the user is typing in the + // language of the dictionary it's coming from, or if there is no plausible candidate + // coming from another language. + whitelistedWord = whitelistedWordInfo.mWord; + } else { + // If on the contrary we are not confident in the current language and we have + // at least a plausible candidate in any other language, then we don't use this + // whitelist candidate. + whitelistedWord = null; + } final boolean resultsArePredictions = !wordComposer.isComposingWord(); // We allow auto-correction if we have a whitelisted word, or if the word had more than // one char and was not suggested. final boolean allowsToBeAutoCorrected = (null != whitelistedWord) - || (consideredWord.length() > 1 && !didRemoveTypedWord); + || (consideredWord.length() > 1 && (null == sourceDictionaryOfRemovedWord)); final boolean hasAutoCorrection; // If correction is not enabled, we never auto-correct. This is for example for when @@ -194,7 +270,7 @@ public final class Suggest { hasAutoCorrection = false; } else { final SuggestedWordInfo firstSuggestion = suggestionResults.first(); - if (!AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold( + if (!AutoCorrectionUtils.suggestionExceedsThreshold( firstSuggestion, consideredWord, mAutoCorrectionThreshold)) { // Score is too low for autocorrect hasAutoCorrection = false; @@ -209,7 +285,8 @@ public final class Suggest { final SuggestedWordInfo typedWordInfo = new SuggestedWordInfo(typedWordString, SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED, - Dictionary.DICTIONARY_USER_TYPED, + null == sourceDictionaryOfRemovedWord ? Dictionary.DICTIONARY_USER_TYPED + : sourceDictionaryOfRemovedWord, SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */); if (!TextUtils.isEmpty(typedWordString)) { @@ -242,6 +319,20 @@ public final class Suggest { false /* isObsoleteSuggestions */, inputStyle, sequenceNumber)); } + private boolean hasPlausibleCandidateInAnyOtherLanguage( + final ArrayList<SuggestedWordInfo> suggestionsContainer, final String consideredWord, + final SuggestedWordInfo whitelistedWordInfo) { + for (final SuggestedWordInfo info : suggestionsContainer) { + if (whitelistedWordInfo.mSourceDict.mLocale.equals(info.mSourceDict.mLocale)) { + continue; + } + return AutoCorrectionUtils.suggestionExceedsThreshold(info, consideredWord, + mPlausibilityThreshold); + } + // No candidate in another language + return false; + } + // Retrieves suggestions for the batch input // and calls the callback function with the suggestions. private void getSuggestedWordsForBatchInput(final WordComposer wordComposer, diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 49153d261..30dd51aed 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -355,37 +355,30 @@ public class SuggestedWords { } // This will always remove the higher index if a duplicate is found. - public static boolean removeDups(final String typedWord, - ArrayList<SuggestedWordInfo> candidates) { + public static void removeDups(@Nullable final String typedWord, + @Nonnull ArrayList<SuggestedWordInfo> candidates) { if (candidates.isEmpty()) { - return false; + return; } - final boolean didRemoveTypedWord; if (!TextUtils.isEmpty(typedWord)) { - didRemoveTypedWord = removeSuggestedWordInfoFrom(typedWord, candidates, - -1 /* startIndexExclusive */); - } else { - didRemoveTypedWord = false; + removeSuggestedWordInfoFromList(typedWord, candidates, -1 /* startIndexExclusive */); } for (int i = 0; i < candidates.size(); ++i) { - removeSuggestedWordInfoFrom(candidates.get(i).mWord, candidates, + removeSuggestedWordInfoFromList(candidates.get(i).mWord, candidates, i /* startIndexExclusive */); } - return didRemoveTypedWord; } - private static boolean removeSuggestedWordInfoFrom(final String word, - final ArrayList<SuggestedWordInfo> candidates, final int startIndexExclusive) { - boolean didRemove = false; + private static void removeSuggestedWordInfoFromList( + @Nonnull final String word, @Nonnull final ArrayList<SuggestedWordInfo> candidates, + final int startIndexExclusive) { for (int i = startIndexExclusive + 1; i < candidates.size(); ++i) { final SuggestedWordInfo previous = candidates.get(i); if (word.equals(previous.mWord)) { - didRemove = true; candidates.remove(i); --i; } } - return didRemove; } } diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java index 123ab208c..982d4c690 100644 --- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java +++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java @@ -69,7 +69,7 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { // subtypes when the package is replaced. RichInputMethodManager.init(context); final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); - final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(context); + final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(); richImm.setAdditionalInputMethodSubtypes(additionalSubtypes); LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) { diff --git a/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java b/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java index 78bfd2b52..8cc3552ed 100644 --- a/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java +++ b/java/src/com/android/inputmethod/latin/debug/ExternalDictionaryGetterForDebug.java @@ -101,12 +101,12 @@ public class ExternalDictionaryGetterForDebug { final File file = new File(dirPath, fileName.toString()); final DictionaryHeader header = DictionaryInfoUtils.getDictionaryFileHeaderOrNull(file); final StringBuilder message = new StringBuilder(); - final String locale = header.getLocaleString(); - for (String key : header.mDictionaryOptions.mAttributes.keySet()) { + final String localeString = header.mLocaleString; + for (final String key : header.mDictionaryOptions.mAttributes.keySet()) { message.append(key + " = " + header.mDictionaryOptions.mAttributes.get(key)); message.append("\n"); } - final String languageName = LocaleUtils.constructLocaleFromString(locale) + final String languageName = LocaleUtils.constructLocaleFromString(localeString) .getDisplayName(Locale.getDefault()); final String title = String.format( context.getString(R.string.read_external_dictionary_confirm_install_message), @@ -146,11 +146,12 @@ public class ExternalDictionaryGetterForDebug { BufferedOutputStream outputStream = null; File tempFile = null; try { - final String locale = header.getLocaleString(); + final String localeString = header.mLocaleString; // Create the id for a main dictionary for this locale final String id = BinaryDictionaryGetter.MAIN_DICTIONARY_CATEGORY - + BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR + locale; - final String finalFileName = DictionaryInfoUtils.getCacheFileName(id, locale, context); + + BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR + localeString; + final String finalFileName = DictionaryInfoUtils.getCacheFileName( + id, localeString, context); final String tempFileName = BinaryDictionaryGetter.getTempFileName(id, context); tempFile = new File(tempFileName); tempFile.delete(); diff --git a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java index 644818ba6..4d253b0cb 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java +++ b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java @@ -19,13 +19,24 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Class representing dictionary header. */ public final class DictionaryHeader { public final int mBodyOffset; + @Nonnull public final DictionaryOptions mDictionaryOptions; + @Nonnull public final FormatOptions mFormatOptions; + @Nonnull + public final String mLocaleString; + @Nonnull + public final String mVersionString; + @Nonnull + public final String mIdString; // Note that these are corresponding definitions in native code in latinime::HeaderPolicy // and latinime::HeaderReadWriteUtils. @@ -46,39 +57,32 @@ public final class DictionaryHeader { public static final String ATTRIBUTE_VALUE_TRUE = "1"; public static final String CODE_POINT_TABLE_KEY = "codePointTable"; - public DictionaryHeader(final int headerSize, final DictionaryOptions dictionaryOptions, - final FormatOptions formatOptions) throws UnsupportedFormatException { + public DictionaryHeader(final int headerSize, + @Nonnull final DictionaryOptions dictionaryOptions, + @Nonnull final FormatOptions formatOptions) throws UnsupportedFormatException { mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; mBodyOffset = formatOptions.mVersion < FormatSpec.VERSION4 ? headerSize : 0; - if (null == getLocaleString()) { + final String localeString = dictionaryOptions.mAttributes.get(DICTIONARY_LOCALE_KEY); + if (null == localeString) { throw new UnsupportedFormatException("Cannot create a FileHeader without a locale"); } - if (null == getVersion()) { + final String versionString = dictionaryOptions.mAttributes.get(DICTIONARY_VERSION_KEY); + if (null == versionString) { throw new UnsupportedFormatException( "Cannot create a FileHeader without a version"); } - if (null == getId()) { + final String idString = dictionaryOptions.mAttributes.get(DICTIONARY_ID_KEY); + if (null == idString) { throw new UnsupportedFormatException("Cannot create a FileHeader without an ID"); } - } - - // Helper method to get the locale as a String - public String getLocaleString() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_LOCALE_KEY); - } - - // Helper method to get the version String - public String getVersion() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_VERSION_KEY); - } - - // Helper method to get the dictionary ID as a String - public String getId() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_ID_KEY); + mLocaleString = localeString; + mVersionString = versionString; + mIdString = idString; } // Helper method to get the description + @Nullable public String getDescription() { // TODO: Right now each dictionary file comes with a description in its own language. // It will display as is no matter the device's locale. It should be internationalized. diff --git a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java b/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java index 221bb9a8f..e974f3320 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java +++ b/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java @@ -43,17 +43,40 @@ public class DictionaryDecayBroadcastReciever extends BroadcastReceiver { /** * Interval to update for decaying dictionaries. */ - /* package */ static final long DICTIONARY_DECAY_INTERVAL = TimeUnit.MINUTES.toMillis(60); + static final long DICTIONARY_DECAY_INTERVAL_IN_MILLIS = TimeUnit.MINUTES.toMillis(60); - public static void setUpIntervalAlarmForDictionaryDecaying(Context context) { - AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + private static PendingIntent getPendingIntentForDictionaryDecay(final Context context) { final Intent updateIntent = new Intent(DICTIONARY_DECAY_INTENT_ACTION); updateIntent.setClass(context, DictionaryDecayBroadcastReciever.class); - final long alarmTime = System.currentTimeMillis() + DICTIONARY_DECAY_INTERVAL; - final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0 /* requestCode */, + return PendingIntent.getBroadcast(context, 0 /* requestCode */, updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); - if (null != alarmManager) alarmManager.setInexactRepeating(AlarmManager.RTC, - alarmTime, DICTIONARY_DECAY_INTERVAL, pendingIntent); + } + + /** + * Set up interval alarm for dynamic dictionaries. + */ + public static void setUpIntervalAlarmForDictionaryDecaying(final Context context) { + final AlarmManager alarmManager = + (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + if (null == alarmManager) { + return; + } + final long alarmTriggerTimeInMillis = + System.currentTimeMillis() + DICTIONARY_DECAY_INTERVAL_IN_MILLIS; + alarmManager.setInexactRepeating(AlarmManager.RTC, alarmTriggerTimeInMillis, + DICTIONARY_DECAY_INTERVAL_IN_MILLIS, getPendingIntentForDictionaryDecay(context)); + } + + /** + * Cancel interval alarm that has been set up. + */ + public static void cancelIntervalAlarmForDictionaryDecaying(final Context context) { + final AlarmManager alarmManager = + (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + if (null == alarmManager) { + return; + } + alarmManager.cancel(getPendingIntentForDictionaryDecay(context)); } @Override diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java index 8c5eb0aa7..74196dd6d 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java @@ -74,7 +74,7 @@ public class PersonalizationHelper { private static int sCurrentTimestampForTesting = 0; public static void currentTimeChangedForTesting(final int currentTimestamp) { if (TimeUnit.MILLISECONDS.toSeconds( - DictionaryDecayBroadcastReciever.DICTIONARY_DECAY_INTERVAL) + DictionaryDecayBroadcastReciever.DICTIONARY_DECAY_INTERVAL_IN_MILLIS) < currentTimestamp - sCurrentTimestampForTesting) { runGCOnAllOpenedUserHistoryDictionaries(); runGCOnAllOpenedPersonalizationDictionaries(); diff --git a/java/src/com/android/inputmethod/latin/settings/CustomInputStylePreference.java b/java/src/com/android/inputmethod/latin/settings/CustomInputStylePreference.java index b749aa51a..21ea8f859 100644 --- a/java/src/com/android/inputmethod/latin/settings/CustomInputStylePreference.java +++ b/java/src/com/android/inputmethod/latin/settings/CustomInputStylePreference.java @@ -196,16 +196,6 @@ final class CustomInputStylePreference extends DialogPreference } } - private static int getSpinnerPosition(final Spinner spinner) { - if (spinner == null) return -1; - return spinner.getSelectedItemPosition(); - } - - private static void setSpinnerPosition(final Spinner spinner, final int position) { - if (spinner == null || position < 0) return; - spinner.setSelection(position); - } - @Override protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); @@ -216,8 +206,6 @@ final class CustomInputStylePreference extends DialogPreference final SavedState myState = new SavedState(superState); myState.mSubtype = mSubtype; - myState.mSubtypeLocaleSelectedPos = getSpinnerPosition(mSubtypeLocaleSpinner); - myState.mKeyboardLayoutSetSelectedPos = getSpinnerPosition(mKeyboardLayoutSetSpinner); return myState; } @@ -230,15 +218,11 @@ final class CustomInputStylePreference extends DialogPreference final SavedState myState = (SavedState) state; super.onRestoreInstanceState(myState.getSuperState()); - setSpinnerPosition(mSubtypeLocaleSpinner, myState.mSubtypeLocaleSelectedPos); - setSpinnerPosition(mKeyboardLayoutSetSpinner, myState.mKeyboardLayoutSetSelectedPos); setSubtype(myState.mSubtype); } static final class SavedState extends Preference.BaseSavedState { InputMethodSubtype mSubtype; - int mSubtypeLocaleSelectedPos; - int mKeyboardLayoutSetSelectedPos; public SavedState(final Parcelable superState) { super(superState); @@ -247,15 +231,11 @@ final class CustomInputStylePreference extends DialogPreference @Override public void writeToParcel(final Parcel dest, final int flags) { super.writeToParcel(dest, flags); - dest.writeInt(mSubtypeLocaleSelectedPos); - dest.writeInt(mKeyboardLayoutSetSelectedPos); dest.writeParcelable(mSubtype, 0); } public SavedState(final Parcel source) { super(source); - mSubtypeLocaleSelectedPos = source.readInt(); - mKeyboardLayoutSetSelectedPos = source.readInt(); mSubtype = (InputMethodSubtype)source.readParcelable(null); } diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java index 068f56df1..b788d7fcf 100644 --- a/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java @@ -281,8 +281,7 @@ public final class DebugSettingsFragment extends SubScreenFragment @Override public int readValue(final String key) { - return getPercentageFromValue( - Settings.readKeyboardHeight(prefs, key, defaultValue)); + return getPercentageFromValue(Settings.readKeyboardHeight(prefs, defaultValue)); } @Override diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 16c053474..0d3dab57c 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -238,6 +238,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang return !currentAutoCorrectionSetting.equals(autoCorrectionOff); } + public static float readPlausibilityThreshold(final Resources res) { + return Float.parseFloat(res.getString(R.string.plausibility_threshold)); + } + public static boolean readBlockPotentiallyOffensive(final SharedPreferences prefs, final Resources res) { return prefs.getBoolean(PREF_BLOCK_POTENTIALLY_OFFENSIVE, @@ -364,8 +368,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang } public static float readKeyboardHeight(final SharedPreferences prefs, - final String prefKey, final float defaultValue) { - final float percentage = prefs.getFloat(prefKey, UNDEFINED_PREFERENCE_VALUE_FLOAT); + final float defaultValue) { + final float percentage = prefs.getFloat( + DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, UNDEFINED_PREFERENCE_VALUE_FLOAT); return (percentage != UNDEFINED_PREFERENCE_VALUE_FLOAT) ? percentage : defaultValue; } diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index 26415e7d4..5f1a7af44 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -96,6 +96,7 @@ public class SettingsValues { public final int mKeyPreviewPopupDismissDelay; private final boolean mAutoCorrectEnabled; public final float mAutoCorrectionThreshold; + public final float mPlausibilityThreshold; public final boolean mAutoCorrectionEnabledPerUserSettings; private final boolean mSuggestionsEnabledPerUserSettings; private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds; @@ -172,6 +173,7 @@ public class SettingsValues { Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true); mAutoCorrectionThreshold = readAutoCorrectionThreshold(res, autoCorrectionThresholdRawValue); + mPlausibilityThreshold = Settings.readPlausibilityThreshold(res); mGestureInputEnabled = Settings.readGestureInputEnabled(prefs, res); mGestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true); mGestureFloatingPreviewTextEnabled = !mInputAttributes.mDisableGestureFloatingPreviewText @@ -188,8 +190,7 @@ public class SettingsValues { mHasCustomKeyPreviewAnimationParams = prefs.getBoolean( DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false); mHasKeyboardResize = prefs.getBoolean(DebugSettings.PREF_RESIZE_KEYBOARD, false); - mKeyboardHeightScale = Settings.readKeyboardHeight( - prefs, DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE); + mKeyboardHeightScale = Settings.readKeyboardHeight(prefs, DEFAULT_SIZE_SCALE); mKeyPreviewShowUpDuration = Settings.readKeyPreviewAnimationDuration( prefs, DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION, res.getInteger(R.integer.config_key_preview_show_up_duration)); diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java index c90e8a3cf..4b8d2a3f9 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java @@ -115,7 +115,8 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { @Override public void onCreate() { final String localeString = getLocale(); - mLocale = LocaleUtils.constructLocaleFromString(localeString); + mLocale = (null == localeString) ? null + : LocaleUtils.constructLocaleFromString(localeString); mScript = ScriptUtils.getScriptFromSpellCheckerLocale(mLocale); } diff --git a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryAddWordContents.java b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryAddWordContents.java index 22fc35a42..69029c51e 100644 --- a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryAddWordContents.java +++ b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryAddWordContents.java @@ -34,6 +34,8 @@ import java.util.ArrayList; import java.util.Locale; import java.util.TreeSet; +import javax.annotation.Nullable; + // Caveat: This class is basically taken from // packages/apps/Settings/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java // in order to deal with some devices that have issues with the user dictionary handling @@ -218,8 +220,8 @@ public class UserDictionaryAddWordContents { public static class LocaleRenderer { private final String mLocaleString; private final String mDescription; - // LocaleString may NOT be null. - public LocaleRenderer(final Context context, final String localeString) { + + public LocaleRenderer(final Context context, @Nullable final String localeString) { mLocaleString = localeString; if (null == localeString) { mDescription = context.getString(R.string.user_dict_settings_more_languages); diff --git a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java index b9ed35375..6254b54ff 100644 --- a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java +++ b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java @@ -37,6 +37,8 @@ import java.util.List; import java.util.Locale; import java.util.TreeSet; +import javax.annotation.Nullable; + // Caveat: This class is basically taken from // packages/apps/Settings/src/com/android/settings/inputmethod/UserDictionaryList.java // in order to deal with some devices that have issues with the user dictionary handling @@ -131,21 +133,23 @@ public class UserDictionaryList extends PreferenceFragment { /** * Create a single User Dictionary Preference object, with its parameters set. - * @param locale The locale for which this user dictionary is for. + * @param localeString The locale for which this user dictionary is for. * @return The corresponding preference. */ - protected Preference createUserDictionaryPreference(final String locale) { + protected Preference createUserDictionaryPreference(@Nullable final String localeString) { final Preference newPref = new Preference(getActivity()); final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION); - if (null == locale) { + if (null == localeString) { newPref.setTitle(Locale.getDefault().getDisplayName()); } else { - if ("".equals(locale)) + if (localeString.isEmpty()) { newPref.setTitle(getString(R.string.user_dict_settings_all_languages)); - else - newPref.setTitle(LocaleUtils.constructLocaleFromString(locale).getDisplayName()); - intent.putExtra("locale", locale); - newPref.getExtras().putString("locale", locale); + } else { + newPref.setTitle( + LocaleUtils.constructLocaleFromString(localeString).getDisplayName()); + } + intent.putExtra("locale", localeString); + newPref.getExtras().putString("locale", localeString); } newPref.setIntent(intent); newPref.setFragment(UserDictionarySettings.class.getName()); diff --git a/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java b/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java index 120cffbde..2fd257922 100644 --- a/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java @@ -29,9 +29,8 @@ public final class AutoCorrectionUtils { // Purely static class: can't instantiate. } - public static boolean suggestionExceedsAutoCorrectionThreshold( - final SuggestedWordInfo suggestion, final String consideredWord, - final float autoCorrectionThreshold) { + public static boolean suggestionExceedsThreshold(final SuggestedWordInfo suggestion, + final String consideredWord, final float threshold) { if (null != suggestion) { // Shortlist a whitelisted word if (suggestion.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { @@ -45,11 +44,11 @@ public final class AutoCorrectionUtils { if (DBG) { Log.d(TAG, "Normalized " + consideredWord + "," + suggestion + "," + autoCorrectionSuggestionScore + ", " + normalizedScore - + "(" + autoCorrectionThreshold + ")"); + + "(" + threshold + ")"); } - if (normalizedScore >= autoCorrectionThreshold) { + if (normalizedScore >= threshold) { if (DBG) { - Log.d(TAG, "Auto corrected by S-threshold."); + Log.d(TAG, "Exceeds threshold."); } return true; } diff --git a/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java b/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java index 8699f2ce7..476c13406 100644 --- a/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java @@ -88,7 +88,7 @@ public class CombinedFormatUtils { for (int i = 0; i < ngramProperty.mNgramContext.getPrevWordCount(); i++) { builder.append(" " + NGRAM_PREV_WORD_TAG + "[" + i + "]=" + ngramProperty.mNgramContext.getNthPrevWord(i + 1)); - if (ngramProperty.mNgramContext.isNthPrevWordBeginningOfSontence(i + 1)) { + if (ngramProperty.mNgramContext.isNthPrevWordBeginningOfSentence(i + 1)) { builder.append("," + BEGINNING_OF_SENTENCE_TAG + "=true"); } builder.append("\n"); diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index 81c3e3c61..fcce1ecdd 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -40,6 +40,9 @@ import java.util.Iterator; import java.util.Locale; import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * This class encapsulates the logic for the Latin-IME side of dictionary information management. */ @@ -59,19 +62,26 @@ public class DictionaryInfoUtils { private static final String DATE_COLUMN = "date"; private static final String FILESIZE_COLUMN = "filesize"; private static final String VERSION_COLUMN = "version"; + @Nonnull public final String mId; + @Nonnull public final Locale mLocale; + @Nullable public final String mDescription; + @Nonnull public final AssetFileAddress mFileAddress; public final int mVersion; - public DictionaryInfo(final String id, final Locale locale, final String description, - final AssetFileAddress fileAddress, final int version) { + + public DictionaryInfo(@Nonnull final String id, @Nonnull final Locale locale, + @Nullable final String description, @Nonnull final AssetFileAddress fileAddress, + final int version) { mId = id; mLocale = locale; mDescription = description; mFileAddress = fileAddress; mVersion = version; } + public ContentValues toContentValues() { final ContentValues values = new ContentValues(); values.put(WORDLISTID_COLUMN, mId); @@ -144,7 +154,8 @@ public class DictionaryInfoUtils { /** * Reverse escaping done by replaceFileNameDangerousCharacters. */ - public static String getWordListIdFromFileName(final String fname) { + @Nonnull + public static String getWordListIdFromFileName(@Nonnull final String fname) { final StringBuilder sb = new StringBuilder(); final int fnameLength = fname.length(); for (int i = 0; i < fnameLength; i = fname.offsetByCodePoints(i, 1)) { @@ -176,12 +187,15 @@ public class DictionaryInfoUtils { * {@link #getMainDictId(Locale)} and {@link #isMainWordListId(String)}. * @return The category as a string or null if it can't be found in the file name. */ - public static String getCategoryFromFileName(final String fileName) { + @Nullable + public static String getCategoryFromFileName(@Nonnull final String fileName) { final String id = getWordListIdFromFileName(fileName); final String[] idArray = id.split(BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR); // An id is supposed to be in format category:locale, so splitting on the separator // should yield a 2-elements array - if (2 != idArray.length) return null; + if (2 != idArray.length) { + return null; + } return idArray[0]; } @@ -225,11 +239,24 @@ public class DictionaryInfoUtils { final String[] idArray = id.split(BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR); // An id is supposed to be in format category:locale, so splitting on the separator // should yield a 2-elements array - if (2 != idArray.length) return false; + if (2 != idArray.length) { + return false; + } return BinaryDictionaryGetter.MAIN_DICTIONARY_CATEGORY.equals(idArray[0]); } /** + * Find out whether a dictionary is available for this locale. + * @param context the context on which to check resources. + * @param locale the locale to check for. + * @return whether a (non-placeholder) dictionary is available or not. + */ + public static boolean isDictionaryAvailable(final Context context, final Locale locale) { + final Resources res = context.getResources(); + return 0 != getMainDictionaryResourceIdIfAvailableForLocale(res, locale); + } + + /** * Helper method to return a dictionary res id for a locale, or 0 if none. * @param res resources for the app * @param locale dictionary locale @@ -266,7 +293,9 @@ public class DictionaryInfoUtils { */ public static int getMainDictionaryResourceId(final Resources res, final Locale locale) { int resourceId = getMainDictionaryResourceIdIfAvailableForLocale(res, locale); - if (0 != resourceId) return resourceId; + if (0 != resourceId) { + return resourceId; + } return res.getIdentifier(DEFAULT_MAIN_DICT, "raw", RESOURCE_PACKAGE_NAME); } @@ -335,10 +364,10 @@ public class DictionaryInfoUtils { if (header == null) { return null; } - final String id = header.getId(); - final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString()); + final String id = header.mIdString; + final Locale locale = LocaleUtils.constructLocaleFromString(header.mLocaleString); final String description = header.getDescription(); - final String version = header.getVersion(); + final String version = header.mVersionString; return new DictionaryInfo(id, locale, description, fileAddress, Integer.parseInt(version)); } @@ -366,10 +395,13 @@ public class DictionaryInfoUtils { if (null != directoryList) { for (final File directory : directoryList) { final String localeString = getWordListIdFromFileName(directory.getName()); - File[] dicts = BinaryDictionaryGetter.getCachedWordLists(localeString, context); + final File[] dicts = BinaryDictionaryGetter.getCachedWordLists( + localeString, context); for (final File dict : dicts) { final String wordListId = getWordListIdFromFileName(dict.getName()); - if (!DictionaryInfoUtils.isMainWordListId(wordListId)) continue; + if (!DictionaryInfoUtils.isMainWordListId(wordListId)) { + continue; + } final Locale locale = LocaleUtils.constructLocaleFromString(localeString); final AssetFileAddress fileAddress = AssetFileAddress.makeFromFile(dict); final DictionaryInfo dictionaryInfo = @@ -377,7 +409,9 @@ public class DictionaryInfoUtils { // Protect against cases of a less-specific dictionary being found, like an // en dictionary being used for an en_US locale. In this case, the en dictionary // should be used for en_US but discounted for listing purposes. - if (dictionaryInfo == null || !dictionaryInfo.mLocale.equals(locale)) continue; + if (dictionaryInfo == null || !dictionaryInfo.mLocale.equals(locale)) { + continue; + } addOrUpdateDictInfo(dictList, dictionaryInfo); } } @@ -391,14 +425,18 @@ public class DictionaryInfoUtils { final int resourceId = DictionaryInfoUtils.getMainDictionaryResourceIdIfAvailableForLocale( context.getResources(), locale); - if (0 == resourceId) continue; + if (0 == resourceId) { + continue; + } final AssetFileAddress fileAddress = BinaryDictionaryGetter.loadFallbackResource(context, resourceId); final DictionaryInfo dictionaryInfo = createDictionaryInfoFromFileAddress(fileAddress); // Protect against cases of a less-specific dictionary being found, like an // en dictionary being used for an en_US locale. In this case, the en dictionary // should be used for en_US but discounted for listing purposes. - if (!dictionaryInfo.mLocale.equals(locale)) continue; + if (!dictionaryInfo.mLocale.equals(locale)) { + continue; + } addOrUpdateDictInfo(dictList, dictionaryInfo); } @@ -408,7 +446,9 @@ public class DictionaryInfoUtils { @UsedForTesting public static boolean looksValidForDictionaryInsertion(final CharSequence text, final SpacingAndPunctuations spacingAndPunctuations) { - if (TextUtils.isEmpty(text)) return false; + if (TextUtils.isEmpty(text)) { + return false; + } final int length = text.length(); if (length > Constants.DICTIONARY_MAX_WORD_LENGTH) { return false; @@ -424,7 +464,9 @@ public class DictionaryInfoUtils { digitCount += charCount; continue; } - if (!spacingAndPunctuations.isWordCodePoint(codePoint)) return false; + if (!spacingAndPunctuations.isWordCodePoint(codePoint)) { + return false; + } } // We reject strings entirely comprised of digits to avoid using PIN codes or credit // card numbers. It would come in handy for word prediction though; a good example is diff --git a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java index 0e7f4717d..54a3fc39c 100644 --- a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java @@ -199,8 +199,7 @@ public final class SubtypeLocaleUtils { if (sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) { languageString = localeString; } else { - final Locale locale = LocaleUtils.constructLocaleFromString(localeString); - languageString = locale.getLanguage(); + languageString = LocaleUtils.constructLocaleFromString(localeString).getLanguage(); } return getSubtypeLocaleDisplayNameInternal(languageString, displayLocale); } @@ -232,8 +231,8 @@ public final class SubtypeLocaleUtils { }; displayName = getExceptionalName.runInLocale(sResources, displayLocale); } else { - final Locale locale = LocaleUtils.constructLocaleFromString(localeString); - displayName = locale.getDisplayName(displayLocale); + displayName = LocaleUtils.constructLocaleFromString(localeString) + .getDisplayName(displayLocale); } return StringUtils.capitalizeFirstCodePoint(displayName, displayLocale); } diff --git a/native/dicttoolkit/src/command_executors/makedict_executor.cpp b/native/dicttoolkit/src/command_executors/makedict_executor.cpp index 8a84e8069..4b0a5aeea 100644 --- a/native/dicttoolkit/src/command_executors/makedict_executor.cpp +++ b/native/dicttoolkit/src/command_executors/makedict_executor.cpp @@ -24,6 +24,12 @@ namespace dicttoolkit { const char *const MakedictExecutor::COMMAND_NAME = "makedict"; /* static */ int MakedictExecutor::run(const int argc, char **argv) { + const ArgumentsAndOptions argumentsAndOptions = + getArgumentsParser().parseArguments(argc, argv, true /* printErrorMessages */); + if (!argumentsAndOptions.isValid()) { + printUsage(); + return 1; + } fprintf(stderr, "Command '%s' has not been implemented yet.\n", COMMAND_NAME); return 0; } diff --git a/native/dicttoolkit/src/utils/arguments_and_options.h b/native/dicttoolkit/src/utils/arguments_and_options.h index d8f5985e5..2d81b1ecb 100644 --- a/native/dicttoolkit/src/utils/arguments_and_options.h +++ b/native/dicttoolkit/src/utils/arguments_and_options.h @@ -42,6 +42,29 @@ class ArgumentsAndOptions { return mOptions.find(optionName) != mOptions.end(); } + const std::string &getOptionValue(const std::string &optionName) const { + const auto &it = mOptions.find(optionName); + ASSERT(it != mOptions.end()); + return it->second; + } + + bool hasArgument(const std::string &name) const { + const auto &it = mArguments.find(name); + return it != mArguments.end() && !it->second.empty(); + } + + const std::string &getSingleArgument(const std::string &name) const { + const auto &it = mArguments.find(name); + ASSERT(it != mArguments.end() && !it->second.empty()); + return it->second.front(); + } + + const std::vector<std::string> &getVariableLengthArguments(const std::string &name) const { + const auto &it = mArguments.find(name); + ASSERT(it != mArguments.end()); + return it->second; + } + private: DISALLOW_ASSIGNMENT_OPERATOR(ArgumentsAndOptions); diff --git a/native/dicttoolkit/src/utils/arguments_parser.cpp b/native/dicttoolkit/src/utils/arguments_parser.cpp index 52cc7b21d..1451284f1 100644 --- a/native/dicttoolkit/src/utils/arguments_parser.cpp +++ b/native/dicttoolkit/src/utils/arguments_parser.cpp @@ -21,7 +21,7 @@ namespace latinime { namespace dicttoolkit { -const int ArgumentSpec::UNLIMITED_COUNT = -1; +const size_t ArgumentSpec::UNLIMITED_COUNT = S_INT_MAX; bool ArgumentsParser::validateSpecs() const { std::unordered_set<std::string> argumentNameSet; @@ -53,7 +53,7 @@ void ArgumentsParser::printUsage(const std::string &commandName, const std::string &optionName = option.first; const OptionSpec &spec = option.second; printf(" [-%s", optionName.c_str()); - if (spec.takeValue()) { + if (spec.needsValue()) { printf(" <%s>", spec.getValueName().c_str()); } printf("]"); @@ -74,11 +74,11 @@ void ArgumentsParser::printUsage(const std::string &commandName, const std::string &optionName = option.first; const OptionSpec &spec = option.second; printf(" -%s", optionName.c_str()); - if (spec.takeValue()) { + if (spec.needsValue()) { printf(" <%s>", spec.getValueName().c_str()); } printf("\t\t\t%s", spec.getDescription().c_str()); - if (spec.takeValue() && !spec.getDefaultValue().empty()) { + if (spec.needsValue() && !spec.getDefaultValue().empty()) { printf("\tdefault: %s", spec.getDefaultValue().c_str()); } printf("\n"); @@ -89,9 +89,76 @@ void ArgumentsParser::printUsage(const std::string &commandName, printf("\n\n"); } -const ArgumentsAndOptions ArgumentsParser::parseArguments(const int argc, char **argv) const { - // TODO: Implement - return ArgumentsAndOptions(); +const ArgumentsAndOptions ArgumentsParser::parseArguments(const int argc, char **argv, + const bool printErrorMessage) const { + if (argc <= 0) { + AKLOGE("Invalid argc (%d).", argc); + ASSERT(false); + return ArgumentsAndOptions(); + } + std::unordered_map<std::string, std::string> options; + for (const auto &entry : mOptionSpecs) { + const std::string &optionName = entry.first; + const OptionSpec &optionSpec = entry.second; + if (optionSpec.needsValue() && !optionSpec.getDefaultValue().empty()) { + // Set default value. + options[optionName] = optionSpec.getDefaultValue(); + } + } + std::unordered_map<std::string, std::vector<std::string>> arguments; + auto argumentSpecIt = mArgumentSpecs.cbegin(); + for (int i = 1; i < argc; ++i) { + const std::string arg = argv[i]; + if (arg.length() > 1 && arg[0] == '-') { + // option + const std::string optionName = arg.substr(1); + const auto it = mOptionSpecs.find(optionName); + if (it == mOptionSpecs.end()) { + if (printErrorMessage) { + fprintf(stderr, "Unknown option: '%s'\n", optionName.c_str()); + } + return ArgumentsAndOptions(); + } + std::string optionValue; + if (it->second.needsValue()) { + ++i; + if (i >= argc) { + if (printErrorMessage) { + fprintf(stderr, "Missing argument for option '%s'\n", optionName.c_str()); + } + return ArgumentsAndOptions(); + } + optionValue = argv[i]; + } + options[optionName] = optionValue; + } else { + // argument + if (argumentSpecIt == mArgumentSpecs.end()) { + if (printErrorMessage) { + fprintf(stderr, "Too many arguments.\n"); + } + return ArgumentsAndOptions(); + } + arguments[argumentSpecIt->getName()].push_back(arg); + if (arguments[argumentSpecIt->getName()].size() >= argumentSpecIt->getMaxCount()) { + ++argumentSpecIt; + } + } + } + + if (argumentSpecIt != mArgumentSpecs.end()) { + const auto &it = arguments.find(argumentSpecIt->getName()); + const size_t minCount = argumentSpecIt->getMinCount(); + const size_t actualcount = it == arguments.end() ? 0 : it->second.size(); + if (minCount > actualcount) { + if (printErrorMessage) { + fprintf(stderr, "Not enough arguments. %zd argumant(s) required for <%s>\n", + minCount, argumentSpecIt->getName().c_str()); + } + return ArgumentsAndOptions(); + } + } + return ArgumentsAndOptions(std::move(options), std::move(arguments)); } } // namespace dicttoolkit diff --git a/native/dicttoolkit/src/utils/arguments_parser.h b/native/dicttoolkit/src/utils/arguments_parser.h index 510a8722b..32bd328d4 100644 --- a/native/dicttoolkit/src/utils/arguments_parser.h +++ b/native/dicttoolkit/src/utils/arguments_parser.h @@ -35,29 +35,29 @@ class OptionSpec { static OptionSpec keyValueOption(const std::string &valueName, const std::string &defaultValue, const std::string &description) { - return OptionSpec(true /* takeValue */, valueName, defaultValue, description); + return OptionSpec(true /* needsValue */, valueName, defaultValue, description); } static OptionSpec switchOption(const std::string &description) { - return OptionSpec(false /* takeValue */, "" /* valueName */, "" /* defaultValue */, + return OptionSpec(false /* needsValue */, "" /* valueName */, "" /* defaultValue */, description); } - bool takeValue() const { return mTakeValue; } + bool needsValue() const { return mNeedsValue; } const std::string &getValueName() const { return mValueName; } const std::string &getDefaultValue() const { return mDefaultValue; } const std::string &getDescription() const { return mDescription; } private: - OptionSpec(const bool takeValue, const std::string &valueName, const std::string &defaultValue, + OptionSpec(const bool needsValue, const std::string &valueName, const std::string &defaultValue, const std::string &description) - : mTakeValue(takeValue), mValueName(valueName), mDefaultValue(defaultValue), + : mNeedsValue(needsValue), mValueName(valueName), mDefaultValue(defaultValue), mDescription(description) {} // Whether the option have to be used with a value or just a switch. - // e.g. 'f' in "command -f /path/to/file" is mTakeValue == true. - // 'f' in "command -f -t" is mTakeValue == false. - bool mTakeValue; + // e.g. 'f' in "command -f /path/to/file" is mNeedsValue == true. + // 'f' in "command -f -t" is mNeedsValue == false. + bool mNeedsValue; // Name of the value used to show usage. std::string mValueName; std::string mDefaultValue; @@ -66,32 +66,32 @@ class OptionSpec { class ArgumentSpec { public: - static const int UNLIMITED_COUNT; + static const size_t UNLIMITED_COUNT; static ArgumentSpec singleArgument(const std::string &name, const std::string &description) { return ArgumentSpec(name, 1 /* minCount */, 1 /* maxCount */, description); } - static ArgumentSpec variableLengthArguments(const std::string &name, const int minCount, - const int maxCount, const std::string &description) { + static ArgumentSpec variableLengthArguments(const std::string &name, const size_t minCount, + const size_t maxCount, const std::string &description) { return ArgumentSpec(name, minCount, maxCount, description); } const std::string &getName() const { return mName; } - int getMinCount() const { return mMinCount; } - int getMaxCount() const { return mMaxCount; } + size_t getMinCount() const { return mMinCount; } + size_t getMaxCount() const { return mMaxCount; } const std::string &getDescription() const { return mDescription; } private: DISALLOW_DEFAULT_CONSTRUCTOR(ArgumentSpec); - ArgumentSpec(const std::string &name, const int minCount, const int maxCount, + ArgumentSpec(const std::string &name, const size_t minCount, const size_t maxCount, const std::string &description) : mName(name), mMinCount(minCount), mMaxCount(maxCount), mDescription(description) {} const std::string mName; - const int mMinCount; - const int mMaxCount; + const size_t mMinCount; + const size_t mMaxCount; const std::string mDescription; }; @@ -101,7 +101,8 @@ class ArgumentsParser { const std::vector<ArgumentSpec> &&argumentSpecs) : mOptionSpecs(std::move(optionSpecs)), mArgumentSpecs(std::move(argumentSpecs)) {} - const ArgumentsAndOptions parseArguments(const int argc, char **argv) const; + const ArgumentsAndOptions parseArguments(const int argc, char **argv, + const bool printErrorMessage) const; bool validateSpecs() const; void printUsage(const std::string &commandName, const std::string &description) const; diff --git a/native/dicttoolkit/tests/utils/arguments_parser_test.cpp b/native/dicttoolkit/tests/utils/arguments_parser_test.cpp index e79425b87..58b499823 100644 --- a/native/dicttoolkit/tests/utils/arguments_parser_test.cpp +++ b/native/dicttoolkit/tests/utils/arguments_parser_test.cpp @@ -68,6 +68,80 @@ TEST(ArgumentsParserTests, TestValitadeSpecs) { } } +int initArgv(char *mutableCommandLine, char **argv) { + bool readingSeparator = false; + int argc = 1; + argv[0] = mutableCommandLine; + const size_t length = strlen(mutableCommandLine); + for (size_t i = 0; i < length; ++i) { + if (mutableCommandLine[i] != ' ' && readingSeparator) { + readingSeparator = false; + argv[argc] = mutableCommandLine + i; + ++argc; + } else if (mutableCommandLine[i] == ' ' && !readingSeparator) { + readingSeparator = true; + mutableCommandLine[i] = '\0'; + } + } + argv[argc] = nullptr; + return argc; +} + +TEST(ArgumentsParserTests, TestParseArguments) { + std::unordered_map<std::string, OptionSpec> optionSpecs; + optionSpecs["a"] = OptionSpec::switchOption("description"); + optionSpecs["b"] = OptionSpec::keyValueOption("valueName", "default", "description"); + const std::vector<ArgumentSpec> argumentSpecs = { + ArgumentSpec::singleArgument("arg0", "description"), + ArgumentSpec::variableLengthArguments("arg1", 0 /* minCount */, 2 /* maxCount */, + "description"), + }; + const ArgumentsParser parser = + ArgumentsParser(std::move(optionSpecs), std::move(argumentSpecs)); + + { + char kMutableCommandLine[1024] = "command arg"; + char *argv[128] = {}; + const int argc = initArgv(kMutableCommandLine, argv); + ASSERT_EQ(2, argc); + const ArgumentsAndOptions argumentsAndOptions = parser.parseArguments( + argc, argv, false /* printErrorMessages */); + EXPECT_FALSE(argumentsAndOptions.hasOption("a")); + EXPECT_EQ("default", argumentsAndOptions.getOptionValue("b")); + EXPECT_EQ("arg", argumentsAndOptions.getSingleArgument("arg0")); + EXPECT_FALSE(argumentsAndOptions.hasArgument("arg1")); + } + { + char kArgumentBuffer[1024] = "command -a arg arg"; + char *argv[128] = {}; + const int argc = initArgv(kArgumentBuffer, argv); + ASSERT_EQ(4, argc); + const ArgumentsAndOptions argumentsAndOptions = parser.parseArguments( + argc, argv, false /* printErrorMessages */); + EXPECT_TRUE(argumentsAndOptions.hasOption("a")); + EXPECT_EQ("default", argumentsAndOptions.getOptionValue("b")); + EXPECT_EQ("arg", argumentsAndOptions.getSingleArgument("arg0")); + EXPECT_TRUE(argumentsAndOptions.hasArgument("arg1")); + EXPECT_EQ(1u, argumentsAndOptions.getVariableLengthArguments("arg1").size()); + } + { + char kArgumentBuffer[1024] = "command -b value arg arg1 arg2"; + char *argv[128] = {}; + const int argc = initArgv(kArgumentBuffer, argv); + ASSERT_EQ(6, argc); + const ArgumentsAndOptions argumentsAndOptions = parser.parseArguments( + argc, argv, false /* printErrorMessages */); + EXPECT_FALSE(argumentsAndOptions.hasOption("a")); + EXPECT_EQ("value", argumentsAndOptions.getOptionValue("b")); + EXPECT_EQ("arg", argumentsAndOptions.getSingleArgument("arg0")); + const std::vector<std::string> &arg1 = + argumentsAndOptions.getVariableLengthArguments("arg1"); + EXPECT_EQ(2u, arg1.size()); + EXPECT_EQ("arg1", arg1[0]); + EXPECT_EQ("arg2", arg1[1]); + } +} + } // namespace } // namespace dicttoolkit } // namespace latinime diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java index 0246c49a1..7f828111d 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -75,7 +75,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { mRichImm = RichInputMethodManager.getInstance(); // Save and reset additional subtypes preference. - mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes(context); + mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes(); final InputMethodSubtype[] predefinedAdditionalSubtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray( AdditionalSubtypeUtils.createPrefSubtypes( diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java index bcf016ae9..8614ccc0e 100644 --- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java +++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java @@ -176,7 +176,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { assertEquals(NgramContextUtils.getNgramContextFromNthPreviousWord( "abc def", mSpacingAndPunctuations, 1).getNthPrevWord(2), "abc"); assertTrue(NgramContextUtils.getNgramContextFromNthPreviousWord( - "abc def", mSpacingAndPunctuations, 2).isNthPrevWordBeginningOfSontence(2)); + "abc def", mSpacingAndPunctuations, 2).isNthPrevWordBeginningOfSentence(2)); // The following tests reflect the current behavior of the function // RichInputConnection#getNthPreviousWord. diff --git a/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java b/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java index aed7d6ad6..9c8e16511 100644 --- a/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java +++ b/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java @@ -76,7 +76,7 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase { mRichImm = RichInputMethodManager.getInstance(); // Save and reset additional subtypes - mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes(context); + mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes(); final InputMethodSubtype[] predefinedAddtionalSubtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray( AdditionalSubtypeUtils.createPrefSubtypes( diff --git a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java index 03dcdfc78..111d5c56a 100644 --- a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java @@ -73,7 +73,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase { mRichImm = RichInputMethodManager.getInstance(); // Save and reset additional subtypes - mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes(context); + mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes(); final InputMethodSubtype[] predefinedAddtionalSubtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray( AdditionalSubtypeUtils.createPrefSubtypes( @@ -418,9 +418,17 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase { SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI)); // These are preliminary subtypes and may not exist. if (HI_LATN != null) { - assertEquals("hi_ZZ", "हिंग्लिश", + // TODO: Uncommented because of the current translation of these strings + // in Hindi are described in Latin script. + // assertEquals("hi_ZZ", "हिंग्लिश", + // SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN)); + // assertEquals("hi_ZZ", "हिंग्लिश (Dvorak)", + // SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN_DVORAK)); + // TODO: Remove these tests once the translation of these strings in Hindi + // are described in Devanagari script. + assertEquals("hi_ZZ", "Hinglish", SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN)); - assertEquals("hi_ZZ", "हिंग्लिश (Dvorak)", + assertEquals("hi_ZZ", "Hinglish (Dvorak)", SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN_DVORAK)); } return null; diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java index 84c3956f7..b5ed94ccd 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java @@ -37,8 +37,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.util.Arrays; -import java.util.ArrayList; import java.util.HashMap; import javax.annotation.Nonnull; diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Header.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Header.java index ba96c0aeb..aa1762ff1 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Header.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Header.java @@ -16,14 +16,12 @@ package com.android.inputmethod.latin.dicttool; -import com.android.inputmethod.latin.BinaryDictionary; import com.android.inputmethod.latin.dicttool.BinaryDictOffdeviceUtils.DecoderChainSpec; import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import java.io.File; import java.util.Arrays; -import java.util.Locale; public class Header extends Dicttool.Command { public static final String COMMAND = "header"; diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java index ea9d4cc19..e68aeb0eb 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java @@ -154,7 +154,6 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { public void runTestHeaderReaderProcessorWithOneSpec(final boolean compress, final boolean crypt) throws IOException, UnsupportedFormatException { final String dictName = "testHeaderReaderProcessor"; - final String dictVersion = Long.toString(System.currentTimeMillis()); final FormatOptions formatOptions = BinaryDictUtils.STATIC_OPTIONS; final int MAX_NUMBER_OF_OPTIONS_TO_ADD = 5; final HashMap<String, String> options = new HashMap<>(); |