Remove heads up panel translation.

The only time I got a non-zero translation was RTL orientation changes, and it was a transient artifact that caused visual glitches.  The translation was done in the name of alignment, which is no longer a desire of this class.

Fixes: 185679234
Test: manual; especially with RTL and rotation changes.
Change-Id: I8ca03eb4baee05bfec76d708a901048828d53261
This commit is contained in:
Jeff DeCew
2021-08-05 16:57:45 -04:00
parent 8d6022e778
commit 8da2e133e4
3 changed files with 1 additions and 79 deletions

View File

@@ -137,7 +137,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mIconPlaceholder.getLocationOnScreen(mTmpPosition);
int left = (int) (mTmpPosition[0] - getTranslationX());
int left = mTmpPosition[0];
int top = mTmpPosition[1];
int right = left + mIconPlaceholder.getWidth();
int bottom = top + mIconPlaceholder.getHeight();
@@ -145,20 +145,9 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
updateDrawingRect();
}
/** In order to do UI alignment, this view will be notified by
* {@link com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout}.
* After scroller laid out, the scroller will tell this view about scroller's getX()
* @param translationX how to translate the horizontal position
*/
public void setPanelTranslation(float translationX) {
setTranslationX(translationX);
updateDrawingRect();
}
private void updateDrawingRect() {
float oldLeft = mIconDrawingRect.left;
mIconDrawingRect.set(mLayoutedIconRect);
mIconDrawingRect.offset((int) getTranslationX(), 0);
if (oldLeft != mIconDrawingRect.left && mOnDrawingRectChangedListener != null) {
mOnDrawingRectChangedListener.run();
}

View File

@@ -18,9 +18,7 @@ package com.android.systemui.statusbar.phone;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.ViewClippingUtil;
@@ -61,7 +59,6 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
private final NotificationPanelViewController mNotificationPanelViewController;
private final Consumer<ExpandableNotificationRow>
mSetTrackingHeadsUp = this::setTrackingHeadsUp;
private final Runnable mUpdatePanelTranslation = this::updatePanelTranslation;
private final BiConsumer<Float, Float> mSetExpandedHeight = this::setAppearFraction;
private final KeyguardBypassController mBypassController;
private final StatusBarStateController mStatusBarStateController;
@@ -75,9 +72,6 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
float mAppearFraction;
private ExpandableNotificationRow mTrackedChild;
private boolean mShown;
private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
-> updatePanelTranslation();
private final ViewClippingUtil.ClippingParameters mParentClippingParams =
new ViewClippingUtil.ClippingParameters() {
@Override
@@ -134,10 +128,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
mStackScrollerController = stackScrollerController;
mNotificationPanelViewController = notificationPanelViewController;
notificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp);
notificationPanelViewController.setVerticalTranslationListener(mUpdatePanelTranslation);
notificationPanelViewController.setHeadsUpAppearanceController(this);
mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight);
mStackScrollerController.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
mStackScrollerController.setHeadsUpAppearanceController(this);
mClockView = clockView;
mOperatorNameView = operatorNameView;
@@ -174,7 +166,6 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
mNotificationPanelViewController.setVerticalTranslationListener(null);
mNotificationPanelViewController.setHeadsUpAppearanceController(null);
mStackScrollerController.removeOnExpandedHeightChangedListener(mSetExpandedHeight);
mStackScrollerController.removeOnLayoutChangeListener(mStackScrollLayoutChangeListener);
mDarkIconDispatcher.removeDarkReceiver(this);
}
@@ -189,63 +180,6 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
updateHeader(entry);
}
/** To count the distance from the window right boundary to scroller right boundary. The
* distance formula is the following:
* Y = screenSize - (SystemWindow's width + Scroller.getRight())
* There are four modes MUST to be considered in Cut Out of RTL.
* No Cut Out:
* Scroller + NB
* NB + Scroller
* => SystemWindow = NavigationBar's width
* => Y = screenSize - (SystemWindow's width + Scroller.getRight())
* Corner Cut Out or Tall Cut Out:
* cut out + Scroller + NB
* NB + Scroller + cut out
* => SystemWindow = NavigationBar's width
* => Y = screenSize - (SystemWindow's width + Scroller.getRight())
* Double Cut Out:
* cut out left + Scroller + (NB + cut out right)
* SystemWindow = NavigationBar's width + cut out right width
* => Y = screenSize - (SystemWindow's width + Scroller.getRight())
* (cut out left + NB) + Scroller + cut out right
* SystemWindow = NavigationBar's width + cut out left width
* => Y = screenSize - (SystemWindow's width + Scroller.getRight())
* @return the translation X value for RTL. In theory, it should be negative. i.e. -Y
*/
private int getRtlTranslation() {
if (mPoint == null) {
mPoint = new Point();
}
int realDisplaySize = 0;
if (mStackScrollerController.getDisplay() != null) {
mStackScrollerController.getDisplay().getRealSize(mPoint);
realDisplaySize = mPoint.x;
}
WindowInsets windowInset = mStackScrollerController.getRootWindowInsets();
DisplayCutout cutout = (windowInset != null) ? windowInset.getDisplayCutout() : null;
int sysWinLeft = (windowInset != null) ? windowInset.getStableInsetLeft() : 0;
int sysWinRight = (windowInset != null) ? windowInset.getStableInsetRight() : 0;
int cutoutLeft = (cutout != null) ? cutout.getSafeInsetLeft() : 0;
int cutoutRight = (cutout != null) ? cutout.getSafeInsetRight() : 0;
int leftInset = Math.max(sysWinLeft, cutoutLeft);
int rightInset = Math.max(sysWinRight, cutoutRight);
return leftInset + mStackScrollerController.getRight() + rightInset - realDisplaySize;
}
public void updatePanelTranslation() {
float newTranslation;
if (mStackScrollerController.isLayoutRtl()) {
newTranslation = getRtlTranslation();
} else {
newTranslation = mStackScrollerController.getLeft();
}
newTranslation += mStackScrollerController.getTranslationX();
mHeadsUpStatusBarView.setPanelTranslation(newTranslation);
}
private void updateTopEntry() {
NotificationEntry newEntry = null;
if (shouldBeVisible()) {

View File

@@ -202,6 +202,5 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
verify(mPanelView).removeTrackingHeadsUpListener(any());
verify(mPanelView).setHeadsUpAppearanceController(isNull());
verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
verify(mStackScrollerController).removeOnLayoutChangeListener(any());
}
}