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

Commit 7591b837 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge changes Ia67a244b,I7bd162f0 into main

* changes:
  [flexiglass] Update NSSL stack heights, when maxNotifications changes
  [flexiglass] Update ScrollViewFields#intrinsicStackHeight on the LS
parents 2d61edf0 d8336d21
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -1574,7 +1574,7 @@ public class NotificationStackScrollLayout
        if (mMaxDisplayedNotifications != -1) {
            // The stack intrinsic height already contains the correct value when there is a limit
            // in the max number of notifications (e.g. as in keyguard).
            height = mIntrinsicContentHeight;
            height = mScrollViewFields.getIntrinsicStackHeight();
        } else {
            height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop());
        }
@@ -2610,7 +2610,7 @@ public class NotificationStackScrollLayout
    }

    @VisibleForTesting
    void updateStackHeight() {
    void updateIntrinsicStackHeight() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;

        final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0;
@@ -2621,8 +2621,11 @@ public class NotificationStackScrollLayout
                mMaxDisplayedNotifications,
                shelfIntrinsicHeight
        );
        mIntrinsicContentHeight = notificationsHeight;
        final int fullStackHeight = notificationsHeight + footerIntrinsicHeight + mBottomPadding;
        // When there is a limit in the max number of notifications, we never display the footer.
        final int fullStackHeight = mMaxDisplayedNotifications != -1
                ? notificationsHeight
                : notificationsHeight + footerIntrinsicHeight + mBottomPadding;

        if (mScrollViewFields.getIntrinsicStackHeight() != fullStackHeight) {
            mScrollViewFields.setIntrinsicStackHeight(fullStackHeight);
            notifyStackHeightChangedListeners();
@@ -2631,7 +2634,7 @@ public class NotificationStackScrollLayout

    private void updateContentHeight() {
        if (SceneContainerFlag.isEnabled()) {
            updateStackHeight();
            updateIntrinsicStackHeight();
            return;
        }

@@ -5348,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);
        }
    }
+33 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        when(mStackSizeCalculator.computeHeight(eq(mStackScroller), anyInt(), anyFloat()))
                .thenReturn((float) stackHeight);

        mStackScroller.updateStackHeight();
        mStackScroller.updateIntrinsicStackHeight();

        assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeight);
    }
@@ -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);