From 5134fd50fa74f822a61ce7eb07131e8202a9a590 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 27 May 2020 15:20:46 -0700 Subject: [PATCH] Fixed the positioning of the media panel after reinflation Previously, the view would have a wrong translation set since the heights weren't initialized yet. We're now updating the height as soon as we are getting the first layout Fixes: 156951111 Test: add media notification, click on darkmode tile, observe no shift Change-Id: If29891ac3eaab22b97c4def726124282fd03e517 --- .../src/com/android/systemui/qs/QSFragment.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index 8f9e9e2eacd51..6af9e1ef45711 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -94,6 +94,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca private int mState; private QSContainerImplController mQSContainerImplController; private int[] mTmpLocation = new int[2]; + private int mLastViewHeight; + private float mLastHeaderTranslation; @Inject public QSFragment(RemoteInputQuickSettingsDisabler remoteInputQsDisabler, @@ -148,6 +150,13 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca setHost(mHost); mStatusBarStateController.addCallback(this); onStateChanged(mStatusBarStateController.getState()); + view.addOnLayoutChangeListener( + (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { + boolean sizeChanged = (oldTop - oldBottom) != (top - bottom); + if (sizeChanged) { + setQsExpansion(mLastQSExpansion, mLastQSExpansion); + } + }); } @Override @@ -374,11 +383,15 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca ? translationScaleY * mHeader.getHeight() : headerTranslation); } - if (expansion == mLastQSExpansion && mLastKeyguardAndExpanded == onKeyguardAndExpanded) { + int currentHeight = getView().getHeight(); + mLastHeaderTranslation = headerTranslation; + if (expansion == mLastQSExpansion && mLastKeyguardAndExpanded == onKeyguardAndExpanded + && mLastViewHeight == currentHeight) { return; } mLastQSExpansion = expansion; mLastKeyguardAndExpanded = onKeyguardAndExpanded; + mLastViewHeight = currentHeight; boolean fullyExpanded = expansion == 1; int heightDiff = mQSPanel.getBottom() - mHeader.getBottom() + mHeader.getPaddingBottom();