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

Commit 9816defe authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Android (Google) Code Review
Browse files

Merge "Fix possible crash when swiping horizontally" into main

parents c2b644f0 b3736028
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -263,10 +263,10 @@ private suspend fun PointerInputScope.detectDragGestures(
                    val deltaOffset = drag.position - initialDown.position
                    val delta =
                        when (orientation) {
                            Orientation.Horizontal -> deltaOffset.y
                            Orientation.Horizontal -> deltaOffset.x
                            Orientation.Vertical -> deltaOffset.y
                        }
                    check(delta != 0f)
                    check(delta != 0f) { "delta is equal to 0" }
                    overSlop = delta.sign
                }

+17 −0
Original line number Diff line number Diff line
@@ -442,6 +442,23 @@ class SwipeToSceneTest {
        transition = layoutState.currentTransition
        assertThat(transition).isNotNull()
        assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB)

        // Release the finger, animating back to scene A.
        rule.onRoot().performTouchInput { up() }
        rule.waitForIdle()
        assertThat(layoutState.currentTransition).isNull()
        assertThat(layoutState.transitionState.currentScene).isEqualTo(TestScenes.SceneA)

        // Swipe left by exactly touchSlop, so that the drag overSlop is 0f.
        rule.onRoot().performTouchInput {
            down(middle)
            moveBy(Offset(-touchSlop, 0f), delayMillis = 1_000)
        }

        // We should still correctly compute that we are swiping down to scene B.
        transition = layoutState.currentTransition
        assertThat(transition).isNotNull()
        assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB)
    }

    @Test