diff options
author | Alan Viverette <alanv@google.com> | 2014-09-25 20:11:27 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-25 20:11:28 +0000 |
commit | 314dc4c553d7ab712151003c0d569982301a44e3 (patch) | |
tree | 203804f0cd7cc36f6e542839d80e34f7ecee92ad /policy/src | |
parent | 57ce30ddfe279d1fe5d62da75ec73a843f1132a8 (diff) | |
parent | 98a514221af081885f7283c347a8ef5db012ffcf (diff) | |
download | frameworks_base-314dc4c553d7ab712151003c0d569982301a44e3.zip frameworks_base-314dc4c553d7ab712151003c0d569982301a44e3.tar.gz frameworks_base-314dc4c553d7ab712151003c0d569982301a44e3.tar.bz2 |
Merge "Fix "Always apply window insets to action modes"" into lmp-dev
Diffstat (limited to 'policy/src')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 00026dc..42ee666 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -274,6 +274,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private long mBackgroundFadeDurationMillis = -1; private Boolean mSharedElementsUseOverlay; + private Rect mTempRect; + static class WindowManagerHolder { static final IWindowManager sWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService("window")); @@ -2892,37 +2894,53 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // Show the status guard when the non-overlay contextual action bar is showing if (mActionModeView != null) { if (mActionModeView.getLayoutParams() instanceof MarginLayoutParams) { - MarginLayoutParams mlp = (MarginLayoutParams) mActionModeView.getLayoutParams(); + // Insets are magic! + final MarginLayoutParams mlp = (MarginLayoutParams) + mActionModeView.getLayoutParams(); boolean mlpChanged = false; if (mActionModeView.isShown()) { - final boolean nonOverlay = (getLocalFeatures() - & (1 << FEATURE_ACTION_MODE_OVERLAY)) == 0; - if (mlp.topMargin != insets.getSystemWindowInsetTop()) { + if (mTempRect == null) { + mTempRect = new Rect(); + } + final Rect rect = mTempRect; + + // If the parent doesn't consume the insets, manually + // apply the default system window insets. + mContentParent.computeSystemWindowInsets(insets, rect); + final int newMargin = rect.top == 0 ? insets.getSystemWindowInsetTop() : 0; + if (mlp.topMargin != newMargin) { mlpChanged = true; mlp.topMargin = insets.getSystemWindowInsetTop(); - // Only show status guard for non-overlay modes. - if (nonOverlay) { - if (mStatusGuard == null) { - mStatusGuard = new View(mContext); - mStatusGuard.setBackgroundColor(mContext.getResources() - .getColor(R.color.input_method_navigation_guard)); - addView(mStatusGuard, indexOfChild(mStatusColorView), - new LayoutParams(LayoutParams.MATCH_PARENT, - mlp.topMargin, - Gravity.START | Gravity.TOP)); - } else { - LayoutParams lp = (LayoutParams) mStatusGuard.getLayoutParams(); - if (lp.height != mlp.topMargin) { - lp.height = mlp.topMargin; - mStatusGuard.setLayoutParams(lp); - } + if (mStatusGuard == null) { + mStatusGuard = new View(mContext); + mStatusGuard.setBackgroundColor(mContext.getResources() + .getColor(R.color.input_method_navigation_guard)); + addView(mStatusGuard, indexOfChild(mStatusColorView), + new LayoutParams(LayoutParams.MATCH_PARENT, + mlp.topMargin, Gravity.START | Gravity.TOP)); + } else { + final LayoutParams lp = (LayoutParams) + mStatusGuard.getLayoutParams(); + if (lp.height != mlp.topMargin) { + lp.height = mlp.topMargin; + mStatusGuard.setLayoutParams(lp); } } } + + // We only need to consume the insets if the action + // mode is overlaid on the app content (e.g. it's + // sitting in a FrameLayout, see + // screen_simple_overlay_action_mode.xml). + final boolean nonOverlay = (getLocalFeatures() + & (1 << FEATURE_ACTION_MODE_OVERLAY)) == 0; insets = insets.consumeSystemWindowInsets( false, nonOverlay /* top */, false, false); - showStatusGuard = nonOverlay; + + // The action mode's theme may differ from the app, so + // always show the status guard above it. + showStatusGuard = true; } else { // reset top margin if (mlp.topMargin != 0) { |