Merge "Add CUJ_NOTIFICATION_SHADE_ROW_SWIPE CUJ"

This commit is contained in:
TreeHugger Robot
2021-11-12 07:06:23 +00:00
committed by Android (Google) Code Review
2 changed files with 38 additions and 0 deletions

View File

@@ -371,6 +371,11 @@ public class SwipeHelper implements Gefingerpoken {
return mIsSwiping || mLongPressSent || mMenuRowIntercepting;
}
/**
* After dismissChild() and related animation finished, this function will be called.
*/
protected void onDismissChildWithAnimationFinished() {}
/**
* @param view The view to be dismissed
* @param velocity The desired pixels/second speed at which the view should move
@@ -436,6 +441,7 @@ public class SwipeHelper implements Gefingerpoken {
Animator anim = getViewTranslationAnimator(animView, newPos, updateListener);
if (anim == null) {
onDismissChildWithAnimationFinished();
return;
}
if (useAccelerateInterpolator) {
@@ -481,6 +487,7 @@ public class SwipeHelper implements Gefingerpoken {
if (!mDisableHwLayers) {
animView.setLayerType(View.LAYER_TYPE_NONE, null);
}
onDismissChildWithAnimationFinished();
}
});
@@ -505,6 +512,11 @@ public class SwipeHelper implements Gefingerpoken {
// Do nothing
}
/**
* After snapChild() and related animation finished, this function will be called.
*/
protected void onSnapChildWithAnimationFinished() {}
public void snapChild(final View animView, final float targetLeft, float velocity) {
final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
AnimatorUpdateListener updateListener = animation -> onTranslationUpdate(animView,
@@ -512,6 +524,7 @@ public class SwipeHelper implements Gefingerpoken {
Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
if (anim == null) {
onSnapChildWithAnimationFinished();
return;
}
anim.addListener(new AnimatorListenerAdapter() {
@@ -529,6 +542,7 @@ public class SwipeHelper implements Gefingerpoken {
updateSwipeProgressFromOffset(animView, canBeDismissed);
resetSwipeState();
}
onSnapChildWithAnimationFinished();
}
});
prepareSnapBackAnimation(animView, anim);

View File

@@ -17,6 +17,8 @@
package com.android.systemui.statusbar.notification.stack;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_SWIPE;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.res.Resources;
@@ -28,6 +30,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.systemui.SwipeHelper;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.FalsingManager;
@@ -263,6 +266,22 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
final boolean previousIsSwiping = isSwiping();
boolean ret = super.onInterceptTouchEvent(ev);
final View swipedView = getSwipedView();
if (!previousIsSwiping && swipedView != null) {
InteractionJankMonitor.getInstance().begin(swipedView,
CUJ_NOTIFICATION_SHADE_ROW_SWIPE);
}
return ret;
}
protected void onDismissChildWithAnimationFinished() {
InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_SHADE_ROW_SWIPE);
}
@Override
public void dismissChild(final View view, float velocity,
boolean useAccelerateInterpolator) {
@@ -281,6 +300,11 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc
super.dismissChild(view, velocity, useAccelerateInterpolator);
}
@Override
protected void onSnapChildWithAnimationFinished() {
InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_SHADE_ROW_SWIPE);
}
@VisibleForTesting
protected void superSnapChild(final View animView, final float targetLeft, float velocity) {
super.snapChild(animView, targetLeft, velocity);