summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-09-24 17:55:52 -0700
committerAlan Viverette <alanv@google.com>2014-09-24 17:55:52 -0700
commit98a514221af081885f7283c347a8ef5db012ffcf (patch)
treef31171de10e6037e9c8a909fc6ce1fefab724a03 /policy
parenta93e58f888c8012312cf83f051236ecea46a6b95 (diff)
downloadframeworks_base-98a514221af081885f7283c347a8ef5db012ffcf.zip
frameworks_base-98a514221af081885f7283c347a8ef5db012ffcf.tar.gz
frameworks_base-98a514221af081885f7283c347a8ef5db012ffcf.tar.bz2
Fix "Always apply window insets to action modes"
BUG: 17628875 Change-Id: I03bf6cfd68d0ca2904b43e00f68d07d497ff9879
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java60
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) {