diff options
| author | 2011-02-23 18:35:01 -0800 | |
|---|---|---|
| committer | 2011-02-24 10:03:23 -0800 | |
| commit | ece945291e04ea8493895349ed95a2ab46b51c93 (patch) | |
| tree | 9d5c498ec1530514bfa046f7b2c8097cc848c005 | |
| parent | 7b76c8d3fc25aedea6edfed9638b008faa2f6ae8 (diff) | |
Fix 3272590: Long-press on home & menu should be same as click
Change-Id: I151571900f4bb63910ccfb77fc64c8be9676a224
3 files changed, 21 insertions, 36 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java index e80e37d95763..8ab231b574d7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java @@ -42,13 +42,12 @@ public class KeyButtonView extends ImageView { IWindowManager mWindowManager; long mDownTime; - boolean mSending, mLongPressed; + boolean mSending; int mCode; int mRepeat; Runnable mCheckLongPress = new Runnable() { public void run() { if (isPressed()) { - mLongPressed = true; mRepeat++; sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_FROM_SYSTEM @@ -91,7 +90,6 @@ public class KeyButtonView extends ImageView { mDownTime = SystemClock.uptimeMillis(); mRepeat = 0; mSending = true; - mLongPressed = false; sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, mDownTime); setPressed(true); @@ -107,7 +105,7 @@ public class KeyButtonView extends ImageView { break; case MotionEvent.ACTION_CANCEL: setPressed(false); - if (mSending && !mLongPressed) { + if (mSending) { mSending = false; sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY @@ -117,7 +115,7 @@ public class KeyButtonView extends ImageView { break; case MotionEvent.ACTION_UP: setPressed(false); - if (mSending && !mLongPressed) { + if (mSending) { mSending = false; sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY); diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 79b5ced9d018..b746c372de67 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 f6649fd74af1..f5f4c6e3feaa 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, |