diff options
| author | Phil Tunstall <ptunstall@gmail.com> | 2012-07-27 12:00:44 +0100 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-12-10 16:50:22 -0800 |
| commit | b055725d0b1df2f23ecfa95bff940aa8b57f97df (patch) | |
| tree | 582b3ee8a9dadda15505bbcae960f4badec1eacc /core/java | |
| parent | f84e114527b5c4761026b34a8d08f0284d6c2f34 (diff) | |
| download | frameworks_base-b055725d0b1df2f23ecfa95bff940aa8b57f97df.zip frameworks_base-b055725d0b1df2f23ecfa95bff940aa8b57f97df.tar.gz frameworks_base-b055725d0b1df2f23ecfa95bff940aa8b57f97df.tar.bz2 | |
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
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/provider/Settings.java | 70 | ||||
| -rw-r--r-- | core/java/android/view/ViewConfiguration.java | 17 |
2 files changed, 86 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index db2598f..9f66bc7 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2896,6 +2896,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. * diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 499075e..73295a2 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -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,7 +682,18 @@ public class ViewConfiguration { * @return true if a permanent menu key is present, false otherwise. */ public boolean hasPermanentMenuKey() { - return sHasPermanentMenuKey; + // 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; + } } /** |
