From ece945291e04ea8493895349ed95a2ab46b51c93 Mon Sep 17 00:00:00 2001 From: Patrick Dubroy Date: Wed, 23 Feb 2011 18:35:01 -0800 Subject: Fix 3272590: Long-press on home & menu should be same as click Change-Id: I151571900f4bb63910ccfb77fc64c8be9676a224 --- .../android/internal/policy/impl/PhoneWindow.java | 15 ---------- .../internal/policy/impl/PhoneWindowManager.java | 34 ++++++++++++---------- 2 files changed, 18 insertions(+), 31 deletions(-) (limited to 'policy') diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 79b5ced..b746c37 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -143,7 +143,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { * this is 0, there is no key held down. */ private int mPanelChordingKey; - private boolean mPanelMayLongPress; private ImageView mLeftIconView; @@ -658,22 +657,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (event.getRepeatCount() == 0) { // The panel key was pushed, so set the chording key mPanelChordingKey = keyCode; - mPanelMayLongPress = false; PanelFeatureState st = getPanelState(featureId, true); if (!st.isOpen) { - if (getContext().getResources().getConfiguration().keyboard - == Configuration.KEYBOARD_NOKEYS) { - mPanelMayLongPress = true; - } return preparePanel(st, event); } - } else if (mPanelMayLongPress && mPanelChordingKey == keyCode - && (event.getFlags()&KeyEvent.FLAG_LONG_PRESS) != 0) { - // We have had a long press while in a state where this - // should be executed... do it! - mPanelChordingKey = 0; - mPanelMayLongPress = false; } return false; @@ -688,7 +676,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // The panel key was released, so clear the chording key if (mPanelChordingKey != 0) { mPanelChordingKey = 0; - mPanelMayLongPress = false; if (event.isCanceled()) { return; @@ -2140,8 +2127,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public void onWindowFocusChanged(boolean hasWindowFocus) { super.onWindowFocusChanged(hasWindowFocus); - mPanelMayLongPress = false; - // If the user is chording a menu shortcut, release the chord since // this window lost focus if (!hasWindowFocus && mPanelChordingKey != 0) { diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index f6649fd..f5f4c6e 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -601,19 +601,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { */ Runnable mHomeLongPress = new Runnable() { public void run() { - /* - * Eat the longpress so it won't dismiss the recent apps dialog when - * the user lets go of the home key - */ - mHomePressed = false; - showRecentAppsDialog(); + handleLongPressOnHome(); } }; - /** - * Create (if necessary) and launch the recent apps dialog - */ - void showRecentAppsDialog() { + private void handleLongPressOnHome() { // We can't initialize this in init() since the configuration hasn't been loaded yet. if (mLongPressOnHomeBehavior < 0) { mLongPressOnHomeBehavior @@ -627,14 +619,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); + + // Eat the longpress so it won't dismiss the recent apps dialog when + // the user lets go of the home key + mHomePressed = false; } - + if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_DIALOG) { - // Fallback to dialog if we fail to launch the above. - if (mRecentAppsDialog == null) { - mRecentAppsDialog = new RecentApplicationsDialog(mContext); - } - mRecentAppsDialog.show(); + showRecentAppsDialog(); } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_ACTIVITY) { try { Intent intent = new Intent(); @@ -649,6 +641,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } + + /** + * Create (if necessary) and launch the recent apps dialog + */ + void showRecentAppsDialog() { + if (mRecentAppsDialog == null) { + mRecentAppsDialog = new RecentApplicationsDialog(mContext); + } + mRecentAppsDialog.show(); + } /** {@inheritDoc} */ public void init(Context context, IWindowManager windowManager, -- cgit v1.1