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

Commit fc0badee authored by William Xiao's avatar William Xiao
Browse files

Hide lockscreen UI when transitioning to dream with shade open

When the dream starts, it requests to close all system dialogs. This
includes the notification shade. If the dream is started from
lockscreen while the shade is open, the shade quickly collapses then
the lockscreen UI is visible for a very short period of time before the
dream starts, which looks janky.

Instead, if the shade is open when this transition starts, we just keep
the lockscreen UI hidden the whole time.

Bug: 409720192
Test: atest LockscreenToDreamingTransitionViewModelTest
      (see bug for video)
Flag: NONE minor transition fix
Change-Id: I3d0529f647613e1e66acecb7075d114380fa3f4c
parent 1404bfc7
Loading
Loading
Loading
Loading
+73 −2
Original line number Diff line number Diff line
@@ -104,6 +104,77 @@ class LockscreenToDreamingTransitionViewModelTest(flags: FlagsParameterization)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

    @Test
    fun lockscreenFadeOut_shadeExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.lockscreenAlpha)
            shadeExpanded(true)
            runCurrent()

            repository.sendTransitionSteps(
                steps =
                    listOf(
                        step(0f, TransitionState.STARTED),
                        step(0f),
                        step(.3f),
                        step(.5f),
                        step(1f),
                        step(1f, TransitionState.FINISHED),
                    ),
                testScope = testScope,
            )

            // Lockscreen is not shown during the whole transition.
            values.forEach { assertThat(it).isEqualTo(0f) }
        }

    @Test
    fun shortcutsFadeOut() =
        testScope.runTest {
            val values by collectValues(underTest.shortcutsAlpha)
            repository.sendTransitionSteps(
                steps =
                    listOf(
                        step(0f, TransitionState.STARTED), // Should start running here...
                        step(0f),
                        step(.1f),
                        step(.2f),
                        step(.3f), // ...up to here
                        step(1f),
                    ),
                testScope = testScope,
            )

            // Only five values should be present, since the dream overlay runs for a small
            // fraction of the overall animation time
            assertThat(values.size).isEqualTo(5)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

    @Test
    fun shortcutsFadeOut_shadeExpanded() =
        testScope.runTest {
            val values by collectValues(underTest.shortcutsAlpha)
            shadeExpanded(true)
            runCurrent()

            repository.sendTransitionSteps(
                steps =
                    listOf(
                        step(0f, TransitionState.STARTED),
                        step(0f),
                        step(.3f),
                        step(.5f),
                        step(1f),
                        step(1f, TransitionState.FINISHED),
                    ),
                testScope = testScope,
            )

            // Shortcuts are not shown during the whole transition.
            values.forEach { assertThat(it).isEqualTo(0f) }
        }

    @Test
    fun lockscreenTranslationY() =
        testScope.runTest {
@@ -177,14 +248,14 @@ class LockscreenToDreamingTransitionViewModelTest(flags: FlagsParameterization)

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return TransitionStep(
            from = KeyguardState.LOCKSCREEN,
            to = KeyguardState.DREAMING,
            value = value,
            transitionState = state,
            ownerName = "LockscreenToDreamingTransitionViewModelTest"
            ownerName = "LockscreenToDreamingTransitionViewModelTest",
        )
    }

+6 −3
Original line number Diff line number Diff line
@@ -56,12 +56,15 @@ constructor(animationFlow: KeyguardTransitionAnimationFlow) : DeviceEntryIconTra

    /** Lockscreen views alpha */
    val lockscreenAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(duration = 250.milliseconds, onStep = { 1f - it })
        transitionAnimation.sharedFlowWithShade(
            duration = 250.milliseconds,
            onStep = { step, isShadeExpanded -> if (isShadeExpanded) 0f else 1f - step },
        )

    val shortcutsAlpha: Flow<Float> =
        transitionAnimation.sharedFlow(
        transitionAnimation.sharedFlowWithShade(
            duration = 250.milliseconds,
            onStep = { 1 - it },
            onStep = { step, isShadeExpanded -> if (isShadeExpanded) 0f else 1f - step },
            onFinish = { 0f },
            onCancel = { 1f },
        )