Search in sources :

Example 11 with TOUCH_RESPONSE_INTERPOLATOR

use of com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR in project android_packages_apps_Trebuchet by LineageOS.

the class AppToOverviewAnimationProvider method createWindowAnimation.

/**
 * Create remote window animation from the currently running app to the overview panel.
 *
 * @param appTargets the target apps
 * @return animation from app to overview
 */
@Override
public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets) {
    PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    if (mActivity == null) {
        Log.e(TAG, "Animation created, before activity");
        return pa.buildAnim();
    }
    mRecentsView.setRunningTaskIconScaledDown(true);
    pa.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            mActivityInterface.onSwipeUpToRecentsComplete();
            mRecentsView.animateUpRunningTaskIconScale();
        }
    });
    DepthController depthController = mActivityInterface.getDepthController();
    if (depthController != null) {
        pa.addFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mActivity), OVERVIEW.getDepth(mActivity), TOUCH_RESPONSE_INTERPOLATOR);
    }
    RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, MODE_CLOSING);
    // Use the top closing app to determine the insets for the animation
    RemoteAnimationTargetCompat runningTaskTarget = mTargetTask == null ? null : targets.findTask(mTargetTask.taskId);
    if (runningTaskTarget == null) {
        Log.e(TAG, "No closing app");
        return pa.buildAnim();
    }
    TaskViewSimulator tsv = new TaskViewSimulator(mActivity, mRecentsView.getSizeStrategy());
    tsv.setDp(mActivity.getDeviceProfile());
    tsv.setPreview(runningTaskTarget);
    tsv.setLayoutRotation(mRecentsView.getPagedViewOrientedState().getTouchRotation(), mRecentsView.getPagedViewOrientedState().getDisplayRotation());
    TransformParams params = new TransformParams().setTargetSet(targets).setSyncTransactionApplier(new SurfaceTransactionApplier(mActivity.getRootView()));
    AnimatedFloat recentsAlpha = new AnimatedFloat(() -> {
    });
    params.setBaseBuilderProxy((builder, app, p) -> builder.withAlpha(recentsAlpha.value));
    Interpolator taskInterpolator;
    if (targets.isAnimatingHome()) {
        params.setHomeBuilderProxy((builder, app, p) -> builder.withAlpha(1 - p.getProgress()));
        taskInterpolator = TOUCH_RESPONSE_INTERPOLATOR;
        pa.addFloat(recentsAlpha, AnimatedFloat.VALUE, 0, 1, TOUCH_RESPONSE_INTERPOLATOR);
    } else {
        // When animation from app to recents, the recents layer is drawn on top of the app. To
        // prevent the overlap, we animate the task first and then quickly fade in the recents.
        taskInterpolator = clampToProgress(TOUCH_RESPONSE_INTERPOLATOR, 0, 0.8f);
        pa.addFloat(recentsAlpha, AnimatedFloat.VALUE, 0, 1, clampToProgress(TOUCH_RESPONSE_INTERPOLATOR, 0.8f, 1));
    }
    pa.addFloat(params, TransformParams.PROGRESS, 0, 1, taskInterpolator);
    tsv.addAppToOverviewAnim(pa, taskInterpolator);
    pa.addOnFrameCallback(() -> tsv.apply(params));
    return pa.buildAnim();
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Animator(android.animation.Animator) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) TransformParams(com.android.quickstep.util.TransformParams) Interpolator(android.view.animation.Interpolator) DepthController(com.android.launcher3.statehandlers.DepthController) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Aggregations

Animator (android.animation.Animator)9 RecentsView (com.android.quickstep.views.RecentsView)9 SurfaceTransactionApplier (com.android.quickstep.util.SurfaceTransactionApplier)8 TaskViewSimulator (com.android.quickstep.util.TaskViewSimulator)8 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)8 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 Context (android.content.Context)7 Rect (android.graphics.Rect)7 RectF (android.graphics.RectF)7 DeviceProfile (com.android.launcher3.DeviceProfile)7 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)7 ValueAnimator (android.animation.ValueAnimator)6 Matrix (android.graphics.Matrix)6 MultiValueUpdateListener (com.android.quickstep.util.MultiValueUpdateListener)6 TaskThumbnailView (com.android.quickstep.views.TaskThumbnailView)6 ObjectAnimator (android.animation.ObjectAnimator)5 SurfaceParams (com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)5 RemoteTargetHandle (com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle)4 TransformParams (com.android.quickstep.util.TransformParams)4 PendingAnimation (com.android.launcher3.anim.PendingAnimation)3