Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8336d21 authored by András Kurucz's avatar András Kurucz
Browse files

[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
parent aede0217
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -5351,7 +5351,12 @@ public class NotificationStackScrollLayout
    public void setMaxDisplayedNotifications(int maxDisplayedNotifications) {
        if (mMaxDisplayedNotifications != maxDisplayedNotifications) {
            mMaxDisplayedNotifications = maxDisplayedNotifications;
            if (SceneContainerFlag.isEnabled()) {
                updateIntrinsicStackHeight();
                updateStackEndHeightAndStackHeight(mAmbientState.getExpansionFraction());
            } else {
                updateContentHeight();
            }
            notifyHeightChangeListener(mShelf);
        }
    }
+32 −1
Original line number Diff line number Diff line
@@ -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);