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

Commit 5856a9db authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Resetting notification roundness when the snapback animation overshoots.

This occurs in the update listener of the SwipeHelper, when the value
changes its direction of change. The NSSL controller reacts to the event
by resetting the roundness.

Test: manual. Verified UI change when notifications snap back.
Flag: com.android.systemui.magnetic_notification_swipes
Bug: 390179908
Change-Id: I8e39ecd54e4e40ae1e5d5120261463f2e4dfefde
parent 25d0404d
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {

    private final ArrayMap<View, Animator> mDismissPendingMap = new ArrayMap<>();

    private float mSnapBackDirection = 0;

    public SwipeHelper(
            Callback callback, Resources resources, ViewConfiguration viewConfiguration,
            FalsingManager falsingManager, FeatureFlags featureFlags) {
@@ -523,17 +525,24 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
     */
    protected void snapChild(final View animView, final float targetLeft, float velocity) {
        final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
        mSnapBackDirection = getTranslation(animView) - targetLeft;

        cancelTranslateAnimation(animView);

        PhysicsAnimator<? extends View> anim =
                createSnapBackAnimation(animView, targetLeft, velocity);
        anim.addUpdateListener((target, values) -> {
            onTranslationUpdate(target, getTranslation(target), canBeDismissed);
            float translation = getTranslation(target);
            onTranslationUpdate(target, translation, canBeDismissed);
            if ((mSnapBackDirection > 0 && translation < targetLeft)
                    || (mSnapBackDirection < 0 && translation > targetLeft)) {
                mCallback.onChildSnapBackOvershoots();
                mSnapBackDirection = 0;
            }
        });
        anim.addEndListener((t, p, wasFling, cancelled, finalValue, finalVelocity, allEnded) -> {
            mSnappingChild = false;

            mSnapBackDirection = 0;
            if (!cancelled) {
                updateSwipeProgressFromOffset(animView, canBeDismissed);
                resetViewIfSwiping(animView);
@@ -946,6 +955,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
         */
        void onLongPressSent(View v);

        /**
         * The snap back animation on a view overshoots for the first time.
         */
        void onChildSnapBackOvershoots();

        /**
         * Called when the child is snapped to a position.
         *
+8 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.view.OneShotPreDrawListener;
import com.android.systemui.Dumpable;
import com.android.systemui.ExpandHelper;
import com.android.systemui.Flags;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.classifier.Classifier;
import com.android.systemui.classifier.FalsingCollector;
@@ -620,6 +621,13 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    mView.onSwipeBegin(v);
                }

                @Override
                public void onChildSnapBackOvershoots() {
                    if (Flags.magneticNotificationSwipes()) {
                        mNotificationRoundnessManager.setViewsAffectedBySwipe(null, null, null);
                    }
                }

                @Override
                public void onChildSnappedBack(View animView, float targetLeft) {
                    mView.onSwipeEnd();