Merge "Personalization dictionary updater."
This commit is contained in:
commit
81bd7e2007
2 changed files with 28 additions and 32 deletions
|
@ -70,7 +70,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
|||
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||
import com.android.inputmethod.latin.inputlogic.InputLogic;
|
||||
import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionarySessionRegistrar;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionaryUpdater;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationHelper;
|
||||
import com.android.inputmethod.latin.settings.Settings;
|
||||
import com.android.inputmethod.latin.settings.SettingsActivity;
|
||||
|
@ -122,6 +122,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private final Settings mSettings;
|
||||
private final DictionaryFacilitator mDictionaryFacilitator =
|
||||
new DictionaryFacilitator(new DistracterFilterCheckingExactMatches(this /* context */));
|
||||
// TODO: Move from LatinIME.
|
||||
private final PersonalizationDictionaryUpdater mPersonalizationDictionaryUpdater =
|
||||
new PersonalizationDictionaryUpdater(this /* context */, mDictionaryFacilitator);
|
||||
private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */,
|
||||
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
|
||||
// We expect to have only one decoder in almost all cases, hence the default capacity of 1.
|
||||
|
@ -540,34 +543,26 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
mDictionaryFacilitator.updateEnabledSubtypes(mRichImm.getMyEnabledInputMethodSubtypeList(
|
||||
true /* allowsImplicitlySelectedSubtypes */));
|
||||
refreshPersonalizationDictionarySession();
|
||||
refreshPersonalizationDictionarySession(currentSettingsValues);
|
||||
StatsUtils.onLoadSettings(currentSettingsValues);
|
||||
}
|
||||
|
||||
private void refreshPersonalizationDictionarySession() {
|
||||
private void refreshPersonalizationDictionarySession(
|
||||
final SettingsValues currentSettingsValues) {
|
||||
mPersonalizationDictionaryUpdater.onLoadSettings(
|
||||
currentSettingsValues.mUsePersonalizedDicts,
|
||||
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes());
|
||||
final boolean shouldKeepUserHistoryDictionaries;
|
||||
final boolean shouldKeepPersonalizationDictionaries;
|
||||
if (mSettings.getCurrent().mUsePersonalizedDicts) {
|
||||
shouldKeepUserHistoryDictionaries = true;
|
||||
// TODO: Eliminate this restriction
|
||||
shouldKeepPersonalizationDictionaries =
|
||||
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes();
|
||||
} else {
|
||||
shouldKeepUserHistoryDictionaries = false;
|
||||
shouldKeepPersonalizationDictionaries = false;
|
||||
}
|
||||
if (!shouldKeepUserHistoryDictionaries) {
|
||||
// Remove user history dictionaries.
|
||||
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
|
||||
mDictionaryFacilitator.clearUserHistoryDictionary();
|
||||
}
|
||||
if (!shouldKeepPersonalizationDictionaries) {
|
||||
// Remove personalization dictionaries.
|
||||
PersonalizationHelper.removeAllPersonalizationDictionaries(this);
|
||||
PersonalizationDictionarySessionRegistrar.resetAll(this);
|
||||
} else {
|
||||
PersonalizationDictionarySessionRegistrar.init(this, mDictionaryFacilitator);
|
||||
}
|
||||
}
|
||||
|
||||
// Note that this method is called from a non-UI thread.
|
||||
|
@ -627,11 +622,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
mDictionaryFacilitator.closeDictionaries();
|
||||
mPersonalizationDictionaryUpdater.onDestroy();
|
||||
mSettings.onDestroy();
|
||||
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
|
||||
unregisterReceiver(mDictionaryPackInstallReceiver);
|
||||
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
|
||||
PersonalizationDictionarySessionRegistrar.close(this);
|
||||
StatsUtils.onDestroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
@ -660,8 +655,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
mInputLogic.mConnection.endBatchEdit();
|
||||
}
|
||||
}
|
||||
PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf,
|
||||
mDictionaryFacilitator);
|
||||
// TODO: Remove this test.
|
||||
if (!conf.locale.equals(mPersonalizationDictionaryUpdater.getLocale())) {
|
||||
refreshPersonalizationDictionarySession(settingsValues);
|
||||
}
|
||||
super.onConfigurationChanged(conf);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,29 +16,28 @@
|
|||
|
||||
package com.android.inputmethod.latin.personalization;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.android.inputmethod.latin.DictionaryFacilitator;
|
||||
|
||||
public class PersonalizationDictionarySessionRegistrar {
|
||||
public static void init(final Context context,
|
||||
public class PersonalizationDictionaryUpdater {
|
||||
public PersonalizationDictionaryUpdater(final Context context,
|
||||
final DictionaryFacilitator dictionaryFacilitator) {
|
||||
// Clear and never update the personalization dictionary.
|
||||
PersonalizationHelper.removeAllPersonalizationDictionaries(context);
|
||||
dictionaryFacilitator.clearPersonalizationDictionary();
|
||||
}
|
||||
|
||||
public static void onConfigurationChanged(final Context context, final Configuration conf,
|
||||
final DictionaryFacilitator dictionaryFacilitator) {
|
||||
public Locale getLocale() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void onUpdateData(final Context context, final String type) {
|
||||
public void onLoadSettings(final boolean usePersonalizedDicts,
|
||||
final boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes) {
|
||||
}
|
||||
|
||||
public static void onRemoveData(final Context context, final String type) {
|
||||
}
|
||||
|
||||
public static void resetAll(final Context context) {
|
||||
}
|
||||
|
||||
public static void close(final Context context) {
|
||||
public void onDestroy() {
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue