Merge "Reset translation and fading of top-level notifs on collapse/hide/show" into udc-dev am: 4815a874a5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23642106 Change-Id: I04d8fae32a7e3a88bb1bdcf99b8041bb6a28e6d9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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;
|
||||
@@ -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
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -4011,7 +4011,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
||||
mCentralSurfaces.resetUserExpandedStates();
|
||||
clearTemporaryViews();
|
||||
clearUserLockedViews();
|
||||
cancelActiveSwipe();
|
||||
resetAllSwipeState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4077,7 +4077,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
||||
mGroupExpansionManager.collapseGroups();
|
||||
mExpandHelper.cancelImmediately();
|
||||
if (!mIsExpansionChanging) {
|
||||
cancelActiveSwipe();
|
||||
resetAllSwipeState();
|
||||
}
|
||||
finalizeClearAllAnimation();
|
||||
}
|
||||
@@ -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 */);
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user