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

Commit f225fe41 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Dismissing with correct velocity when flinging and not detaching." into main

parents 34558a2c e9a3ef94
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -488,6 +488,25 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            assertThat(detachDirection).isEqualTo(-1)
        }

    @Test
    fun getDetachDirection_afterADismissal_returnsCorrectDirection() =
        kosmos.testScope.runTest {
            // GIVEN that the swiped row is detached to the right
            setDetachedState()
            assertThat(underTest.getDetachDirection(swipedRow)).isEqualTo(1)

            // GIVEN that the notification is dismissed
            underTest.onMagneticInteractionEnd(swipedRow, dismissing = true, velocity = 5000f)

            // WHEN we begin interacting with another row
            swipedRow = children.attachedChildren.first()
            setTargets()
            underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

            // THEN the detach direction is 0
            assertThat(underTest.getDetachDirection(swipedRow)).isEqualTo(0)
        }

    @After
    fun tearDown() {
        // We reset the manager so that all MagneticRowListener can cancel all animations
+4 −1
Original line number Diff line number Diff line
@@ -429,8 +429,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
            boolean isDismissAll) {
        if (magneticNotificationSwipes()) {
            int direction = mCallback.getMagneticDetachDirection(animView);
            if (direction != 0) {
                // If detached, modify the velocity to agree with the detaching direction
                velocity = direction * Math.max(getMinDismissVelocity(), Math.abs(velocity));
            }
        }
        final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
        float newPos;
        boolean isLayoutRtl = animView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
+1 −0
Original line number Diff line number Diff line
@@ -484,6 +484,7 @@ constructor(
        }

        fun reset() {
            direction = 0f
            translationBuffer.clear()
            acceptTranslations = true
        }