diff options
| author | 2024-10-21 18:22:50 +0000 | |
|---|---|---|
| committer | 2024-10-22 13:24:31 +0000 | |
| commit | d8336d2133e17572e7e795cb1aad2b7e224cf0a8 (patch) | |
| tree | a7ea424723e643d33e07bdd305c242771c1b4300 | |
| parent | aede021754ca2b9a8b47c1023403e41fd56d878a (diff) | |
[flexiglass] Update NSSL stack heights, when maxNotifications changes
AmbientState#mStackEndHeight depends on NSSL#mMaxDisplayedNotifications,
so we need to recalculate the stack end height, whenever the number of max
displayed notifications changes.
Fixes: 365727076
Test: receive Notifications on the LS, check whether there is enough space
to be displayed
Flag: com.android.systemui.scene_container
Change-Id: Ia67a244b4c229d979718af528a1149f41eb8eee3
2 files changed, 38 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index b51ec782f183..87b16efc64fc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5351,7 +5351,12 @@ public class NotificationStackScrollLayout public void setMaxDisplayedNotifications(int maxDisplayedNotifications) { if (mMaxDisplayedNotifications != maxDisplayedNotifications) { mMaxDisplayedNotifications = maxDisplayedNotifications; - updateContentHeight(); + if (SceneContainerFlag.isEnabled()) { + updateIntrinsicStackHeight(); + updateStackEndHeightAndStackHeight(mAmbientState.getExpansionFraction()); + } else { + updateContentHeight(); + } notifyHeightChangeListener(mShelf); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index eea929da83ce..fdfc25390a3f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -1218,7 +1218,38 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test - @DisableSceneContainer // TODO(b/312473478): address disabled test + @EnableSceneContainer + public void testSetMaxDisplayedNotifications_updatesStackHeight() { + int fullStackHeight = 300; + int limitedStackHeight = 100; + int maxNotifs = 2; // any non-zero limit + float stackTop = 100; + float stackCutoff = 1100; + float stackViewPortHeight = stackCutoff - stackTop; + mStackScroller.setStackTop(stackTop); + mStackScroller.setStackCutoff(stackCutoff); + when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(-1), anyFloat())) + .thenReturn((float) fullStackHeight); + when(mStackSizeCalculator.computeHeight(eq(mStackScroller), eq(maxNotifs), anyFloat())) + .thenReturn((float) limitedStackHeight); + + // When we set a limit on max displayed notifications + mStackScroller.setMaxDisplayedNotifications(maxNotifs); + + // Then + assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(limitedStackHeight); + assertThat(mAmbientState.getStackEndHeight()).isEqualTo(limitedStackHeight); + + // When there is no limit on max displayed notifications + mStackScroller.setMaxDisplayedNotifications(-1); + + // Then + assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(fullStackHeight); + assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackViewPortHeight); + } + + @Test + @DisableSceneContainer public void testSetMaxDisplayedNotifications_notifiesListeners() { ExpandableView.OnHeightChangedListener listener = mock(ExpandableView.OnHeightChangedListener.class); |