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

Commit 0d42f62f authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Snap the transition progress to target progress when skipping

This CL ensures that we correctly snap the swipe transition progress to
its target progress when skipping the animation entirely. This is
important when dealing with interruptions and multiple transitions are
running at the same time.

Bug: 290930950
Test: atest DraggableHandlerTest
Flag: com.android.systemui.scene_container
Change-Id: I4fed4e3d850ce0db482696fa2bb621235dbef0bf
parent cfdc4d24
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -705,6 +705,8 @@ private class SwipeTransition(
                        // coroutine if we don't need to animate.
                        if (skipAnimation) {
                            snapToScene(targetScene)
                            cancelOffsetAnimation()
                            dragOffset = targetOffset
                            return@launch
                        }

+6 −2
Original line number Diff line number Diff line
@@ -160,13 +160,14 @@ class DraggableHandlerTest {
            toScene: SceneKey? = null,
            progress: Float? = null,
            isUserInputOngoing: Boolean? = null
        ) {
        ): Transition {
            val transition = assertThat(transitionState).isTransition()
            currentScene?.let { assertThat(transition).hasCurrentScene(it) }
            fromScene?.let { assertThat(transition).hasFromScene(it) }
            toScene?.let { assertThat(transition).hasToScene(it) }
            progress?.let { assertThat(transition).hasProgress(it) }
            isUserInputOngoing?.let { assertThat(transition).hasIsUserInputOngoing(it) }
            return transition
        }

        fun onDragStarted(
@@ -1017,7 +1018,7 @@ class DraggableHandlerTest {
        // Swipe up to scene B at progress = 200%.
        val middle = Offset(SCREEN_SIZE / 2f, SCREEN_SIZE / 2f)
        val dragController = onDragStarted(startedPosition = middle, overSlop = up(2f))
        assertTransition(fromScene = SceneA, toScene = SceneB, progress = 2f)
        val transition = assertTransition(fromScene = SceneA, toScene = SceneB, progress = 2f)

        // Release the finger.
        dragController.onDragStopped(velocity = -velocityThreshold)
@@ -1026,6 +1027,9 @@ class DraggableHandlerTest {
        // 100% and that the overscroll on scene B is doing nothing, we are already idle.
        runCurrent()
        assertIdle(SceneB)

        // Progress is snapped to 100%.
        assertThat(transition).hasProgress(1f)
    }

    @Test