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

View File

@ -17,7 +17,6 @@
package com.android.inputmethod.latin;
import android.content.Context;
import android.preference.PreferenceManager;
import android.text.TextUtils;
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.PersonalizationHelper;
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.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BoundedTreeSet;
@ -89,15 +87,13 @@ public final class Suggest {
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) {
initAsynchronously(context, locale, listener);
mLocale = locale;
mContext = context;
// TODO: Use SettingsValues instead of Settings.
// initialize a debug flag for the personalization
if (Settings.readUseOnlyPersonalizationDictionaryForDebug(
PreferenceManager.getDefaultSharedPreferences(context))) {
if (settingsValues.mUseOnlyPersonalizationDictionaryForDebug) {
mOnlyDictionarySetForDebug = new HashSet<String>();
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);
}
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) {
if (token == null) {
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 boolean mCorrectionEnabled;
public final int mSuggestionVisibility;
public final boolean mBoostPersonalizationDictionaryForDebug;
public final boolean mUseOnlyPersonalizationDictionaryForDebug;
public final int mDisplayOrientation;
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
@ -181,10 +180,8 @@ public final class SettingsValues {
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
prefs, mAdditionalFeaturesSettingValues);
mIsInternal = Settings.isInternal(prefs);
mBoostPersonalizationDictionaryForDebug =
Settings.readBoostPersonalizationDictionaryForDebug(prefs);
mUseOnlyPersonalizationDictionaryForDebug =
Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
mUseOnlyPersonalizationDictionaryForDebug = prefs.getBoolean(
DebugSettings.PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
mDisplayOrientation = res.getConfiguration().orientation;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
@ -241,7 +238,6 @@ public final class SettingsValues {
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
mSuggestionVisibility = 0;
mIsInternal = false;
mBoostPersonalizationDictionaryForDebug = false;
mUseOnlyPersonalizationDictionaryForDebug = false;
mDisplayOrientation = Configuration.ORIENTATION_PORTRAIT;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();