am bb39518b: Use SettingsValues instead of Settings in Suggest.

* commit 'bb39518bd7bb58d76f11d0deb16978a5c5fca7d9':
  Use SettingsValues instead of Settings in Suggest.
main
Keisuke Kuroyanagi 2013-12-25 01:57:18 -08:00 committed by Android Git Automerger
commit 52b417dca0
4 changed files with 7 additions and 29 deletions

View File

@ -79,7 +79,6 @@ import com.android.inputmethod.latin.settings.SettingsActivity;
import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.suggestions.SuggestionStripView; import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.CompletionInfoUtils; import com.android.inputmethod.latin.utils.CompletionInfoUtils;
import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.IntentUtils;
@ -554,9 +553,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
subtypeLocale = switcherSubtypeLocale; subtypeLocale = switcherSubtypeLocale;
} }
final Suggest newSuggest = new Suggest(this /* Context */, subtypeLocale,
this /* SuggestInitializationListener */);
final SettingsValues settingsValues = mSettings.getCurrent(); final SettingsValues settingsValues = mSettings.getCurrent();
final Suggest newSuggest = new Suggest(this /* Context */, subtypeLocale, settingsValues,
this /* SuggestInitializationListener */);
if (settingsValues.mCorrectionEnabled) { if (settingsValues.mCorrectionEnabled) {
newSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold); newSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold);
} }
@ -565,8 +564,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ResearchLogger.getInstance().initSuggest(newSuggest); ResearchLogger.getInstance().initSuggest(newSuggest);
} }
// TODO: Quit setting dictionaries from LatinIME. // TODO: Quit setting dictionaries from LatinIME.
newSuggest.setAdditionalDictionaries(mInputLogic.mSuggest /* oldSuggest */, newSuggest.setAdditionalDictionaries(mInputLogic.mSuggest /* oldSuggest */, settingsValues);
mSettings.getCurrent());
final Suggest oldSuggest = mInputLogic.mSuggest; final Suggest oldSuggest = mInputLogic.mSuggest;
mInputLogic.mSuggest = newSuggest; mInputLogic.mSuggest = newSuggest;
if (oldSuggest != null) oldSuggest.close(); if (oldSuggest != null) oldSuggest.close();

View File

@ -17,7 +17,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import android.content.Context; import android.content.Context;
import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -27,7 +26,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.personalization.PersonalizationDictionary; import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
import com.android.inputmethod.latin.personalization.PersonalizationHelper; import com.android.inputmethod.latin.personalization.PersonalizationHelper;
import com.android.inputmethod.latin.personalization.UserHistoryDictionary; import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils; import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BoundedTreeSet; import com.android.inputmethod.latin.utils.BoundedTreeSet;
@ -89,15 +87,13 @@ public final class Suggest {
private final Context mContext; private final Context mContext;
public Suggest(final Context context, final Locale locale, public Suggest(final Context context, final Locale locale, final SettingsValues settingsValues,
final SuggestInitializationListener listener) { final SuggestInitializationListener listener) {
initAsynchronously(context, locale, listener); initAsynchronously(context, locale, listener);
mLocale = locale; mLocale = locale;
mContext = context; mContext = context;
// TODO: Use SettingsValues instead of Settings.
// initialize a debug flag for the personalization // initialize a debug flag for the personalization
if (Settings.readUseOnlyPersonalizationDictionaryForDebug( if (settingsValues.mUseOnlyPersonalizationDictionaryForDebug) {
PreferenceManager.getDefaultSharedPreferences(context))) {
mOnlyDictionarySetForDebug = new HashSet<String>(); mOnlyDictionarySetForDebug = new HashSet<String>();
mOnlyDictionarySetForDebug.add(Dictionary.TYPE_PERSONALIZATION); mOnlyDictionarySetForDebug.add(Dictionary.TYPE_PERSONALIZATION);
} }

View File

@ -358,18 +358,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getBoolean(Settings.PREF_KEY_IS_INTERNAL, false); return prefs.getBoolean(Settings.PREF_KEY_IS_INTERNAL, false);
} }
public static boolean readUseOnlyPersonalizationDictionaryForDebug(
final SharedPreferences prefs) {
return prefs.getBoolean(
DebugSettings.PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
}
public static boolean readBoostPersonalizationDictionaryForDebug(
final SharedPreferences prefs) {
return prefs.getBoolean(
DebugSettings.PREF_BOOST_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
}
public void writeLastUsedPersonalizationToken(byte[] token) { public void writeLastUsedPersonalizationToken(byte[] token) {
if (token == null) { if (token == null) {
mPrefs.edit().remove(PREF_LAST_USED_PERSONALIZATION_TOKEN).apply(); mPrefs.edit().remove(PREF_LAST_USED_PERSONALIZATION_TOKEN).apply();

View File

@ -99,7 +99,6 @@ public final class SettingsValues {
public final float mAutoCorrectionThreshold; public final float mAutoCorrectionThreshold;
public final boolean mCorrectionEnabled; public final boolean mCorrectionEnabled;
public final int mSuggestionVisibility; public final int mSuggestionVisibility;
public final boolean mBoostPersonalizationDictionaryForDebug;
public final boolean mUseOnlyPersonalizationDictionaryForDebug; public final boolean mUseOnlyPersonalizationDictionaryForDebug;
public final int mDisplayOrientation; public final int mDisplayOrientation;
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds; private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
@ -181,10 +180,8 @@ public final class SettingsValues {
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray( AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
prefs, mAdditionalFeaturesSettingValues); prefs, mAdditionalFeaturesSettingValues);
mIsInternal = Settings.isInternal(prefs); mIsInternal = Settings.isInternal(prefs);
mBoostPersonalizationDictionaryForDebug = mUseOnlyPersonalizationDictionaryForDebug = prefs.getBoolean(
Settings.readBoostPersonalizationDictionaryForDebug(prefs); DebugSettings.PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
mUseOnlyPersonalizationDictionaryForDebug =
Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
mDisplayOrientation = res.getConfiguration().orientation; mDisplayOrientation = res.getConfiguration().orientation;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>(); mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo( final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
@ -241,7 +238,6 @@ public final class SettingsValues {
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
mSuggestionVisibility = 0; mSuggestionVisibility = 0;
mIsInternal = false; mIsInternal = false;
mBoostPersonalizationDictionaryForDebug = false;
mUseOnlyPersonalizationDictionaryForDebug = false; mUseOnlyPersonalizationDictionaryForDebug = false;
mDisplayOrientation = Configuration.ORIENTATION_PORTRAIT; mDisplayOrientation = Configuration.ORIENTATION_PORTRAIT;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>(); mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();