diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-03-11 20:48:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-11 20:48:55 +0000 |
commit | 41edb22d75dc5d60cda75835e3880d30c18e5a10 (patch) | |
tree | bf5e1e45296cc685e3978ab25ee8e132bec5c3f6 | |
parent | 3e8ad0c666c154bd65625b63677e497b6b86513f (diff) | |
parent | ae242892e2ba416cfbf5fd707069faf2350ace9c (diff) | |
download | base-41edb22d75dc5d60cda75835e3880d30c18e5a10.tar.gz |
Merge "DO NOT MERGE Ignore insets on status_bar_container" into qt-qpr1-dev
3 files changed, 45 insertions, 11 deletions
diff --git a/packages/SystemUI/res/layout/super_status_bar.xml b/packages/SystemUI/res/layout/super_status_bar.xml index 9d56e08bc555..d68bd5d442ed 100644 --- a/packages/SystemUI/res/layout/super_status_bar.xml +++ b/packages/SystemUI/res/layout/super_status_bar.xml @@ -55,7 +55,8 @@ android:id="@+id/status_bar_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/system_bar_background" /> + android:background="@drawable/system_bar_background" + sysui:ignoreRightInset="true" /> <include layout="@layout/status_bar_expanded" android:layout_width="match_parent" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 32402e1f3042..c2317bab891e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -46,6 +46,7 @@ import com.android.systemui.R; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.util.leak.RotationUtils; import java.util.Objects; @@ -71,6 +72,7 @@ public class PhoneStatusBarView extends PanelBar { }; private DarkReceiver mBattery; private int mLastOrientation; + private int mRotationOrientation; @Nullable private View mCenterIconSpace; @Nullable @@ -81,6 +83,7 @@ public class PhoneStatusBarView extends PanelBar { * Draw this many pixels into the left/right side of the cutout to optimally use the space */ private int mCutoutSideNudge = 0; + private int mStatusBarHeight; private boolean mHeadsUpVisible; public PhoneStatusBarView(Context context, AttributeSet attrs) { @@ -155,6 +158,7 @@ public class PhoneStatusBarView extends PanelBar { changed = true; mLastOrientation = newOrientation; } + mRotationOrientation = RotationUtils.getExactRotation(mContext); } if (!Objects.equals(getRootWindowInsets().getDisplayCutout(), mDisplayCutout)) { @@ -289,14 +293,14 @@ public class PhoneStatusBarView extends PanelBar { R.dimen.display_cutout_margin_consumption); ViewGroup.LayoutParams layoutParams = getLayoutParams(); - layoutParams.height = getResources().getDimensionPixelSize( - R.dimen.status_bar_height); + mStatusBarHeight = getResources().getDimensionPixelSize(R.dimen.status_bar_height); + layoutParams.height = mStatusBarHeight; setLayoutParams(layoutParams); } private void updateLayoutForCutout() { Pair<Integer, Integer> cornerCutoutMargins = cornerCutoutMargins(mDisplayCutout, - getDisplay()); + getDisplay(), mRotationOrientation, mStatusBarHeight); updateCutoutLocation(cornerCutoutMargins); updateSafeInsets(cornerCutoutMargins); } @@ -332,15 +336,13 @@ public class PhoneStatusBarView extends PanelBar { // or letterboxing from the right or left sides. FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); - if (mDisplayCutout == null || mDisplayCutout.isEmpty() - || mLastOrientation != ORIENTATION_PORTRAIT || cornerCutoutMargins == null) { + if (mDisplayCutout == null || mDisplayCutout.isEmpty() || cornerCutoutMargins == null) { lp.leftMargin = 0; lp.rightMargin = 0; return; } - - lp.leftMargin = Math.max(lp.leftMargin, cornerCutoutMargins.first); - lp.rightMargin = Math.max(lp.rightMargin, cornerCutoutMargins.second); + lp.leftMargin = cornerCutoutMargins.first; + lp.rightMargin = cornerCutoutMargins.second; // If we're already inset enough (e.g. on the status bar side), we can have 0 margin WindowInsets insets = getRootWindowInsets(); @@ -354,8 +356,19 @@ public class PhoneStatusBarView extends PanelBar { } } + /** + * Returns a Pair of integers where + * - Pair.first is the left margin inset + * - Pair.second is the right margin inset + * This method always assumes the cutout is on the top when the device is in portrait mode. + */ public static Pair<Integer, Integer> cornerCutoutMargins(DisplayCutout cutout, Display display) { + return cornerCutoutMargins(cutout, display, RotationUtils.ROTATION_NONE, -1); + } + + private static Pair<Integer, Integer> cornerCutoutMargins(DisplayCutout cutout, + Display display, int rotationOrientation, int statusBarHeight) { if (cutout == null) { return null; } @@ -363,14 +376,33 @@ public class PhoneStatusBarView extends PanelBar { display.getRealSize(size); Rect bounds = new Rect(); - boundsFromDirection(cutout, Gravity.TOP, bounds); + switch (rotationOrientation) { + case RotationUtils.ROTATION_LANDSCAPE: + boundsFromDirection(cutout, Gravity.LEFT, bounds); + break; + case RotationUtils.ROTATION_SEASCAPE: + boundsFromDirection(cutout, Gravity.RIGHT, bounds); + break; + case RotationUtils.ROTATION_NONE: + boundsFromDirection(cutout, Gravity.TOP, bounds); + break; + case RotationUtils.ROTATION_UPSIDE_DOWN: + // we assume the cutout is always on top in portrait mode + return null; + } + + if (statusBarHeight >= 0 && bounds.top > statusBarHeight) { + return null; + } if (bounds.left <= 0) { return new Pair<>(bounds.right, 0); } + if (bounds.right >= size.x) { return new Pair<>(0, size.x - bounds.left); } + return null; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 0ab2af864383..459e0da0b067 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -180,7 +180,8 @@ public class StatusBarWindowView extends FrameLayout { int targetLeft = Math.max(insets.left, leftCutout); int targetRight = Math.max(insets.right, rightCutout); - // Super-special right inset handling, because scrims and backdrop need to ignore it. + // Super-special right inset handling, because scrims, backdrop and status bar + // container need to ignore it. if (targetRight != mRightInset || targetLeft != mLeftInset) { mRightInset = targetRight; mLeftInset = targetLeft; |