am 0fe3611b: Resolve TODOs: add some members to store prefs

* commit '0fe3611bee5095e7bd0fff2d0fdf8d5a13379132':
  Resolve TODOs: add some members to store prefs
main
Jean Chalard 2011-12-09 11:00:52 -08:00 committed by Android Git Automerger
commit 6684bd1a47
2 changed files with 21 additions and 11 deletions

View File

@ -144,6 +144,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
*/ */
private static final String SCHEME_PACKAGE = "package"; private static final String SCHEME_PACKAGE = "package";
// TODO: migrate this to SettingsValues
private int mSuggestionVisibility; private int mSuggestionVisibility;
private static final int SUGGESTION_VISIBILILTY_SHOW_VALUE private static final int SUGGESTION_VISIBILILTY_SHOW_VALUE
= R.string.prefs_suggestion_visibility_show_value; = R.string.prefs_suggestion_visibility_show_value;
@ -2389,9 +2390,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
private void updateSuggestionVisibility(final SharedPreferences prefs, final Resources res) { private void updateSuggestionVisibility(final SharedPreferences prefs, final Resources res) {
final String suggestionVisiblityStr = prefs.getString( final String suggestionVisiblityStr = mSettingsValues.mShowSuggestionsSetting;
Settings.PREF_SHOW_SUGGESTIONS_SETTING,
res.getString(R.string.prefs_suggestion_visibility_default_value));
for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) { for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) {
if (suggestionVisiblityStr.equals(res.getString(visibility))) { if (suggestionVisiblityStr.equals(res.getString(visibility))) {
mSuggestionVisibility = visibility; mSuggestionVisibility = visibility;

View File

@ -50,9 +50,9 @@ public class SettingsValues {
private final boolean mShowSettingsKey; private final boolean mShowSettingsKey;
private final String mVoiceMode; private final String mVoiceMode;
private final String mAutoCorrectionThresholdRawValue; private final String mAutoCorrectionThresholdRawValue;
// TODO: add a member for the raw "show_suggestions_setting" setting public final String mShowSuggestionsSetting;
// TODO: add a member for the raw "usability_study_mode" setting private final boolean mUsabilityStudyMode;
// TODO: add a member for the raw "pref_key_preview_popup_dismiss_delay" setting private final String mKeyPreviewPopupDismissDelayRawValue;
public final boolean mUseContactsDict; public final boolean mUseContactsDict;
// Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary // Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
public final boolean mBigramSuggestionEnabled; public final boolean mBigramSuggestionEnabled;
@ -107,8 +107,14 @@ public class SettingsValues {
mVoiceMode = prefs.getString(Settings.PREF_VOICE_MODE, voiceModeMain); mVoiceMode = prefs.getString(Settings.PREF_VOICE_MODE, voiceModeMain);
mAutoCorrectionThresholdRawValue = prefs.getString(Settings.PREF_AUTO_CORRECTION_THRESHOLD, mAutoCorrectionThresholdRawValue = prefs.getString(Settings.PREF_AUTO_CORRECTION_THRESHOLD,
res.getString(R.string.auto_correction_threshold_mode_index_modest)); res.getString(R.string.auto_correction_threshold_mode_index_modest));
mShowSuggestionsSetting = prefs.getString(Settings.PREF_SHOW_SUGGESTIONS_SETTING,
res.getString(R.string.prefs_suggestion_visibility_default_value));
mUsabilityStudyMode = getUsabilityStudyMode(prefs, res);
mKeyPreviewPopupDismissDelayRawValue = prefs.getString(
Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(R.integer.config_delay_after_preview)));
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true); mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs, res); mAutoCorrectEnabled = isAutoCorrectEnabled(prefs, res, mAutoCorrectionThresholdRawValue);
mBigramSuggestionEnabled = mAutoCorrectEnabled mBigramSuggestionEnabled = mAutoCorrectEnabled
&& isBigramSuggestionEnabled(prefs, res, mAutoCorrectEnabled); && isBigramSuggestionEnabled(prefs, res, mAutoCorrectEnabled);
mBigramPredictionEnabled = mBigramSuggestionEnabled mBigramPredictionEnabled = mBigramSuggestionEnabled
@ -191,10 +197,8 @@ public class SettingsValues {
return mMagicSpaceSwappers.contains(String.valueOf((char)code)); return mMagicSpaceSwappers.contains(String.valueOf((char)code));
} }
private static boolean isAutoCorrectEnabled(SharedPreferences sp, Resources resources) { private static boolean isAutoCorrectEnabled(final SharedPreferences sp,
final String currentAutoCorrectionSetting = sp.getString( final Resources resources, final String currentAutoCorrectionSetting) {
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
resources.getString(R.string.auto_correction_threshold_mode_index_modest));
final String autoCorrectionOff = resources.getString( final String autoCorrectionOff = resources.getString(
R.string.auto_correction_threshold_mode_index_off); R.string.auto_correction_threshold_mode_index_off);
return !currentAutoCorrectionSetting.equals(autoCorrectionOff); return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
@ -213,6 +217,7 @@ public class SettingsValues {
// Likewise // Likewise
public static int getKeyPreviewPopupDismissDelay(SharedPreferences sp, public static int getKeyPreviewPopupDismissDelay(SharedPreferences sp,
Resources resources) { Resources resources) {
// TODO: use mKeyPreviewPopupDismissDelayRawValue instead of reading it again here.
return Integer.parseInt(sp.getString(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, return Integer.parseInt(sp.getString(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(resources.getInteger(R.integer.config_delay_after_preview)))); Integer.toString(resources.getInteger(R.integer.config_delay_after_preview))));
} }
@ -307,4 +312,10 @@ public class SettingsValues {
} }
return -1; return -1;
} }
// Likewise
public static boolean getUsabilityStudyMode(final SharedPreferences prefs,
final Resources res) {
return prefs.getBoolean(Settings.PREF_USABILITY_STUDY_MODE, true);
}
} }