Skip to content
Snippets Groups Projects
Commit 55713e36 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Update personalized dict only when single subtype is used.

Bug: 12424891
Change-Id: If041d1ab45988dbf9b878ae3367fee0fbc8a8988
parent 6d5f9fd3
No related branches found
No related tags found
No related merge requests found
......@@ -523,7 +523,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
suggest.close();
}
if (currentSettingsValues.mUsePersonalizedDicts) {
PersonalizationDictionarySessionRegistrar.init(this);
if (mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes()) {
PersonalizationDictionarySessionRegistrar.init(this);
} else {
PersonalizationDictionarySessionRegistrar.close(this);
}
} else {
PersonalizationHelper.removeAllPersonalizedDictionaries(this);
PersonalizationDictionarySessionRegistrar.resetAll(this);
......@@ -595,7 +599,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ResearchLogger.getInstance().onDestroy();
}
unregisterReceiver(mDictionaryPackInstallReceiver);
PersonalizationDictionarySessionRegistrar.onDestroy(this);
PersonalizationDictionarySessionRegistrar.close(this);
LatinImeLogger.commit();
LatinImeLogger.onDestroy();
super.onDestroy();
......
......@@ -273,6 +273,18 @@ public final class SubtypeSwitcher {
return mNeedsToDisplayLanguage.getValue();
}
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypes() {
final Locale systemLocale = mResources.getConfiguration().locale;
final List<InputMethodSubtype> enabledSubtypesOfThisIme =
mRichImm.getMyEnabledInputMethodSubtypeList(true);
for (final InputMethodSubtype subtype : enabledSubtypesOfThisIme) {
if (!systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
return false;
}
}
return true;
}
private static InputMethodSubtype sForcedSubtypeForTesting = null;
@UsedForTesting
void forceSubtype(final InputMethodSubtype subtype) {
......
......@@ -35,6 +35,6 @@ public class PersonalizationDictionarySessionRegistrar {
public static void resetAll(final Context context) {
}
public static void onDestroy(final Context context) {
public static void close(final Context context) {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment