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

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

Merge "Revert "Add spring to shelf for home <-> overview <-> all apps state...

Merge "Revert "Add spring to shelf for home <-> overview <-> all apps state transitions."" into ub-launcher3-master
parents 2c3089d5 2bdac8f7
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
@@ -52,9 +53,9 @@ import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragLayer;
@@ -294,8 +295,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {


            AnimatorSet anim = new AnimatorSet();
            AnimatorSet anim = new AnimatorSet();
            if (!activity.getDeviceProfile().isVerticalBarLayout()) {
            if (!activity.getDeviceProfile().isVerticalBarLayout()) {
                Animator shiftAnim = new SpringObjectAnimator(activity.getAllAppsController(),
                AllAppsTransitionController controller = activity.getAllAppsController();
                        activity.getAllAppsController().getShiftRange(),
                ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(controller, ALL_APPS_PROGRESS,
                        fromState.getVerticalProgress(activity),
                        fromState.getVerticalProgress(activity),
                        endState.getVerticalProgress(activity));
                        endState.getVerticalProgress(activity));
                shiftAnim.setInterpolator(LINEAR);
                shiftAnim.setInterpolator(LINEAR);
+3 −8
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ import static com.android.launcher3.LauncherAnimUtils.MIN_PROGRESS_TO_ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
import static com.android.quickstep.WindowTransformSwipeHandler.MIN_OVERSHOOT_DURATION;
import static com.android.quickstep.WindowTransformSwipeHandler.MIN_OVERSHOOT_DURATION;


@@ -42,6 +41,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.FlingBlockCheck;
import com.android.launcher3.util.FlingBlockCheck;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;


/**
/**
 * Utility class to handle long swipe from an app.
 * Utility class to handle long swipe from an app.
@@ -113,7 +113,7 @@ public class LongSwipeHelper {
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);


            if (blockedFling && !toAllApps && !QUICKSTEP_SPRINGS.get()) {
            if (blockedFling && !toAllApps) {
                Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction,
                Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction,
                        currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance);
                        currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance);
                duration = (overshoot.duration + duration);
                duration = (overshoot.duration + duration);
@@ -145,13 +145,8 @@ public class LongSwipeHelper {
        ValueAnimator animator = mAnimator.getAnimationPlayer();
        ValueAnimator animator = mAnimator.getAnimationPlayer();
        animator.setDuration(duration).setInterpolator(interpolator);
        animator.setDuration(duration).setInterpolator(interpolator);
        animator.setFloatValues(currentFraction, endProgress);
        animator.setFloatValues(currentFraction, endProgress);

        if (QUICKSTEP_SPRINGS.get()) {
            mAnimator.dispatchOnStartWithVelocity(endProgress, velocityPxPerMs);
        } else {
        animator.start();
        animator.start();
    }
    }
    }


    private void onSwipeAnimationComplete(boolean toAllApps, boolean isFling, Runnable callback) {
    private void onSwipeAnimationComplete(boolean toAllApps, boolean isFling, Runnable callback) {
        RecentsView rv = mLauncher.getOverviewPanel();
        RecentsView rv = mLauncher.getOverviewPanel();
+7 −14
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.QuickScrubController.QUICK_SWITCH_FROM_APP_START_DURATION;
import static com.android.quickstep.QuickScrubController.QUICK_SWITCH_FROM_APP_START_DURATION;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
@@ -789,8 +788,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
            mRecentsAnimationWrapper.enableTouchProxy();
            mRecentsAnimationWrapper.enableTouchProxy();
        }
        }


        animateToProgress(startShift, endShift, duration, interpolator, goingToHome,
        animateToProgress(startShift, endShift, duration, interpolator, goingToHome);
                velocityPxPerMs);
    }
    }


    private void doLogGesture(boolean toLauncher) {
    private void doLogGesture(boolean toLauncher) {
@@ -815,14 +813,14 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
    }
    }


    /** Animates to the given progress, where 0 is the current app and 1 is overview. */
    /** Animates to the given progress, where 0 is the current app and 1 is overview. */
    private void animateToProgress(float start, float end, long duration, Interpolator interpolator,
    private void animateToProgress(float start, float end, long duration,
            boolean goingToHome, float velocityPxPerMs) {
            Interpolator interpolator, boolean goingToHome) {
        mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
        mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
                interpolator, goingToHome, velocityPxPerMs));
                interpolator, goingToHome));
    }
    }


    private void animateToProgressInternal(float start, float end, long duration,
    private void animateToProgressInternal(float start, float end, long duration,
            Interpolator interpolator, boolean goingToHome, float velocityPxPerMs) {
            Interpolator interpolator, boolean goingToHome) {
        mIsGoingToHome = goingToHome;
        mIsGoingToHome = goingToHome;
        ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
        ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
        anim.setInterpolator(interpolator);
        anim.setInterpolator(interpolator);
@@ -856,13 +854,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
                mLauncherTransitionController.dispatchSetInterpolator(Interpolators.mapToProgress(
                mLauncherTransitionController.dispatchSetInterpolator(Interpolators.mapToProgress(
                        interpolator, adjustedStart, end));
                        interpolator, adjustedStart, end));
                mLauncherTransitionController.getAnimationPlayer().setDuration(adjustedDuration);
                mLauncherTransitionController.getAnimationPlayer().setDuration(adjustedDuration);

                if (QUICKSTEP_SPRINGS.get()) {
                    mLauncherTransitionController.dispatchOnStartWithVelocity(end, velocityPxPerMs);
                } else {
                mLauncherTransitionController.getAnimationPlayer().start();
                mLauncherTransitionController.getAnimationPlayer().start();
            }
            }
            }
        });
        });
    }
    }


