Remove personalization dicts for multilingual users.
Bug: 13067743 Change-Id: I1f50cb137b6054dc9442237586b70fc0aa2bf427
This commit is contained in:
parent
920c40fe45
commit
d102eb80da
3 changed files with 26 additions and 13 deletions
|
@ -512,7 +512,6 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
|
||||||
public void clearUserHistoryDictionary() {
|
public void clearUserHistoryDictionary() {
|
||||||
if (mUserHistoryDictionary == null) {
|
if (mUserHistoryDictionary == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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 {
|
|
||||||
PersonalizationDictionarySessionRegistrar.close(this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
PersonalizationHelper.removeAllPersonalizedDictionaries(this);
|
shouldKeepUserHistoryDictionaries = false;
|
||||||
|
shouldKeepPersonalizationDictionaries = false;
|
||||||
|
}
|
||||||
|
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);
|
PersonalizationDictionarySessionRegistrar.resetAll(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue