Loading java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +2 −5 Original line number Diff line number Diff line Loading @@ -107,7 +107,8 @@ public class InputMethodManagerCompatWrapper { public List<InputMethodSubtypeCompatWrapper> getEnabledInputMethodSubtypeList( InputMethodInfoCompatWrapper imi, boolean allowsImplicitlySelectedSubtypes) { if (!SUBTYPE_SUPPORTED) { String[] languages = mLanguageSwitcherProxy.getEnabledLanguages(); String[] languages = mLanguageSwitcherProxy.getEnabledLanguages( allowsImplicitlySelectedSubtypes); List<InputMethodSubtypeCompatWrapper> subtypeList = new ArrayList<InputMethodSubtypeCompatWrapper>(); for (String lang: languages) { Loading Loading @@ -195,10 +196,6 @@ public class InputMethodManagerCompatWrapper { public void setInputMethodAndSubtype( IBinder token, String id, InputMethodSubtypeCompatWrapper subtype) { if (!SUBTYPE_SUPPORTED) { mLanguageSwitcherProxy.setLocale(subtype.getLocale()); return; } CompatUtils.invoke(mImm, null, METHOD_setInputMethodAndSubtype, token, id, subtype.getOriginalObject()); } Loading java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.inputmethod.compat; import com.android.inputmethod.deprecated.LanguageSwitcherProxy; import com.android.inputmethod.latin.SubtypeSwitcher; import android.inputmethodservice.InputMethodService; Loading Loading @@ -51,6 +52,9 @@ public class InputMethodServiceCompatWrapper extends InputMethodService { subtype = mImm.getCurrentInputMethodSubtype(); } if (subtype != null) { if (!InputMethodManagerCompatWrapper.SUBTYPE_SUPPORTED) { LanguageSwitcherProxy.getInstance().setLocale(subtype.getLocale()); } SubtypeSwitcher.getInstance().updateSubtype(subtype); } } Loading java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java +15 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.deprecated; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.deprecated.languageswitcher.LanguageSwitcher; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.Settings; import android.content.SharedPreferences; import android.content.res.Configuration; Loading @@ -26,7 +27,7 @@ import android.content.res.Configuration; import java.util.Locale; // This class is used only when the IME doesn't use method.xml for language switching. public class LanguageSwitcherProxy { public class LanguageSwitcherProxy implements SharedPreferences.OnSharedPreferenceChangeListener { private static final LanguageSwitcherProxy sInstance = new LanguageSwitcherProxy(); private LanguageSwitcher mLanguageSwitcher; private SharedPreferences mPrefs; Loading @@ -42,6 +43,7 @@ public class LanguageSwitcherProxy { sInstance.mLanguageSwitcher = new LanguageSwitcher(service); sInstance.mLanguageSwitcher.loadLocales(prefs, conf.locale); sInstance.mPrefs = prefs; prefs.registerOnSharedPreferenceChangeListener(sInstance); } public static void onConfigurationChanged(Configuration conf) { Loading @@ -58,8 +60,8 @@ public class LanguageSwitcherProxy { return mLanguageSwitcher.getLocaleCount(); } public String[] getEnabledLanguages() { return mLanguageSwitcher.getEnabledLanguages(); public String[] getEnabledLanguages(boolean allowImplicitlySelectedLanguages) { return mLanguageSwitcher.getEnabledLanguages(allowImplicitlySelectedLanguages); } public Locale getInputLocale() { Loading @@ -70,4 +72,14 @@ public class LanguageSwitcherProxy { mLanguageSwitcher.setLocale(localeStr); mLanguageSwitcher.persist(mPrefs); } @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { // PREF_SELECTED_LANGUAGES: enabled input subtypes // PREF_INPUT_LANGUAGE: current input subtype if (key.equals(Settings.PREF_SELECTED_LANGUAGES) || key.equals(Settings.PREF_INPUT_LANGUAGE)) { mLanguageSwitcher.loadLocales(prefs, null); } } } java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java +17 −7 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.deprecated.languageswitcher; import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.Settings; import com.android.inputmethod.latin.SharedPreferencesCompat; Loading @@ -25,6 +26,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; import java.util.Locale; Loading @@ -34,12 +36,14 @@ import java.util.Locale; * input language that the user has selected. */ public class LanguageSwitcher { private static final String TAG = LanguageSwitcher.class.getSimpleName(); private static final String KEYBOARD_MODE = "keyboard"; private static final String[] EMPTY_STIRNG_ARRAY = new String[0]; private final ArrayList<Locale> mLocales = new ArrayList<Locale>(); private final LatinIME mIme; private String[] mSelectedLanguageArray; private String[] mSelectedLanguageArray = EMPTY_STIRNG_ARRAY; private String mSelectedLanguages; private int mCurrentIndex = 0; private String mDefaultInputLanguage; Loading Loading @@ -69,12 +73,16 @@ public class LanguageSwitcher { * @return whether there was any change */ public boolean loadLocales(SharedPreferences sp, Locale systemLocale) { if (LatinImeLogger.sDBG) { Log.d(TAG, "load locales"); } if (systemLocale != null) { setSystemLocale(systemLocale); } String selectedLanguages = sp.getString(Settings.PREF_SELECTED_LANGUAGES, null); String currentLanguage = sp.getString(Settings.PREF_INPUT_LANGUAGE, null); if (selectedLanguages == null || selectedLanguages.length() < 1) { if (TextUtils.isEmpty(selectedLanguages)) { mSelectedLanguageArray = EMPTY_STIRNG_ARRAY; loadDefaults(); if (mLocales.size() == 0) { return false; Loading Loading @@ -104,6 +112,9 @@ public class LanguageSwitcher { } private void loadDefaults() { if (LatinImeLogger.sDBG) { Log.d(TAG, "load default locales:"); } mDefaultInputLocale = mIme.getResources().getConfiguration().locale; String country = mDefaultInputLocale.getCountry(); mDefaultInputLanguage = mDefaultInputLocale.getLanguage() + Loading Loading @@ -132,7 +143,10 @@ public class LanguageSwitcher { /** * Returns the list of enabled language codes. */ public String[] getEnabledLanguages() { public String[] getEnabledLanguages(boolean allowImplicitlySelectedLanguages) { if (mSelectedLanguageArray.length == 0 && allowImplicitlySelectedLanguages) { return new String[] { mDefaultInputLanguage }; } return mSelectedLanguageArray; } Loading Loading @@ -218,9 +232,5 @@ public class LanguageSwitcher { Editor editor = prefs.edit(); editor.putString(Settings.PREF_INPUT_LANGUAGE, getInputLanguage()); SharedPreferencesCompat.apply(editor); // When the current language is changed, the event for this change should be handled // internally as a subtype switching. mIme.notifyOnCurrentInputMethodSubtypeChanged(new InputMethodSubtypeCompatWrapper( 0, 0, getInputLocale().toString(), KEYBOARD_MODE, "")); } } java/src/com/android/inputmethod/latin/LatinIME.java +1 −1 Original line number Diff line number Diff line Loading @@ -375,10 +375,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mPrefs = prefs; LatinImeLogger.init(this, prefs); LanguageSwitcherProxy.init(this, prefs); SubtypeSwitcher.init(this, prefs); KeyboardSwitcher.init(this, prefs); AccessibilityUtils.init(this, prefs); LanguageSwitcherProxy.init(this, prefs); super.onCreate(); Loading Loading
java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +2 −5 Original line number Diff line number Diff line Loading @@ -107,7 +107,8 @@ public class InputMethodManagerCompatWrapper { public List<InputMethodSubtypeCompatWrapper> getEnabledInputMethodSubtypeList( InputMethodInfoCompatWrapper imi, boolean allowsImplicitlySelectedSubtypes) { if (!SUBTYPE_SUPPORTED) { String[] languages = mLanguageSwitcherProxy.getEnabledLanguages(); String[] languages = mLanguageSwitcherProxy.getEnabledLanguages( allowsImplicitlySelectedSubtypes); List<InputMethodSubtypeCompatWrapper> subtypeList = new ArrayList<InputMethodSubtypeCompatWrapper>(); for (String lang: languages) { Loading Loading @@ -195,10 +196,6 @@ public class InputMethodManagerCompatWrapper { public void setInputMethodAndSubtype( IBinder token, String id, InputMethodSubtypeCompatWrapper subtype) { if (!SUBTYPE_SUPPORTED) { mLanguageSwitcherProxy.setLocale(subtype.getLocale()); return; } CompatUtils.invoke(mImm, null, METHOD_setInputMethodAndSubtype, token, id, subtype.getOriginalObject()); } Loading
java/src/com/android/inputmethod/compat/InputMethodServiceCompatWrapper.java +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.inputmethod.compat; import com.android.inputmethod.deprecated.LanguageSwitcherProxy; import com.android.inputmethod.latin.SubtypeSwitcher; import android.inputmethodservice.InputMethodService; Loading Loading @@ -51,6 +52,9 @@ public class InputMethodServiceCompatWrapper extends InputMethodService { subtype = mImm.getCurrentInputMethodSubtype(); } if (subtype != null) { if (!InputMethodManagerCompatWrapper.SUBTYPE_SUPPORTED) { LanguageSwitcherProxy.getInstance().setLocale(subtype.getLocale()); } SubtypeSwitcher.getInstance().updateSubtype(subtype); } } Loading
java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java +15 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.deprecated; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.deprecated.languageswitcher.LanguageSwitcher; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.Settings; import android.content.SharedPreferences; import android.content.res.Configuration; Loading @@ -26,7 +27,7 @@ import android.content.res.Configuration; import java.util.Locale; // This class is used only when the IME doesn't use method.xml for language switching. public class LanguageSwitcherProxy { public class LanguageSwitcherProxy implements SharedPreferences.OnSharedPreferenceChangeListener { private static final LanguageSwitcherProxy sInstance = new LanguageSwitcherProxy(); private LanguageSwitcher mLanguageSwitcher; private SharedPreferences mPrefs; Loading @@ -42,6 +43,7 @@ public class LanguageSwitcherProxy { sInstance.mLanguageSwitcher = new LanguageSwitcher(service); sInstance.mLanguageSwitcher.loadLocales(prefs, conf.locale); sInstance.mPrefs = prefs; prefs.registerOnSharedPreferenceChangeListener(sInstance); } public static void onConfigurationChanged(Configuration conf) { Loading @@ -58,8 +60,8 @@ public class LanguageSwitcherProxy { return mLanguageSwitcher.getLocaleCount(); } public String[] getEnabledLanguages() { return mLanguageSwitcher.getEnabledLanguages(); public String[] getEnabledLanguages(boolean allowImplicitlySelectedLanguages) { return mLanguageSwitcher.getEnabledLanguages(allowImplicitlySelectedLanguages); } public Locale getInputLocale() { Loading @@ -70,4 +72,14 @@ public class LanguageSwitcherProxy { mLanguageSwitcher.setLocale(localeStr); mLanguageSwitcher.persist(mPrefs); } @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { // PREF_SELECTED_LANGUAGES: enabled input subtypes // PREF_INPUT_LANGUAGE: current input subtype if (key.equals(Settings.PREF_SELECTED_LANGUAGES) || key.equals(Settings.PREF_INPUT_LANGUAGE)) { mLanguageSwitcher.loadLocales(prefs, null); } } }
java/src/com/android/inputmethod/deprecated/languageswitcher/LanguageSwitcher.java +17 −7 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.deprecated.languageswitcher; import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.Settings; import com.android.inputmethod.latin.SharedPreferencesCompat; Loading @@ -25,6 +26,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; import java.util.Locale; Loading @@ -34,12 +36,14 @@ import java.util.Locale; * input language that the user has selected. */ public class LanguageSwitcher { private static final String TAG = LanguageSwitcher.class.getSimpleName(); private static final String KEYBOARD_MODE = "keyboard"; private static final String[] EMPTY_STIRNG_ARRAY = new String[0]; private final ArrayList<Locale> mLocales = new ArrayList<Locale>(); private final LatinIME mIme; private String[] mSelectedLanguageArray; private String[] mSelectedLanguageArray = EMPTY_STIRNG_ARRAY; private String mSelectedLanguages; private int mCurrentIndex = 0; private String mDefaultInputLanguage; Loading Loading @@ -69,12 +73,16 @@ public class LanguageSwitcher { * @return whether there was any change */ public boolean loadLocales(SharedPreferences sp, Locale systemLocale) { if (LatinImeLogger.sDBG) { Log.d(TAG, "load locales"); } if (systemLocale != null) { setSystemLocale(systemLocale); } String selectedLanguages = sp.getString(Settings.PREF_SELECTED_LANGUAGES, null); String currentLanguage = sp.getString(Settings.PREF_INPUT_LANGUAGE, null); if (selectedLanguages == null || selectedLanguages.length() < 1) { if (TextUtils.isEmpty(selectedLanguages)) { mSelectedLanguageArray = EMPTY_STIRNG_ARRAY; loadDefaults(); if (mLocales.size() == 0) { return false; Loading Loading @@ -104,6 +112,9 @@ public class LanguageSwitcher { } private void loadDefaults() { if (LatinImeLogger.sDBG) { Log.d(TAG, "load default locales:"); } mDefaultInputLocale = mIme.getResources().getConfiguration().locale; String country = mDefaultInputLocale.getCountry(); mDefaultInputLanguage = mDefaultInputLocale.getLanguage() + Loading Loading @@ -132,7 +143,10 @@ public class LanguageSwitcher { /** * Returns the list of enabled language codes. */ public String[] getEnabledLanguages() { public String[] getEnabledLanguages(boolean allowImplicitlySelectedLanguages) { if (mSelectedLanguageArray.length == 0 && allowImplicitlySelectedLanguages) { return new String[] { mDefaultInputLanguage }; } return mSelectedLanguageArray; } Loading Loading @@ -218,9 +232,5 @@ public class LanguageSwitcher { Editor editor = prefs.edit(); editor.putString(Settings.PREF_INPUT_LANGUAGE, getInputLanguage()); SharedPreferencesCompat.apply(editor); // When the current language is changed, the event for this change should be handled // internally as a subtype switching. mIme.notifyOnCurrentInputMethodSubtypeChanged(new InputMethodSubtypeCompatWrapper( 0, 0, getInputLocale().toString(), KEYBOARD_MODE, "")); } }
java/src/com/android/inputmethod/latin/LatinIME.java +1 −1 Original line number Diff line number Diff line Loading @@ -375,10 +375,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mPrefs = prefs; LatinImeLogger.init(this, prefs); LanguageSwitcherProxy.init(this, prefs); SubtypeSwitcher.init(this, prefs); KeyboardSwitcher.init(this, prefs); AccessibilityUtils.init(this, prefs); LanguageSwitcherProxy.init(this, prefs); super.onCreate(); Loading