Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +12 −3 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.app.PendingIntent; import android.content.res.Resources; import android.graphics.RectF; import android.os.Handler; import android.os.Trace; import android.util.ArrayMap; import android.util.Log; import android.view.MotionEvent; Loading Loading @@ -277,9 +278,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { // invalidate the view's own bounds all the way up the view hierarchy public static void invalidateGlobalRegion(View view) { Trace.beginSection("SwipeHelper.invalidateGlobalRegion"); invalidateGlobalRegion( view, new RectF(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())); Trace.endSection(); } // invalidate a rectangle relative to the view's coordinate system all the way up the view Loading Loading @@ -492,7 +495,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { } if (!mCancelled || wasRemoved) { mCallback.onChildDismissed(animView); resetSwipeOfView(animView); resetViewIfSwiping(animView); } if (endAction != null) { endAction.accept(mCancelled); Loading Loading @@ -547,7 +550,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { if (!cancelled) { updateSwipeProgressFromOffset(animView, canBeDismissed); resetSwipeOfView(animView); resetViewIfSwiping(animView); // Clear the snapped view after success, assuming it's not being swiped now if (animView == mTouchedView && !mIsSwiping) { mTouchedView = null; Loading Loading @@ -811,7 +814,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { return mIsSwiping ? mTouchedView : null; } protected void resetSwipeOfView(View view) { protected void resetViewIfSwiping(View view) { if (getSwipedView() == view) { resetSwipeState(); } Loading @@ -825,6 +828,12 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { resetSwipeStates(/* resetAll= */ true); } public void forceResetSwipeState(@NonNull View view) { if (view.getTranslationX() == 0) return; setTranslation(view, 0); updateSwipeProgressFromOffset(view, /* dismissable= */ true, 0); } /** This method resets the swipe state, and if `resetAll` is true, also resets the snap state */ private void resetSwipeStates(boolean resetAll) { final View touchedView = mTouchedView; Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +9 −4 Original line number Diff line number Diff line Loading @@ -4011,7 +4011,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mCentralSurfaces.resetUserExpandedStates(); clearTemporaryViews(); clearUserLockedViews(); cancelActiveSwipe(); resetAllSwipeState(); } } Loading Loading @@ -4077,7 +4077,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mGroupExpansionManager.collapseGroups(); mExpandHelper.cancelImmediately(); if (!mIsExpansionChanging) { cancelActiveSwipe(); resetAllSwipeState(); } finalizeClearAllAnimation(); } Loading Loading @@ -4406,7 +4406,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable boolean nowHiddenAtAll = mAmbientState.isHiddenAtAll(); if (nowFullyHidden != wasFullyHidden) { updateVisibility(); mSwipeHelper.resetTouchState(); resetAllSwipeState(); } if (!wasHiddenAtAll && nowHiddenAtAll) { resetExposedMenuView(true /* animate */, true /* animate */); Loading Loading @@ -5866,9 +5866,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } } private void cancelActiveSwipe() { private void resetAllSwipeState() { Trace.beginSection("NSSL.resetAllSwipeState()"); mSwipeHelper.resetTouchState(); for (int i = 0; i < getChildCount(); i++) { mSwipeHelper.forceResetSwipeState(getChildAt(i)); } updateContinuousShadowDrawing(); Trace.endSection(); } void updateContinuousShadowDrawing() { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; Loading @@ -29,6 +30,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.animation.Animator; Loading Loading @@ -669,6 +671,28 @@ public class NotificationSwipeHelperTest extends SysuiTestCase { verify(mNotificationRow, never()).setContentAlpha(anyFloat()); } @Test public void testForceResetSwipeStateDoesNothingIfTranslationIsZero() { doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth(); doReturn(0f).when(mNotificationRow).getTranslationX(); mSwipeHelper.forceResetSwipeState(mNotificationRow); verify(mNotificationRow).getTranslationX(); verifyNoMoreInteractions(mNotificationRow); } @Test public void testForceResetSwipeStateResetsTranslationAndAlpha() { doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth(); doReturn(10f).when(mNotificationRow).getTranslationX(); mSwipeHelper.forceResetSwipeState(mNotificationRow); verify(mNotificationRow).setTranslation(eq(0f)); verify(mNotificationRow).setContentAlpha(eq(1f)); } @Test public void testContentAlphaRemainsUnchangedWhenFeatureFlagIsDisabled() { Loading Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +12 −3 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.app.PendingIntent; import android.content.res.Resources; import android.graphics.RectF; import android.os.Handler; import android.os.Trace; import android.util.ArrayMap; import android.util.Log; import android.view.MotionEvent; Loading Loading @@ -277,9 +278,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { // invalidate the view's own bounds all the way up the view hierarchy public static void invalidateGlobalRegion(View view) { Trace.beginSection("SwipeHelper.invalidateGlobalRegion"); invalidateGlobalRegion( view, new RectF(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())); Trace.endSection(); } // invalidate a rectangle relative to the view's coordinate system all the way up the view Loading Loading @@ -492,7 +495,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { } if (!mCancelled || wasRemoved) { mCallback.onChildDismissed(animView); resetSwipeOfView(animView); resetViewIfSwiping(animView); } if (endAction != null) { endAction.accept(mCancelled); Loading Loading @@ -547,7 +550,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { if (!cancelled) { updateSwipeProgressFromOffset(animView, canBeDismissed); resetSwipeOfView(animView); resetViewIfSwiping(animView); // Clear the snapped view after success, assuming it's not being swiped now if (animView == mTouchedView && !mIsSwiping) { mTouchedView = null; Loading Loading @@ -811,7 +814,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { return mIsSwiping ? mTouchedView : null; } protected void resetSwipeOfView(View view) { protected void resetViewIfSwiping(View view) { if (getSwipedView() == view) { resetSwipeState(); } Loading @@ -825,6 +828,12 @@ public class SwipeHelper implements Gefingerpoken, Dumpable { resetSwipeStates(/* resetAll= */ true); } public void forceResetSwipeState(@NonNull View view) { if (view.getTranslationX() == 0) return; setTranslation(view, 0); updateSwipeProgressFromOffset(view, /* dismissable= */ true, 0); } /** This method resets the swipe state, and if `resetAll` is true, also resets the snap state */ private void resetSwipeStates(boolean resetAll) { final View touchedView = mTouchedView; Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +9 −4 Original line number Diff line number Diff line Loading @@ -4011,7 +4011,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mCentralSurfaces.resetUserExpandedStates(); clearTemporaryViews(); clearUserLockedViews(); cancelActiveSwipe(); resetAllSwipeState(); } } Loading Loading @@ -4077,7 +4077,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mGroupExpansionManager.collapseGroups(); mExpandHelper.cancelImmediately(); if (!mIsExpansionChanging) { cancelActiveSwipe(); resetAllSwipeState(); } finalizeClearAllAnimation(); } Loading Loading @@ -4406,7 +4406,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable boolean nowHiddenAtAll = mAmbientState.isHiddenAtAll(); if (nowFullyHidden != wasFullyHidden) { updateVisibility(); mSwipeHelper.resetTouchState(); resetAllSwipeState(); } if (!wasHiddenAtAll && nowHiddenAtAll) { resetExposedMenuView(true /* animate */, true /* animate */); Loading Loading @@ -5866,9 +5866,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } } private void cancelActiveSwipe() { private void resetAllSwipeState() { Trace.beginSection("NSSL.resetAllSwipeState()"); mSwipeHelper.resetTouchState(); for (int i = 0; i < getChildCount(); i++) { mSwipeHelper.forceResetSwipeState(getChildAt(i)); } updateContinuousShadowDrawing(); Trace.endSection(); } void updateContinuousShadowDrawing() { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; Loading @@ -29,6 +30,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.animation.Animator; Loading Loading @@ -669,6 +671,28 @@ public class NotificationSwipeHelperTest extends SysuiTestCase { verify(mNotificationRow, never()).setContentAlpha(anyFloat()); } @Test public void testForceResetSwipeStateDoesNothingIfTranslationIsZero() { doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth(); doReturn(0f).when(mNotificationRow).getTranslationX(); mSwipeHelper.forceResetSwipeState(mNotificationRow); verify(mNotificationRow).getTranslationX(); verifyNoMoreInteractions(mNotificationRow); } @Test public void testForceResetSwipeStateResetsTranslationAndAlpha() { doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth(); doReturn(10f).when(mNotificationRow).getTranslationX(); mSwipeHelper.forceResetSwipeState(mNotificationRow); verify(mNotificationRow).setTranslation(eq(0f)); verify(mNotificationRow).setContentAlpha(eq(1f)); } @Test public void testContentAlphaRemainsUnchangedWhenFeatureFlagIsDisabled() { Loading