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

Commit d3ea6676 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Comparing thresholds to the gesture directly.

As a mistake, we were comparing the value of transformed translations to
the thresholds, but they should be compared to the finger translation
directly instead.

Test: manual. Verified magnetic detach and attach works as expected.
Test: MagneticNotificationRowManagerImplTest
Flag: com.android.systemui.magnetic_notification_swipes
Bug: 403576232
Change-Id: I1810603c7dc2e21efd36a9ff1e35dd8c9063a090
parent 40592956
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

            // WHEN setting a translation that will fall below the threshold
            val translation = threshold / underTest.swipedRowMultiplier - 50f
            val translation = 50f
            underTest.setMagneticRowTranslation(swipedRow, translation)

            // THEN the targets continue to be pulled and translations are set
@@ -162,7 +162,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

            // WHEN setting a translation that will fall below the threshold
            val translation = threshold / underTest.swipedRowMultiplier - 50f
            val translation = 50f
            underTest.setMagneticRowTranslation(swipedRow, translation)

            // THEN the targets continue to be pulled and reduced translations are set
@@ -185,7 +185,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

            // WHEN setting a translation that will fall above the threshold
            val translation = threshold / underTest.swipedRowMultiplier + 50f
            val translation = 150f
            underTest.setMagneticRowTranslation(swipedRow, translation)

            // THEN the swiped view detaches and the correct detach haptics play
@@ -208,7 +208,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

            // WHEN setting a translation that will fall above the threshold
            val translation = threshold / underTest.swipedRowMultiplier + 50f
            val translation = 150f
            underTest.setMagneticRowTranslation(swipedRow, translation)

            // THEN the swiped view does not detach and the reduced translation is set
@@ -342,7 +342,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
        underTest.setMagneticRowTranslation(swipedRow, translation = 100f)

        // Set a translation that will fall above the threshold
        val translation = threshold / underTest.swipedRowMultiplier + 50f
        val translation = 150f
        underTest.setMagneticRowTranslation(swipedRow, translation)

        assertThat(underTest.currentState).isEqualTo(State.DETACHED)
+2 −4
Original line number Diff line number Diff line
@@ -169,8 +169,7 @@ constructor(
    }

    private fun pullDismissibleRow(translation: Float) {
        val targetTranslation = swipedRowMultiplier * translation
        val crossedThreshold = abs(targetTranslation) >= magneticDetachThreshold
        val crossedThreshold = abs(translation) >= magneticDetachThreshold
        if (crossedThreshold) {
            snapNeighborsBack()
            currentMagneticListeners.swipedListener()?.let { detach(it, translation) }
@@ -247,8 +246,7 @@ constructor(
    }

    private fun translateDetachedRow(translation: Float) {
        val targetTranslation = swipedRowMultiplier * translation
        val crossedThreshold = abs(targetTranslation) <= magneticAttachThreshold
        val crossedThreshold = abs(translation) <= magneticAttachThreshold
        if (crossedThreshold) {
            translationOffset += translation
            updateRoundness(translation = 0f, animate = true)