Match constant names to option names

Change-Id: I7586fa342d7a39412d656890f7b525139c45ea4a
This commit is contained in:
Jean Chalard 2011-12-09 17:58:51 +09:00
parent 837b109f27
commit ba93dda8ce
2 changed files with 28 additions and 28 deletions

View file

@ -59,28 +59,28 @@ public class Settings extends InputMethodSettingsActivity
public static final boolean ENABLE_EXPERIMENTAL_SETTINGS = false; public static final boolean ENABLE_EXPERIMENTAL_SETTINGS = false;
// In the same order as xml/prefs.xml // In the same order as xml/prefs.xml
public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings"; public static final String PREF_GENERAL_SETTINGS = "general_settings";
public static final String PREF_SUBTYPES = "subtype_settings"; public static final String PREF_SUBTYPES_SETTINGS = "subtype_settings";
public static final String PREF_AUTO_CAP = "auto_cap"; public static final String PREF_AUTO_CAP = "auto_cap";
public static final String PREF_VIBRATE_ON = "vibrate_on"; public static final String PREF_VIBRATE_ON = "vibrate_on";
public static final String PREF_SOUND_ON = "sound_on"; public static final String PREF_SOUND_ON = "sound_on";
public static final String PREF_KEY_PREVIEW_POPUP_ON = "popup_on"; public static final String PREF_POPUP_ON = "popup_on";
public static final String PREF_SHOW_SETTINGS_KEY = "show_settings_key"; public static final String PREF_SHOW_SETTINGS_KEY = "show_settings_key";
public static final String PREF_VOICE_SETTINGS_KEY = "voice_mode"; public static final String PREF_VOICE_MODE = "voice_mode";
public static final String PREF_CORRECTION_SETTINGS_KEY = "correction_settings"; public static final String PREF_CORRECTION_SETTINGS = "correction_settings";
public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key"; public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key";
public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold"; public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting"; public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
public static final String PREF_MISC_SETTINGS_KEY = "misc_settings"; public static final String PREF_MISC_SETTINGS = "misc_settings";
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode"; public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings"; public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings";
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
"pref_key_preview_popup_dismiss_delay"; "pref_key_preview_popup_dismiss_delay";
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
public static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion"; public static final String PREF_BIGRAM_SUGGESTION = "bigram_suggestion";
public static final String PREF_BIGRAM_PREDICTIONS = "bigram_prediction"; public static final String PREF_BIGRAM_PREDICTIONS = "bigram_prediction";
public static final String PREF_KEY_ENABLE_SPAN_INSERT = "enable_span_insert"; public static final String PREF_KEY_ENABLE_SPAN_INSERT = "enable_span_insert";
public static final String PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS = public static final String PREF_VIBRATION_DURATION_SETTINGS =
"pref_vibration_duration_settings"; "pref_vibration_duration_settings";
public static final String PREF_KEYPRESS_SOUND_VOLUME = public static final String PREF_KEYPRESS_SOUND_VOLUME =
"pref_keypress_sound_volume"; "pref_keypress_sound_volume";
@ -144,9 +144,9 @@ public class Settings extends InputMethodSettingsActivity
final Context context = getActivityInternal(); final Context context = getActivityInternal();
addPreferencesFromResource(R.xml.prefs); addPreferencesFromResource(R.xml.prefs);
mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES); mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES_SETTINGS);
mInputLanguageSelection.setOnPreferenceClickListener(this); mInputLanguageSelection.setOnPreferenceClickListener(this);
mVoicePreference = (ListPreference) findPreference(PREF_VOICE_SETTINGS_KEY); mVoicePreference = (ListPreference) findPreference(PREF_VOICE_MODE);
mShowSettingsKeyPreference = (CheckBoxPreference) findPreference(PREF_SHOW_SETTINGS_KEY); mShowSettingsKeyPreference = (CheckBoxPreference) findPreference(PREF_SHOW_SETTINGS_KEY);
mShowCorrectionSuggestionsPreference = mShowCorrectionSuggestionsPreference =
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING); (ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
@ -154,12 +154,12 @@ public class Settings extends InputMethodSettingsActivity
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
mVoiceModeOff = getString(R.string.voice_mode_off); mVoiceModeOff = getString(R.string.voice_mode_off);
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) mVoiceOn = !(prefs.getString(PREF_VOICE_MODE, mVoiceModeOff)
.equals(mVoiceModeOff)); .equals(mVoiceModeOff));
mAutoCorrectionThresholdPreference = mAutoCorrectionThresholdPreference =
(ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD); (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS); mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTION);
mBigramPrediction = (CheckBoxPreference) findPreference(PREF_BIGRAM_PREDICTIONS); mBigramPrediction = (CheckBoxPreference) findPreference(PREF_BIGRAM_PREDICTIONS);
mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS); mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS);
if (mDebugSettingsPreference != null) { if (mDebugSettingsPreference != null) {
@ -172,11 +172,11 @@ public class Settings extends InputMethodSettingsActivity
ensureConsistencyOfAutoCorrectionSettings(); ensureConsistencyOfAutoCorrectionSettings();
final PreferenceGroup generalSettings = final PreferenceGroup generalSettings =
(PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS_KEY); (PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS);
final PreferenceGroup textCorrectionGroup = final PreferenceGroup textCorrectionGroup =
(PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS_KEY); (PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS);
final PreferenceGroup miscSettings = final PreferenceGroup miscSettings =
(PreferenceGroup) findPreference(PREF_MISC_SETTINGS_KEY); (PreferenceGroup) findPreference(PREF_MISC_SETTINGS);
if (!SettingsValues.isShowSettingsKeyOption(res)) { if (!SettingsValues.isShowSettingsKeyOption(res)) {
generalSettings.removePreference(mShowSettingsKeyPreference); generalSettings.removePreference(mShowSettingsKeyPreference);
@ -193,13 +193,13 @@ public class Settings extends InputMethodSettingsActivity
} }
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) { if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
generalSettings.removePreference(findPreference(PREF_SUBTYPES)); generalSettings.removePreference(findPreference(PREF_SUBTYPES_SETTINGS));
} }
final boolean showPopupOption = res.getBoolean( final boolean showPopupOption = res.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option); R.bool.config_enable_show_popup_on_keypress_option);
if (!showPopupOption) { if (!showPopupOption) {
generalSettings.removePreference(findPreference(PREF_KEY_PREVIEW_POPUP_ON)); generalSettings.removePreference(findPreference(PREF_POPUP_ON));
} }
final boolean showBigramSuggestionsOption = res.getBoolean( final boolean showBigramSuggestionsOption = res.getBoolean(
@ -256,7 +256,7 @@ public class Settings extends InputMethodSettingsActivity
} }
mKeypressVibrationDurationSettingsPref = mKeypressVibrationDurationSettingsPref =
(PreferenceScreen) findPreference(PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS); (PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
if (mKeypressVibrationDurationSettingsPref != null) { if (mKeypressVibrationDurationSettingsPref != null) {
mKeypressVibrationDurationSettingsPref.setOnPreferenceClickListener( mKeypressVibrationDurationSettingsPref.setOnPreferenceClickListener(
new OnPreferenceClickListener() { new OnPreferenceClickListener() {
@ -312,20 +312,20 @@ public class Settings extends InputMethodSettingsActivity
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
(new BackupManager(getActivityInternal())).dataChanged(); (new BackupManager(getActivityInternal())).dataChanged();
// If turning on voice input, show dialog // If turning on voice input, show dialog
if (key.equals(PREF_VOICE_SETTINGS_KEY) && !mVoiceOn) { if (key.equals(PREF_VOICE_MODE) && !mVoiceOn) {
if (!prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) if (!prefs.getString(PREF_VOICE_MODE, mVoiceModeOff)
.equals(mVoiceModeOff)) { .equals(mVoiceModeOff)) {
showVoiceConfirmation(); showVoiceConfirmation();
} }
} else if (key.equals(PREF_KEY_PREVIEW_POPUP_ON)) { } else if (key.equals(PREF_POPUP_ON)) {
final ListPreference popupDismissDelay = final ListPreference popupDismissDelay =
(ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); (ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
if (null != popupDismissDelay) { if (null != popupDismissDelay) {
popupDismissDelay.setEnabled(prefs.getBoolean(PREF_KEY_PREVIEW_POPUP_ON, true)); popupDismissDelay.setEnabled(prefs.getBoolean(PREF_POPUP_ON, true));
} }
} }
ensureConsistencyOfAutoCorrectionSettings(); ensureConsistencyOfAutoCorrectionSettings();
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) mVoiceOn = !(prefs.getString(PREF_VOICE_MODE, mVoiceModeOff)
.equals(mVoiceModeOff)); .equals(mVoiceModeOff));
updateVoiceModeSummary(); updateVoiceModeSummary();
updateShowCorrectionSuggestionsSummary(); updateShowCorrectionSuggestionsSummary();
@ -467,7 +467,7 @@ public class Settings extends InputMethodSettingsActivity
public void onClick(DialogInterface dialog, int whichButton) { public void onClick(DialogInterface dialog, int whichButton) {
final int ms = Integer.valueOf( final int ms = Integer.valueOf(
mKeypressVibrationDurationSettingsTextView.getText().toString()); mKeypressVibrationDurationSettingsTextView.getText().toString());
sp.edit().putInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, ms).apply(); sp.edit().putInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, ms).apply();
updateKeypressVibrationDurationSettingsSummary(sp, res); updateKeypressVibrationDurationSettingsSummary(sp, res);
} }
}); });

