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

Commit 3cb0d380 authored by Phil Tunstall's avatar Phil Tunstall Committed by Steve Kondik
Browse files

Hardware key custom rebinding (1/2)

Framework changes to allow rebinding of the actions performed on the following
key press events: Home long-press, menu press, menu long-press, search press,
search long-press, app-switch press and app-switch long-press.

The available actions are: Nothing, open/close menu, recent apps switcher,
search assistant, voice search and in-app search.

Patch Set 1: Initial port from ICS [done by Konstantin Koslowski]
Patch Set 2: Added 'assist' (search) key customisation
             Option for ICS-style in-app search, in addition to jellybean-style
             search assistant.
             Fixed double haptic feedback on virtual key press.
Patch Set 3: Checkbox to enable/disable all custom bindings.
             Home long-press defaults to no action on devices with
             an app-switch key.
Patch Set 4: The recent apps list will be preloaded on the initial down press
             of whichever key to which it is bound.
Patch Set 5: Fixed menu virtual key press sometimes performing the custom
             action bound to the menu key instead of just opening or closing
             the menu as it should.

Change-Id: If790aae7cf266f90d1afa07acfe91129b2d19489
parent f64ebe1d
Loading
Loading
Loading
Loading
+73 −0
Original line number Diff line number Diff line
@@ -2674,6 +2674,79 @@ public final class Settings {
         */
        public static final String POWER_MENU_SCREENSHOT_ENABLED = "power_menu_screenshot_enabled";

        /**
         * Whether to enable custom rebindings of the actions performed on
         * certain key press events.
         * @hide
         */
        public static final String HARDWARE_KEY_REBINDING = "hardware_key_rebinding";

         /**
          * Action to perform when the home key is long-pressed. (Default is 2)
          * 0 - Nothing
          * 1 - Menu
          * 2 - App-switch
          * 3 - Search
          * 4 - Voice search
          * 5 - In-app search
          * @hide
          */
         public static final String KEY_HOME_LONG_PRESS_ACTION = "key_home_long_press_action";

         /**
          * Action to perform when the menu key is pressed. (Default is 1)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_MENU_ACTION = "key_menu_action";

         /**
          * Action to perform when the menu key is long-pressed.
          * (Default is 0 on devices with a search key, 3 on devices without)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_MENU_LONG_PRESS_ACTION = "key_menu_long_press_action";

         /**
          * Action to perform when the assistant (search) key is pressed. (Default is 3)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_ASSIST_ACTION = "key_assist_action";

         /**
          * Action to perform when the assistant (search) key is long-pressed. (Default is 4)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_ASSIST_LONG_PRESS_ACTION = "key_assist_long_press_action";

         /**
          * Action to perform when the app switch key is pressed. (Default is 2)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_APP_SWITCH_ACTION = "key_app_switch_action";

         /**
          * Action to perform when the app switch key is long-pressed. (Default is 0)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
          * @hide
          */
         public static final String KEY_APP_SWITCH_LONG_PRESS_ACTION = "key_app_switch_long_press_action";

        /**
         * Control the display of the action overflow button within app UI.
         * 0 = use system default
         * 1 = force on
         * @hide
         */
        public static final String UI_FORCE_OVERFLOW_BUTTON = "ui_force_overflow_button";

        /**
         * Show the pending notification counts as overlays on the status bar

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+16 −1
Original line number Diff line number Diff line
@@ -240,6 +240,8 @@ public class ViewConfiguration {
    private boolean sHasPermanentMenuKey;
    private boolean sHasPermanentMenuKeySet;

    private Context mContext;

    static final SparseArray<ViewConfiguration> sConfigurations =
            new SparseArray<ViewConfiguration>(2);

@@ -287,6 +289,8 @@ public class ViewConfiguration {
            sizeAndDensity = density;
        }

        mContext = context;

        mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
        mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
        mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
@@ -692,8 +696,19 @@ public class ViewConfiguration {
     * @return true if a permanent menu key is present, false otherwise.
     */
    public boolean hasPermanentMenuKey() {
        // The action overflow button within app UI can
        // be controlled with a system setting
        int showOverflowButton = Settings.System.getInt(
                mContext.getContentResolver(),
                Settings.System.UI_FORCE_OVERFLOW_BUTTON, 0);
        if (showOverflowButton == 1) {
            // Force overflow button on by reporting that
            // the device has no permanent menu key
            return false;
        } else {
            return sHasPermanentMenuKey;
        }
    }

    /**
     * @hide
+12 −0
Original line number Diff line number Diff line
@@ -924,4 +924,16 @@
    <!-- If true, adds support for no delay A2DP in Samsung devices -->
    <bool name="config_noDelayInATwoDP">false</bool>

    <!-- Hardware 'face' keys present on the device, stored as a bit field.
         This integer should equal the sum of the corresponding value for each
         of the following keys present:
             1 - Home
             2 - Back
             4 - Menu
             8 - Assistant (search)
            16 - App switch
         For example, a device with Home, Back and Menu keys would set this
         config to 7. -->
    <integer name="config_deviceHardwareKeys">15</integer>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -3680,6 +3680,7 @@
  <java-symbol type="bool" name="config_hasDockBattery" />
  <java-symbol type="bool" name="config_noDelayInATwoDP" />
  <java-symbol type="bool" name="config_smsSamsungCdmaAlternateMessageIDEncoding" />
  <java-symbol type="integer" name="config_deviceHardwareKeys" />

  <!-- Notification and battery light -->
  <java-symbol type="bool" name="config_intrusiveBatteryLed" />
+312 −96

File changed.

Preview size limit exceeded, changes collapsed.