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
This commit is contained in:
felkachang
2018-05-18 20:11:38 +08:00
committed by Felka Chang
parent adc1534453
commit e8a3536660
2 changed files with 15 additions and 5 deletions

View File

@@ -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);
}

View File

@@ -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() {