aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java63
1 files changed, 32 insertions, 31 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 27115e266..45156a31e 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -32,7 +32,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.media.AudioManager;
-import android.net.ConnectivityManager;
import android.os.Build;
import android.os.Debug;
import android.os.IBinder;
@@ -100,6 +99,7 @@ import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
+import com.android.inputmethod.latin.utils.NetworkConnectivityUtils;
import com.android.inputmethod.latin.utils.StatsUtils;
import com.android.inputmethod.latin.utils.StatsUtilsManager;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@@ -166,7 +166,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private RichInputMethodManager mRichImm;
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
- final SubtypeSwitcher mSubtypeSwitcher;
private final SubtypeState mSubtypeState = new SubtypeState();
private final EmojiAltPhysicalKeyDetector mEmojiAltPhysicalKeyDetector =
new EmojiAltPhysicalKeyDetector();
@@ -563,7 +562,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public LatinIME() {
super();
mSettings = Settings.getInstance();
- mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mStatsUtilsManager = StatsUtilsManager.getInstance();
mIsHardwareAcceleratedDrawingEnabled =
@@ -577,7 +575,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this));
RichInputMethodManager.init(this);
mRichImm = RichInputMethodManager.getInstance();
- SubtypeSwitcher.init(this);
KeyboardSwitcher.init(this);
AudioAndHapticFeedbackManager.init(this);
AccessibilityUtils.init(this);
@@ -592,13 +589,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
loadSettings();
resetDictionaryFacilitatorIfNecessary();
- // Register to receive ringer mode change and network state change.
- // Also receive installation and removal of a dictionary pack.
+ NetworkConnectivityUtils.onCreate(this /* context */, mKeyboardSwitcher /* listener */);
+
+ // Register to receive ringer mode change.
final IntentFilter filter = new IntentFilter();
- filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
- registerReceiver(mConnectivityAndRingerModeChangeReceiver, filter);
+ registerReceiver(mRingerModeChangeReceiver, filter);
+ // Register to receive installation and removal of a dictionary pack.
final IntentFilter packageFilter = new IntentFilter();
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
@@ -632,12 +630,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// been displayed. Opening dictionaries never affects responsivity as dictionaries are
// asynchronously loaded.
if (!mHandler.hasPendingReopenDictionaries()) {
- resetDictionaryFacilitatorForLocale(locales);
+ resetDictionaryFacilitator(locales);
}
mDictionaryFacilitator.updateEnabledSubtypes(mRichImm.getMyEnabledInputMethodSubtypeList(
true /* allowsImplicitlySelectedSubtypes */));
refreshPersonalizationDictionarySession(currentSettingsValues);
mStatsUtilsManager.onLoadSettings(currentSettingsValues);
+ resetDictionaryFacilitatorIfNecessary();
}
private void refreshPersonalizationDictionarySession(
@@ -675,7 +674,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
void resetDictionaryFacilitatorIfNecessary() {
final Locale[] subtypeSwitcherLocales = mRichImm.getCurrentSubtypeLocales();
- if (mDictionaryFacilitator.isForLocales(subtypeSwitcherLocales)) {
+ if (mDictionaryFacilitator.isForLocales(subtypeSwitcherLocales)
+ && mDictionaryFacilitator.isForAccount(mSettings.getCurrent().mAccount)) {
return;
}
final Locale[] subtypeLocales;
@@ -689,20 +689,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} else {
subtypeLocales = subtypeSwitcherLocales;
}
- resetDictionaryFacilitatorForLocale(subtypeLocales);
+ resetDictionaryFacilitator(subtypeLocales);
}
/**
- * Reset the facilitator by loading dictionaries for the locales and the current settings values
+ * Reset the facilitator by loading dictionaries for the locales and
+ * the current settings values.
*
* @param locales the locales
*/
- // TODO: make sure the current settings always have the right locales, and read from them
- private void resetDictionaryFacilitatorForLocale(final Locale[] locales) {
+ // TODO: make sure the current settings always have the right locales, and read from them.
+ private void resetDictionaryFacilitator(final Locale[] locales) {
final SettingsValues settingsValues = mSettings.getCurrent();
mDictionaryFacilitator.resetDictionaries(this /* context */, locales,
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
- false /* forceReloadMainDictionary */, this);
+ false /* forceReloadMainDictionary */,
+ settingsValues.mAccount,
+ this /* DictionaryInitializationListener */);
if (settingsValues.mAutoCorrectionEnabledPerUserSettings) {
mInputLogic.mSuggest.setAutoCorrectionThreshold(
settingsValues.mAutoCorrectionThreshold);
@@ -717,7 +720,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final SettingsValues settingsValues = mSettings.getCurrent();
mDictionaryFacilitator.resetDictionaries(this /* context */,
mDictionaryFacilitator.getLocales(), settingsValues.mUseContactsDict,
- settingsValues.mUsePersonalizedDicts, true /* forceReloadMainDictionary */, this);
+ settingsValues.mUsePersonalizedDicts,
+ true /* forceReloadMainDictionary */,
+ settingsValues.mAccount,
+ this /* DictionaryInitializationListener */);
}
@Override
@@ -726,7 +732,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mPersonalizationDictionaryUpdater.onDestroy();
mContextualDictionaryUpdater.onDestroy();
mSettings.onDestroy();
- unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
+ NetworkConnectivityUtils.onDestroy(this /* context */);
+ unregisterReceiver(mRingerModeChangeReceiver);
unregisterReceiver(mDictionaryPackInstallReceiver);
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
mStatsUtilsManager.onDestroy();
@@ -738,7 +745,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void recycle() {
unregisterReceiver(mDictionaryPackInstallReceiver);
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
- unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
+ unregisterReceiver(mRingerModeChangeReceiver);
+ NetworkConnectivityUtils.onDestroy(this /* context */);
mInputLogic.recycle();
}
@@ -866,7 +874,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
// is not guaranteed. It may even be called at the same time on a different thread.
mRichImm.onSubtypeChanged(subtype);
- mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype),
mSettings.getCurrent());
loadKeyboard();
@@ -883,7 +890,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// also wouldn't be consuming gesture data.
mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER;
mRichImm.refreshSubtypeCaches();
- mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
final KeyboardSwitcher switcher = mKeyboardSwitcher;
switcher.updateKeyboardTheme();
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
@@ -945,10 +951,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
Settings.getInstance().getCurrent().mDisplayOrientation,
!isDifferentTextField);
- if (isDifferentTextField) {
- mSubtypeSwitcher.updateParametersOnStartInputView();
- }
-
// The EditorInfo might have a flag that affects fullscreen mode.
// Note: This call should be done by InputMethodService?
updateFullscreenMode();
@@ -1828,15 +1830,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// boolean onKeyLongPress(final int keyCode, final KeyEvent event);
// boolean onKeyMultiple(final int keyCode, final int count, final KeyEvent event);
- // receive ringer mode change and network state change.
- private final BroadcastReceiver mConnectivityAndRingerModeChangeReceiver =
- new BroadcastReceiver() {
+ // receive ringer mode change.
+ private final BroadcastReceiver mRingerModeChangeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();
- if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
- mRichImm.onNetworkStateChanged(intent);
- } else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
+ if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
AudioAndHapticFeedbackManager.getInstance().onRingerModeChanged();
}
}
@@ -1934,7 +1933,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final SettingsValues settingsValues = mSettings.getCurrent();
mDictionaryFacilitator.resetDictionaries(this, new Locale[] { locale },
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
- false /* forceReloadMainDictionary */, this /* listener */);
+ false /* forceReloadMainDictionary */,
+ settingsValues.mAccount,
+ this /* DictionaryInitializationListener */);
}
// DO NOT USE THIS for any other purpose than testing.