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

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

Change-Id: I4ddd9d26a0264fc17110cc3916a531d7d4028bfc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-05-23 00:18:36 +00:00
committed by Automerger Merge Worker
2 changed files with 21 additions and 8 deletions

View File

@@ -354,7 +354,11 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
@Override
protected void snapChild(final View animView, final float targetLeft, float velocity) {
superSnapChild(animView, targetLeft, 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();

View File

@@ -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