summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.xml68
-rw-r--r--core/java/android/app/Activity.java4
-rw-r--r--core/java/android/view/MenuInflater.java4
-rw-r--r--core/java/android/view/Window.java7
-rw-r--r--core/java/com/android/internal/app/ActionBarImpl.java22
-rw-r--r--core/java/com/android/internal/view/StandaloneActionMode.java123
-rw-r--r--core/java/com/android/internal/widget/ActionBarContextView.java4
-rw-r--r--core/res/res/layout-xlarge/screen_action_bar.xml (renamed from core/res/res/layout/screen_xlarge_action_bar.xml)6
-rw-r--r--core/res/res/layout/screen.xml7
-rw-r--r--core/res/res/layout/screen_custom_title.xml7
-rw-r--r--core/res/res/layout/screen_progress.xml7
-rw-r--r--core/res/res/layout/screen_title.xml6
-rw-r--r--core/res/res/layout/screen_title_icons.xml6
-rwxr-xr-xcore/res/res/values/attrs.xml16
-rw-r--r--core/res/res/values/public.xml5
-rw-r--r--core/res/res/values/themes.xml4
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java74
17 files changed, 314 insertions, 56 deletions
diff --git a/api/current.xml b/api/current.xml
index a7e6c52..850073e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -2088,55 +2088,55 @@
visibility="public"
>
</field>
-<field name="actionBarCloseContextDrawable"
+<field name="actionButtonPadding"
type="int"
transient="false"
volatile="false"
- value="16843550"
+ value="16843547"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
-<field name="actionBarContextBackground"
+<field name="actionButtonStyle"
type="int"
transient="false"
volatile="false"
- value="16843549"
+ value="16843545"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
-<field name="actionButtonPadding"
+<field name="actionDropDownStyle"
type="int"
transient="false"
volatile="false"
- value="16843547"
+ value="16843544"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
-<field name="actionButtonStyle"
+<field name="actionModeBackground"
type="int"
transient="false"
volatile="false"
- value="16843545"
+ value="16843549"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
-<field name="actionDropDownStyle"
+<field name="actionModeCloseDrawable"
type="int"
transient="false"
volatile="false"
- value="16843544"
+ value="16843550"
static="true"
final="true"
deprecated="not deprecated"
@@ -10525,6 +10525,17 @@
visibility="public"
>
</field>
+<field name="windowActionModeOverlay"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843551"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="windowAnimationStyle"
type="int"
transient="false"
@@ -21849,6 +21860,19 @@
<parameter name="args" type="android.os.Bundle">
</parameter>
</method>
+<method name="startActionMode"
+ return="android.view.ActionMode"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="callback" type="android.view.ActionMode.Callback">
+</parameter>
+</method>
<method name="startActivityForResult"
return="void"
abstract="false"
@@ -21913,19 +21937,6 @@
<parameter name="requestCode" type="int">
</parameter>
</method>
-<method name="startContextMode"
- return="android.view.ActionMode"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="callback" type="android.view.ActionMode.Callback">
-</parameter>
-</method>
<method name="startIntentSenderForResult"
return="void"
abstract="false"
@@ -194331,6 +194342,17 @@
type="int"
transient="false"
volatile="false"
+ value="8"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_ACTION_MODE_OVERLAY"
+ type="int"
+ transient="false"
+ volatile="false"
value="9"
static="true"
final="true"
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 142c325..9beaec0 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4080,13 +4080,13 @@ public class Activity extends ContextThemeWrapper
*
* @see ActionMode
*/
- public ActionMode startContextMode(ActionMode.Callback callback) {
+ public ActionMode startActionMode(ActionMode.Callback callback) {
return mWindow.getDecorView().startActionMode(callback);
}
public ActionMode onStartActionMode(ActionMode.Callback callback) {
if (mActionBar != null) {
- return mActionBar.startContextMode(callback);
+ return mActionBar.startActionMode(callback);
}
return null;
}
diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java
index 4a966b5..a959e0d 100644
--- a/core/java/android/view/MenuInflater.java
+++ b/core/java/android/view/MenuInflater.java
@@ -350,6 +350,10 @@ public class MenuInflater {
.setShowAsAction(itemShowAsAction);
if (itemListenerMethodName != null) {
+ if (mContext.isRestricted()) {
+ throw new IllegalStateException("The android:onClick attribute cannot "
+ + "be used within a restricted context");
+ }
item.setOnMenuItemClickListener(
new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName));
}
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index b077b56..0d4e84b 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -62,7 +62,12 @@ public abstract class Window {
* replaces the title bar and provides an alternate location
* for an on-screen menu button on some devices.
*/
- public static final int FEATURE_ACTION_BAR = 9;
+ public static final int FEATURE_ACTION_BAR = 8;
+ /**
+ * Flag for specifying the behavior of action modes when an Action Bar is not present.
+ * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
+ */
+ public static final int FEATURE_ACTION_MODE_OVERLAY = 9;
/** Flag for setting the progress bar's visibility to VISIBLE */
public static final int PROGRESS_VISIBILITY_ON = -1;
/** Flag for setting the progress bar's visibility to GONE */
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 6515f25..e457701 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -66,7 +66,7 @@ public class ActionBarImpl extends ActionBar {
private TabImpl mSelectedTab;
private int mTabSwitchMode = TAB_SWITCH_ADD_REMOVE;
- private ActionMode mContextMode;
+ private ActionMode mActionMode;
private static final int CONTEXT_DISPLAY_NORMAL = 0;
private static final int CONTEXT_DISPLAY_SPLIT = 1;
@@ -229,9 +229,9 @@ public class ActionBarImpl extends ActionBar {
return mActionView.getDisplayOptions();
}
- public ActionMode startContextMode(ActionMode.Callback callback) {
- if (mContextMode != null) {
- mContextMode.finish();
+ public ActionMode startActionMode(ActionMode.Callback callback) {
+ if (mActionMode != null) {
+ mActionMode.finish();
}
// Don't wait for the close context mode animation to finish.
@@ -241,7 +241,7 @@ public class ActionBarImpl extends ActionBar {
mCloseContext.run();
}
- ActionMode mode = new ContextModeImpl(callback);
+ ActionMode mode = new ActionModeImpl(callback);
if (callback.onCreateActionMode(mode, mode.getMenu())) {
mode.invalidate();
mUpperContextView.initForMode(mode);
@@ -250,7 +250,7 @@ public class ActionBarImpl extends ActionBar {
// TODO animate this
mLowerContextView.setVisibility(View.VISIBLE);
}
- mContextMode = mode;
+ mActionMode = mode;
return mode;
}
return null;
@@ -361,12 +361,12 @@ public class ActionBarImpl extends ActionBar {
/**
* @hide
*/
- public class ContextModeImpl extends ActionMode implements MenuBuilder.Callback {
+ public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
private ActionMode.Callback mCallback;
private MenuBuilder mMenu;
private WeakReference<View> mCustomView;
- public ContextModeImpl(ActionMode.Callback callback) {
+ public ActionModeImpl(ActionMode.Callback callback) {
mCallback = callback;
mMenu = new MenuBuilder(mActionView.getContext());
mMenu.setCallback(this);
@@ -379,8 +379,8 @@ public class ActionBarImpl extends ActionBar {
@Override
public void finish() {
- if (mContextMode != this) {
- // Not the active context mode - no-op
+ if (mActionMode != this) {
+ // Not the active action mode - no-op
return;
}
@@ -395,7 +395,7 @@ public class ActionBarImpl extends ActionBar {
// TODO Animate this
mLowerContextView.setVisibility(View.GONE);
}
- mContextMode = null;
+ mActionMode = null;
}
@Override
diff --git a/core/java/com/android/internal/view/StandaloneActionMode.java b/core/java/com/android/internal/view/StandaloneActionMode.java
new file mode 100644
index 0000000..13eda10
--- /dev/null
+++ b/core/java/com/android/internal/view/StandaloneActionMode.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.internal.view;
+
+import com.android.internal.view.menu.MenuBuilder;
+import com.android.internal.view.menu.MenuPopupHelper;
+import com.android.internal.view.menu.SubMenuBuilder;
+import com.android.internal.widget.ActionBarContextView;
+
+import android.content.Context;
+import android.view.ActionMode;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+import java.lang.ref.WeakReference;
+
+public class StandaloneActionMode extends ActionMode implements MenuBuilder.Callback {
+ private Context mContext;
+ private ActionBarContextView mContextView;
+ private ActionMode.Callback mCallback;
+ private WeakReference<View> mCustomView;
+ private boolean mFinished;
+
+ private MenuBuilder mMenu;
+
+ public StandaloneActionMode(Context context, ActionBarContextView view,
+ ActionMode.Callback callback) {
+ mContext = context;
+ mContextView = view;
+ mCallback = callback;
+
+ mMenu = new MenuBuilder(context);
+ mMenu.setCallback(this);
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mContextView.setTitle(title);
+ }
+
+ @Override
+ public void setSubtitle(CharSequence subtitle) {
+ mContextView.setSubtitle(subtitle);
+ }
+
+ @Override
+ public void setCustomView(View view) {
+ mContextView.setCustomView(view);
+ mCustomView = view != null ? new WeakReference<View>(view) : null;
+ }
+
+ @Override
+ public void invalidate() {
+ mCallback.onPrepareActionMode(this, mMenu);
+ }
+
+ @Override
+ public void finish() {
+ if (mFinished) {
+ return;
+ }
+ mFinished = true;
+
+ mCallback.onDestroyActionMode(this);
+ mContextView.setVisibility(View.GONE);
+ }
+
+ @Override
+ public Menu getMenu() {
+ return mMenu;
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mContextView.getTitle();
+ }
+
+ @Override
+ public CharSequence getSubtitle() {
+ return mContextView.getSubtitle();
+ }
+
+ @Override
+ public View getCustomView() {
+ return mCustomView != null ? mCustomView.get() : null;
+ }
+
+ public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
+ return mCallback.onActionItemClicked(this, item);
+ }
+
+ public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
+ }
+
+ public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
+ if (!subMenu.hasVisibleItems()) {
+ return true;
+ }
+
+ new MenuPopupHelper(mContext, subMenu).show();
+ return true;
+ }
+
+ public void onCloseSubMenu(SubMenuBuilder menu) {
+ }
+
+ public void onMenuModeChange(MenuBuilder menu) {
+ }
+}
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index a185e21..0bedc4e 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -70,9 +70,9 @@ public class ActionBarContextView extends ViewGroup {
mItemPadding = a.getDimensionPixelOffset(
com.android.internal.R.styleable.Theme_actionButtonPadding, 0);
setBackgroundDrawable(a.getDrawable(
- com.android.internal.R.styleable.Theme_actionBarContextBackground));
+ com.android.internal.R.styleable.Theme_actionModeBackground));
mCloseDrawable = a.getDrawable(
- com.android.internal.R.styleable.Theme_actionBarCloseContextDrawable);
+ com.android.internal.R.styleable.Theme_actionModeCloseDrawable);
mItemMargin = mItemPadding / 2;
mContentHeight =
diff --git a/core/res/res/layout/screen_xlarge_action_bar.xml b/core/res/res/layout-xlarge/screen_action_bar.xml
index c51ca13..41ce8e4 100644
--- a/core/res/res/layout/screen_xlarge_action_bar.xml
+++ b/core/res/res/layout-xlarge/screen_action_bar.xml
@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@ This is an optimized layout for a screen with the Action Bar enabled.
android:layout_height="wrap_content" />
</ViewAnimator>
<FrameLayout android:id="@android:id/content"
- android:layout_width="match_parent"
+ android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:foregroundGravity="fill_horizontal|top"
diff --git a/core/res/res/layout/screen.xml b/core/res/res/layout/screen.xml
index dfa9731..0269bf1 100644
--- a/core/res/res/layout/screen.xml
+++ b/core/res/res/layout/screen.xml
@@ -25,6 +25,13 @@ This is the basic layout for a screen, with all of its features enabled.
android:layout_width="match_parent"
android:layout_height="match_parent"
>
+ <!-- Popout bar for action modes -->
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_mode_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
<!-- Title bar -->
<RelativeLayout android:id="@android:id/title_container"
style="?android:attr/windowTitleBackgroundStyle"
diff --git a/core/res/res/layout/screen_custom_title.xml b/core/res/res/layout/screen_custom_title.xml
index 34c9de0..fe06ddd 100644
--- a/core/res/res/layout/screen_custom_title.xml
+++ b/core/res/res/layout/screen_custom_title.xml
@@ -21,6 +21,13 @@ This is an custom layout for a screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true">
+ <!-- Popout bar for action modes -->
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_mode_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
<FrameLayout android:id="@android:id/title_container"
android:layout_width="match_parent"
android:layout_height="?android:attr/windowTitleSize"
diff --git a/core/res/res/layout/screen_progress.xml b/core/res/res/layout/screen_progress.xml
index 6e694c1..9669533 100644
--- a/core/res/res/layout/screen_progress.xml
+++ b/core/res/res/layout/screen_progress.xml
@@ -26,6 +26,13 @@ This is the basic layout for a screen, with all of its features enabled.
android:layout_width="match_parent"
android:layout_height="match_parent"
>
+ <!-- Popout bar for action modes -->
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_mode_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
<RelativeLayout android:id="@android:id/title_container"
style="?android:attr/windowTitleBackgroundStyle"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/screen_title.xml b/core/res/res/layout/screen_title.xml
index 39ea131..26597af 100644
--- a/core/res/res/layout/screen_title.xml
+++ b/core/res/res/layout/screen_title.xml
@@ -22,6 +22,12 @@ enabled.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true">
+ <!-- Popout bar for action modes -->
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_mode_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/windowTitleSize"
diff --git a/core/res/res/layout/screen_title_icons.xml b/core/res/res/layout/screen_title_icons.xml
index 62a0228..c8cf334 100644
--- a/core/res/res/layout/screen_title_icons.xml
+++ b/core/res/res/layout/screen_title_icons.xml
@@ -23,6 +23,12 @@ This is the basic layout for a screen, with all of its features enabled.
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <!-- Popout bar for action modes -->
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_mode_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
<RelativeLayout android:id="@android:id/title_container"
style="?android:attr/windowTitleBackgroundStyle"
android:layout_width="match_parent"
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 4edd964..d1024fe 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -251,6 +251,10 @@
<!-- Reference to a style for the Action Bar -->
<attr name="windowActionBarStyle" format="reference" />
+ <!-- Flag indicating whether action modes should overlay window content
+ when there is not reserved space for their UI (such as an Action Bar). -->
+ <attr name="windowActionModeOverlay" format="boolean" />
+
<!-- Defines the default soft input state that this window would
like when it is displayed. -->
<attr name="windowSoftInputMode">
@@ -444,8 +448,15 @@
<eat-comment />
<!-- Default amount of padding to use between action buttons. -->
<attr name="actionButtonPadding" format="dimension" />
- <attr name="actionBarContextBackground" format="reference" />
- <attr name="actionBarCloseContextDrawable" format="reference" />
+
+ <!-- =================== -->
+ <!-- Action mode styles -->
+ <!-- =================== -->
+ <eat-comment />
+ <!-- Background drawable to use for action mode UI -->
+ <attr name="actionModeBackground" format="reference" />
+ <!-- Drawable to use for the close action mode button -->
+ <attr name="actionModeCloseDrawable" format="reference" />
<!-- =================== -->
<!-- Preference styles -->
@@ -987,6 +998,7 @@
<attr name="backgroundDimAmount" />
<attr name="windowActionBar" />
<attr name="windowActionBarStyle" />
+ <attr name="windowActionModeOverlay" />
</declare-styleable>
<!-- The set of attributes that describe a AlertDialog's theme. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 34dd46c..f1ff3a3 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1306,8 +1306,9 @@
<public type="attr" name="showAsAction" />
<public type="attr" name="actionButtonPadding" />
<public type="attr" name="previewImage" />
- <public type="attr" name="actionBarContextBackground" />
- <public type="attr" name="actionBarCloseContextDrawable" />
+ <public type="attr" name="actionModeBackground" />
+ <public type="attr" name="actionModeCloseDrawable" />
+ <public type="attr" name="windowActionModeOverlay" />
<public type="id" name="home" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index bce0e02..998480d 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -206,8 +206,8 @@
<!-- Action bar styles -->
<item name="actionButtonPadding">12dip</item>
- <item name="actionBarContextBackground">@android:drawable/action_bar_context_background</item>
- <item name="actionBarCloseContextDrawable">@android:drawable/ic_menu_close_clear_cancel</item>
+ <item name="actionModeBackground">@android:drawable/action_bar_context_background</item>
+ <item name="actionModeCloseDrawable">@android:drawable/ic_menu_close_clear_cancel</item>
</style>
<!-- Variant of the default (dark) theme with no title bar -->
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 2976e3e..458ac9d 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -24,12 +24,14 @@ import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
+import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuDialogHelper;
import com.android.internal.view.menu.MenuPopupHelper;
import com.android.internal.view.menu.MenuView;
import com.android.internal.view.menu.SubMenuBuilder;
+import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.ActionBarView;
import android.app.KeyguardManager;
@@ -1638,6 +1640,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
private boolean mWatchingForMenu;
private int mDownY;
+ private ActionMode mActionMode;
+ private ActionBarContextView mActionModeView;
+
public DecorView(Context context, int featureId) {
super(context);
mFeatureId = featureId;
@@ -1935,7 +1940,33 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
- return getCallback().onStartActionMode(callback);
+ if (mActionMode != null) {
+ mActionMode.finish();
+ }
+
+ ActionMode mode = getCallback().onStartActionMode(callback);
+ if (mode != null) {
+ mActionMode = mode;
+ } else {
+ if (mActionModeView == null) {
+ mActionModeView = (ActionBarContextView) findViewById(
+ com.android.internal.R.id.action_mode_bar);
+ }
+
+ if (mActionModeView != null) {
+ mode = new StandaloneActionMode(getContext(), mActionModeView,
+ new ActionModeCallbackWrapper(callback));
+ if (callback.onCreateActionMode(mode, mode.getMenu())) {
+ mode.invalidate();
+ mActionModeView.initForMode(mode);
+ mActionModeView.setVisibility(View.VISIBLE);
+ mActionMode = mode;
+ } else {
+ mActionMode = null;
+ }
+ }
+ }
+ return mActionMode;
}
public void startChanging() {
@@ -2117,6 +2148,35 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (keepOn) PhoneWindow.this.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
else PhoneWindow.this.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
+
+ /**
+ * Clears out internal reference when the action mode is destroyed.
+ */
+ private class ActionModeCallbackWrapper implements ActionMode.Callback {
+ private ActionMode.Callback mWrapped;
+
+ public ActionModeCallbackWrapper(ActionMode.Callback wrapped) {
+ mWrapped = wrapped;
+ }
+
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ return mWrapped.onCreateActionMode(mode, menu);
+ }
+
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return mWrapped.onPrepareActionMode(mode, menu);
+ }
+
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return mWrapped.onActionItemClicked(mode, item);
+ }
+
+ public void onDestroyActionMode(ActionMode mode) {
+ mWrapped.onDestroyActionMode(mode);
+ mActionModeView.removeAllViews();
+ mActionMode = null;
+ }
+ }
}
protected DecorView generateDecor() {
@@ -2170,6 +2230,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
requestFeature(FEATURE_ACTION_BAR);
}
+ if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionModeOverlay, false)) {
+ requestFeature(FEATURE_ACTION_MODE_OVERLAY);
+ }
+
if (a.getBoolean(com.android.internal.R.styleable.Window_windowFullscreen, false)) {
setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN&(~getForcedWindowFlags()));
}
@@ -2252,13 +2316,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (mIsFloating) {
layoutResource = com.android.internal.R.layout.dialog_title;
} else if ((features & (1 << FEATURE_ACTION_BAR)) != 0) {
- Configuration config = getContext().getResources().getConfiguration();
- if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_XLARGE) ==
- Configuration.SCREENLAYOUT_SIZE_XLARGE) {
- layoutResource = com.android.internal.R.layout.screen_xlarge_action_bar;
- } else {
- layoutResource = com.android.internal.R.layout.screen_action_bar;
- }
+ layoutResource = com.android.internal.R.layout.screen_action_bar;
} else {
layoutResource = com.android.internal.R.layout.screen_title;
}