Add a type parameter to startActionMode() calls.
This requires adding a new method to View and Window.Callback to pass
down the type as a parameter.
For compatibility purposes, the new method implementations keep the
type and call the old method, in case clients have subclassed it.
Change-Id: If5d857f131e33be8cc6a8814f2e9c4e85ad2da25
diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java
index 70a0b6b..2bf02f1 100644
--- a/core/java/com/android/internal/app/WindowDecorActionBar.java
+++ b/core/java/com/android/internal/app/WindowDecorActionBar.java
@@ -493,21 +493,15 @@
}
public ActionMode startActionMode(ActionMode.Callback callback) {
- return new ActionModeWrapper(mContext, callback, new ActionModeProviderImpl());
- }
-
- private class ActionModeProviderImpl implements ActionModeWrapper.ActionModeProvider {
+ if (mActionMode != null) {
+ mActionMode.finish();
+ }
- @Override
- public ActionMode createActionMode(Callback callback, MenuBuilder menuBuilder) {
- if (mActionMode != null) {
- mActionMode.finish();
- }
-
- mOverlayLayout.setHideOnContentScrollEnabled(false);
- mContextView.killMode();
- ActionModeImpl mode = new ActionModeImpl(
- mContextView.getContext(), callback, menuBuilder);
+ mOverlayLayout.setHideOnContentScrollEnabled(false);
+ mContextView.killMode();
+ ActionModeImpl mode = new ActionModeImpl(mContextView.getContext(), callback);
+ if (mode.dispatchOnCreate()) {
+ mode.invalidate();
mContextView.initForMode(mode);
animateToMode(true);
if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
@@ -523,6 +517,7 @@
mActionMode = mode;
return mode;
}
+ return null;
}
private void configureTab(Tab tab, int position) {
@@ -951,13 +946,11 @@
private WeakReference<View> mCustomView;
public ActionModeImpl(
- Context context, ActionMode.Callback callback, MenuBuilder menuBuilder) {
+ Context context, ActionMode.Callback callback) {
mActionModeContext = context;
mCallback = callback;
- mMenu = menuBuilder == null
- ? new MenuBuilder(context)
- .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
- : menuBuilder;
+ mMenu = new MenuBuilder(context)
+ .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
mMenu.setCallback(this);
}
@@ -1019,6 +1012,15 @@
}
}
+ public boolean dispatchOnCreate() {
+ mMenu.stopDispatchingItemsChanged();
+ try {
+ return mCallback.onCreateActionMode(this, mMenu);
+ } finally {
+ mMenu.startDispatchingItemsChanged();
+ }
+ }
+
@Override
public void setCustomView(View view) {
mContextView.setCustomView(view);