Don't auto-select the system language in IME language selection screen.

Fixes http://b/2650378

On entering the selection screen, don't add the system language in addition
to other selected languages.

Change-Id: Id7a3b45df39a8493d17be668029eee139bf00ff3
main
Amith Yamasani 2010-05-03 11:14:31 -07:00
parent 221d99c891
commit f02964264f
4 changed files with 29 additions and 6 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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();

View File

@ -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();