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: Id7a3b45df39a8493d17be668029eee139bf00ff3main
parent
221d99c891
commit
f02964264f
|
@ -89,11 +89,6 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
if (lang.equalsIgnoreCase(list[i])) return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class LanguageSwitcher {
|
||||||
private int mCurrentIndex = 0;
|
private int mCurrentIndex = 0;
|
||||||
private String mDefaultInputLanguage;
|
private String mDefaultInputLanguage;
|
||||||
private Locale mDefaultInputLocale;
|
private Locale mDefaultInputLocale;
|
||||||
|
private Locale mSystemLocale;
|
||||||
|
|
||||||
public LanguageSwitcher(LatinIME ime) {
|
public LanguageSwitcher(LatinIME ime) {
|
||||||
mIme = ime;
|
mIme = ime;
|
||||||
|
@ -97,7 +98,9 @@ public class LanguageSwitcher {
|
||||||
private void constructLocales() {
|
private void constructLocales() {
|
||||||
mLocales = new Locale[mSelectedLanguageArray.length];
|
mLocales = new Locale[mSelectedLanguageArray.length];
|
||||||
for (int i = 0; i < mLocales.length; i++) {
|
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];
|
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
|
* 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.
|
* list if we're at the beginning of the list.
|
||||||
|
|
|
@ -283,6 +283,7 @@ public class LatinIME extends InputMethodService
|
||||||
mKeyboardSwitcher = new KeyboardSwitcher(this, this);
|
mKeyboardSwitcher = new KeyboardSwitcher(this, this);
|
||||||
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
|
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
|
||||||
mSystemLocale = conf.locale.toString();
|
mSystemLocale = conf.locale.toString();
|
||||||
|
mLanguageSwitcher.setSystemLocale(conf.locale);
|
||||||
String inputLanguage = mLanguageSwitcher.getInputLanguage();
|
String inputLanguage = mLanguageSwitcher.getInputLanguage();
|
||||||
if (inputLanguage == null) {
|
if (inputLanguage == null) {
|
||||||
inputLanguage = conf.locale.toString();
|
inputLanguage = conf.locale.toString();
|
||||||
|
@ -368,6 +369,7 @@ public class LatinIME extends InputMethodService
|
||||||
if (mLanguageSwitcher != null) {
|
if (mLanguageSwitcher != null) {
|
||||||
mLanguageSwitcher.loadLocales(
|
mLanguageSwitcher.loadLocales(
|
||||||
PreferenceManager.getDefaultSharedPreferences(this));
|
PreferenceManager.getDefaultSharedPreferences(this));
|
||||||
|
mLanguageSwitcher.setSystemLocale(conf.locale);
|
||||||
toggleLanguage(true, true);
|
toggleLanguage(true, true);
|
||||||
} else {
|
} else {
|
||||||
reloadKeyboards();
|
reloadKeyboards();
|
||||||
|
|
|
@ -430,6 +430,13 @@ public class LatinKeyboard extends Keyboard {
|
||||||
Locale locale = mLanguageSwitcher.getLocaleCount() > 0
|
Locale locale = mLanguageSwitcher.getLocaleCount() > 0
|
||||||
? mLanguageSwitcher.getInputLocale()
|
? mLanguageSwitcher.getInputLocale()
|
||||||
: null;
|
: 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;
|
if (mLocale != null && mLocale.equals(locale)) return;
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
updateSpaceBarForLocale();
|
updateSpaceBarForLocale();
|
||||||
|
|
Loading…
Reference in New Issue