From fed9cb561095040446449244fbc09a361678d6a3 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 14 Sep 2009 21:23:11 -0700 Subject: [PATCH] Various fixes for back key handling. Change-Id: I8ad314722ce38711ce5c57c4fd3b2942cfe099a7 --- .../internal/policy/impl/PhoneWindow.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/policy/com/android/internal/policy/impl/PhoneWindow.java b/policy/com/android/internal/policy/impl/PhoneWindow.java index fac41823ed5ff..d8d278824d2f3 100644 --- a/policy/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/com/android/internal/policy/impl/PhoneWindow.java @@ -1195,19 +1195,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } case KeyEvent.KEYCODE_BACK: { - // Currently don't do anything with long presses. if (event.getRepeatCount() > 0) break; if (featureId < 0) break; - if (featureId == FEATURE_OPTIONS_PANEL) { - PanelFeatureState st = getPanelState(featureId, false); - if (st != null && st.isInExpandedMode) { - // If the user is in an expanded menu and hits back, it - // should go back to the icon menu - reopenMenu(true); - return true; - } - } - closePanel(featureId); + // Currently don't do anything with long press. + dispatcher.startTracking(event, this); return true; } @@ -1321,17 +1312,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { case KeyEvent.KEYCODE_BACK: { if (featureId < 0) break; - if (featureId == FEATURE_OPTIONS_PANEL) { - PanelFeatureState st = getPanelState(featureId, false); - if (st != null && st.isInExpandedMode) { - // If the user is in an expanded menu and hits back, it - // should go back to the icon menu - reopenMenu(true); - return true; + if (event.isTracking() && !event.isCanceled()) { + if (featureId == FEATURE_OPTIONS_PANEL) { + PanelFeatureState st = getPanelState(featureId, false); + if (st != null && st.isInExpandedMode) { + // If the user is in an expanded menu and hits back, it + // should go back to the icon menu + reopenMenu(true); + return true; + } } + closePanel(featureId); + return true; } - closePanel(featureId); - return true; + break; } case KeyEvent.KEYCODE_HEADSETHOOK: