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

Commit b055725d authored by Phil Tunstall's avatar Phil Tunstall Committed by Gerrit Code Review
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.

Conflicts:
	core/res/res/values/public.xml
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Change-Id: I72c0d220a09d79230bfa299e0521ed693e5c25f1
parent f84e1145
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -2895,6 +2895,76 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_VIBRATE_ENABLED = "lockscreen.vibrate_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";

        /**
         * 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
@@ -223,6 +223,8 @@ public class ViewConfiguration {
    private boolean sHasPermanentMenuKey;
    private boolean sHasPermanentMenuKeySet;

    private Context mContext;

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

@@ -270,6 +272,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);
@@ -678,8 +682,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
@@ -1057,4 +1057,16 @@
    <!-- Disable the home key unlock setting -->
    <bool name="config_disableHomeUnlockSetting">true</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>
+3 −0
Original line number Diff line number Diff line
@@ -1837,6 +1837,9 @@
  <java-symbol type="bool" name="config_smsSamsungCdmaAlternateMessageIDEncoding" />
  <java-symbol type="bool" name="config_samsung_stk" />

  <!-- Hardware Key ReMapping -->
  <java-symbol type="integer" name="config_deviceHardwareKeys" />

  <!-- Notification and battery light -->
  <java-symbol type="bool" name="config_intrusiveBatteryLed" />
  <java-symbol type="bool" name="config_multiColorBatteryLed" />
+314 −93

File changed.

Preview size limit exceeded, changes collapsed.