am b1068051: am f0296426: Don\'t auto-select the system language in IME language selection screen.

main
Amith Yamasani 2010-05-04 13:08:44 -07:00 committed by Android Git Automerger
commit dbab992963
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();