Search in sources :

Example 1 with ACCEL_1_5

use of com.android.launcher3.anim.Interpolators.ACCEL_1_5 in project Neo-Launcher by NeoApplications.

the class BaseSwipeUpHandler 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 RemoteAnimationTargetSet targetSet = mRecentsAnimationWrapper.targetSet;
    final RectF startRect = new RectF(mClipAnimationHelper.applyTransform(targetSet, mTransformParams.setProgress(startProgress), false));
    final RectF targetRect = homeAnimationFactory.getWindowTargetRect();
    final View floatingView = homeAnimationFactory.getFloatingView();
    final boolean isFloatingIconView = floatingView instanceof FloatingIconView;
    RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mContext.getResources());
    if (isFloatingIconView) {
        FloatingIconView fiv = (FloatingIconView) floatingView;
        anim.addAnimatorListener(fiv);
        fiv.setOnTargetChangeListener(anim::onTargetPositionChanged);
    }
    AnimatorPlaybackController homeAnim = homeAnimationFactory.createActivityAnimationToHome();
    // 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.
    float startRadius = mClipAnimationHelper.getCurrentCornerRadius();
    float endRadius = startRect.width() / 6f;
    // 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.
    final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
    anim.addOnUpdateListener(new RectFSpringAnim.OnUpdateListener() {

        // Alpha interpolates between [1, 0] between progress values [start, end]
        final float start = 0f;

        final float end = 0.85f;

        private float getWindowAlpha(float progress) {
            if (progress <= start) {
                return 1f;
            }
            if (progress >= end) {
                return 0f;
            }
            return Utilities.mapToRange(progress, start, end, 1, 0, ACCEL_1_5);
        }

        @Override
        public void onUpdate(RectF currentRect, float progress) {
            homeAnim.setPlayFraction(progress);
            mTransformParams.setProgress(progress).setCurrentRectAndTargetAlpha(currentRect, getWindowAlpha(progress));
            if (isFloatingIconView) {
                mTransformParams.setCornerRadius(endRadius * progress + startRadius * (1f - progress));
            }
            mClipAnimationHelper.applyTransform(targetSet, mTransformParams, false);
            if (isFloatingIconView) {
                ((FloatingIconView) floatingView).update(currentRect, 1f, progress, windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
            }
        }

        @Override
        public void onCancel() {
            if (isFloatingIconView) {
                ((FloatingIconView) floatingView).fastFinish();
            }
        }
    });
    anim.addAnimatorListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            homeAnim.dispatchOnStart();
        }

        @Override
        public void onAnimationSuccess(Animator animator) {
            homeAnim.getAnimationPlayer().end();
        }
    });
    return anim;
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) View(android.view.View) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskView(com.android.quickstep.views.TaskView) RecentsView(com.android.quickstep.views.RecentsView) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) Animator(android.animation.Animator) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Aggregations

Animator (android.animation.Animator)1 RectF (android.graphics.RectF)1 View (android.view.View)1 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)1 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)1 FloatingIconView (com.android.launcher3.views.FloatingIconView)1 RectFSpringAnim (com.android.quickstep.util.RectFSpringAnim)1 RemoteAnimationTargetSet (com.android.quickstep.util.RemoteAnimationTargetSet)1 RecentsView (com.android.quickstep.views.RecentsView)1 TaskView (com.android.quickstep.views.TaskView)1