diff options
author | Clara Bayarri <clarabayarri@google.com> | 2015-02-20 10:26:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-20 10:26:15 +0000 |
commit | 7415d6667ee5a04044424ac065f0ec3ee574ba33 (patch) | |
tree | 6f174132b89a7275453fa3524a42183b003b81b2 /core/java/android/view | |
parent | c86703f575f238560afb78476332edcb31dfdd25 (diff) | |
parent | ed2a54cfd336bb935f281c04509ecd48c8cf116d (diff) | |
download | frameworks_base-7415d6667ee5a04044424ac065f0ec3ee574ba33.zip frameworks_base-7415d6667ee5a04044424ac065f0ec3ee574ba33.tar.gz frameworks_base-7415d6667ee5a04044424ac065f0ec3ee574ba33.tar.bz2 |
Merge "Floating Toolbars: Wrap the ActionMode creation in DecorView"
Diffstat (limited to 'core/java/android/view')
-rw-r--r-- | core/java/android/view/PhoneWindow.java | 130 |
1 files changed, 69 insertions, 61 deletions
diff --git a/core/java/android/view/PhoneWindow.java b/core/java/android/view/PhoneWindow.java index ca8a68a..c1498ec 100644 --- a/core/java/android/view/PhoneWindow.java +++ b/core/java/android/view/PhoneWindow.java @@ -25,7 +25,9 @@ import static android.view.WindowManager.LayoutParams.*; import android.app.ActivityManagerNative; import android.app.SearchManager; import android.os.UserHandle; + import com.android.internal.R; +import com.android.internal.view.ActionModeWrapper; import com.android.internal.view.RootViewSurfaceTaker; import com.android.internal.view.StandaloneActionMode; import com.android.internal.view.menu.ContextMenuBuilder; @@ -2689,72 +2691,78 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (mode != null) { mActionMode = mode; } else { - if (mActionModeView == null) { - if (isFloating()) { - // Use the action bar theme. - final TypedValue outValue = new TypedValue(); - final Theme baseTheme = mContext.getTheme(); - baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true); - - final Context actionBarContext; - if (outValue.resourceId != 0) { - final Theme actionBarTheme = mContext.getResources().newTheme(); - actionBarTheme.setTo(baseTheme); - actionBarTheme.applyStyle(outValue.resourceId, true); - - actionBarContext = new ContextThemeWrapper(mContext, 0); - actionBarContext.getTheme().setTo(actionBarTheme); - } else { - actionBarContext = mContext; - } + if (mActionModeView != null) { + mActionModeView.killMode(); + } + ActionModeWrapper wrapperMode = + new ActionModeWrapper(mContext, wrappedCallback); + if (callback.onCreateActionMode(wrapperMode, wrapperMode.getMenu())) { + if (wrapperMode.getType() == ActionMode.TYPE_PRIMARY) { + if (mActionModeView == null) { + if (isFloating()) { + // Use the action bar theme. + final TypedValue outValue = new TypedValue(); + final Theme baseTheme = mContext.getTheme(); + baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true); + + final Context actionBarContext; + if (outValue.resourceId != 0) { + final Theme actionBarTheme = mContext.getResources().newTheme(); + actionBarTheme.setTo(baseTheme); + actionBarTheme.applyStyle(outValue.resourceId, true); + + actionBarContext = new ContextThemeWrapper(mContext, 0); + actionBarContext.getTheme().setTo(actionBarTheme); + } else { + actionBarContext = mContext; + } - mActionModeView = new ActionBarContextView(actionBarContext); - mActionModePopup = new PopupWindow(actionBarContext, null, - R.attr.actionModePopupWindowStyle); - mActionModePopup.setWindowLayoutType( - WindowManager.LayoutParams.TYPE_APPLICATION); - mActionModePopup.setContentView(mActionModeView); - mActionModePopup.setWidth(MATCH_PARENT); - - actionBarContext.getTheme().resolveAttribute( - R.attr.actionBarSize, outValue, true); - final int height = TypedValue.complexToDimensionPixelSize(outValue.data, - actionBarContext.getResources().getDisplayMetrics()); - mActionModeView.setContentHeight(height); - mActionModePopup.setHeight(WRAP_CONTENT); - mShowActionModePopup = new Runnable() { - public void run() { - mActionModePopup.showAtLocation( - mActionModeView.getApplicationWindowToken(), - Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); + mActionModeView = new ActionBarContextView(actionBarContext); + mActionModePopup = new PopupWindow(actionBarContext, null, + R.attr.actionModePopupWindowStyle); + mActionModePopup.setWindowLayoutType( + WindowManager.LayoutParams.TYPE_APPLICATION); + mActionModePopup.setContentView(mActionModeView); + mActionModePopup.setWidth(MATCH_PARENT); + + actionBarContext.getTheme().resolveAttribute( + R.attr.actionBarSize, outValue, true); + final int height = TypedValue.complexToDimensionPixelSize(outValue.data, + actionBarContext.getResources().getDisplayMetrics()); + mActionModeView.setContentHeight(height); + mActionModePopup.setHeight(WRAP_CONTENT); + mShowActionModePopup = new Runnable() { + public void run() { + mActionModePopup.showAtLocation( + mActionModeView.getApplicationWindowToken(), + Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); + } + }; + } else { + ViewStub stub = (ViewStub) findViewById( + R.id.action_mode_bar_stub); + if (stub != null) { + mActionModeView = (ActionBarContextView) stub.inflate(); + } } - }; - } else { - ViewStub stub = (ViewStub) findViewById( - R.id.action_mode_bar_stub); - if (stub != null) { - mActionModeView = (ActionBarContextView) stub.inflate(); } - } - } - - if (mActionModeView != null) { - mActionModeView.killMode(); - mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, - wrappedCallback, mActionModePopup == null); - if (callback.onCreateActionMode(mode, mode.getMenu())) { - mode.invalidate(); - mActionModeView.initForMode(mode); - mActionModeView.setVisibility(View.VISIBLE); - mActionMode = mode; - if (mActionModePopup != null) { - post(mShowActionModePopup); + if (mActionModeView != null) { + wrapperMode.setActionModeView(mActionModeView); + wrapperMode.setFocusable(mActionModePopup == null); + wrapperMode.lockType(); + wrapperMode.invalidate(); + mActionModeView.initForMode(wrapperMode); + mActionModeView.setVisibility(View.VISIBLE); + mActionMode = wrapperMode; + if (mActionModePopup != null) { + post(mShowActionModePopup); + } + mActionModeView.sendAccessibilityEvent( + AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } - mActionModeView.sendAccessibilityEvent( - AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - } else { - mActionMode = null; } + } else { + mActionMode = null; } } if (mActionMode != null && getCallback() != null && !isDestroyed()) { |