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

Commit b3736028 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Fix possible crash when swiping horizontally

This CL fixes a typo introduced in ag/26026254: we should read delta.x
when computing the drag offset in MultiPointerDraggable.

Bug: 322547404
Test: SwipeToSceneTest
Flag: N/A
Change-Id: I25aab88404dd281353145226f791baa9bb109942
parent 6b135b01
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