@@ -1006,7 +999,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
        long duration = FeatureFlags.QUICK_SWITCH.get()
        long duration = FeatureFlags.QUICK_SWITCH.get()
                ? QUICK_SWITCH_FROM_APP_START_DURATION
                ? QUICK_SWITCH_FROM_APP_START_DURATION
                : QUICK_SCRUB_FROM_APP_START_DURATION;
                : QUICK_SCRUB_FROM_APP_START_DURATION;
        animateToProgress(mCurrentShift.value, 1f, duration, LINEAR, true /* goingToHome */, 1f);
        animateToProgress(mCurrentShift.value, 1f, duration, LINEAR, true /* goingToHome */);
    }
    }


    private void onQuickScrubStartUi() {
    private void onQuickScrubStartUi() {
+5 −54
Original line number Original line Diff line number Diff line
package com.android.launcher3.allapps;
package com.android.launcher3.allapps;


import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR;
import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR;
@@ -14,7 +15,9 @@ import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;


import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.util.Property;
import android.util.Property;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;


import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile;
@@ -26,15 +29,10 @@ import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.SpringObjectAnimator.SpringProperty;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
import com.android.launcher3.views.ScrimView;


import androidx.dynamicanimation.animation.FloatPropertyCompat;
import androidx.dynamicanimation.animation.SpringAnimation;

/**
/**
 * Handles AllApps view transition.
 * Handles AllApps view transition.
 * 1) Slides all apps view using direct manipulation
 * 1) Slides all apps view using direct manipulation
@@ -61,53 +59,6 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
        }
        }
    };
    };


    public static final FloatPropertyCompat<AllAppsTransitionController> ALL_APPS_PROGRESS_SPRING
            = new FloatPropertyCompat<AllAppsTransitionController>("allAppsProgressSpring") {
        @Override
        public float getValue(AllAppsTransitionController controller) {
            return controller.mProgress;
        }

        @Override
        public void setValue(AllAppsTransitionController controller, float progress) {
            controller.setProgress(progress);
        }
    };

    /**
     * Property that either sets the progress directly or animates the progress via a spring.
     */
    public static class AllAppsSpringProperty extends
            SpringProperty<AllAppsTransitionController, Float> {

        SpringAnimation mSpring;
        boolean useSpring = false;

        public AllAppsSpringProperty(SpringAnimation spring) {
            super(Float.class, "allAppsSpringProperty");
            mSpring = spring;
        }

        @Override
        public Float get(AllAppsTransitionController controller) {
            return controller.getProgress();
        }

        @Override
        public void set(AllAppsTransitionController controller, Float progress) {
            if (useSpring) {
                mSpring.animateToFinalPosition(progress);
            } else {
                controller.setProgress(progress);
            }
        }

        @Override
        public void switchToSpring() {
            useSpring = true;
        }
    }

    private AllAppsContainerView mAppsView;
    private AllAppsContainerView mAppsView;
    private ScrimView mScrimView;
    private ScrimView mScrimView;


@@ -223,8 +174,8 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
        Interpolator interpolator = config.userControlled ? LINEAR : toState == OVERVIEW
        Interpolator interpolator = config.userControlled ? LINEAR : toState == OVERVIEW
                ? builder.getInterpolator(ANIM_OVERVIEW_SCALE, FAST_OUT_SLOW_IN)
                ? builder.getInterpolator(ANIM_OVERVIEW_SCALE, FAST_OUT_SLOW_IN)
                : FAST_OUT_SLOW_IN;
                : FAST_OUT_SLOW_IN;
        Animator anim = new SpringObjectAnimator(this, 1f / mShiftRange, mProgress,
        ObjectAnimator anim =
                targetProgress);
                ObjectAnimator.ofFloat(this, ALL_APPS_PROGRESS, mProgress, targetProgress);
        anim.setDuration(config.duration);
        anim.setDuration(config.duration);
        anim.setInterpolator(builder.getInterpolator(ANIM_VERTICAL_PROGRESS, interpolator));
        anim.setInterpolator(builder.getInterpolator(ANIM_VERTICAL_PROGRESS, interpolator));
        anim.addListener(getProgressAnimatorListener());
        anim.addListener(getProgressAnimatorListener());
+4 −66
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.launcher3.anim;
package com.android.launcher3.anim;


import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;


import android.animation.Animator;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.Animator.AnimatorListener;
@@ -24,16 +23,10 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.util.Log;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Set;

import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;


/**
/**
 * Helper class to control the playback of an {@link AnimatorSet}, with custom interpolators
 * Helper class to control the playback of an {@link AnimatorSet}, with custom interpolators
@@ -44,9 +37,6 @@ import androidx.dynamicanimation.animation.SpringAnimation;
 */
 */
public abstract class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateListener {
public abstract class AnimatorPlaybackController implements ValueAnimator.AnimatorUpdateListener {


    private static final String TAG = "AnimatorPlaybackCtrler";
    private static boolean DEBUG = false;

    public static AnimatorPlaybackController wrap(AnimatorSet anim, long duration) {
    public static AnimatorPlaybackController wrap(AnimatorSet anim, long duration) {
        return wrap(anim, duration, null);
        return wrap(anim, duration, null);
    }
    }
@@ -70,7 +60,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
    private final long mDuration;
    private final long mDuration;


    protected final AnimatorSet mAnim;
    protected final AnimatorSet mAnim;
    private Set<SpringAnimation> mSprings;


    protected float mCurrentFraction;
    protected float mCurrentFraction;
    private Runnable mEndAction;
    private Runnable mEndAction;
@@ -78,9 +67,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
    protected boolean mTargetCancelled = false;
    protected boolean mTargetCancelled = false;
    protected Runnable mOnCancelRunnable;
    protected Runnable mOnCancelRunnable;


    private OnAnimationEndDispatcher mEndListener;
    private DynamicAnimation.OnAnimationEndListener mSpringEndListener;

    protected AnimatorPlaybackController(AnimatorSet anim, long duration,
    protected AnimatorPlaybackController(AnimatorSet anim, long duration,
            Runnable onCancelRunnable) {
            Runnable onCancelRunnable) {
        mAnim = anim;
        mAnim = anim;
@@ -89,8 +75,7 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat


        mAnimationPlayer = ValueAnimator.ofFloat(0, 1);
        mAnimationPlayer = ValueAnimator.ofFloat(0, 1);
        mAnimationPlayer.setInterpolator(LINEAR);
        mAnimationPlayer.setInterpolator(LINEAR);
        mEndListener = new OnAnimationEndDispatcher();
        mAnimationPlayer.addListener(new OnAnimationEndDispatcher());
        mAnimationPlayer.addListener(mEndListener);
        mAnimationPlayer.addUpdateListener(this);
        mAnimationPlayer.addUpdateListener(this);


        mAnim.addListener(new AnimatorListenerAdapter() {
        mAnim.addListener(new AnimatorListenerAdapter() {
@@ -114,15 +99,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
                mTargetCancelled = false;
                mTargetCancelled = false;
            }
            }
        });
        });

        mSprings = new HashSet<>();
        mSpringEndListener = (animation, canceled, value, velocity1) -> {
            if (canceled) {
                mEndListener.onAnimationCancel(mAnimationPlayer);
            } else {
                mEndListener.onAnimationEnd(mAnimationPlayer);
            }
        };
    }
    }


    public AnimatorSet getTarget() {
    public AnimatorSet getTarget() {
@@ -204,29 +180,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
        }
        }
    }
    }


    /**
     * Starts playback and sets the spring.
     */
    public void dispatchOnStartWithVelocity(float end, float velocity) {
        if (!QUICKSTEP_SPRINGS.get()) {
            dispatchOnStart();
            return;
        }

        if (DEBUG) Log.d(TAG, "dispatchOnStartWithVelocity#end=" + end + ", velocity=" + velocity);

        for (Animator a : mAnim.getChildAnimations()) {
            if (a instanceof SpringObjectAnimator) {
                if (DEBUG) Log.d(TAG, "Found springAnimator=" + a);
                SpringObjectAnimator springAnimator = (SpringObjectAnimator) a;
                mSprings.add(springAnimator.getSpring());
                springAnimator.startSpring(end, velocity, mSpringEndListener);
            }
        }

        dispatchOnStart();
    }

    public void dispatchOnStart() {
    public void dispatchOnStart() {
        dispatchOnStartRecursively(mAnim);
        dispatchOnStartRecursively(mAnim);
    }
    }
