summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-12-09 14:25:41 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-12-09 14:25:41 -0800
commitbdc18b28eb04b8c8cc00313096f8bfb142e407e3 (patch)
treee41f9646de276f365c054919031d6433aa15079d
parentfa7fa9a5ba796eabb2dadb8e2ce1b97da38e939e (diff)
parent03e634270d880407316b51fac2278e604fc82703 (diff)
downloadframeworks_base-bdc18b28eb04b8c8cc00313096f8bfb142e407e3.zip
frameworks_base-bdc18b28eb04b8c8cc00313096f8bfb142e407e3.tar.gz
frameworks_base-bdc18b28eb04b8c8cc00313096f8bfb142e407e3.tar.bz2
am 03e63427: am 8e0ecbfc: Merge "Shortcut keys should be handled on down, not up." into ics-mr1
* commit '03e634270d880407316b51fac2278e604fc82703': Shortcut keys should be handled on down, not up.
-rw-r--r--core/java/android/view/ViewRootImpl.java3
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java42
2 files changed, 33 insertions, 12 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7a9d82c..72966ef 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3257,8 +3257,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
}
// If the Control modifier is held, try to interpret the key as a shortcut.
- if (event.getAction() == KeyEvent.ACTION_UP
+ if (event.getAction() == KeyEvent.ACTION_DOWN
&& event.isCtrlPressed()
+ && event.getRepeatCount() == 0
&& !KeyEvent.isModifierKey(event.getKeyCode())) {
if (mView.dispatchKeyShortcutEvent(event)) {
finishInputEvent(q, true);
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index af86ae9..535f039 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -1816,22 +1816,42 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
@Override
public boolean dispatchKeyShortcutEvent(KeyEvent ev) {
- // Perform the shortcut (mPreparedPanel can be null since
- // global shortcuts (such as search) don't rely on a
- // prepared panel or menu).
- boolean handled = performPanelShortcut(mPreparedPanel, ev.getKeyCode(), ev,
- Menu.FLAG_PERFORM_NO_CLOSE);
- if (handled) {
- if (mPreparedPanel != null) {
- mPreparedPanel.isHandled = true;
+ // If the panel is already prepared, then perform the shortcut using it.
+ boolean handled;
+ if (mPreparedPanel != null) {
+ handled = performPanelShortcut(mPreparedPanel, ev.getKeyCode(), ev,
+ Menu.FLAG_PERFORM_NO_CLOSE);
+ if (handled) {
+ if (mPreparedPanel != null) {
+ mPreparedPanel.isHandled = true;
+ }
+ return true;
}
- return true;
}
// Shortcut not handled by the panel. Dispatch to the view hierarchy.
final Callback cb = getCallback();
- return cb != null && !isDestroyed() && mFeatureId < 0 ? cb.dispatchKeyShortcutEvent(ev)
- : super.dispatchKeyShortcutEvent(ev);
+ handled = cb != null && !isDestroyed() && mFeatureId < 0
+ ? cb.dispatchKeyShortcutEvent(ev) : super.dispatchKeyShortcutEvent(ev);
+ if (handled) {
+ return true;
+ }
+
+ // If the panel is not prepared, then we may be trying to handle a shortcut key
+ // combination such as Control+C. Temporarily prepare the panel then mark it
+ // unprepared again when finished to ensure that the panel will again be prepared
+ // the next time it is shown for real.
+ if (mPreparedPanel == null) {
+ PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true);
+ preparePanel(st, ev);
+ handled = performPanelShortcut(st, ev.getKeyCode(), ev,
+ Menu.FLAG_PERFORM_NO_CLOSE);
+ st.isPrepared = false;
+ if (handled) {
+ return true;
+ }
+ }
+ return false;
}
@Override