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

Commit 989607f6 authored by András Kurucz's avatar András Kurucz
Browse files

[Flexiglass] Don't recalculate expandFraction in the NSSL

Don't override the expandFraction received from
NotificationScrollViewModel.
Fork NSSL.setExpandedHeight, and remove all the parts that are
non-functional in Flexiglass.

Bug: 332574413
Fixes: 332577544
Test: check notifications during shade/expand collapse in
different states:
 - single/split shade
 - launcher/lockscreen
 - no notifications/scrollable notifications
 - hun displayed/not displayed

Flag: com.android.systemui.scene_container

Change-Id: Idb04c4b93df3081336d5a00b7a67f88123dafbf8
parent 70cd8eaf
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -1236,7 +1236,6 @@ public class NotificationStackScrollLayout
        if (mAmbientState.getStackTop() != stackTop) {
            mAmbientState.setStackTop(stackTop);
            onTopPaddingChanged(/* animate = */ isAddOrRemoveAnimationPending());
            setExpandedHeight(mExpandedHeight);
        }
    }

@@ -1573,8 +1572,11 @@ public class NotificationStackScrollLayout

        // Update the expand progress between started/stopped events
        mAmbientState.setExpansionFraction(expandFraction);
        // TODO(b/332577544): don't convert to height which then converts to the fraction again
        setExpandedHeight(expandFraction * getHeight());

        if (!shouldSkipHeightUpdate()) {
            updateStackEndHeightAndStackHeight(expandFraction);
            updateExpandedHeight(expandFraction);
        }

        // expansion stopped event requires that the expandFraction has already been updated
        if (!nowExpanding && wasExpanding) {
@@ -1583,6 +1585,19 @@ public class NotificationStackScrollLayout
        }
    }

    private void updateExpandedHeight(float expandFraction) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        float expandedHeight = expandFraction * getHeight();
        setIsExpanded(expandedHeight > 0);

        if (mExpandedHeight != expandedHeight) {
            mExpandedHeight = expandedHeight;
            updateAlgorithmHeightAndPadding();
            requestChildrenUpdate();
            notifyAppearChangedListeners();
        }
    }

    @Override
    public void setQsExpandFraction(float expandFraction) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
@@ -1595,6 +1610,7 @@ public class NotificationStackScrollLayout
     * @param height the expanded height of the panel
     */
    public void setExpandedHeight(float height) {
        SceneContainerFlag.assertInLegacyMode();
        final boolean skipHeightUpdate = shouldSkipHeightUpdate();

        updateStackPosition();
@@ -1726,6 +1742,7 @@ public class NotificationStackScrollLayout
     * Measured relative to the resting position.
     */
    private float getExpandTranslationStart() {
        SceneContainerFlag.assertInLegacyMode();
        return -getTopPadding() + getMinExpansionHeight() - mShelf.getIntrinsicHeight();
    }

@@ -1734,6 +1751,7 @@ public class NotificationStackScrollLayout
     * Measured in absolute height.
     */
    private float getAppearStartPosition() {
        SceneContainerFlag.assertInLegacyMode();
        if (isHeadsUpTransition()) {
            final NotificationSection firstVisibleSection = getFirstVisibleSection();
            final int pinnedHeight = firstVisibleSection != null
@@ -1789,6 +1807,7 @@ public class NotificationStackScrollLayout
     *    have the shelf on its own)
     */
    private float getAppearEndPosition() {
        SceneContainerFlag.assertInLegacyMode();
        if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) {
            return getAppearEndPositionLegacy();
        }
@@ -1849,7 +1868,7 @@ public class NotificationStackScrollLayout
     */
    @FloatRange(from = -1.0, to = 1.0)
    public float calculateAppearFraction(float height) {
        if (isHeadsUpTransition()) {
        if (isHeadsUpTransition() && !SceneContainerFlag.isEnabled()) {
            // HUN is a special case because fraction can go negative if swiping up. And for now
            // it must go negative as other pieces responsible for proper translation up assume
            // negative value for HUN going up.
+1 −0
Original line number Diff line number Diff line
@@ -1409,6 +1409,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
    }

    public float calculateAppearFraction(float height) {
        SceneContainerFlag.assertInLegacyMode();
        return mView.calculateAppearFraction(height);
    }

+16 −3
Original line number Diff line number Diff line
@@ -429,7 +429,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    @EnableSceneContainer
    public void setExpandFraction_fullyCollapsed() {
        // Given: stack bounds are set
        // Given: NSSL has a height
        when(mStackScroller.getHeight()).thenReturn(1200);
        // And: stack bounds are set
        float expandFraction = 0.0f;
        float stackTop = 100;
        float stackCutoff = 1100;
@@ -446,12 +448,16 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeight);
        assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(
                stackHeight * StackScrollAlgorithm.START_FRACTION);
        assertThat(mAmbientState.isShadeExpanded()).isFalse();
        assertThat(mStackScroller.getExpandedHeight()).isZero();
    }

    @Test
    @EnableSceneContainer
    public void setExpandFraction_expanding() {
        // Given: stack bounds are set
        // Given: NSSL has a height
        when(mStackScroller.getHeight()).thenReturn(1200);
        // And: stack bounds are set
        float expandFraction = 0.6f;
        float stackTop = 100;
        float stackCutoff = 1100;
@@ -469,12 +475,17 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        assertThat(mAmbientState.getInterpolatedStackHeight()).isGreaterThan(
                stackHeight * StackScrollAlgorithm.START_FRACTION);
        assertThat(mAmbientState.getInterpolatedStackHeight()).isLessThan(stackHeight);
        assertThat(mStackScroller.getExpandedHeight()).isGreaterThan(0f);
        assertThat(mAmbientState.isShadeExpanded()).isTrue();
    }

    @Test
    @EnableSceneContainer
    public void setExpandFraction_fullyExpanded() {
        // Given: stack bounds are set
        // Given: NSSL has a height
        int viewHeight = 1200;
        when(mStackScroller.getHeight()).thenReturn(viewHeight);
        // And: stack bounds are set
        float expandFraction = 1.0f;
        float stackTop = 100;
        float stackCutoff = 1100;
@@ -490,6 +501,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        assertThat(mAmbientState.isExpansionChanging()).isFalse();
        assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeight);
        assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(stackHeight);
        assertThat(mStackScroller.getExpandedHeight()).isEqualTo(viewHeight);
        assertThat(mAmbientState.isShadeExpanded()).isTrue();
    }

    @Test