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

Commit c1db292b authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Fix shadeExpansion being 0 when QS partially expanded

The shadeExpansion should gradually decrease as QS are being expanded.

I checked the usages of this flow to make sure this change is safe to
make unflagged, and I saw that they fall into 3 categories:
1) They need to know if either the shade or qs are expanded, so this
change would be a no-op for them
2) They assume that shadeExpansion and qsExpansion are complementary
(and this fix makes that actually true)
3) They use the SceneContainer implementation, so this change wouldn't
affect them

Bug: 330143161
Test: ShadeInteractorLegacyImplTest
Flag: NONE
Change-Id: Id3b3a12be5b7ed284e5947bc9eabda020519086a
parent 4213999c
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ class ShadeInteractorImplTest : SysuiTestCase() {
        }

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsExpanded() =
    fun shadeExpansionWhenNotInSplitShadeAndQsPartiallyExpanded() =
        testScope.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

@@ -337,6 +337,22 @@ class ShadeInteractorImplTest : SysuiTestCase() {
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()

            // THEN shade expansion is zero
            assertThat(actual).isEqualTo(.5f)
        }

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsFullyExpanded() =
        testScope.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS is expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            overrideResource(R.bool.config_use_split_notification_shade, false)
            shadeRepository.setQsExpansion(1f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()

            // THEN shade expansion is zero
            assertThat(actual).isEqualTo(0f)
        }
+22 −4
Original line number Diff line number Diff line
@@ -95,14 +95,14 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {
        }

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsExpanded() =
    fun shadeExpansionWhenNotInSplitShadeAndQsFullyExpanded() =
        testScope.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS is expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            overrideResource(R.bool.config_use_split_notification_shade, false)
            shadeRepository.setQsExpansion(.5f)
            shadeRepository.setQsExpansion(1f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()

@@ -110,17 +110,35 @@ class ShadeInteractorLegacyImplTest : SysuiTestCase() {
            assertThat(actual).isEqualTo(0f)
        }

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsPartlyExpanded() =
        testScope.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS partly expanded
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            overrideResource(R.bool.config_use_split_notification_shade, false)
            shadeRepository.setQsExpansion(.4f)
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()

            // THEN shade expansion is the difference
            assertThat(actual).isEqualTo(.6f)
        }

    @Test
    fun shadeExpansionWhenNotInSplitShadeAndQsCollapsed() =
        testScope.runTest {
            val actual by collectLastValue(underTest.shadeExpansion)

            // WHEN split shade is not enabled and QS is expanded
            // WHEN split shade is not enabled and QS collapsed
            keyguardRepository.setStatusBarState(StatusBarState.SHADE)
            overrideResource(R.bool.config_use_split_notification_shade, false)
            shadeRepository.setQsExpansion(0f)
            shadeRepository.setLegacyShadeExpansion(.6f)
            runCurrent()

            // THEN shade expansion is zero
            // THEN shade expansion is the legacy one
            assertThat(actual).isEqualTo(.6f)
        }

+15 −0
Original line number Diff line number Diff line
@@ -482,6 +482,21 @@ class NotificationListViewModelTest : SysuiTestCase() {
            assertThat(shouldHide).isFalse()
        }

    @Test
    fun shouldHideFooterView_falseWhenQSPartiallyOpen() =
        testScope.runTest {
            val shouldHide by collectLastValue(underTest.shouldHideFooterView)

            // WHEN QS partially open
            fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE)
            fakeShadeRepository.setQsExpansion(0.5f)
            fakeShadeRepository.setLegacyShadeExpansion(0.5f)
            runCurrent()

            // THEN footer is hidden
            assertThat(shouldHide).isFalse()
        }

    @Test
    @EnableFlags(NotificationsHeadsUpRefactor.FLAG_NAME)
    fun pinnedHeadsUpRows_filtersForPinnedItems() =
+2 −1
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ constructor(
                when (statusBarState) {
                    // legacyShadeExpansion is 1 instead of 0 when QS is expanded
                    StatusBarState.SHADE ->
                        if (!splitShadeEnabled && qsExpansion > 0f) 0f else legacyShadeExpansion
                        if (!splitShadeEnabled && qsExpansion > 0f) 1f - qsExpansion
                        else legacyShadeExpansion
                    StatusBarState.KEYGUARD -> lockscreenShadeExpansion
                    // dragDownAmount, which drives lockscreenShadeExpansion resets to 0f when
                    // the pointer is lifted and the lockscreen shade is fully expanded