diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index ddb20a1a37..9254803bae 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -110,7 +110,6 @@ import com.android.launcher3.widget.LauncherAppWidgetHostView; import com.android.quickstep.RemoteAnimationTargets; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TaskViewUtils; -import com.android.quickstep.util.AppCloseConfig; import com.android.quickstep.util.MultiValueUpdateListener; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.RemoteAnimationProvider; @@ -1338,12 +1337,11 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect) { @Override - public void onUpdate(@Nullable AppCloseConfig values, RectF currentRectF, - float progress) { + public void onUpdate(RectF currentRectF, float progress) { finalFloatingIconView.update(1f, 255 /* fgAlpha */, currentRectF, progress, windowAlphaThreshold, getCornerRadius(progress), false); - super.onUpdate(values, currentRectF, progress); + super.onUpdate(currentRectF, progress); } }; anim.addOnUpdateListener(runner); @@ -1356,8 +1354,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener FloatingWidgetView finalFloatingWidget = floatingWidget; RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect) { @Override - public void onUpdate(@Nullable AppCloseConfig values, RectF currentRectF, - float progress) { + public void onUpdate(RectF currentRectF, float progress) { final float fallbackBackgroundAlpha = 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE); final float foregroundAlpha = @@ -1365,7 +1362,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener finalFloatingWidget.update(currentRectF, floatingWidgetAlpha, foregroundAlpha, fallbackBackgroundAlpha, 1 - progress); - super.onUpdate(values, currentRectF, progress); + super.onUpdate(currentRectF, progress); } }; anim.addOnUpdateListener(runner); @@ -1776,7 +1773,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener } @Override - public void onUpdate(@Nullable AppCloseConfig values, RectF currentRectF, float progress) { + public void onUpdate(RectF currentRectF, float progress) { SurfaceParams[] params = new SurfaceParams[mAppTargets.length]; for (int i = mAppTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = mAppTargets[i]; diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 3ab73bbc5c..58320cbeb3 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1443,7 +1443,7 @@ public abstract class AbsSwipeUpHandler, } private void setupWindowAnimation(RectFSpringAnim[] anims) { - anims[0].addOnUpdateListener((v, r, p) -> { + anims[0].addOnUpdateListener((r, p) -> { updateSysUiFlags(Math.max(p, mCurrentShift.value)); }); anims[0].addAnimatorListener(new AnimationSuccessListener() { diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index c1b45e0257..fed5ae56ea 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -50,7 +50,6 @@ import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; @@ -59,7 +58,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.SpringAnimationBuilder; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.fallback.RecentsState; -import com.android.quickstep.util.AppCloseConfig; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.TransformParams; import com.android.quickstep.util.TransformParams.BuilderProxy; @@ -317,8 +315,7 @@ public class FallbackSwipeHandler extends } @Override - public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, - float radius) { + public void update(RectF currentRect, float progress, float radius) { if (mSurfaceControl != null) { currentRect.roundOut(mTempRect); Transaction t = new Transaction(); diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 0181cd7018..8a30aad90a 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -18,18 +18,14 @@ package com.android.quickstep; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; import static com.android.launcher3.LauncherState.NORMAL; -import static com.android.launcher3.Utilities.boundToRange; import static com.android.launcher3.Utilities.dpToPx; import static com.android.launcher3.Utilities.mapBoundToRange; import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE; import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static com.android.launcher3.views.FloatingIconView.getFloatingIconView; -import static java.lang.Math.round; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -59,10 +55,8 @@ import com.android.launcher3.util.ObjectWrapper; import com.android.launcher3.views.FloatingIconView; import com.android.launcher3.views.FloatingView; import com.android.launcher3.widget.LauncherAppWidgetHostView; -import com.android.quickstep.util.AppCloseConfig; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.StaggeredWorkspaceAnim; -import com.android.quickstep.util.WorkspaceRevealAnim; import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -167,15 +161,9 @@ public class LauncherSwipeHandlerV2 extends } @Override - public void update(@Nullable AppCloseConfig config, RectF currentRect, - float progress, float radius) { - super.update(config, currentRect, progress, radius); - int fgAlpha = 255; - if (config != null && PROTOTYPE_APP_CLOSE.get()) { - progress = config.getInterpolatedProgress(); - fgAlpha = config.getFgAlpha(); - } - floatingIconView.update(1f, fgAlpha, currentRect, progress, + public void update(RectF currentRect, float progress, float radius) { + super.update(currentRect, progress, radius); + floatingIconView.update(1f /* alpha */, 255 /* fgAlpha */, currentRect, progress, windowAlphaThreshold, radius, false); } }; @@ -232,9 +220,8 @@ public class LauncherSwipeHandlerV2 extends } @Override - public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, - float radius) { - super.update(config, currentRect, progress, radius); + public void update(RectF currentRect, float progress, float radius) { + super.update(currentRect, progress, radius); final float fallbackBackgroundAlpha = 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE); final float foregroundAlpha = @@ -293,27 +280,12 @@ public class LauncherSwipeHandlerV2 extends private final float mTransY; private final FloatingView mFloatingView; private ValueAnimator mBounceBackAnimator; - private final AnimatorSet mWorkspaceReveal; FloatingViewHomeAnimationFactory(FloatingView floatingView) { mFloatingView = floatingView; ResourceProvider rp = DynamicResource.provider(mActivity); mTransY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp)); - - mWorkspaceReveal = PROTOTYPE_APP_CLOSE.get() - ? new WorkspaceRevealAnim(mActivity, true /* animateScrim */).getAnimators() - : null; - } - - @Override - public @NonNull RectF getWindowTargetRect() { - if (PROTOTYPE_APP_CLOSE.get()) { - // We want the target rect to be at this offset position, so that all - // launcher content can spring back upwards. - mFloatingView.setPositionOffsetY(mTransY); - } - return super.getWindowTargetRect(); } @Override @@ -321,20 +293,6 @@ public class LauncherSwipeHandlerV2 extends return false; } - @Override - public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, - float radius) { - if (config != null && PROTOTYPE_APP_CLOSE.get()) { - DragLayer dl = mActivity.getDragLayer(); - float translationY = config.getWorkspaceTransY(); - dl.setTranslationY(translationY); - - long duration = mWorkspaceReveal.getDuration(); - long playTime = boundToRange(round(duration * progress), 0, duration); - mWorkspaceReveal.setCurrentPlayTime(playTime); - } - } - protected void bounceBackToRestingPosition() { final float startValue = mTransY; final float endValue = 0; @@ -368,31 +326,6 @@ public class LauncherSwipeHandlerV2 extends mBounceBackAnimator.start(); } - @Override - public void setAnimation(RectFSpringAnim anim) { - if (PROTOTYPE_APP_CLOSE.get()) { - // Use a spring to put drag layer translation back to 0. - anim.addAnimatorListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mFloatingView.setPositionOffsetY(0); - bounceBackToRestingPosition(); - } - }); - - // Will be updated manually below so that the two animations are in sync. - mWorkspaceReveal.start(); - mWorkspaceReveal.pause(); - - anim.addAnimatorListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mWorkspaceReveal.end(); - } - }); - } - } - @Override public void onCancel() { mFloatingView.fastFinish(); @@ -425,13 +358,9 @@ public class LauncherSwipeHandlerV2 extends @Override public void playAtomicAnimation(float velocity) { - if (!PROTOTYPE_APP_CLOSE.get()) { - new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */, - getViewIgnoredInWorkspaceRevealAnimation()) - .start(); - } else if (shouldPlayAtomicWorkspaceReveal()) { - new WorkspaceRevealAnim(mActivity, true).start(); - } + new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */, + getViewIgnoredInWorkspaceRevealAnimation()) + .start(); } @Override diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index f64d506ba8..b36cb0afea 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -18,7 +18,6 @@ package com.android.quickstep; import static com.android.launcher3.anim.Interpolators.ACCEL_1_5; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_SELECT; -import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE; import android.animation.Animator; import android.content.Context; @@ -28,7 +27,6 @@ import android.graphics.Rect; import android.graphics.RectF; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.android.launcher3.DeviceProfile; @@ -39,10 +37,8 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle; import com.android.quickstep.util.AnimatorControllerWithResistance; -import com.android.quickstep.util.AppCloseConfig; import com.android.quickstep.util.LauncherSplitScreenListener; import com.android.quickstep.util.RectFSpringAnim; -import com.android.quickstep.util.RectFSpringAnim2; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; import com.android.quickstep.util.TransformParams.BuilderProxy; @@ -189,8 +185,7 @@ public abstract class SwipeUpAnimationLogic implements public boolean keepWindowOpaque() { return false; } - public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, - float radius) { } + public void update(RectF currentRect, float progress, float radius) { } public void onCancel() { } @@ -290,14 +285,7 @@ public abstract class SwipeUpAnimationLogic implements homeToWindowPositionMap.invert(windowToHomePositionMap); windowToHomePositionMap.mapRect(startRect); - RectFSpringAnim anim; - if (PROTOTYPE_APP_CLOSE.get()) { - anim = new RectFSpringAnim2(startRect, targetRect, mContext, - taskViewSimulator.getCurrentCornerRadius(), - homeAnimationFactory.getEndRadius(cropRectF)); - } else { - anim = new RectFSpringAnim(startRect, targetRect, mContext, mDp); - } + RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mContext, mDp); homeAnimationFactory.setAnimation(anim); SpringAnimationRunner runner = new SpringAnimationRunner( @@ -343,17 +331,13 @@ public abstract class SwipeUpAnimationLogic implements } @Override - public void onUpdate(@Nullable AppCloseConfig config, RectF currentRect, float progress) { + public void onUpdate(RectF currentRect, float progress) { mHomeAnim.setPlayFraction(progress); mHomeToWindowPositionMap.mapRect(mWindowCurrentRect, currentRect); mMatrix.setRectToRect(mCropRectF, mWindowCurrentRect, ScaleToFit.FILL); float cornerRadius = Utilities.mapRange(progress, mStartRadius, mEndRadius); float alpha = mAnimationFactory.getWindowAlpha(progress); - if (config != null && PROTOTYPE_APP_CLOSE.get()) { - alpha = config.getWindowAlpha(); - cornerRadius = config.getCornerRadius(); - } if (mAnimationFactory.keepWindowOpaque()) { alpha = 1f; } @@ -362,8 +346,7 @@ public abstract class SwipeUpAnimationLogic implements .setCornerRadius(cornerRadius); mLocalTransformParams.applySurfaceParams(mLocalTransformParams .createSurfaceParams(this)); - mAnimationFactory.update(config, currentRect, progress, - mMatrix.mapRadius(cornerRadius)); + mAnimationFactory.update(currentRect, progress, mMatrix.mapRadius(cornerRadius)); } @Override diff --git a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java index a923519a75..90ce25c4ca 100644 --- a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java @@ -53,7 +53,6 @@ import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.RemoteTargetGluer; import com.android.quickstep.SwipeUpAnimationLogic; import com.android.quickstep.SwipeUpAnimationLogic.RunningWindowAnim; -import com.android.quickstep.util.AppCloseConfig; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.TransformParams; import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; @@ -328,8 +327,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController { } @Override - public void update(@Nullable AppCloseConfig config, RectF rect, float progress, - float radius) { + public void update(RectF rect, float progress, float radius) { mFakeIconView.setVisibility(View.VISIBLE); mFakeIconView.update(rect, progress, 1f - SHAPE_PROGRESS_DURATION /* shapeProgressStart */, diff --git a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java index 158fba9b31..c4909de510 100644 --- a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java +++ b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java @@ -328,7 +328,7 @@ public class RectFSpringAnim extends ReleaseCheck { break; } for (OnUpdateListener onUpdateListener : mOnUpdateListeners) { - onUpdateListener.onUpdate(null, mCurrentRect, mCurrentScaleProgress); + onUpdateListener.onUpdate(mCurrentRect, mCurrentScaleProgress); } } } @@ -353,7 +353,12 @@ public class RectFSpringAnim extends ReleaseCheck { } public interface OnUpdateListener { - void onUpdate(@Nullable AppCloseConfig values, RectF currentRect, float progress); + /** + * Called when an update is made to the animation. + * @param currentRect The rect of the window. + * @param progress [0, 1] The progress of the rect scale animation. + */ + void onUpdate(RectF currentRect, float progress); default void onCancel() { } } diff --git a/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java b/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java deleted file mode 100644 index cb35809de9..0000000000 --- a/quickstep/src/com/android/quickstep/util/RectFSpringAnim2.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (C) 2021 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.quickstep.util; - -import static com.android.launcher3.Utilities.dpToPx; -import static com.android.launcher3.anim.Interpolators.LINEAR; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; -import android.content.Context; -import android.graphics.PointF; -import android.graphics.RectF; -import android.util.PathParser; -import android.util.Property; -import android.view.animation.Interpolator; - -import androidx.core.view.animation.PathInterpolatorCompat; -import androidx.dynamicanimation.animation.FloatPropertyCompat; -import androidx.dynamicanimation.animation.SpringAnimation; -import androidx.dynamicanimation.animation.SpringForce; - -import com.android.launcher3.R; -import com.android.launcher3.Utilities; -import com.android.launcher3.util.DynamicResource; -import com.android.systemui.plugins.ResourceProvider; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -/** - * Applies spring forces to animate from a starting rect to a target rect, - * while providing update callbacks to the caller. - */ -public class RectFSpringAnim2 extends RectFSpringAnim { - - private static final FloatPropertyCompat RECT_CENTER_X = - new FloatPropertyCompat("rectCenterXSpring") { - @Override - public float getValue(RectFSpringAnim2 anim) { - return anim.mCurrentCenterX; - } - - @Override - public void setValue(RectFSpringAnim2 anim, float currentCenterX) { - anim.mCurrentCenterX = currentCenterX; - anim.onUpdate(); - } - }; - - private static final FloatPropertyCompat RECT_Y = - new FloatPropertyCompat("rectYSpring") { - @Override - public float getValue(RectFSpringAnim2 anim) { - return anim.mCurrentCenterY; - } - - @Override - public void setValue(RectFSpringAnim2 anim, float y) { - anim.mCurrentCenterY = y; - anim.onUpdate(); - } - }; - - private static final Property PROGRESS = - new Property(Float.class, "rectFProgress") { - @Override - public Float get(RectFSpringAnim2 rectFSpringAnim) { - return rectFSpringAnim.mProgress; - } - - @Override - public void set(RectFSpringAnim2 rectFSpringAnim, Float progress) { - rectFSpringAnim.mProgress = progress; - rectFSpringAnim.onUpdate(); - } - }; - - private final RectF mStartRect; - private final RectF mTargetRect; - private final RectF mCurrentRect = new RectF(); - private final List mOnUpdateListeners = new ArrayList<>(); - private final List mAnimatorListeners = new ArrayList<>(); - - private float mCurrentCenterX; - private float mCurrentCenterY; - - private float mTargetX; - private float mTargetY; - - // If true, tracking the bottom of the rects, else tracking the top. - private float mProgress; - private SpringAnimation mRectXAnim; - private SpringAnimation mRectYAnim; - private ValueAnimator mRectScaleAnim; - private boolean mAnimsStarted; - private boolean mRectXAnimEnded; - private boolean mRectYAnimEnded; - private boolean mRectScaleAnimEnded; - - private final float mXDamping; - private final float mXStiffness; - - private final float mYDamping; - private float mYStiffness; - - private long mDuration; - - private final Interpolator mCloseInterpolator; - - private AppCloseConfig mValues; - final float mStartRadius; - final float mEndRadius; - - final float mHomeTransYEnd; - final float mScaleStart; - - public RectFSpringAnim2(RectF startRect, RectF targetRect, Context context, float startRadius, - float endRadius) { - super(startRect, targetRect, context, null); - mStartRect = startRect; - mTargetRect = targetRect; - - mCurrentCenterY = mStartRect.centerY(); - mCurrentCenterX = mStartRect.centerX(); - - mTargetY = mTargetRect.centerY(); - mTargetX = mTargetRect.centerX(); - - ResourceProvider rp = DynamicResource.provider(context); - mXDamping = rp.getFloat(R.dimen.swipe_up_rect_2_x_damping_ratio); - mXStiffness = rp.getFloat(R.dimen.swipe_up_rect_2_x_stiffness); - - mYDamping = rp.getFloat(R.dimen.swipe_up_rect_2_y_damping_ratio); - mYStiffness = rp.getFloat(R.dimen.swipe_up_rect_2_y_stiffness); - mDuration = Math.round(rp.getFloat(R.dimen.swipe_up_duration)); - - mHomeTransYEnd = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp)); - mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start); - - mCloseInterpolator = getAppCloseInterpolator(context); - - // End on a "round-enough" radius so that the shape reveal doesn't have to do too much - // rounding at the end of the animation. - mStartRadius = startRadius; - mEndRadius = endRadius; - - setCanRelease(true); - } - - public void onTargetPositionChanged() { - if (mRectXAnim != null && mTargetX != mTargetRect.centerX()) { - mTargetX = mTargetRect.centerX(); - mRectXAnim.animateToFinalPosition(mTargetX); - } - - if (mRectYAnim != null) { - if (mTargetY != mTargetRect.centerY()) { - mTargetY = mTargetRect.centerY(); - mRectYAnim.animateToFinalPosition(mTargetY); - } - } - } - - public void addOnUpdateListener(OnUpdateListener onUpdateListener) { - mOnUpdateListeners.add(onUpdateListener); - } - - public void addAnimatorListener(Animator.AnimatorListener animatorListener) { - mAnimatorListeners.add(animatorListener); - } - - /** - * Starts the fling/spring animation. - * @param context The activity context. - * @param velocityPxPerMs Velocity of swipe in px/ms. - */ - public void start(Context context, PointF velocityPxPerMs) { - mRectXAnim = new SpringAnimation(this, RECT_CENTER_X) - .setStartValue(mCurrentCenterX) - .setStartVelocity(velocityPxPerMs.x * 1000) - .setSpring(new SpringForce(mTargetX) - .setStiffness(mXStiffness) - .setDampingRatio(mXDamping)); - mRectXAnim.addEndListener(((animation, canceled, centerX, velocityX) -> { - mRectXAnimEnded = true; - maybeOnEnd(); - })); - - mRectYAnim = new SpringAnimation(this, RECT_Y) - .setStartValue(mCurrentCenterY) - .setStartVelocity(velocityPxPerMs.y * 1000) - .setSpring(new SpringForce(mTargetY) - .setStiffness(mYStiffness) - .setDampingRatio(mYDamping)); - mRectYAnim.addEndListener(((animation, canceled, centerY, velocityY) -> { - mRectYAnimEnded = true; - maybeOnEnd(); - })); - - mRectScaleAnim = ObjectAnimator.ofFloat(this, PROGRESS, 0, 1f) - .setDuration(mDuration); - mRectScaleAnim.setInterpolator(mCloseInterpolator); - mRectScaleAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mRectScaleAnimEnded = true; - maybeOnEnd(); - } - }); - - mValues = buildConfig(); - mRectScaleAnim.addUpdateListener(mValues); - - setCanRelease(false); - mAnimsStarted = true; - - mRectXAnim.start(); - mRectYAnim.start(); - mRectScaleAnim.start(); - for (Animator.AnimatorListener animatorListener : mAnimatorListeners) { - animatorListener.onAnimationStart(null); - } - } - - private AppCloseConfig buildConfig() { - return new AppCloseConfig() { - FloatProp mHomeTransY = new FloatProp(0, mHomeTransYEnd, 0, mDuration, LINEAR); - FloatProp mHomeScale = new FloatProp(mScaleStart, 1f, 0, mDuration, LINEAR); - FloatProp mWindowFadeOut = new FloatProp(1f, 0f, 0, 116, LINEAR); - // There should be a slight overlap b/w window fading out and fg fading in. - // (fg startDelay < window fade out duration) - FloatProp mFgFadeIn = new FloatProp(0, 255f, 100, mDuration - 100, LINEAR); - FloatProp mRadius = new FloatProp(mStartRadius, mEndRadius, 0, mDuration, LINEAR); - FloatProp mThreePointInterpolation = new FloatProp(0, 1, 0, mDuration, LINEAR); - - @Override - public float getWorkspaceTransY() { - return mHomeTransY.value; - } - - @Override - public float getWorkspaceScale() { - return mHomeScale.value; - } - - @Override - public float getWindowAlpha() { - return mWindowFadeOut.value; - } - - @Override - public int getFgAlpha() { - return (int) mFgFadeIn.value; - } - - @Override - public float getCornerRadius() { - return mRadius.value; - } - - @Override - public float getInterpolatedProgress() { - return mThreePointInterpolation.value; - } - - @Override - public void onUpdate(float percent, boolean initOnly) {} - }; - } - - public void end() { - if (mAnimsStarted) { - if (mRectXAnim.canSkipToEnd()) { - mRectXAnim.skipToEnd(); - } - if (mRectYAnim.canSkipToEnd()) { - mRectYAnim.skipToEnd(); - } - mRectScaleAnim.end(); - } - mRectXAnimEnded = true; - mRectYAnimEnded = true; - mRectScaleAnimEnded = true; - maybeOnEnd(); - } - - private boolean isEnded() { - return mRectXAnimEnded && mRectYAnimEnded && mRectScaleAnimEnded; - } - - private void onUpdate() { - if (isEnded()) { - // Prevent further updates from being called. This can happen between callbacks for - // ending the x/y/scale animations. - return; - } - - if (!mOnUpdateListeners.isEmpty()) { - float rectProgress = mProgress; - float currentWidth = Utilities.mapRange(rectProgress, mStartRect.width(), - mTargetRect.width()); - float currentHeight = Utilities.mapRange(rectProgress, mStartRect.height(), - mTargetRect.height()); - - mCurrentRect.set(mCurrentCenterX - currentWidth / 2, - mCurrentCenterY - currentHeight / 2, - mCurrentCenterX + currentWidth / 2, - mCurrentCenterY + currentHeight / 2); - - float currentPlayTime = mRectScaleAnimEnded ? mRectScaleAnim.getDuration() - : mRectScaleAnim.getCurrentPlayTime(); - float linearProgress = Math.min(1f, currentPlayTime / mRectScaleAnim.getDuration()); - for (OnUpdateListener onUpdateListener : mOnUpdateListeners) { - onUpdateListener.onUpdate(mValues, mCurrentRect, linearProgress); - } - } - } - - private void maybeOnEnd() { - if (mAnimsStarted && isEnded()) { - mAnimsStarted = false; - setCanRelease(true); - for (Animator.AnimatorListener animatorListener : mAnimatorListeners) { - animatorListener.onAnimationEnd(null); - } - } - } - - public void cancel() { - if (mAnimsStarted) { - for (OnUpdateListener onUpdateListener : mOnUpdateListeners) { - onUpdateListener.onCancel(); - } - } - end(); - } - - private Interpolator getAppCloseInterpolator(Context context) { - ResourceProvider rp = DynamicResource.provider(context); - String path = String.format(Locale.ENGLISH, - "M 0,0 C %f, %f, %f, %f, %f, %f C %f, %f, %f, %f, 1, 1", - rp.getFloat(R.dimen.c1_a), - rp.getFloat(R.dimen.c1_b), - rp.getFloat(R.dimen.c1_c), - rp.getFloat(R.dimen.c1_d), - rp.getFloat(R.dimen.mp_x), - rp.getFloat(R.dimen.mp_y), - rp.getFloat(R.dimen.c2_a), - rp.getFloat(R.dimen.c2_b), - rp.getFloat(R.dimen.c2_c), - rp.getFloat(R.dimen.c2_d)); - return PathInterpolatorCompat.create(PathParser.createPathFromPathData(path)); - } -} diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index a30216cdff..a534450e4e 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -158,7 +158,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { t.reparent(mContentOverlay, mLeash); t.apply(); - addOnUpdateListener((values, currentRect, progress) -> { + addOnUpdateListener((currentRect, progress) -> { float alpha = progress < 0.5f ? 0 : Utilities.mapToRange(Math.min(progress, 1f), 0.5f, 1f, @@ -201,8 +201,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { addOnUpdateListener(this::onAnimationUpdate); } - private void onAnimationUpdate(@Nullable AppCloseConfig values, RectF currentRect, - float progress) { + private void onAnimationUpdate(RectF currentRect, float progress) { if (mHasAnimationEnded) return; final SurfaceControl.Transaction tx = PipSurfaceTransactionHelper.newSurfaceControlTransaction(); diff --git a/res/values/config.xml b/res/values/config.xml index 6fdb4de1fe..25911e688f 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -136,7 +136,6 @@ 1.5 0.88 - 400 4.5 3 @@ -147,33 +146,10 @@ 0.8 200 - - 1 - 250 - - 1 - 600 - - 0.8 1 0.85 - - 0.05 - 0 - 0.133333 - 0.06 - - 0.166666 - .4 - - 0.208333 - .82 - .25 - 1 - - 0.7 150 2dp @@ -188,33 +164,14 @@ 7.619dp - @dimen/swipe_up_duration @dimen/swipe_up_scale_start @dimen/swipe_up_trans_y_dp @dimen/swipe_up_trans_y_dp_per_s @dimen/swipe_up_trans_y_damping @dimen/swipe_up_trans_y_stiffness - @dimen/swipe_up_rect_2_x_damping_ratio - @dimen/swipe_up_rect_2_x_stiffness - @dimen/swipe_up_rect_2_y_damping_ratio - @dimen/swipe_up_rect_2_y_stiffness @dimen/swipe_up_launcher_alpha_max_progress - @dimen/swipe_up_rect_2_y_stiffness_low_swipe_multiplier @dimen/swipe_up_low_swipe_duration_multiplier @dimen/swipe_up_max_velocity - - @dimen/c1_a - @dimen/c1_b - @dimen/c1_c - @dimen/c1_d - - @dimen/mp_x - @dimen/mp_y - - @dimen/c2_a - @dimen/c2_b - @dimen/c2_c - @dimen/c2_d diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 796c91213e..13583874b9 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -233,9 +233,6 @@ public final class FeatureFlags { public static final BooleanFlag NOTIFY_CRASHES = getDebugFlag("NOTIFY_CRASHES", false, "Sends a notification whenever launcher encounters an uncaught exception."); - public static final BooleanFlag PROTOTYPE_APP_CLOSE = getDebugFlag( - "PROTOTYPE_APP_CLOSE", false, "Enables new app close"); - public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag( "ENABLE_WALLPAPER_SCRIM", false, "Enables scrim over wallpaper for text protection.");