summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-08-18 11:59:11 -0700
committerAdam Powell <adamp@google.com>2010-08-18 11:59:16 -0700
commit04253aa134c4795d98cdb219b952393be1914f8b (patch)
treefe4cf848126d6f4bb86a4020e8b19806d965e047 /policy
parent487300abe17417283e4339e044485cf262647d92 (diff)
downloadframeworks_base-04253aa134c4795d98cdb219b952393be1914f8b.zip
frameworks_base-04253aa134c4795d98cdb219b952393be1914f8b.tar.gz
frameworks_base-04253aa134c4795d98cdb219b952393be1914f8b.tar.bz2
Back button closes ActionModes
Change-Id: I763782706ce7aa65a5a11129450d97a2bcb3a625
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index f59f32c..2bb4456 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -1683,7 +1683,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
final int keyCode = event.getKeyCode();
- final boolean isDown = event.getAction() == KeyEvent.ACTION_DOWN;
+ final int action = event.getAction();
+ final boolean isDown = action == KeyEvent.ACTION_DOWN;
/*
* If the user hits another key within the play sound delay, then
@@ -1740,6 +1741,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
}
+ // Back cancels action modes first.
+ if (mActionMode != null && keyCode == KeyEvent.KEYCODE_BACK) {
+ if (action == KeyEvent.ACTION_UP) {
+ mActionMode.finish();
+ }
+ return true;
+ }
+
final Callback cb = getCallback();
final boolean handled = cb != null && mFeatureId < 0 ? cb.dispatchKeyEvent(event)
: super.dispatchKeyEvent(event);
@@ -1976,7 +1985,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
mActionMode.finish();
}
- ActionMode mode = getCallback().onStartActionMode(callback);
+ final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
+ ActionMode mode = getCallback().onStartActionMode(wrappedCallback);
if (mode != null) {
mActionMode = mode;
} else {
@@ -1989,13 +1999,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
} else {
ViewStub stub = (ViewStub) findViewById(
com.android.internal.R.id.action_mode_bar_stub);
- mActionModeView = (ActionBarContextView) stub.inflate();
+ if (stub != null) {
+ mActionModeView = (ActionBarContextView) stub.inflate();
+ }
}
}
if (mActionModeView != null) {
- mode = new StandaloneActionMode(getContext(), mActionModeView,
- new ActionModeCallbackWrapper(callback));
+ mode = new StandaloneActionMode(getContext(), mActionModeView, wrappedCallback);
if (callback.onCreateActionMode(mode, mode.getMenu())) {
mode.invalidate();
mActionModeView.initForMode(mode);
@@ -2213,7 +2224,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
public void onDestroyActionMode(ActionMode mode) {
mWrapped.onDestroyActionMode(mode);
- mActionModeView.removeAllViews();
+ if (mActionModeView != null) {
+ mActionModeView.removeAllViews();
+ }
mActionMode = null;
}
}