From e8a3536660bd783acec41a1785f425a1d357c69c Mon Sep 17 00:00:00 2001 From: felkachang Date: Fri, 18 May 2018 20:11:38 +0800 Subject: [PATCH] Clock notification text was cut off The root cause is that HeadsUpStatusBarView doesn't considerate the Cut Out situation. The Cut Out situation can use getRootWindowInsets().getDisplayCutout().getSafeInsetLeft() to get the the value. There are two parts need to handle Cut out. The one part is to handle the padding. It needs to considerate both of mLeftInset and mLeftCutOutInset because it use getLocationOnScreen to count the location. The other part is to handle the HeadsUpStatusBarView.translationX. It only needs to considerate mLeftCutOutInset because landscape degree 90 has the left side cut out and translationX by the distance between screen left boundary and scroller's left boundary. The distance include Cut Out so it need minus mCutOutInsetLeft in the setPanelTranslation. Cut Out has 4 mode: Disable, Corner, Double, and Tall. Disable and Double are handled by the same way. Corner and Tall are handled by the same way. Bug: 78113562 Test: atest SystemUITests Change-Id: Ic2a272c43f65eed8c4b3749787637f5fb848bb8a Fix: 78113562 --- .../systemui/statusbar/HeadsUpStatusBarView.java | 18 ++++++++++++++---- .../statusbar/phone/HeadsUpAppearanceController.java | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java index 5e03fbfc1222..32e51b3a137c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java @@ -44,6 +44,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { private boolean mPublicMode; private int mMaxWidth; private View mRootView; + private int mLeftCutOutInset; private int mLeftInset; private Rect mIconDrawingRect = new Rect(); private Runnable mOnDrawingRectChangedListener; @@ -136,7 +137,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { int bottom = top + mIconPlaceholder.getHeight(); mLayoutedIconRect.set(left, top, right, bottom); updateDrawingRect(); - int targetPadding = mAbsoluteStartPadding + mLeftInset; + int targetPadding = mAbsoluteStartPadding + mLeftInset + mLeftCutOutInset; if (left != targetPadding) { int newPadding = targetPadding - left + getPaddingStart(); setPaddingRelative(newPadding, 0, mEndMargin, 0); @@ -150,9 +151,8 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { } } - @Override - public void setTranslationX(float translationX) { - super.setTranslationX(translationX); + public void setPanelTranslation(float translationX) { + setTranslationX(translationX - mLeftCutOutInset); updateDrawingRect(); } @@ -168,6 +168,16 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { @Override protected boolean fitSystemWindows(Rect insets) { mLeftInset = insets.left; + mLeftCutOutInset = (getRootWindowInsets().getDisplayCutout() != null) + ? getRootWindowInsets().getDisplayCutout().getSafeInsetLeft() : 0; + + // For Double Cut Out mode, the System window navigation bar is at the right + // hand side of the left cut out. In this condition, mLeftInset include the left cut + // out width so we set mLeftCutOutInset to be 0. + if (mLeftInset != 0) { + mLeftCutOutInset = 0; + } + return super.fitSystemWindows(insets); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 06f3c508585a..6d78d1d4e9d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -123,7 +123,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, public void updatePanelTranslation() { float newTranslation = mStackScroller.getLeft() + mStackScroller.getTranslationX(); - mHeadsUpStatusBarView.setTranslationX(newTranslation); + mHeadsUpStatusBarView.setPanelTranslation(newTranslation); } private void updateTopEntry() { -- 2.11.0