From b055725d0b1df2f23ecfa95bff940aa8b57f97df Mon Sep 17 00:00:00 2001 From: Phil Tunstall Date: Fri, 27 Jul 2012 12:00:44 +0100 Subject: 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 --- core/java/android/view/ViewConfiguration.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'core/java/android/view') 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 sConfigurations = new SparseArray(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; + } } /** -- cgit v1.1