From 17a96ba564afe9b45cfd2fe99d068e1c59d24b0d Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Wed, 23 May 2018 18:21:56 -0400 Subject: [PATCH] Add tuning to SystemUI to draw into a DisplayCutout's bounds Allows for more optimal tuning of status bar's usage of space otherwise claimed by a cutout Test: visual Change-Id: Ic821eae4dcb22fc3d9063a1fcd6927707e347eaa Bug: 79703378 --- packages/SystemUI/res/values/dimens.xml | 5 ++++- .../statusbar/phone/KeyguardStatusBarView.java | 9 +++++++++ .../systemui/statusbar/phone/PhoneStatusBarView.java | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 0c7c60010818a..7445f3d354cc7 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -201,7 +201,7 @@ 6dp - 8dp + 6dp 1dp @@ -1005,4 +1005,7 @@ 12dp 2dp + + 0px + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 58d3b9a2bf330..0bd3cc795bc3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -90,6 +90,11 @@ public class KeyguardStatusBarView extends RelativeLayout private ViewGroup mStatusIconArea; private int mLayoutState = LAYOUT_NONE; + /** + * Draw this many pixels into the left/right side of the cutout to optimally use the space + */ + private int mCutoutSideNudge = 0; + public KeyguardStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -158,6 +163,8 @@ public class KeyguardStatusBarView extends RelativeLayout R.dimen.system_icons_switcher_hidden_expanded_margin); mSystemIconsBaseMargin = res.getDimensionPixelSize( R.dimen.system_icons_super_container_avatarless_margin_end); + mCutoutSideNudge = getResources().getDimensionPixelSize( + R.dimen.display_cutout_margin_consumption); } private void updateVisibilities() { @@ -266,6 +273,8 @@ public class KeyguardStatusBarView extends RelativeLayout mCutoutSpace.setVisibility(View.VISIBLE); RelativeLayout.LayoutParams lp = (LayoutParams) mCutoutSpace.getLayoutParams(); + bounds.left = bounds.left + mCutoutSideNudge; + bounds.right = bounds.right - mCutoutSideNudge; lp.width = bounds.width(); lp.height = bounds.height(); lp.addRule(RelativeLayout.CENTER_IN_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 01582d090999d..5477f882e5f90 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -74,6 +74,10 @@ public class PhoneStatusBarView extends PanelBar { private View mCutoutSpace; @Nullable private DisplayCutout mDisplayCutout; + /** + * Draw this many pixels into the left/right side of the cutout to optimally use the space + */ + private int mCutoutSideNudge = 0; public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); @@ -98,6 +102,8 @@ public class PhoneStatusBarView extends PanelBar { mBarTransitions.init(); mBattery = findViewById(R.id.battery); mCutoutSpace = findViewById(R.id.cutout_space_view); + + updateResources(); } @Override @@ -280,6 +286,9 @@ public class PhoneStatusBarView extends PanelBar { } public void updateResources() { + mCutoutSideNudge = getResources().getDimensionPixelSize( + R.dimen.display_cutout_margin_consumption); + ViewGroup.LayoutParams layoutParams = getLayoutParams(); layoutParams.height = getResources().getDimensionPixelSize( R.dimen.status_bar_height); @@ -311,6 +320,8 @@ public class PhoneStatusBarView extends PanelBar { Rect bounds = new Rect(); boundsFromDirection(mDisplayCutout, Gravity.TOP, bounds); + bounds.left = bounds.left + mCutoutSideNudge; + bounds.right = bounds.right - mCutoutSideNudge; lp.width = bounds.width(); lp.height = bounds.height(); }