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

Commit 03e76731 authored by András Kurucz's avatar András Kurucz
Browse files

Calculate the correct HUN position, while dragging down the shade

Fixes: 324758331
Test: atest StackScrollAlgorithmTest
Test: post a HUN, pull down the shade by scrolling on the empty space
above the HUN
Flag: ACONFIG notifications_improved_hun_animation DEVELOPMENT

Change-Id: Ie893c0569c6d6a0854b102e59ed9cb6d5a55f8e1
parent 89e122c8
Loading
Loading
Loading
Loading
+5 −10
Original line number Original line Diff line number Diff line
@@ -826,16 +826,11 @@ public class StackScrollAlgorithm {
                }
                }
            }
            }
            if (row.isPinned()) {
            if (row.isPinned()) {
                if (NotificationsImprovedHunAnimation.isEnabled()) {
                // Make sure row yTranslation is at at least the HUN yTranslation,
                    // Make sure row yTranslation is at the HUN yTranslation,
                    // which accounts for AmbientState.stackTopMargin in split-shade.
                    childState.setYTranslation(headsUpTranslation);
                } else {
                    // Make sure row yTranslation is at maximum the HUN yTranslation,
                // which accounts for AmbientState.stackTopMargin in split-shade.
                // which accounts for AmbientState.stackTopMargin in split-shade.
                // Once we start opening the shade, we keep the previously calculated translation.
                childState.setYTranslation(
                childState.setYTranslation(
                        Math.max(childState.getYTranslation(), headsUpTranslation));
                        Math.max(childState.getYTranslation(), headsUpTranslation));
                }
                childState.height = Math.max(row.getIntrinsicHeight(), childState.height);
                childState.height = Math.max(row.getIntrinsicHeight(), childState.height);
                childState.hidden = false;
                childState.hidden = false;
                ExpandableViewState topState =
                ExpandableViewState topState =
+13 −0
Original line number Original line Diff line number Diff line
@@ -85,6 +85,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() {


    private val bigGap = px(R.dimen.notification_section_divider_height)
    private val bigGap = px(R.dimen.notification_section_divider_height)
    private val smallGap = px(R.dimen.notification_section_divider_height_lockscreen)
    private val smallGap = px(R.dimen.notification_section_divider_height_lockscreen)
    private val scrimPadding = px(R.dimen.notification_side_paddings)


    @Before
    @Before
    fun setUp() {
    fun setUp() {
@@ -118,6 +119,18 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
        resetViewStates_stackMargin_changesHunYTranslation()
        resetViewStates_stackMargin_changesHunYTranslation()
    }
    }


    @Test
    fun resetViewStates_defaultHunWhenShadeIsOpening_yTranslationIsInset() {
        whenever(notificationRow.isPinned).thenReturn(true)
        whenever(notificationRow.isHeadsUp).thenReturn(true)

        // scroll the panel over the HUN inset
        ambientState.stackY = stackScrollAlgorithm.mHeadsUpInset + bigGap

        // the HUN translation should be the panel scroll position + the scrim padding
        resetViewStates_hunYTranslationIs(ambientState.stackY + scrimPadding)
    }

    @Test
    @Test
    @DisableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    @DisableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAway_yTranslationIsInset() {
    fun resetViewStates_hunAnimatingAway_yTranslationIsInset() {