summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adrian Roos <roosa@google.com> 2019-06-11 10:45:09 -0700
committer android-build-merger <android-build-merger@google.com> 2019-06-11 10:45:09 -0700
commit55fe653956dec87ad0c231e9a55ef363b0e1881c (patch)
tree21e078d36009ff7960bbca7508d57a4f37c004c2
parentf0b39049f396f309dd9e1f98bdd059b593ebeb4e (diff)
parentf5432f186290ef04124496f27f09b1faa7197dcc (diff)
Merge "DecorView: Fix status guard" into qt-dev
am: f5432f1862 Change-Id: I0f455bb3e860e089dfe31b6d5e8109a74580989d
-rw-r--r--core/java/com/android/internal/policy/DecorView.java81
-rw-r--r--core/res/res/values/colors.xml1
-rw-r--r--core/res/res/values/symbols.xml5
3 files changed, 63 insertions, 24 deletions
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 585a27978c4f..2941a813fecb 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -1004,6 +1004,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
public void onWindowSystemUiVisibilityChanged(int visible) {
updateColorViews(null /* insets */, true /* animate */);
updateDecorCaptionStatus(getResources().getConfiguration());
+
+ if (mStatusGuard != null && mStatusGuard.getVisibility() == VISIBLE) {
+ updateStatusGuardColor();
+ }
}
@Override
@@ -1462,28 +1466,45 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
final Rect rect = mTempRect;
- // If the parent doesn't consume the insets, manually
- // apply the default system window insets.
- mWindow.mContentParent.computeSystemWindowInsets(insets, rect);
- final int newMargin = rect.top == 0 ? insets.getSystemWindowInsetTop() : 0;
- if (mlp.topMargin != newMargin) {
+ // Apply the insets that have not been applied by the contentParent yet.
+ WindowInsets innerInsets =
+ mWindow.mContentParent.computeSystemWindowInsets(insets, rect);
+ int newTopMargin = innerInsets.getSystemWindowInsetTop();
+ int newLeftMargin = innerInsets.getSystemWindowInsetLeft();
+ int newRightMargin = innerInsets.getSystemWindowInsetRight();
+
+ // Must use root window insets for the guard, because the color views consume
+ // the navigation bar inset if the window does not request LAYOUT_HIDE_NAV - but
+ // the status guard is attached at the root.
+ WindowInsets rootInsets = getRootWindowInsets();
+ int newGuardLeftMargin = rootInsets.getSystemWindowInsetLeft();
+ int newGuardRightMargin = rootInsets.getSystemWindowInsetRight();
+
+ if (mlp.topMargin != newTopMargin || mlp.leftMargin != newLeftMargin
+ || mlp.rightMargin != newRightMargin) {
mlpChanged = true;
- mlp.topMargin = insets.getSystemWindowInsetTop();
-
- if (mStatusGuard == null) {
- mStatusGuard = new View(mContext);
- mStatusGuard.setBackgroundColor(mContext.getColor(
- R.color.decor_view_status_guard));
- addView(mStatusGuard, indexOfChild(mStatusColorViewState.view),
- 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);
- }
+ mlp.topMargin = newTopMargin;
+ mlp.leftMargin = newLeftMargin;
+ mlp.rightMargin = newRightMargin;
+ }
+
+ if (newTopMargin > 0 && mStatusGuard == null) {
+ mStatusGuard = new View(mContext);
+ mStatusGuard.setVisibility(GONE);
+ final LayoutParams lp = new LayoutParams(MATCH_PARENT,
+ mlp.topMargin, Gravity.LEFT | Gravity.TOP);
+ lp.leftMargin = newGuardLeftMargin;
+ lp.rightMargin = newGuardRightMargin;
+ addView(mStatusGuard, indexOfChild(mStatusColorViewState.view), lp);
+ } else if (mStatusGuard != null) {
+ final LayoutParams lp = (LayoutParams)
+ mStatusGuard.getLayoutParams();
+ if (lp.height != mlp.topMargin || lp.leftMargin != newGuardLeftMargin
+ || lp.rightMargin != newGuardRightMargin) {
+ lp.height = mlp.topMargin;
+ lp.leftMargin = newGuardLeftMargin;
+ lp.rightMargin = newGuardRightMargin;
+ mStatusGuard.setLayoutParams(lp);
}
}
@@ -1491,6 +1512,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
// always show the status guard above it if we have one.
showStatusGuard = mStatusGuard != null;
+ if (showStatusGuard && mStatusGuard.getVisibility() != VISIBLE) {
+ // If it wasn't previously shown, the color may be stale
+ updateStatusGuardColor();
+ }
+
// 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
@@ -1502,7 +1528,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
} else {
// reset top margin
- if (mlp.topMargin != 0) {
+ if (mlp.topMargin != 0 || mlp.leftMargin != 0 || mlp.rightMargin != 0) {
mlpChanged = true;
mlp.topMargin = 0;
}
@@ -1513,11 +1539,19 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
}
if (mStatusGuard != null) {
- mStatusGuard.setVisibility(showStatusGuard ? View.VISIBLE : View.GONE);
+ mStatusGuard.setVisibility(showStatusGuard ? VISIBLE : GONE);
}
return insets;
}
+ private void updateStatusGuardColor() {
+ boolean lightStatusBar =
+ (getWindowSystemUiVisibility() & SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
+ mStatusGuard.setBackgroundColor(lightStatusBar
+ ? mContext.getColor(R.color.decor_view_status_guard_light)
+ : mContext.getColor(R.color.decor_view_status_guard));
+ }
+
/**
* Overrides the view outline when the activity enters picture-in-picture to ensure that it has
* an opaque shadow even if the window background is completely transparent. This only applies
@@ -2594,6 +2628,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
lastActionModeView.killMode();
mFadeAnim = null;
+ requestApplyInsets();
}
}
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 3b282650d59e..1dcd389d9d8f 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -79,6 +79,7 @@
<drawable name="input_method_fullscreen_background">#fff9f9f9</drawable>
<color name="decor_view_status_guard">#ff000000</color>
+ <color name="decor_view_status_guard_light">#ffffffff</color>
<!-- For date picker widget -->
<drawable name="selected_day_background">#ff0092f4</drawable>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 893892eac61d..3af9a3af9fb5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1962,6 +1962,7 @@
<java-symbol type="bool" name="show_ongoing_ime_switcher" />
<java-symbol type="color" name="config_defaultNotificationColor" />
<java-symbol type="color" name="decor_view_status_guard" />
+ <java-symbol type="color" name="decor_view_status_guard_light" />
<java-symbol type="drawable" name="ic_notification_ime_default" />
<java-symbol type="drawable" name="ic_menu_refresh" />
<java-symbol type="drawable" name="ic_settings" />
@@ -3800,7 +3801,9 @@
<java-symbol type="string" name="chooser_all_apps_button_label" />
<java-symbol type="anim" name="resolver_launch_anim" />
<java-symbol type="style" name="Animation.DeviceDefault.Activity.Resolver" />
-
+
+ <java-symbol type="color" name="decor_view_status_guard_light" />
+
<java-symbol type="string" name="config_defaultSupervisionProfileOwnerComponent" />
<java-symbol type="bool" name="config_inflateSignalStrength" />
</resources>