Remove PROTOTYPE_APP_CLOSE feature flag and associated code.
Flag was never enabled, safe to remove. Bug: 200999899 Test: manual Change-Id: Ie2646d8c4b9a1c40fac1bfd7dadf4ec714171aec
This commit is contained in:
parent
85da1db1aa
commit
029a644a6e
|
@ -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];
|
||||
|
|
|
@ -1443,7 +1443,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */,
|
||||
|
|
|
@ -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() { }
|
||||
}
|
||||
|
|
|
@ -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<RectFSpringAnim2> RECT_CENTER_X =
|
||||
new FloatPropertyCompat<RectFSpringAnim2>("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<RectFSpringAnim2> RECT_Y =
|
||||
new FloatPropertyCompat<RectFSpringAnim2>("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<RectFSpringAnim2, Float> PROGRESS =
|
||||
new Property<RectFSpringAnim2, Float>(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<OnUpdateListener> mOnUpdateListeners = new ArrayList<>();
|
||||
private final List<Animator.AnimatorListener> 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));
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -136,7 +136,6 @@
|
|||
<item name="swipe_up_rect_xy_fling_friction" type="dimen" format="float">1.5</item>
|
||||
|
||||
<item name="swipe_up_scale_start" type="dimen" format="float">0.88</item>
|
||||
<item name="swipe_up_duration" type="dimen" format="float">400</item>
|
||||
|
||||
<item name="swipe_up_trans_y_dp" type="dimen" format="float">4.5</item>
|
||||
<item name="swipe_up_trans_y_dp_per_s" type="dimen" format="float">3</item>
|
||||
|
@ -147,33 +146,10 @@
|
|||
<item name="swipe_up_rect_xy_damping_ratio" type="dimen" format="float">0.8</item>
|
||||
<item name="swipe_up_rect_xy_stiffness" type="dimen" format="float">200</item>
|
||||
|
||||
|
||||
<item name="swipe_up_rect_2_x_damping_ratio" type="dimen" format="float">1</item>
|
||||
<item name="swipe_up_rect_2_x_stiffness" type="dimen" format="float">250</item>
|
||||
|
||||
<item name="swipe_up_rect_2_y_damping_ratio" type="dimen" format="float">1</item>
|
||||
<item name="swipe_up_rect_2_y_stiffness" type="dimen" format="float">600</item>
|
||||
|
||||
<item name="swipe_up_rect_2_y_stiffness_low_swipe_multiplier" type="dimen" format="float">0.8</item>
|
||||
<item name="swipe_up_low_swipe_duration_multiplier" type="dimen" format="float">1</item>
|
||||
|
||||
<item name="swipe_up_launcher_alpha_max_progress" type="dimen" format="float">0.85</item>
|
||||
|
||||
|
||||
<item name="c1_a" type="dimen" format="float">0.05</item>
|
||||
<item name="c1_b" type="dimen" format="float">0</item>
|
||||
<item name="c1_c" type="dimen" format="float">0.133333</item>
|
||||
<item name="c1_d" type="dimen" format="float">0.06</item>
|
||||
|
||||
<item name="mp_x" type="dimen" format="float">0.166666</item>
|
||||
<item name="mp_y" type="dimen" format="float">.4</item>
|
||||
|
||||
<item name="c2_a" type="dimen" format="float">0.208333</item>
|
||||
<item name="c2_b" type="dimen" format="float">.82</item>
|
||||
<item name="c2_c" type="dimen" format="float">.25</item>
|
||||
<item name="c2_d" type="dimen" format="float">1</item>
|
||||
|
||||
|
||||
<item name="staggered_damping_ratio" type="dimen" format="float">0.7</item>
|
||||
<item name="staggered_stiffness" type="dimen" format="float">150</item>
|
||||
<dimen name="unlock_staggered_velocity_dp_per_s">2dp</dimen>
|
||||
|
@ -188,33 +164,14 @@
|
|||
<dimen name="swipe_up_max_velocity">7.619dp</dimen>
|
||||
|
||||
<array name="dynamic_resources">
|
||||
<item>@dimen/swipe_up_duration</item>
|
||||
<item>@dimen/swipe_up_scale_start</item>
|
||||
<item>@dimen/swipe_up_trans_y_dp</item>
|
||||
<item>@dimen/swipe_up_trans_y_dp_per_s</item>
|
||||
<item>@dimen/swipe_up_trans_y_damping</item>
|
||||
<item>@dimen/swipe_up_trans_y_stiffness</item>
|
||||
<item>@dimen/swipe_up_rect_2_x_damping_ratio</item>
|
||||
<item>@dimen/swipe_up_rect_2_x_stiffness</item>
|
||||
<item>@dimen/swipe_up_rect_2_y_damping_ratio</item>
|
||||
<item>@dimen/swipe_up_rect_2_y_stiffness</item>
|
||||
<item>@dimen/swipe_up_launcher_alpha_max_progress</item>
|
||||
<item>@dimen/swipe_up_rect_2_y_stiffness_low_swipe_multiplier</item>
|
||||
<item>@dimen/swipe_up_low_swipe_duration_multiplier</item>
|
||||
<item>@dimen/swipe_up_max_velocity</item>
|
||||
|
||||
<item>@dimen/c1_a</item>
|
||||
<item>@dimen/c1_b</item>
|
||||
<item>@dimen/c1_c</item>
|
||||
<item>@dimen/c1_d</item>
|
||||
|
||||
<item>@dimen/mp_x</item>
|
||||
<item>@dimen/mp_y</item>
|
||||
|
||||
<item>@dimen/c2_a</item>
|
||||
<item>@dimen/c2_b</item>
|
||||
<item>@dimen/c2_c</item>
|
||||
<item>@dimen/c2_d</item>
|
||||
</array>
|
||||
|
||||
<string-array name="filtered_components" ></string-array>
|
||||
|
|
|
@ -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.");
|
||||
|
|
Loading…
Reference in New Issue