Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce875664 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Clean up Settings and SettingsFragment a bit

Change-Id: I93bf3cb1ea7e8fc09f4ad34b0bdd74f5f5ff1a68
parent 20b6775a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@
    <!-- Device form factor. This value must be aligned with {@link KeyboardId.FORM_FACTOR_TABLET7} -->
    <integer name="config_device_form_factor">1</integer>
    <bool name="config_enable_show_voice_key_option">false</bool>
    <bool name="config_enable_show_popup_on_keypress_option">false</bool>
    <bool name="config_enable_show_option_of_key_preview_popup">false</bool>
    <bool name="config_enable_bigram_suggestions_option">false</bool>
    <!-- Whether or not Popup on key press is enabled by default -->
    <bool name="config_default_popup_preview">false</bool>
    <bool name="config_default_key_preview_popup">false</bool>
    <bool name="config_default_sound_enabled">true</bool>
    <bool name="config_auto_correction_spacebar_led_enabled">false</bool>
    <!-- The language is never displayed if == 0, always displayed if < 0 -->
+2 −2
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@
    <!-- Device form factor. This value must be aligned with {@link KeyboardId.FORM_FACTOR_TABLET10} -->
    <integer name="config_device_form_factor">2</integer>
    <bool name="config_enable_show_voice_key_option">false</bool>
    <bool name="config_enable_show_popup_on_keypress_option">false</bool>
    <bool name="config_enable_show_option_of_key_preview_popup">false</bool>
    <bool name="config_enable_bigram_suggestions_option">false</bool>
    <!-- Whether or not Popup on key press is enabled by default -->
    <bool name="config_default_popup_preview">false</bool>
    <bool name="config_default_key_preview_popup">false</bool>
    <bool name="config_default_sound_enabled">true</bool>
    <bool name="config_auto_correction_spacebar_led_enabled">false</bool>
    <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
+2 −2
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@
    <integer name="config_device_form_factor">0</integer>
    <bool name="config_use_fullscreen_mode">false</bool>
    <bool name="config_enable_show_voice_key_option">true</bool>
    <bool name="config_enable_show_popup_on_keypress_option">true</bool>
    <bool name="config_enable_show_option_of_key_preview_popup">true</bool>
    <!-- TODO: Disable the following configuration for production. -->
    <bool name="config_enable_usability_study_mode_option">true</bool>
    <!-- Whether or not Popup on key press is enabled by default -->
    <bool name="config_default_popup_preview">true</bool>
    <bool name="config_default_key_preview_popup">true</bool>
    <!-- Default value for next word prediction: after entering a word and a space only, should we look
         at input history to suggest a hopefully helpful suggestions for the next word? -->
    <bool name="config_default_next_word_prediction">true</bool>
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
            android:key="popup_on"
            android:title="@string/popup_on_keypress"
            android:persistent="true"
            android:defaultValue="@bool/config_default_popup_preview" />
            android:defaultValue="@bool/config_default_key_preview_popup" />
        <ListPreference
            android:key="voice_mode"
            android:title="@string/voice_input"
+41 −5
Original line number Diff line number Diff line
@@ -126,13 +126,49 @@ 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,
                res.getBoolean(R.bool.config_default_sound_enabled));
    }

    public static boolean readVibrationEnabled(final SharedPreferences prefs,
            final Resources res) {
        final boolean hasVibrator = AudioAndHapticFeedbackManager.getInstance().hasVibrator();
        return hasVibrator && prefs.getBoolean(PREF_VIBRATE_ON,
                res.getBoolean(R.bool.config_default_vibration_enabled));
    }

    public static boolean readAutoCorrectEnabled(final String currentAutoCorrectionSetting,
            final Resources res) {
        final String autoCorrectionOff = res.getString(
                R.string.auto_correction_threshold_mode_index_off);
        return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
    }

    public static boolean readFromBuildConfigIfGestureInputEnabled(final Resources res) {
        return res.getBoolean(R.bool.config_gesture_input_enabled_by_build_config);
    }

    public static boolean readGestureInputEnabled(final SharedPreferences prefs,
            final Resources res) {
        return readFromBuildConfigIfGestureInputEnabled(res)
                && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true);
    }

    public static boolean readFromBuildConfigIfToShowKeyPreviewPopupSettingsOption(
            final Resources res) {
        return res.getBoolean(R.bool.config_enable_show_option_of_key_preview_popup);
    }

    public static boolean readKeyPreviewPopupEnabled(final SharedPreferences prefs,
            final Resources res) {
        final boolean showPopupOption = res.getBoolean(
                R.bool.config_enable_show_popup_on_keypress_option);
        if (!showPopupOption) return res.getBoolean(R.bool.config_default_popup_preview);
        return prefs.getBoolean(PREF_POPUP_ON,
                res.getBoolean(R.bool.config_default_popup_preview));
        final boolean defaultKeyPreviewPopup = res.getBoolean(
                R.bool.config_default_key_preview_popup);
        if (!readFromBuildConfigIfToShowKeyPreviewPopupSettingsOption(res)) {
            return defaultKeyPreviewPopup;
        }
        return prefs.getBoolean(PREF_POPUP_ON, defaultKeyPreviewPopup);
    }

    public static int readKeyPreviewPopupDismissDelay(final SharedPreferences prefs,
Loading