View file

@ -127,7 +127,7 @@ public class SettingsValues {
: defaultShowSettingsKey; : defaultShowSettingsKey;
final String voiceModeMain = res.getString(R.string.voice_mode_main); final String voiceModeMain = res.getString(R.string.voice_mode_main);
final String voiceModeOff = res.getString(R.string.voice_mode_off); final String voiceModeOff = res.getString(R.string.voice_mode_off);
final String voiceMode = prefs.getString(Settings.PREF_VOICE_SETTINGS_KEY, voiceModeMain); final String voiceMode = prefs.getString(Settings.PREF_VOICE_MODE, voiceModeMain);
mVoiceKeyEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff); mVoiceKeyEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff);
mVoiceKeyOnMain = voiceMode != null && voiceMode.equals(voiceModeMain); mVoiceKeyOnMain = voiceMode != null && voiceMode.equals(voiceModeMain);
@ -172,7 +172,7 @@ public class SettingsValues {
final boolean showPopupOption = resources.getBoolean( final boolean showPopupOption = resources.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option); R.bool.config_enable_show_popup_on_keypress_option);
if (!showPopupOption) return resources.getBoolean(R.bool.config_default_popup_preview); if (!showPopupOption) return resources.getBoolean(R.bool.config_default_popup_preview);
return sp.getBoolean(Settings.PREF_KEY_PREVIEW_POPUP_ON, return sp.getBoolean(Settings.PREF_POPUP_ON,
resources.getBoolean(R.bool.config_default_popup_preview)); resources.getBoolean(R.bool.config_default_popup_preview));
} }
@ -190,7 +190,7 @@ public class SettingsValues {
if (!showBigramSuggestionsOption) { if (!showBigramSuggestionsOption) {
return autoCorrectEnabled; return autoCorrectEnabled;
} }
return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTIONS, resources.getBoolean( return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTION, resources.getBoolean(
R.bool.config_default_bigram_suggestions)); R.bool.config_default_bigram_suggestions));
} }
@ -277,7 +277,7 @@ public class SettingsValues {
// Likewise // Likewise
public static int getCurrentVibrationDuration(final SharedPreferences sp, public static int getCurrentVibrationDuration(final SharedPreferences sp,
final Resources res) { final Resources res) {
final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1); final int ms = sp.getInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, -1);
if (ms >= 0) { if (ms >= 0) {
return ms; return ms;
} }