summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-07-27 16:34:07 -0700
committerAdam Powell <adamp@google.com>2010-07-27 21:04:52 -0700
commit5d27977f9da482627ceb19317a2cd70467aff046 (patch)
treea96b2c2a9aeba5f2e3b92a256949677880063d35 /policy/src
parent85d8daa889db113b51c5d98929245e80f7277388 (diff)
downloadframeworks_base-5d27977f9da482627ceb19317a2cd70467aff046.zip
frameworks_base-5d27977f9da482627ceb19317a2cd70467aff046.tar.gz
frameworks_base-5d27977f9da482627ceb19317a2cd70467aff046.tar.bz2
Action modes without action bar
Change-Id: I0367ab35e598a17980bd373b30828175f6283acc
Diffstat (limited to 'policy/src')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java74
1 files changed, 66 insertions, 8 deletions
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;
}