From ea9f269282fee5fc0aeb5435c63b4b4f9e931d4e Mon Sep 17 00:00:00 2001 From: Xiaowen Lei Date: Mon, 14 Aug 2023 09:14:30 -0700 Subject: [PATCH] Animate top padding of notifications on status view height change. Note that `requestScrollerTopPaddingUpdate(true);` doesn't work because the topPadding doesn't update until later, through the `ShadeLayoutChangeListener.onLayoutChange`. Fix: 293564374 Test: on Keyguard turn on/off flashlight via shortcut Test: onKeyguardStatusViewHeightChange_animatesNextTopPaddingChangeForNSSL() Change-Id: Id3cee8616df497f0957c25cd1ba56a4dbfbfbc0e --- .../shade/NotificationPanelViewController.java | 7 +++++++ .../NotificationPanelViewControllerTest.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 35fd98cf34c69..89029059b2c62 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1241,6 +1241,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusViewController.init(); } mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); + mKeyguardStatusViewController.getView().addOnLayoutChangeListener( + (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { + int oldHeight = oldBottom - oldTop; + if (v.getHeight() != oldHeight) { + mNotificationStackScrollLayoutController.animateNextTopPaddingChange(); + } + }); updateClockAppearance(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index eb4ae1a743ef8..7aeafeb2a752f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -538,6 +538,23 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo assertKeyguardStatusViewCentered(); } + @Test + public void onKeyguardStatusViewHeightChange_animatesNextTopPaddingChangeForNSSL() { + ArgumentCaptor captor = + ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); + verify(mKeyguardStatusView).addOnLayoutChangeListener(captor.capture()); + View.OnLayoutChangeListener listener = captor.getValue(); + + clearInvocations(mNotificationStackScrollLayoutController); + + when(mKeyguardStatusView.getHeight()).thenReturn(0); + listener.onLayoutChange(mKeyguardStatusView, /* left= */ 0, /* top= */ 0, /* right= */ + 0, /* bottom= */ 0, /* oldLeft= */ 0, /* oldTop= */ 0, /* oldRight= */ + 0, /* oldBottom = */ 200); + + verify(mNotificationStackScrollLayoutController).animateNextTopPaddingChange(); + } + @Test public void testCanCollapsePanelOnTouch_trueForKeyGuard() { mStatusBarStateController.setState(KEYGUARD);