am d102eb80
: Remove personalization dicts for multilingual users.
* commit 'd102eb80da07de6b9541c3e8d767441d84257b8d': Remove personalization dicts for multilingual users.
This commit is contained in:
commit
ae034a1eb9
3 changed files with 26 additions and 13 deletions
|
@ -512,7 +512,6 @@ public class DictionaryFacilitatorForSuggest {
|
|||
}
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
public void clearUserHistoryDictionary() {
|
||||
if (mUserHistoryDictionary == null) {
|
||||
return;
|
||||
|
|
|
@ -534,17 +534,28 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
|
||||
private void refreshPersonalizationDictionarySession() {
|
||||
final Suggest suggest = mInputLogic.mSuggest;
|
||||
final boolean shouldKeepUserHistoryDictionaries;
|
||||
final boolean shouldKeepPersonalizationDictionaries;
|
||||
if (mSettings.getCurrent().mUsePersonalizedDicts) {
|
||||
if (mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes()) {
|
||||
final DictionaryFacilitatorForSuggest dictionaryFacilitator =
|
||||
(mInputLogic.mSuggest == null) ?
|
||||
null : mInputLogic.mSuggest.mDictionaryFacilitator;
|
||||
PersonalizationDictionarySessionRegistrar.init(this, dictionaryFacilitator);
|
||||
shouldKeepUserHistoryDictionaries = true;
|
||||
// TODO: Eliminate this restriction
|
||||
shouldKeepPersonalizationDictionaries =
|
||||
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes();
|
||||
} else {
|
||||
PersonalizationDictionarySessionRegistrar.close(this);
|
||||
shouldKeepUserHistoryDictionaries = false;
|
||||
shouldKeepPersonalizationDictionaries = false;
|
||||
}
|
||||
} else {
|
||||
PersonalizationHelper.removeAllPersonalizedDictionaries(this);
|
||||
if (!shouldKeepUserHistoryDictionaries) {
|
||||
// Remove user history dictionaries.
|
||||
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
|
||||
if (suggest != null) {
|
||||
suggest.mDictionaryFacilitator.clearUserHistoryDictionary();
|
||||
}
|
||||
}
|
||||
if (!shouldKeepPersonalizationDictionaries) {
|
||||
// Remove personalization dictionaries.
|
||||
PersonalizationHelper.removeAllPersonalizationDictionaries(this);
|
||||
PersonalizationDictionarySessionRegistrar.resetAll(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,13 +93,16 @@ public class PersonalizationHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void removeAllPersonalizedDictionaries(final Context context) {
|
||||
removeAllDictionaries(context, sLangUserHistoryDictCache,
|
||||
UserHistoryDictionary.NAME);
|
||||
public static void removeAllPersonalizationDictionaries(final Context context) {
|
||||
removeAllDictionaries(context, sLangPersonalizationDictCache,
|
||||
PersonalizationDictionary.NAME);
|
||||
}
|
||||
|
||||
public static void removeAllUserHistoryDictionaries(final Context context) {
|
||||
removeAllDictionaries(context, sLangUserHistoryDictCache,
|
||||
UserHistoryDictionary.NAME);
|
||||
}
|
||||
|
||||
private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries(
|
||||
final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap,
|
||||
final String dictNamePrefix) {
|
||||
|
|
Loading…
Reference in a new issue