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

Commit c7f1988c authored by Michael Webster's avatar Michael Webster Committed by Steve Kondik
Browse files

Add adjustable haptic feedback stuff

Change-Id: Ib5d6165080970580757277bdf0ba5d081e327b16
parent b50c4e22
Loading
Loading
Loading
Loading
+77 −1
Original line number Diff line number Diff line
@@ -1800,6 +1800,72 @@ public final class Settings {
         */
        public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";

        /**
         * Whether haptic feedback is enabled on virtual key release (as opposed to pressed)
         * boolean (1 or 0).
         * @hide
         */
        public static final String HAPTIC_FEEDBACK_UP_ENABLED = "haptic_feedback_up_enabled";

        /**
         * Whether haptic is also activated for all screen interaction (follows Sound Effects Enabled behaviour)
         * boolean (1 or 0).
         * @hide
         */
        public static final String HAPTIC_FEEDBACK_ALL_ENABLED = "haptic_feedback_all_enabled";

        /**
         * Value for haptic down (string will be converted to array -
         * format is ***"delay in msec before turning on"_"delay in msec before turning off__**repeat**)
         * @hide
         */
        public static final String HAPTIC_DOWN_ARRAY = "haptic_down_array";

        /**
         * Value for haptic up - same format as _DOWN_ARRAY
         * @hide
         */
        public static final String HAPTIC_UP_ARRAY = "haptic_up_array";
        
        /**
         * Value for long presses - same format as _DOWN_ARRAY
         * @hide
         */
        public static final String HAPTIC_LONG_ARRAY = "haptic_long_array";

        /**
         * these store the ORIGINAL default haptic values from config.xml
         * this is so HapticAdjust can easily pull them when resetting defaults
         * these are created and acted on in PhoneWindowManager
         * @hide
         */
        public static final String HAPTIC_DOWN_ARRAY_DEFAULT = "haptic_down_array_default";

        /**
         * Same as HAPTIC_DOWN_ARRAY_DEFAULT but for key releases
         * @hide
         */
        public static final String HAPTIC_UP_ARRAY_DEFAULT = "haptic_up_array_default";

        /**
         * Same as HAPTIC_DOWN_ARRAY_DEFAULT but for key releases
         * @hide
         */
        public static final String HAPTIC_LONG_ARRAY_DEFAULT = "haptic_long_array_default";

        /**
         * Set values for haptic feedback from typing on keypad (new for Froyo)
         * @hide
         */
        public static final String HAPTIC_TAP_ARRAY = "haptic_tap_array";

        /**
         * Default values for haptic feedback from typing on keypad (new for Froyo) - pulled
         * from config.xml
         * @hide
         */
        public static final String HAPTIC_TAP_ARRAY_DEFAULT = "haptic_tap_array_default";

        /**
         * Whether live web suggestions while the user types into search dialogs are
         * enabled. Browsers and other search UIs should respect this, as it allows
@@ -2088,7 +2154,17 @@ public final class Settings {
            QUIET_HOURS_END,
            QUIET_HOURS_MUTE,
            QUIET_HOURS_STILL,
            QUIET_HOURS_DIM
            QUIET_HOURS_DIM,
            HAPTIC_FEEDBACK_UP_ENABLED,
            HAPTIC_FEEDBACK_ALL_ENABLED,
            HAPTIC_DOWN_ARRAY,
            HAPTIC_UP_ARRAY,
            HAPTIC_LONG_ARRAY,
            HAPTIC_DOWN_ARRAY_DEFAULT,
            HAPTIC_UP_ARRAY_DEFAULT,
            HAPTIC_LONG_ARRAY_DEFAULT,
            HAPTIC_TAP_ARRAY,
            HAPTIC_TAP_ARRAY_DEFAULT
        };

        // Settings moved to Settings.Secure
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,12 @@ public class HapticFeedbackConstants {
     */
    public static final int VIRTUAL_KEY = 1;
    
    /**
     * User has released a virtual on-screen key.
     * @hide
     */
    public static final int VIRTUAL_RELEASED = 2;

    /**
     * The user has pressed a soft keyboard key.
     */
+3 −0
Original line number Diff line number Diff line
@@ -2672,6 +2672,9 @@ public final class ViewRoot extends Handler implements ViewParent,
            switch (effectId) {
                case SoundEffectConstants.CLICK:
                    audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
                    if (audioManager.queryHapticsAllEnabled()){
                        performHapticFeedback(HapticFeedbackConstants.VIRTUAL_RELEASED, false);
                        };
                    return;
                case SoundEffectConstants.NAVIGATION_DOWN:
                    audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
+6 −0
Original line number Diff line number Diff line
@@ -256,6 +256,12 @@
        <item>10</item>
    </integer-array>

    <!-- Vibrator pattern for feedback about on a key release -->
    <integer-array name="config_virtualKeyUpPattern">
        <item>5</item>
        <item>18</item>
    </integer-array>

    <bool name="config_use_strict_phone_number_comparation">false</bool>

    <!-- Display low battery warning when battery level dips to this value -->
+7 −0
Original line number Diff line number Diff line
@@ -1216,6 +1216,13 @@ public class AudioManager {
        return Settings.System.getInt(mContext.getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0) != 0;
    }

    /**
     * See if haptic feedback is enabled for screen touches of objects (called by ViewRoot)
     * @hide
     */
    public boolean queryHapticsAllEnabled() {
        return Settings.System.getInt(mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ALL_ENABLED, 0) != 0;
    }

    /**
     *  Load Sound effects.
Loading