@@ -329,18 +282,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
        }
        }
    }
    }


    private boolean isAnySpringRunning() {
        for (SpringAnimation spring : mSprings) {
            if (spring.isRunning()) {
                return true;
            }
        }
        return false;
    }

    /**
     * Only dispatches the on end actions once the animator and all springs have completed running.
     */
    private class OnAnimationEndDispatcher extends AnimationSuccessListener {
    private class OnAnimationEndDispatcher extends AnimationSuccessListener {


        @Override
        @Override
@@ -350,14 +291,11 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat


        @Override
        @Override
        public void onAnimationSuccess(Animator animator) {
        public void onAnimationSuccess(Animator animator) {
            // We wait for the spring (if any) to finish running before completing the end callback.
            if (mSprings.isEmpty() || !isAnySpringRunning()) {
            dispatchOnEndRecursively(mAnim);
            dispatchOnEndRecursively(mAnim);
            if (mEndAction != null) {
            if (mEndAction != null) {
                mEndAction.run();
                mEndAction.run();
            }
            }
        }
        }
        }


        private void dispatchOnEndRecursively(Animator animator) {
        private void dispatchOnEndRecursively(Animator animator) {
            for (AnimatorListener l : nonNullList(animator.getListeners())) {
            for (AnimatorListener l : nonNullList(animator.getListeners())) {
Loading