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.define.ProductionFlag;
|
||||||
import com.android.inputmethod.latin.inputlogic.InputLogic;
|
import com.android.inputmethod.latin.inputlogic.InputLogic;
|
||||||
import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever;
|
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.personalization.PersonalizationHelper;
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
import com.android.inputmethod.latin.settings.SettingsActivity;
|
import com.android.inputmethod.latin.settings.SettingsActivity;
|
||||||
|
@ -122,6 +122,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private final Settings mSettings;
|
private final Settings mSettings;
|
||||||
private final DictionaryFacilitator mDictionaryFacilitator =
|
private final DictionaryFacilitator mDictionaryFacilitator =
|
||||||
new DictionaryFacilitator(new DistracterFilterCheckingExactMatches(this /* context */));
|
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 */,
|
private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */,
|
||||||
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
|
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
|
||||||
// We expect to have only one decoder in almost all cases, hence the default capacity of 1.
|
// 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(
|
mDictionaryFacilitator.updateEnabledSubtypes(mRichImm.getMyEnabledInputMethodSubtypeList(
|
||||||
true /* allowsImplicitlySelectedSubtypes */));
|
true /* allowsImplicitlySelectedSubtypes */));
|
||||||
refreshPersonalizationDictionarySession();
|
refreshPersonalizationDictionarySession(currentSettingsValues);
|
||||||
StatsUtils.onLoadSettings(currentSettingsValues);
|
StatsUtils.onLoadSettings(currentSettingsValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshPersonalizationDictionarySession() {
|
private void refreshPersonalizationDictionarySession(
|
||||||
|
final SettingsValues currentSettingsValues) {
|
||||||
|
mPersonalizationDictionaryUpdater.onLoadSettings(
|
||||||
|
currentSettingsValues.mUsePersonalizedDicts,
|
||||||
|
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes());
|
||||||
final boolean shouldKeepUserHistoryDictionaries;
|
final boolean shouldKeepUserHistoryDictionaries;
|
||||||
final boolean shouldKeepPersonalizationDictionaries;
|
|
||||||
if (mSettings.getCurrent().mUsePersonalizedDicts) {
|
if (mSettings.getCurrent().mUsePersonalizedDicts) {
|
||||||
shouldKeepUserHistoryDictionaries = true;
|
shouldKeepUserHistoryDictionaries = true;
|
||||||
// TODO: Eliminate this restriction
|
|
||||||
shouldKeepPersonalizationDictionaries =
|
|
||||||
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes();
|
|
||||||
} else {
|
} else {
|
||||||
shouldKeepUserHistoryDictionaries = false;
|
shouldKeepUserHistoryDictionaries = false;
|
||||||
shouldKeepPersonalizationDictionaries = false;
|
|
||||||
}
|
}
|
||||||
if (!shouldKeepUserHistoryDictionaries) {
|
if (!shouldKeepUserHistoryDictionaries) {
|
||||||
// Remove user history dictionaries.
|
// Remove user history dictionaries.
|
||||||
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
|
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
|
||||||
mDictionaryFacilitator.clearUserHistoryDictionary();
|
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.
|
// Note that this method is called from a non-UI thread.
|
||||||
|
@ -627,11 +622,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
mDictionaryFacilitator.closeDictionaries();
|
mDictionaryFacilitator.closeDictionaries();
|
||||||
|
mPersonalizationDictionaryUpdater.onDestroy();
|
||||||
mSettings.onDestroy();
|
mSettings.onDestroy();
|
||||||
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
|
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
|
||||||
unregisterReceiver(mDictionaryPackInstallReceiver);
|
unregisterReceiver(mDictionaryPackInstallReceiver);
|
||||||
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
|
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
|
||||||
PersonalizationDictionarySessionRegistrar.close(this);
|
|
||||||
StatsUtils.onDestroy();
|
StatsUtils.onDestroy();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
@ -660,8 +655,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mInputLogic.mConnection.endBatchEdit();
|
mInputLogic.mConnection.endBatchEdit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PersonalizationDictionarySessionRegistrar.onConfigurationChanged(this, conf,
|
// TODO: Remove this test.
|
||||||
mDictionaryFacilitator);
|
if (!conf.locale.equals(mPersonalizationDictionaryUpdater.getLocale())) {
|
||||||
|
refreshPersonalizationDictionarySession(settingsValues);
|
||||||
|
}
|
||||||
super.onConfigurationChanged(conf);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,29 +16,28 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.personalization;
|
package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
|
||||||
|
|
||||||
import com.android.inputmethod.latin.DictionaryFacilitator;
|
import com.android.inputmethod.latin.DictionaryFacilitator;
|
||||||
|
|
||||||
public class PersonalizationDictionarySessionRegistrar {
|
public class PersonalizationDictionaryUpdater {
|
||||||
public static void init(final Context context,
|
public PersonalizationDictionaryUpdater(final Context context,
|
||||||
final DictionaryFacilitator dictionaryFacilitator) {
|
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,
|
public Locale getLocale() {
|
||||||
final DictionaryFacilitator dictionaryFacilitator) {
|
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 void onDestroy() {
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetAll(final Context context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void close(final Context context) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue