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

Commit bc2424d7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Force finishing spring animation on second touch, if the animation is...

Merge "Force finishing spring animation on second touch, if the animation is close to completion" into ub-launcher3-master
parents af106d3c 26729a12
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
    }

    private boolean canInterceptTouch() {
        if (mCurrentAnimation != null) {
            mCurrentAnimation.forceFinishIfCloseToEnd();
        }
        if (mCurrentAnimation != null) {
            // If we are already animating from a previous state, we can intercept.
            return true;
@@ -126,6 +129,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>

                for (int i = 0; i < mRecentsView.getTaskViewCount(); i++) {
                    TaskView view = mRecentsView.getTaskViewAt(i);

                    if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer()
                            .isEventOverView(view, ev)) {
                        // Disable swiping up and down if the task overlay is modal.
+9 −9
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
@@ -88,7 +87,6 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PendingAnimation.EndState;
@@ -96,7 +94,6 @@ import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.anim.SpringProperty;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.touch.PagedOrientationHandler.CurveProperties;
@@ -1165,7 +1162,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    }

    private void addDismissedTaskAnimations(View taskView, long duration, PendingAnimation anim) {
        anim.add(ObjectAnimator.ofFloat(taskView, ALPHA, 0).setDuration(duration), ACCEL_2);
        anim.setViewAlpha(taskView, 0, ACCEL_2);
        FloatProperty<View> secondaryViewTranslate =
            mOrientationHandler.getSecondaryViewTranslate();
        int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
@@ -1257,9 +1254,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        }

        if (needsCurveUpdates) {
            ValueAnimator va = ValueAnimator.ofFloat(0, 1);
            va.addUpdateListener((a) -> updateCurveProperties());
            anim.add(va);
            anim.addOnFrameCallback(this::updateCurveProperties);
        }

        // Add a tiny bit of translation Z, so that it draws on top of other views
@@ -1279,6 +1274,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                }
            }

            @SuppressWarnings("WrongCall")
            private void onEnd(EndState endState) {
                if (endState.isSuccess) {
                    if (shouldRemoveTask) {
@@ -1290,15 +1286,18 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
                            pageToSnapTo == (getTaskViewCount() - 1)) {
                        pageToSnapTo -= 1;
                    }
                    removeView(taskView);
                    removeViewInLayout(taskView);

                    if (getTaskViewCount() == 0) {
                        removeView(mClearAllButton);
                        removeViewInLayout(mClearAllButton);
                        hideActionsView();
                        startHome();
                    } else {
                        snapToPageImmediately(pageToSnapTo);
                    }
                    // Update the layout synchronously so that the position of next view is
                    // immediately available.
                    onLayout(false /*  changed */, getLeft(), getTop(), getRight(), getBottom());
                }
                resetTaskVisuals();
                mPendingAnimation = null;
@@ -1548,6 +1547,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

        updateEmptyStateUi(changed);

        // Set the pivot points to match the task preview center
+13 −0
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
                }
            };

    // Progress factor after which an animation is considered almost completed.
    private static final float ANIMATION_COMPLETE_THRESHOLD = 0.95f;

    private final ValueAnimator mAnimationPlayer;
    private final long mDuration;

@@ -209,6 +212,16 @@ public class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateL
        mAnimationPlayer.start();
    }

    /**
     * Tries to finish the running animation if it is close to completion.
     */
    public void forceFinishIfCloseToEnd() {
        if (mAnimationPlayer.isRunning()
                && mAnimationPlayer.getAnimatedFraction() > ANIMATION_COMPLETE_THRESHOLD) {
            mAnimationPlayer.end();
        }
    }

    /**
     * Pauses the currently playing animation.
     */
+0 −4
Original line number Diff line number Diff line
@@ -62,10 +62,6 @@ public class PendingAnimation implements PropertySetter {
    /**
     * Utility method to sent an interpolator on an animation and add it to the list
     */
    public void add(Animator anim, TimeInterpolator interpolator) {
        add(anim, interpolator, SpringProperty.DEFAULT);
    }

    public void add(Animator anim, TimeInterpolator interpolator, SpringProperty springProperty) {
        anim.setInterpolator(interpolator);
        add(anim, springProperty);