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

Commit 14ab8dc3 authored by ESWAR MAGATAPALLI (xWF)'s avatar ESWAR MAGATAPALLI (xWF)
Browse files

Revert "Consolidating magnetic detachment with dismissibility."

Revert submission 32206328-MAGNETIC_REATTACH

Reason for revert: Droidmonitor created revert due to b/402283055. Will be verifying through ABTD before submission.

Reverted changes: /q/submissionid:32206328-MAGNETIC_REATTACH

Change-Id: I4356464527bd6b139b7d52b151f460f0a07d602a
parent c6b3f7c8
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.platform.test.annotations.DisableFlags;
import android.provider.Settings;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
@@ -39,7 +38,6 @@ import android.view.ViewGroup;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.Flags;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -415,7 +413,6 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
        assertTrue("when alpha is .5, menu is visible", row.isMenuVisible());
    }

    @DisableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
    @Test
    public void testOnTouchMove() {
        NotificationMenuRow row = Mockito.spy(
+5 −24
Original line number Diff line number Diff line
@@ -130,9 +130,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
        kosmos.testScope.runTest {
            // GIVEN a threshold of 100 px
            val threshold = 100f
            underTest.onDensityChange(
                threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
            )
            underTest.setSwipeThresholdPx(threshold)

            // GIVEN that targets are set and the rows are being pulled
            setTargets()
@@ -152,9 +150,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
        kosmos.testScope.runTest {
            // GIVEN a threshold of 100 px
            val threshold = 100f
            underTest.onDensityChange(
                threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
            )
            underTest.setSwipeThresholdPx(threshold)

            // GIVEN that targets are set and the rows are being pulled
            canRowBeDismissed = false
@@ -176,9 +172,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
        kosmos.testScope.runTest {
            // GIVEN a threshold of 100 px
            val threshold = 100f
            underTest.onDensityChange(
                threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
            )
            underTest.setSwipeThresholdPx(threshold)

            // GIVEN that targets are set and the rows are being pulled
            setTargets()
@@ -198,9 +192,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
        kosmos.testScope.runTest {
            // GIVEN a threshold of 100 px
            val threshold = 100f
            underTest.onDensityChange(
                threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
            )
            underTest.setSwipeThresholdPx(threshold)

            // GIVEN that targets are set and the rows are being pulled
            canRowBeDismissed = false
@@ -302,15 +294,6 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            assertThat(underTest.isSwipedViewRoundableSet).isFalse()
        }

    @Test
    fun isMagneticRowDismissible_isDismissibleWhenDetached() =
        kosmos.testScope.runTest {
            setDetachedState()

            val isDismissible = underTest.isMagneticRowSwipeDetached(swipedRow)
            assertThat(isDismissible).isTrue()
        }

    @After
    fun tearDown() {
        // We reset the manager so that all MagneticRowListener can cancel all animations
@@ -319,9 +302,7 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {

    private fun setDetachedState() {
        val threshold = 100f
        underTest.onDensityChange(
            threshold / MagneticNotificationRowManager.MAGNETIC_DETACH_THRESHOLD_DP
        )
        underTest.setSwipeThresholdPx(threshold)

        // Set the pulling state
        setTargets()
+0 −16
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import android.view.ViewConfiguration;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.flags.FakeFeatureFlags;
@@ -363,7 +362,6 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        verify(mSwipeHelper, times(1)).isFalseGesture();
    }

    @DisableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
    @Test
    public void testIsDismissGesture_farEnough() {
        doReturn(false).when(mSwipeHelper).isFalseGesture();
@@ -376,20 +374,6 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        verify(mSwipeHelper, times(1)).isFalseGesture();
    }

    @EnableFlags(Flags.FLAG_MAGNETIC_NOTIFICATION_SWIPES)
    @Test
    public void testIsDismissGesture_magneticSwipeIsDismissible() {
        doReturn(false).when(mSwipeHelper).isFalseGesture();
        doReturn(false).when(mSwipeHelper).swipedFarEnough();
        doReturn(false).when(mSwipeHelper).swipedFastEnough();
        doReturn(true).when(mCallback).isMagneticViewDetached(any());
        when(mCallback.canChildBeDismissedInDirection(any(), anyBoolean())).thenReturn(true);
        when(mEvent.getActionMasked()).thenReturn(MotionEvent.ACTION_UP);

        assertTrue("Should be a dismissal", mSwipeHelper.isDismissGesture(mEvent));
        verify(mSwipeHelper, times(1)).isFalseGesture();
    }

    @Test
    public void testIsDismissGesture_notFarOrFastEnough() {
        doReturn(false).when(mSwipeHelper).isFalseGesture();
+3 −18
Original line number Diff line number Diff line
@@ -778,26 +778,18 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {

    protected boolean swipedFarEnough() {
        float translation = getTranslation(mTouchedView);
        return Math.abs(translation) > SWIPED_FAR_ENOUGH_SIZE_FRACTION * getSize(mTouchedView);
        return Math.abs(translation) > SWIPED_FAR_ENOUGH_SIZE_FRACTION * getSize(
                mTouchedView);
    }

    public boolean isDismissGesture(MotionEvent ev) {
        float translation = getTranslation(mTouchedView);
        return ev.getActionMasked() == MotionEvent.ACTION_UP
                && !mFalsingManager.isUnlockingDisabled()
                && !isFalseGesture() && isSwipeDismissible()
                && !isFalseGesture() && (swipedFastEnough() || swipedFarEnough())
                && mCallback.canChildBeDismissedInDirection(mTouchedView, translation > 0);
    }

    /** Can the swipe gesture on the touched view be considered as a dismiss intention */
    public boolean isSwipeDismissible() {
        if (magneticNotificationSwipes()) {
            return mCallback.isMagneticViewDetached(mTouchedView) || swipedFastEnough();
        } else {
            return swipedFastEnough() || swipedFarEnough();
        }
    }

    /** Returns true if the gesture should be rejected. */
    public boolean isFalseGesture() {
        boolean falsingDetected = mCallback.isAntiFalsingNeeded();
@@ -977,13 +969,6 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
         */
        void onMagneticInteractionEnd(View view, float velocity);

        /**
         * Determine if a view managed by magnetic interactions is magnetically detached
         * @param view The magnetic view
         * @return if the view is detached according to its magnetic state.
         */
        boolean isMagneticViewDetached(View view);

        /**
         * Called when the child is long pressed and available to start drag and drop.
         *
+2 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.View;
@@ -357,10 +358,8 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
            final float dismissThreshold = getDismissThreshold();
            final boolean snappingToDismiss = delta < -dismissThreshold || delta > dismissThreshold;
            if (mSnappingToDismiss != snappingToDismiss) {
                if (!Flags.magneticNotificationSwipes()) {
                getMenuView().performHapticFeedback(CLOCK_TICK);
            }
            }
            mSnappingToDismiss = snappingToDismiss;
        }
    }
Loading