am d102eb80: Remove personalization dicts for multilingual users.

* commit 'd102eb80da07de6b9541c3e8d767441d84257b8d':
  Remove personalization dicts for multilingual users.
main
Keisuke Kuroyanagi 2014-02-19 04:05:54 -08:00 committed by Android Git Automerger
commit ae034a1eb9
3 changed files with 26 additions and 13 deletions

View File

@ -512,7 +512,6 @@ public class DictionaryFacilitatorForSuggest {
} }
} }
@UsedForTesting
public void clearUserHistoryDictionary() { public void clearUserHistoryDictionary() {
if (mUserHistoryDictionary == null) { if (mUserHistoryDictionary == null) {
return; return;

View File

@ -534,17 +534,28 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
private void refreshPersonalizationDictionarySession() { private void refreshPersonalizationDictionarySession() {
final Suggest suggest = mInputLogic.mSuggest;
final boolean shouldKeepUserHistoryDictionaries;
final boolean shouldKeepPersonalizationDictionaries;
if (mSettings.getCurrent().mUsePersonalizedDicts) { if (mSettings.getCurrent().mUsePersonalizedDicts) {
if (mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes()) { shouldKeepUserHistoryDictionaries = true;
final DictionaryFacilitatorForSuggest dictionaryFacilitator = // TODO: Eliminate this restriction
(mInputLogic.mSuggest == null) ? shouldKeepPersonalizationDictionaries =
null : mInputLogic.mSuggest.mDictionaryFacilitator; mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes();
PersonalizationDictionarySessionRegistrar.init(this, dictionaryFacilitator);
} else { } else {
PersonalizationDictionarySessionRegistrar.close(this); shouldKeepUserHistoryDictionaries = false;
shouldKeepPersonalizationDictionaries = false;
} }
} else { if (!shouldKeepUserHistoryDictionaries) {
PersonalizationHelper.removeAllPersonalizedDictionaries(this); // Remove user history dictionaries.
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
if (suggest != null) {
suggest.mDictionaryFacilitator.clearUserHistoryDictionary();
}
}
if (!shouldKeepPersonalizationDictionaries) {
// Remove personalization dictionaries.
PersonalizationHelper.removeAllPersonalizationDictionaries(this);
PersonalizationDictionarySessionRegistrar.resetAll(this); PersonalizationDictionarySessionRegistrar.resetAll(this);
} }
} }

View File

@ -93,13 +93,16 @@ public class PersonalizationHelper {
} }
} }
public static void removeAllPersonalizedDictionaries(final Context context) { public static void removeAllPersonalizationDictionaries(final Context context) {
removeAllDictionaries(context, sLangUserHistoryDictCache,
UserHistoryDictionary.NAME);
removeAllDictionaries(context, sLangPersonalizationDictCache, removeAllDictionaries(context, sLangPersonalizationDictCache,
PersonalizationDictionary.NAME); PersonalizationDictionary.NAME);
} }
public static void removeAllUserHistoryDictionaries(final Context context) {
removeAllDictionaries(context, sLangUserHistoryDictCache,
UserHistoryDictionary.NAME);
}
private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries( private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries(
final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap, final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap,
final String dictNamePrefix) { final String dictNamePrefix) {