diff --git a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java index b5a11010be18f324179693d7488eed742888263e..5e835e543a7042b1a26ee52a37d17ed33f6a761f 100644 --- a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java +++ b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java @@ -89,11 +89,6 @@ public class InputLanguageSelection extends PreferenceActivity { for (int i = 0; i < list.length; i++) { if (lang.equalsIgnoreCase(list[i])) return true; } - // If it matches the current locale - Locale displayLocale = getResources().getConfiguration().locale; - if (lang.equalsIgnoreCase(get5Code(displayLocale))) { - return true; - } return false; } diff --git a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java index 12045125fd4d14685b5291c8b6d34dab8cbae420..578c805267be2d088710fc2f0a987d58cfda5f70 100644 --- a/java/src/com/android/inputmethod/latin/LanguageSwitcher.java +++ b/java/src/com/android/inputmethod/latin/LanguageSwitcher.java @@ -36,6 +36,7 @@ public class LanguageSwitcher { private int mCurrentIndex = 0; private String mDefaultInputLanguage; private Locale mDefaultInputLocale; + private Locale mSystemLocale; public LanguageSwitcher(LatinIME ime) { mIme = ime; @@ -97,7 +98,9 @@ public class LanguageSwitcher { private void constructLocales() { mLocales = new Locale[mSelectedLanguageArray.length]; for (int i = 0; i < mLocales.length; i++) { - mLocales[i] = new Locale(mSelectedLanguageArray[i]); + final String lang = mSelectedLanguageArray[i]; + mLocales[i] = new Locale(lang.substring(0, 2), + lang.length() > 4 ? lang.substring(3, 5) : ""); } } @@ -140,6 +143,22 @@ public class LanguageSwitcher { return mLocales[(mCurrentIndex + 1) % mLocales.length]; } + /** + * Sets the system locale (display UI) used for comparing with the input language. + * @param locale the locale of the system + */ + public void setSystemLocale(Locale locale) { + mSystemLocale = locale; + } + + /** + * Returns the system locale. + * @return the system locale + */ + public Locale getSystemLocale() { + return mSystemLocale; + } + /** * Returns the previous input locale in the list. Wraps around to the end of the * list if we're at the beginning of the list. diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d0baed52a4c1cfa3d666859b252dee42ff2595ce..b4ed80c1f673f1c46bc62e3338960f61b2108d86 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -283,6 +283,7 @@ public class LatinIME extends InputMethodService mKeyboardSwitcher = new KeyboardSwitcher(this, this); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); + mLanguageSwitcher.setSystemLocale(conf.locale); String inputLanguage = mLanguageSwitcher.getInputLanguage(); if (inputLanguage == null) { inputLanguage = conf.locale.toString(); @@ -368,6 +369,7 @@ public class LatinIME extends InputMethodService if (mLanguageSwitcher != null) { mLanguageSwitcher.loadLocales( PreferenceManager.getDefaultSharedPreferences(this)); + mLanguageSwitcher.setSystemLocale(conf.locale); toggleLanguage(true, true); } else { reloadKeyboards(); diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 32cd8a45f5a5abd443c6c86c9479f95e6623b697..6aea5d13a4308292ff0b9be89b798b25cc080fe2 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -430,6 +430,13 @@ public class LatinKeyboard extends Keyboard { Locale locale = mLanguageSwitcher.getLocaleCount() > 0 ? mLanguageSwitcher.getInputLocale() : null; + // If the language count is 1 and is the same as the system language, don't show it. + if (locale != null + && mLanguageSwitcher.getLocaleCount() == 1 + && mLanguageSwitcher.getSystemLocale().getLanguage() + .equalsIgnoreCase(locale.getLanguage())) { + locale = null; + } if (mLocale != null && mLocale.equals(locale)) return; mLocale = locale; updateSpaceBarForLocale();