use of com.android.quickstep.util.RectFSpringAnim in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherSwipeHandlerV2 method createIconHomeAnimationFactory.
private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) {
final ResourceProvider rp = DynamicResource.provider(mActivity);
final float transY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
RectF iconLocation = new RectF();
FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView, true, /* hideOriginal */
iconLocation, false);
// We want the window alpha to be 0 once this threshold is met, so that the
// FolderIconView can be seen morphing into the icon shape.
float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
return new FloatingViewHomeAnimationFactory(floatingIconView) {
// There is a delay in loading the icon, so we need to keep the window
// opaque until it is ready.
private boolean mIsFloatingIconReady = false;
@Override
public RectF getWindowTargetRect() {
super.getWindowTargetRect();
return iconLocation;
}
@Override
public void setAnimation(RectFSpringAnim anim) {
super.setAnimation(anim);
anim.addAnimatorListener(floatingIconView);
floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
floatingIconView.setFastFinishRunnable(anim::end);
}
@Override
public boolean keepWindowOpaque() {
if (mIsFloatingIconReady || floatingIconView.isVisibleToUser()) {
mIsFloatingIconReady = true;
return false;
}
return true;
}
@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, windowAlphaThreshold, radius, false);
}
};
}
use of com.android.quickstep.util.RectFSpringAnim in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method createWindowAnimationToHome.
/**
* Creates an animation that transforms the current app window into the home app.
* @param startProgress The progress of {@link #mCurrentShift} to start the window from.
* @param homeAnimationFactory The home animation factory.
*/
@Override
protected RectFSpringAnim createWindowAnimationToHome(float startProgress, HomeAnimationFactory homeAnimationFactory) {
RectFSpringAnim anim = super.createWindowAnimationToHome(startProgress, homeAnimationFactory);
setupWindowAnimation(anim);
return anim;
}
use of com.android.quickstep.util.RectFSpringAnim in project android_packages_apps_Launcher3 by crdroidandroid.
the class AbsSwipeUpHandler method animateToProgressInternal.
@UiThread
private void animateToProgressInternal(float start, float end, long duration, Interpolator interpolator, GestureEndTarget target, PointF velocityPxPerMs) {
maybeUpdateRecentsAttachedState();
// the transition is in progress
if (mGestureState.getEndTarget().isLauncher) {
TaskStackChangeListeners.getInstance().registerTaskStackListener(mActivityRestartListener);
mParallelRunningAnim = mActivityInterface.getParallelAnimationToLauncher(mGestureState.getEndTarget(), duration);
if (mParallelRunningAnim != null) {
mParallelRunningAnim.start();
}
}
if (mGestureState.getEndTarget() == HOME) {
getOrientationHandler().adjustFloatingIconStartVelocity(velocityPxPerMs);
final RemoteAnimationTargetCompat runningTaskTarget = mRecentsAnimationTargets != null ? mRecentsAnimationTargets.findTask(mGestureState.getRunningTaskId()) : null;
final ArrayList<IBinder> cookies = runningTaskTarget != null ? runningTaskTarget.taskInfo.launchCookies : new ArrayList<>();
boolean isTranslucent = runningTaskTarget != null && runningTaskTarget.isTranslucent;
boolean appCanEnterPip = !mDeviceState.isPipActive() && runningTaskTarget != null && runningTaskTarget.taskInfo.pictureInPictureParams != null && runningTaskTarget.taskInfo.pictureInPictureParams.isAutoEnterEnabled();
HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(cookies, duration, isTranslucent, appCanEnterPip, runningTaskTarget);
mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome() && appCanEnterPip;
final RectFSpringAnim windowAnim;
if (mIsSwipingPipToHome) {
mSwipePipToHomeAnimator = createWindowAnimationToPip(homeAnimFactory, runningTaskTarget, start);
windowAnim = mSwipePipToHomeAnimator;
} else {
mSwipePipToHomeAnimator = null;
windowAnim = createWindowAnimationToHome(start, homeAnimFactory);
windowAnim.addAnimatorListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
if (mRecentsAnimationController == null) {
// we can skip doing any future work here for the current gesture.
return;
}
// Finalize the state and notify of the change
mGestureState.setState(STATE_END_TARGET_ANIMATION_FINISHED);
}
});
}
windowAnim.start(mContext, velocityPxPerMs);
mRunningWindowAnim = RunningWindowAnim.wrap(windowAnim);
homeAnimFactory.setSwipeVelocity(velocityPxPerMs.y);
homeAnimFactory.playAtomicAnimation(velocityPxPerMs.y);
mLauncherTransitionController = null;
if (mRecentsView != null) {
mRecentsView.onPrepareGestureEndAnimation(null, mGestureState.getEndTarget());
}
} else {
AnimatorSet animatorSet = new AnimatorSet();
ValueAnimator windowAnim = mCurrentShift.animateToValue(start, end);
windowAnim.addUpdateListener(valueAnimator -> {
computeRecentsScrollIfInvisible();
});
windowAnim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
if (mRecentsAnimationController == null) {
// skip doing any future work here for the current gesture.
return;
}
if (mRecentsView != null) {
int taskToLaunch = mRecentsView.getNextPage();
int runningTask = getLastAppearedTaskIndex();
boolean hasStartedNewTask = hasStartedNewTask();
if (target == NEW_TASK && taskToLaunch == runningTask && !hasStartedNewTask) {
// We are about to launch the current running task, so use LAST_TASK
// state instead of NEW_TASK. This could happen, for example, if our
// scroll is aborted after we determined the target to be NEW_TASK.
mGestureState.setEndTarget(LAST_TASK);
} else if (target == LAST_TASK && hasStartedNewTask) {
// We are about to re-launch the previously running task, but we can't
// just finish the controller like we normally would because that would
// instead resume the last task that appeared, and not ensure that this
// task is restored to the top. To address this, re-launch the task as
// if it were a new task.
mGestureState.setEndTarget(NEW_TASK);
}
}
mGestureState.setState(STATE_END_TARGET_ANIMATION_FINISHED);
}
});
animatorSet.play(windowAnim);
if (mRecentsView != null) {
mRecentsView.onPrepareGestureEndAnimation(animatorSet, mGestureState.getEndTarget());
}
animatorSet.setDuration(duration).setInterpolator(interpolator);
animatorSet.start();
mRunningWindowAnim = RunningWindowAnim.wrap(animatorSet);
}
}
use of com.android.quickstep.util.RectFSpringAnim in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherSwipeHandlerV2 method createWidgetHomeAnimationFactory.
private HomeAnimationFactory createWidgetHomeAnimationFactory(LauncherAppWidgetHostView hostView, boolean isTargetTranslucent, RemoteAnimationTargetCompat runningTaskTarget) {
final float floatingWidgetAlpha = isTargetTranslucent ? 0 : 1;
RectF backgroundLocation = new RectF();
Rect crop = new Rect();
mTaskViewSimulator.getCurrentCropRect().roundOut(crop);
Size windowSize = new Size(crop.width(), crop.height());
int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mContext, runningTaskTarget);
FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity, hostView, backgroundLocation, windowSize, mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent, fallbackBackgroundColor);
return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
@Override
@Nullable
protected View getViewIgnoredInWorkspaceRevealAnimation() {
return hostView;
}
@Override
public RectF getWindowTargetRect() {
super.getWindowTargetRect();
return backgroundLocation;
}
@Override
public float getEndRadius(RectF cropRectF) {
return floatingWidgetView.getInitialCornerRadius();
}
@Override
public void setAnimation(RectFSpringAnim anim) {
super.setAnimation(anim);
anim.addAnimatorListener(floatingWidgetView);
floatingWidgetView.setOnTargetChangeListener(anim::onTargetPositionChanged);
floatingWidgetView.setFastFinishRunnable(anim::end);
}
@Override
public boolean keepWindowOpaque() {
return false;
}
@Override
public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, float radius) {
super.update(config, currentRect, progress, radius);
final float fallbackBackgroundAlpha = 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE);
final float foregroundAlpha = mapBoundToRange(progress, 0.5f, 1, 0, 1, EXAGGERATED_EASE);
floatingWidgetView.update(currentRect, floatingWidgetAlpha, foregroundAlpha, fallbackBackgroundAlpha, 1 - progress);
}
@Override
protected float getWindowAlpha(float progress) {
return 1 - mapBoundToRange(progress, 0, 0.5f, 0, 1, LINEAR);
}
};
}
use of com.android.quickstep.util.RectFSpringAnim in project android_packages_apps_Launcher3 by crdroidandroid.
the class SwipeUpAnimationLogic method createWindowAnimationToHome.
/**
* Creates an animation that transforms the current app window into the home app.
* @param startProgress The progress of {@link #mCurrentShift} to start the window from.
* @param homeAnimationFactory The home animation factory.
*/
protected RectFSpringAnim createWindowAnimationToHome(float startProgress, HomeAnimationFactory homeAnimationFactory) {
final RectF targetRect = homeAnimationFactory.getWindowTargetRect();
Matrix homeToWindowPositionMap = new Matrix();
final RectF startRect = updateProgressForStartRect(homeToWindowPositionMap, startProgress);
RectF cropRectF = new RectF(mTaskViewSimulator.getCurrentCropRect());
// Move the startRect to Launcher space as floatingIconView runs in Launcher
Matrix windowToHomePositionMap = new Matrix();
homeToWindowPositionMap.invert(windowToHomePositionMap);
windowToHomePositionMap.mapRect(startRect);
RectFSpringAnim anim;
if (PROTOTYPE_APP_CLOSE.get()) {
anim = new RectFSpringAnim2(startRect, targetRect, mContext, mTaskViewSimulator.getCurrentCornerRadius(), homeAnimationFactory.getEndRadius(cropRectF));
} else {
anim = new RectFSpringAnim(startRect, targetRect, mContext);
}
homeAnimationFactory.setAnimation(anim);
SpringAnimationRunner runner = new SpringAnimationRunner(homeAnimationFactory, cropRectF, homeToWindowPositionMap);
anim.addOnUpdateListener(runner);
anim.addAnimatorListener(runner);
return anim;
}
Aggregations