Revert "Add spring to shelf for home <-> overview <-> all apps state transitions."
This reverts commit e018711aac
.
Reason for revert: investigating crash
Change-Id: I157b61a9f1bd46e2fcd3f2f883d3b5c23ca314af
This commit is contained in:
parent
e018711aac
commit
2bdac8f7e5
|
@ -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.FAST_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.states.RotationHelper.REQUEST_LOCK;
|
||||
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.R;
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.allapps.DiscoveryBounce;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.SpringObjectAnimator;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
|
@ -294,8 +295,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
|
|||
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
if (!activity.getDeviceProfile().isVerticalBarLayout()) {
|
||||
Animator shiftAnim = new SpringObjectAnimator(activity.getAllAppsController(),
|
||||
activity.getAllAppsController().getShiftRange(),
|
||||
AllAppsTransitionController controller = activity.getAllAppsController();
|
||||
ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(controller, ALL_APPS_PROGRESS,
|
||||
fromState.getVerticalProgress(activity),
|
||||
endState.getVerticalProgress(activity));
|
||||
shiftAnim.setInterpolator(LINEAR);
|
||||
|
|
|
@ -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.OVERVIEW;
|
||||
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.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.util.FlingBlockCheck;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
||||
|
||||
/**
|
||||
* Utility class to handle long swipe from an app.
|
||||
|
@ -113,7 +113,7 @@ public class LongSwipeHelper {
|
|||
* MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
|
||||
duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
|
||||
|
||||
if (blockedFling && !toAllApps && !QUICKSTEP_SPRINGS.get()) {
|
||||
if (blockedFling && !toAllApps) {
|
||||
Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction,
|
||||
currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance);
|
||||
duration = (overshoot.duration + duration);
|
||||
|
@ -145,12 +145,7 @@ public class LongSwipeHelper {
|
|||
ValueAnimator animator = mAnimator.getAnimationPlayer();
|
||||
animator.setDuration(duration).setInterpolator(interpolator);
|
||||
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) {
|
||||
|
|
|
@ -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.LINEAR;
|
||||
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_SWITCH_FROM_APP_START_DURATION;
|
||||
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
|
||||
|
@ -789,8 +788,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
|||
mRecentsAnimationWrapper.enableTouchProxy();
|
||||
}
|
||||
|
||||
animateToProgress(startShift, endShift, duration, interpolator, goingToHome,
|
||||
velocityPxPerMs);
|
||||
animateToProgress(startShift, endShift, duration, interpolator, goingToHome);
|
||||
}
|
||||
|
||||
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. */
|
||||
private void animateToProgress(float start, float end, long duration, Interpolator interpolator,
|
||||
boolean goingToHome, float velocityPxPerMs) {
|
||||
private void animateToProgress(float start, float end, long duration,
|
||||
Interpolator interpolator, boolean goingToHome) {
|
||||
mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
|
||||
interpolator, goingToHome, velocityPxPerMs));
|
||||
interpolator, goingToHome));
|
||||
}
|
||||
|
||||
private void animateToProgressInternal(float start, float end, long duration,
|
||||
Interpolator interpolator, boolean goingToHome, float velocityPxPerMs) {
|
||||
Interpolator interpolator, boolean goingToHome) {
|
||||
mIsGoingToHome = goingToHome;
|
||||
ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
|
||||
anim.setInterpolator(interpolator);
|
||||
|
@ -856,12 +854,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
|||
mLauncherTransitionController.dispatchSetInterpolator(Interpolators.mapToProgress(
|
||||
interpolator, adjustedStart, end));
|
||||
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()
|
||||
? QUICK_SWITCH_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() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.android.launcher3.allapps;
|
||||
|
||||
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.OVERVIEW;
|
||||
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.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
|
@ -26,15 +29,10 @@ import com.android.launcher3.LauncherStateManager.StateHandler;
|
|||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.SpringObjectAnimator;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.anim.SpringObjectAnimator.SpringProperty;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
|
||||
import androidx.dynamicanimation.animation.FloatPropertyCompat;
|
||||
import androidx.dynamicanimation.animation.SpringAnimation;
|
||||
|
||||
/**
|
||||
* Handles AllApps view transition.
|
||||
* 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 ScrimView mScrimView;
|
||||
|
||||
|
@ -223,8 +174,8 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
|||
Interpolator interpolator = config.userControlled ? LINEAR : toState == OVERVIEW
|
||||
? builder.getInterpolator(ANIM_OVERVIEW_SCALE, FAST_OUT_SLOW_IN)
|
||||
: FAST_OUT_SLOW_IN;
|
||||
Animator anim = new SpringObjectAnimator(this, 1f / mShiftRange, mProgress,
|
||||
targetProgress);
|
||||
ObjectAnimator anim =
|
||||
ObjectAnimator.ofFloat(this, ALL_APPS_PROGRESS, mProgress, targetProgress);
|
||||
anim.setDuration(config.duration);
|
||||
anim.setInterpolator(builder.getInterpolator(ANIM_VERTICAL_PROGRESS, interpolator));
|
||||
anim.addListener(getProgressAnimatorListener());
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package com.android.launcher3.anim;
|
||||
|
||||
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.AnimatorListener;
|
||||
|
@ -24,16 +23,10 @@ import android.animation.AnimatorListenerAdapter;
|
|||
import android.animation.AnimatorSet;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
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
|
||||
|
@ -44,9 +37,6 @@ import androidx.dynamicanimation.animation.SpringAnimation;
|
|||
*/
|
||||
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) {
|
||||
return wrap(anim, duration, null);
|
||||
}
|
||||
|
@ -70,7 +60,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
|
|||
private final long mDuration;
|
||||
|
||||
protected final AnimatorSet mAnim;
|
||||
private Set<SpringAnimation> mSprings;
|
||||
|
||||
protected float mCurrentFraction;
|
||||
private Runnable mEndAction;
|
||||
|
@ -78,9 +67,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
|
|||
protected boolean mTargetCancelled = false;
|
||||
protected Runnable mOnCancelRunnable;
|
||||
|
||||
private OnAnimationEndDispatcher mEndListener;
|
||||
private DynamicAnimation.OnAnimationEndListener mSpringEndListener;
|
||||
|
||||
protected AnimatorPlaybackController(AnimatorSet anim, long duration,
|
||||
Runnable onCancelRunnable) {
|
||||
mAnim = anim;
|
||||
|
@ -89,8 +75,7 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
|
|||
|
||||
mAnimationPlayer = ValueAnimator.ofFloat(0, 1);
|
||||
mAnimationPlayer.setInterpolator(LINEAR);
|
||||
mEndListener = new OnAnimationEndDispatcher();
|
||||
mAnimationPlayer.addListener(mEndListener);
|
||||
mAnimationPlayer.addListener(new OnAnimationEndDispatcher());
|
||||
mAnimationPlayer.addUpdateListener(this);
|
||||
|
||||
mAnim.addListener(new AnimatorListenerAdapter() {
|
||||
|
@ -114,15 +99,6 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
|
|||
mTargetCancelled = false;
|
||||
}
|
||||
});
|
||||
|
||||
mSprings = new HashSet<>();
|
||||
mSpringEndListener = (animation, canceled, value, velocity1) -> {
|
||||
if (canceled) {
|
||||
mEndListener.onAnimationCancel(mAnimationPlayer);
|
||||
} else {
|
||||
mEndListener.onAnimationEnd(mAnimationPlayer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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() {
|
||||
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 {
|
||||
|
||||
@Override
|
||||
|
@ -350,12 +291,9 @@ public abstract class AnimatorPlaybackController implements ValueAnimator.Animat
|
|||
|
||||
@Override
|
||||
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);
|
||||
if (mEndAction != null) {
|
||||
mEndAction.run();
|
||||
}
|
||||
dispatchOnEndRecursively(mAnim);
|
||||
if (mEndAction != null) {
|
||||
mEndAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,270 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.anim;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.Log;
|
||||
import android.util.Property;
|
||||
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController.AllAppsSpringProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
|
||||
import androidx.dynamicanimation.animation.SpringAnimation;
|
||||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
|
||||
/**
|
||||
* This animator allows for an object's property to be be controlled by an {@link ObjectAnimator} or
|
||||
* a {@link SpringAnimation}. It extends ValueAnimator so it can be used in an AnimatorSet.
|
||||
*/
|
||||
public class SpringObjectAnimator extends ValueAnimator {
|
||||
|
||||
private static final String TAG = "SpringObjectAnimator";
|
||||
private static boolean DEBUG = false;
|
||||
|
||||
private AllAppsTransitionController mObject;
|
||||
private ObjectAnimator mObjectAnimator;
|
||||
private float[] mValues;
|
||||
|
||||
private SpringAnimation mSpring;
|
||||
private AllAppsSpringProperty mProperty;
|
||||
|
||||
private ArrayList<AnimatorListener> mListeners;
|
||||
private boolean mSpringEnded = false;
|
||||
private boolean mAnimatorEnded = false;
|
||||
private boolean mEnded = false;
|
||||
|
||||
private static final float SPRING_DAMPING_RATIO = 0.9f;
|
||||
private static final float SPRING_STIFFNESS = 600f;
|
||||
|
||||
public SpringObjectAnimator(AllAppsTransitionController object, float minimumVisibleChange,
|
||||
float... values) {
|
||||
mObject = object;
|
||||
mSpring = new SpringAnimation(object, AllAppsTransitionController.ALL_APPS_PROGRESS_SPRING);
|
||||
mSpring.setMinimumVisibleChange(minimumVisibleChange);
|
||||
mSpring.setSpring(new SpringForce(0)
|
||||
.setDampingRatio(SPRING_DAMPING_RATIO)
|
||||
.setStiffness(SPRING_STIFFNESS));
|
||||
mSpring.setStartVelocity(0.01f);
|
||||
mProperty = new AllAppsSpringProperty(mSpring);
|
||||
mObjectAnimator = ObjectAnimator.ofFloat(object, mProperty, values);
|
||||
mValues = values;
|
||||
mListeners = new ArrayList<>();
|
||||
setFloatValues(values);
|
||||
|
||||
mObjectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mAnimatorEnded = false;
|
||||
mEnded = false;
|
||||
for (AnimatorListener l : mListeners) {
|
||||
l.onAnimationStart(animation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mAnimatorEnded = true;
|
||||
tryEnding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
for (AnimatorListener l : mListeners) {
|
||||
l.onAnimationCancel(animation);
|
||||
}
|
||||
mSpring.animateToFinalPosition(mObject.getProgress());
|
||||
}
|
||||
});
|
||||
|
||||
mSpring.addUpdateListener((animation, value, velocity) -> mSpringEnded = false);
|
||||
mSpring.addEndListener((animation, canceled, value, velocity) -> {
|
||||
mSpringEnded = true;
|
||||
tryEnding();
|
||||
});
|
||||
}
|
||||
|
||||
private void tryEnding() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "tryEnding#mAnimatorEnded=" + mAnimatorEnded + ", mSpringEnded="
|
||||
+ mSpringEnded + ", mEnded=" + mEnded);
|
||||
}
|
||||
|
||||
if (mAnimatorEnded && mSpringEnded && !mEnded) {
|
||||
for (AnimatorListener l : mListeners) {
|
||||
l.onAnimationEnd(mObjectAnimator);
|
||||
}
|
||||
mEnded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public SpringAnimation getSpring() {
|
||||
return mSpring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and sets up the spring to take over controlling the object.
|
||||
*/
|
||||
void startSpring(float end, float velocity, OnAnimationEndListener endListener) {
|
||||
// Cancel the spring so we can set new start velocity and final position. We need to remove
|
||||
// the listener since the spring is not actually ending.
|
||||
mSpring.removeEndListener(endListener);
|
||||
mSpring.cancel();
|
||||
mSpring.addEndListener(endListener);
|
||||
|
||||
mProperty.switchToSpring();
|
||||
|
||||
mSpring.setStartVelocity(velocity);
|
||||
mSpring.animateToFinalPosition(end == 0 ? mValues[0] : mValues[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(AnimatorListener listener) {
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPauseListener(AnimatorPauseListener listener) {
|
||||
mObjectAnimator.addPauseListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
mSpring.animateToFinalPosition(mObject.getProgress());
|
||||
mObjectAnimator.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
mObjectAnimator.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
return mObjectAnimator.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeInterpolator getInterpolator() {
|
||||
return mObjectAnimator.getInterpolator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<AnimatorListener> getListeners() {
|
||||
return mObjectAnimator.getListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartDelay() {
|
||||
return mObjectAnimator.getStartDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalDuration() {
|
||||
return mObjectAnimator.getTotalDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return mObjectAnimator.isPaused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return mObjectAnimator.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return mObjectAnimator.isStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
mObjectAnimator.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners() {
|
||||
mObjectAnimator.removeAllListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(AnimatorListener listener) {
|
||||
mObjectAnimator.removeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePauseListener(AnimatorPauseListener listener) {
|
||||
mObjectAnimator.removePauseListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
mObjectAnimator.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueAnimator setDuration(long duration) {
|
||||
return mObjectAnimator.setDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(TimeInterpolator value) {
|
||||
mObjectAnimator.setInterpolator(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelay(long startDelay) {
|
||||
mObjectAnimator.setStartDelay(startDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Object target) {
|
||||
mObjectAnimator.setTarget(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mObjectAnimator.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentFraction(float fraction) {
|
||||
mObjectAnimator.setCurrentFraction(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentPlayTime(long playTime) {
|
||||
mObjectAnimator.setCurrentPlayTime(playTime);
|
||||
}
|
||||
|
||||
public static abstract class SpringProperty<T, V> extends Property<T, V> {
|
||||
|
||||
public SpringProperty(Class<V> type, String name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
abstract public void switchToSpring();
|
||||
}
|
||||
|
||||
}
|
|
@ -98,9 +98,6 @@ abstract class BaseFlags {
|
|||
public static final TogglableFlag ENABLE_TASK_STABILIZER = new TogglableFlag(
|
||||
"ENABLE_TASK_STABILIZER", false, "Stable task list across fast task switches");
|
||||
|
||||
public static final TogglableFlag QUICKSTEP_SPRINGS = new TogglableFlag("QUICKSTEP_SPRINGS",
|
||||
false, "Enable springs for quickstep animations");
|
||||
|
||||
public static void initialize(Context context) {
|
||||
// Avoid the disk read for user builds
|
||||
if (Utilities.IS_DEBUG_DEVICE) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import static com.android.launcher3.LauncherStateManager.ATOMIC_COMPONENT;
|
|||
import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT;
|
||||
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
|
||||
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
|
||||
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
|
@ -46,7 +45,6 @@ import com.android.launcher3.anim.AnimationSuccessListener;
|
|||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
|
@ -430,8 +428,8 @@ public abstract class AbstractStateChangeTouchController
|
|||
maybeUpdateAtomicAnim(mFromState, targetState, targetState == mToState ? 1f : 0f);
|
||||
updateSwipeCompleteAnimation(anim, Math.max(duration, getRemainingAtomicDuration()),
|
||||
targetState, velocity, fling);
|
||||
mCurrentAnimation.dispatchOnStartWithVelocity(endProgress, velocity);
|
||||
if (fling && targetState == LauncherState.ALL_APPS && !QUICKSTEP_SPRINGS.get()) {
|
||||
mCurrentAnimation.dispatchOnStart();
|
||||
if (fling && targetState == LauncherState.ALL_APPS) {
|
||||
mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
|
||||
}
|
||||
anim.start();
|
||||
|
|
Loading…
Reference in New Issue