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

Commit 2def5ff0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Only do snapback animations on Swipeable views" into udc-dev am:...

Merge "Only do snapback animations on Swipeable views" into udc-dev am: 758dc44b am: e7f6f28a am: 348ec785

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23348517



Change-Id: Ia87bd1422061e613a9b1148cfccc298240184e4d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b8451a0e 348ec785
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -354,7 +354,11 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc

    @Override
    protected void snapChild(final View animView, final float targetLeft, float velocity) {
        if (animView instanceof SwipeableView) {
            // only perform the snapback animation on views that are swipeable inside the shade.
            superSnapChild(animView, targetLeft, velocity);
        }

        mCallback.onDragCancelled(animView);
        if (targetLeft == 0) {
            handleMenuCoveredOrDismissed();
+16 −7
Original line number Diff line number Diff line
@@ -392,23 +392,32 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {

    @Test
    public void testSnapchild_targetIsZero() {
        doNothing().when(mSwipeHelper).superSnapChild(mView, 0, 0);
        mSwipeHelper.snapChild(mView, 0, 0);
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 0, 0);
        mSwipeHelper.snapChild(mNotificationRow, 0, 0);

        verify(mCallback, times(1)).onDragCancelled(mView);
        verify(mSwipeHelper, times(1)).superSnapChild(mView, 0, 0);
        verify(mCallback, times(1)).onDragCancelled(mNotificationRow);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 0, 0);
        verify(mSwipeHelper, times(1)).handleMenuCoveredOrDismissed();
    }


    @Test
    public void testSnapchild_targetNotZero() {
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 10, 0);
        mSwipeHelper.snapChild(mNotificationRow, 10, 0);

        verify(mCallback, times(1)).onDragCancelled(mNotificationRow);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 10, 0);
        verify(mSwipeHelper, times(0)).handleMenuCoveredOrDismissed();
    }

    @Test
    public void testSnapchild_targetNotSwipeable() {
        doNothing().when(mSwipeHelper).superSnapChild(mView, 10, 0);
        mSwipeHelper.snapChild(mView, 10, 0);

        verify(mCallback, times(1)).onDragCancelled(mView);
        verify(mSwipeHelper, times(1)).superSnapChild(mView, 10, 0);
        verify(mSwipeHelper, times(0)).handleMenuCoveredOrDismissed();
        verify(mCallback).onDragCancelled(mView);
        verify(mSwipeHelper, never()).superSnapChild(mView, 10, 0);
    }

    @Test