diff options
author | 2014-04-25 11:49:33 -0700 | |
---|---|---|
committer | 2014-04-25 12:03:47 -0700 | |
commit | a3920c7e6af852764a3b5a6eecd27f51ab83f244 (patch) | |
tree | 28f61fd3528b6e6c5a46be4d56b97af9f1c57584 /java/src/com/android/inputmethod/latin | |
parent | e581d8f8abc55dcf224678c73c7ce834170ee5e6 (diff) | |
download | latinime-a3920c7e6af852764a3b5a6eecd27f51ab83f244.tar.gz latinime-a3920c7e6af852764a3b5a6eecd27f51ab83f244.tar.xz latinime-a3920c7e6af852764a3b5a6eecd27f51ab83f244.zip |
Move some advanced settings to debug settings
This CL moves "Show slide indicator" and "Key long press delay"
advanced options to the debug settings.
Bug: 11866784
Change-Id: Iec16e09ba6e7c9f82ce0fa73a0d75766b843b44b
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
4 files changed, 51 insertions, 51 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java index 11d369282..c4c1234fc 100644 --- a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java @@ -55,6 +55,8 @@ public final class DebugSettings extends PreferenceFragment private static final String PREF_DUMP_USER_DICT = "dump_user_dict"; private static final String PREF_DUMP_USER_HISTORY_DICT = "dump_user_history_dict"; private static final String PREF_DUMP_PERSONALIZATION_DICT = "dump_personalization_dict"; + public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "pref_sliding_key_input_preview"; + public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout"; private static final boolean SHOW_STATISTICS_LOGGING = false; @@ -110,6 +112,7 @@ public final class DebugSettings extends PreferenceFragment findPreference(PREF_DUMP_PERSONALIZATION_DICT).setOnPreferenceClickListener( dictDumpPrefClickListener); final Resources res = getResources(); + setupKeyLongpressTimeoutSettings(prefs, res); setupKeyPreviewAnimationDuration(prefs, res, PREF_KEY_PREVIEW_SHOW_UP_DURATION, res.getInteger(R.integer.config_key_preview_show_up_duration)); setupKeyPreviewAnimationDuration(prefs, res, PREF_KEY_PREVIEW_DISMISS_DURATION, @@ -200,6 +203,44 @@ public final class DebugSettings extends PreferenceFragment } } + private void setupKeyLongpressTimeoutSettings(final SharedPreferences sp, + final Resources res) { + final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference( + PREF_KEY_LONGPRESS_TIMEOUT); + if (pref == null) { + return; + } + pref.setInterface(new SeekBarDialogPreference.ValueProxy() { + @Override + public void writeValue(final int value, final String key) { + sp.edit().putInt(key, value).apply(); + } + + @Override + public void writeDefaultValue(final String key) { + sp.edit().remove(key).apply(); + } + + @Override + public int readValue(final String key) { + return Settings.readKeyLongpressTimeout(sp, res); + } + + @Override + public int readDefaultValue(final String key) { + return Settings.readDefaultKeyLongpressTimeout(res); + } + + @Override + public String getValueText(final int value) { + return res.getString(R.string.abbreviation_unit_milliseconds, value); + } + + @Override + public void feedbackValue(final int value) {} + }); + } + private void setupKeyPreviewAnimationScale(final SharedPreferences sp, final Resources res, final String prefKey, final float defaultValue) { final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(prefKey); diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 353b7463d..a3aae8cb3 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -72,8 +72,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; public static final String PREF_GESTURE_SETTINGS = "gesture_typing_settings"; public static final String PREF_GESTURE_INPUT = "gesture_input"; - public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "pref_sliding_key_input_preview"; - public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout"; public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings"; public static final String PREF_KEYPRESS_SOUND_VOLUME = @@ -196,7 +194,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang // Accessed from the settings interface, hence public public static boolean readKeypressSoundEnabled(final SharedPreferences prefs, final Resources res) { - return prefs.getBoolean(Settings.PREF_SOUND_ON, + return prefs.getBoolean(PREF_SOUND_ON, res.getBoolean(R.bool.config_default_sound_enabled)); } @@ -216,7 +214,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static boolean readBlockPotentiallyOffensive(final SharedPreferences prefs, final Resources res) { - return prefs.getBoolean(Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE, + return prefs.getBoolean(PREF_BLOCK_POTENTIALLY_OFFENSIVE, res.getBoolean(R.bool.config_block_potentially_offensive)); } @@ -227,12 +225,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static boolean readGestureInputEnabled(final SharedPreferences prefs, final Resources res) { return readFromBuildConfigIfGestureInputEnabled(res) - && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true); + && prefs.getBoolean(PREF_GESTURE_INPUT, true); } public static boolean readPhraseGestureEnabled(final SharedPreferences prefs, final Resources res) { - return prefs.getBoolean(Settings.PREF_PHRASE_GESTURE_ENABLED, + return prefs.getBoolean(PREF_PHRASE_GESTURE_ENABLED, res.getBoolean(R.bool.config_default_phrase_gesture_enabled)); } @@ -278,7 +276,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static void writePrefAdditionalSubtypes(final SharedPreferences prefs, final String prefSubtypes) { - prefs.edit().putString(Settings.PREF_CUSTOM_INPUT_STYLES, prefSubtypes).apply(); + prefs.edit().putString(PREF_CUSTOM_INPUT_STYLES, prefSubtypes).apply(); } public static float readKeypressSoundVolume(final SharedPreferences prefs, @@ -301,7 +299,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static int readKeyLongpressTimeout(final SharedPreferences prefs, final Resources res) { final int milliseconds = prefs.getInt( - PREF_KEY_LONGPRESS_TIMEOUT, UNDEFINED_PREFERENCE_VALUE_INT); + DebugSettings.PREF_KEY_LONGPRESS_TIMEOUT, UNDEFINED_PREFERENCE_VALUE_INT); return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds : readDefaultKeyLongpressTimeout(res); } @@ -354,18 +352,18 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang if (!enableSetupWizardByConfig) { return false; } - if (!prefs.contains(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) { + if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) { final ApplicationInfo appInfo = context.getApplicationInfo(); final boolean isApplicationInSystemImage = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; // Default value return !isApplicationInSystemImage; } - return prefs.getBoolean(Settings.PREF_SHOW_SETUP_WIZARD_ICON, false); + return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false); } public static boolean isInternal(final SharedPreferences prefs) { - return prefs.getBoolean(Settings.PREF_KEY_IS_INTERNAL, false); + return prefs.getBoolean(PREF_KEY_IS_INTERNAL, false); } public void writeLastUsedPersonalizationToken(byte[] token) { diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index bb5547fc9..22cbd204c 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -228,7 +228,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment AdditionalFeaturesSettingUtils.addAdditionalFeaturesPreferences(context, this); - setupKeyLongpressTimeoutSettings(prefs, res); setupKeypressVibrationDurationSettings(prefs, res); setupKeypressSoundVolumeSettings(prefs, res); refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res); @@ -368,44 +367,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment }); } - private void setupKeyLongpressTimeoutSettings(final SharedPreferences sp, - final Resources res) { - final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference( - Settings.PREF_KEY_LONGPRESS_TIMEOUT); - if (pref == null) { - return; - } - pref.setInterface(new SeekBarDialogPreference.ValueProxy() { - @Override - public void writeValue(final int value, final String key) { - sp.edit().putInt(key, value).apply(); - } - - @Override - public void writeDefaultValue(final String key) { - sp.edit().remove(key).apply(); - } - - @Override - public int readValue(final String key) { - return Settings.readKeyLongpressTimeout(sp, res); - } - - @Override - public int readDefaultValue(final String key) { - return Settings.readDefaultKeyLongpressTimeout(res); - } - - @Override - public String getValueText(final int value) { - return res.getString(R.string.abbreviation_unit_milliseconds, value); - } - - @Override - public void feedbackValue(final int value) {} - }); - } - private void setupKeypressSoundVolumeSettings(final SharedPreferences sp, final Resources res) { final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference( Settings.PREF_KEYPRESS_SOUND_VOLUME); diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index d47a61ed1..dde50ccaf 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -119,7 +119,7 @@ public final class SettingsValues { mSoundOn = Settings.readKeypressSoundEnabled(prefs, res); mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res); mSlidingKeyInputPreviewEnabled = prefs.getBoolean( - Settings.PREF_SLIDING_KEY_INPUT_PREVIEW, true); + DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true); mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res); final String autoCorrectionThresholdRawValue = prefs.getString( Settings.PREF_AUTO_CORRECTION_THRESHOLD, |