Search in sources :

Example 1 with AnimatorPlaybackController

use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method createWindowAnimationToPip.

private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory, RemoteAnimationTargetCompat runningTaskTarget, float startProgress) {
    // Directly animate the app to PiP (picture-in-picture) mode
    final ActivityManager.RunningTaskInfo taskInfo = mGestureState.getRunningTask();
    final RecentsOrientedState orientationState = mTaskViewSimulator.getOrientationState();
    final int windowRotation = orientationState.getDisplayRotation();
    final int homeRotation = orientationState.getRecentsActivityRotation();
    final Matrix homeToWindowPositionMap = new Matrix();
    final RectF startRect = updateProgressForStartRect(homeToWindowPositionMap, startProgress);
    // Move the startRect to Launcher space as floatingIconView runs in Launcher
    final Matrix windowToHomePositionMap = new Matrix();
    homeToWindowPositionMap.invert(windowToHomePositionMap);
    windowToHomePositionMap.mapRect(startRect);
    final Rect destinationBounds = SystemUiProxy.INSTANCE.get(mContext).startSwipePipToHome(taskInfo.topActivity, taskInfo.topActivityInfo, runningTaskTarget.taskInfo.pictureInPictureParams, homeRotation, mDp.hotseatBarSizePx);
    final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder().setContext(mContext).setTaskId(runningTaskTarget.taskId).setComponentName(taskInfo.topActivity).setLeash(runningTaskTarget.leash.getSurfaceControl()).setSourceRectHint(runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint()).setAppBounds(taskInfo.configuration.windowConfiguration.getBounds()).setHomeToWindowPositionMap(homeToWindowPositionMap).setStartBounds(startRect).setDestinationBounds(destinationBounds).setCornerRadius(mRecentsView.getPipCornerRadius()).setAttachedView(mRecentsView);
    // is not ROTATION_0 (which implies the rotation is turned on in launcher settings).
    if (homeRotation == ROTATION_0 && (windowRotation == ROTATION_90 || windowRotation == ROTATION_270)) {
        builder.setFromRotation(mTaskViewSimulator, windowRotation, taskInfo.displayCutoutInsets);
    }
    final SwipePipToHomeAnimator swipePipToHomeAnimator = builder.build();
    AnimatorPlaybackController activityAnimationToHome = homeAnimFactory.createActivityAnimationToHome();
    swipePipToHomeAnimator.addAnimatorListener(new AnimatorListenerAdapter() {

        private boolean mHasAnimationEnded;

        @Override
        public void onAnimationStart(Animator animation) {
            if (mHasAnimationEnded)
                return;
            // Ensure Launcher ends in NORMAL state
            activityAnimationToHome.dispatchOnStart();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mHasAnimationEnded)
                return;
            mHasAnimationEnded = true;
            activityAnimationToHome.getAnimationPlayer().end();
            if (mRecentsAnimationController == null) {
                // 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);
        }
    });
    setupWindowAnimation(swipePipToHomeAnimator);
    return swipePipToHomeAnimator;
}
Also used : Rect(android.graphics.Rect) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState) ActivityManager(android.app.ActivityManager) RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) SwipePipToHomeAnimator(com.android.quickstep.util.SwipePipToHomeAnimator) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SwipePipToHomeAnimator(com.android.quickstep.util.SwipePipToHomeAnimator)

Example 2 with AnimatorPlaybackController

use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskViewUtils method composeRecentsLaunchAnimator.

public static void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, boolean launcherClosing, @NonNull StateManager stateManager, @NonNull RecentsView recentsView, @NonNull DepthController depthController) {
    boolean skipLauncherChanges = !launcherClosing;
    TaskView taskView = findTaskViewToLaunch(recentsView, v, appTargets);
    PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    createRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, wallpaperTargets, nonAppTargets, depthController, pa);
    Animator childStateAnimation = null;
    // Found a visible recents task that matches the opening app, lets launch the app from there
    Animator launcherAnim;
    final AnimatorListenerAdapter windowAnimEndListener;
    if (launcherClosing) {
        Context context = v.getContext();
        DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
        launcherAnim = dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() ? ObjectAnimator.ofFloat(recentsView, RecentsView.CONTENT_ALPHA, 0) : recentsView.createAdjacentPageAnimForTaskLaunch(taskView);
        launcherAnim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
        launcherAnim.setDuration(RECENTS_LAUNCH_DURATION);
        // Make sure recents gets fixed up by resetting task alphas and scales, etc.
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> {
                    recentsView.post(() -> {
                        stateManager.moveToRestState();
                        stateManager.reapplyState();
                    });
                });
            }
        };
    } else {
        AnimatorPlaybackController controller = stateManager.createAnimationToNewWorkspace(NORMAL, RECENTS_LAUNCH_DURATION);
        controller.dispatchOnStart();
        childStateAnimation = controller.getTarget();
        launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> stateManager.goToState(NORMAL, false));
            }
        };
    }
    pa.add(launcherAnim);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) {
        pa.addOnFrameCallback(recentsView::redrawLiveTile);
    }
    anim.play(pa.buildAnim());
    // Set the current animation first, before adding windowAnimEndListener. Setting current
    // animation adds some listeners which need to be called before windowAnimEndListener
    // (the ordering of listeners matter in this case).
    stateManager.setCurrentAnimation(anim, childStateAnimation);
    anim.addListener(windowAnimEndListener);
}
Also used : Context(android.content.Context) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DeviceProfile(com.android.launcher3.DeviceProfile) TaskView(com.android.quickstep.views.TaskView) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 3 with AnimatorPlaybackController

use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.

the class FallbackRecentsView method onPrepareGestureEndAnimation.

/**
 * When the gesture ends and we're going to recents view, we also remove the temporary
 * invisible tile added for the home task. This also pushes the remaining tiles back
 * to the center.
 */
@Override
public void onPrepareGestureEndAnimation(@Nullable AnimatorSet animatorSet, GestureState.GestureEndTarget endTarget) {
    super.onPrepareGestureEndAnimation(animatorSet, endTarget);
    if (mHomeTaskInfo != null && endTarget == RECENTS && animatorSet != null) {
        TaskView tv = getTaskView(mHomeTaskInfo.taskId);
        if (tv != null) {
            PendingAnimation pa = createTaskDismissAnimation(tv, true, false, 150);
            pa.addEndListener(e -> setCurrentTask(-1));
            AnimatorPlaybackController controller = pa.createPlaybackController();
            controller.dispatchOnStart();
            animatorSet.play(controller.getAnimationPlayer());
        }
    }
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) TaskView(com.android.quickstep.views.TaskView) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 4 with AnimatorPlaybackController

use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method runDismissAnimation.

private void runDismissAnimation(PendingAnimation pendingAnim) {
    AnimatorPlaybackController controller = pendingAnim.createPlaybackController();
    controller.dispatchOnStart();
    controller.getAnimationPlayer().setInterpolator(FAST_OUT_SLOW_IN);
    controller.start();
}
Also used : AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 5 with AnimatorPlaybackController

use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.

the class AnimatorControllerWithResistance method createForRecents.

/**
 * Applies resistance to recents when swiping up past its target position.
 * @param normalController The controller to run from 0 to 1 before this resistance applies.
 * @param context Used to compute start and end values.
 * @param recentsOrientedState Used to compute start and end values.
 * @param dp Used to compute start and end values.
 * @param scaleTarget The target for the scaleProperty.
 * @param scaleProperty Animate the value to change the scale of the window/recents view.
 * @param translationTarget The target for the translationProperty.
 * @param translationProperty Animate the value to change the translation of the recents view.
 */
public static <SCALE, TRANSLATION> AnimatorControllerWithResistance createForRecents(AnimatorPlaybackController normalController, Context context, RecentsOrientedState recentsOrientedState, DeviceProfile dp, SCALE scaleTarget, FloatProperty<SCALE> scaleProperty, TRANSLATION translationTarget, FloatProperty<TRANSLATION> translationProperty) {
    RecentsParams params = new RecentsParams(context, recentsOrientedState, dp, scaleTarget, scaleProperty, translationTarget, translationProperty);
    PendingAnimation resistAnim = createRecentsResistanceAnim(params);
    AnimatorPlaybackController resistanceController = resistAnim.createPlaybackController();
    return new AnimatorControllerWithResistance(normalController, resistanceController);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Aggregations

AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)8 PendingAnimation (com.android.launcher3.anim.PendingAnimation)5 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 TaskView (com.android.quickstep.views.TaskView)3 AnimatorSet (android.animation.AnimatorSet)2 ValueAnimator (android.animation.ValueAnimator)2 Rect (android.graphics.Rect)2 ObjectAnimator (android.animation.ObjectAnimator)1 ActivityManager (android.app.ActivityManager)1 Context (android.content.Context)1 Matrix (android.graphics.Matrix)1 RectF (android.graphics.RectF)1 View (android.view.View)1 DeviceProfile (com.android.launcher3.DeviceProfile)1 LauncherState (com.android.launcher3.LauncherState)1 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)1 FloatingIconView (com.android.launcher3.views.FloatingIconView)1 FloatingIconView.getFloatingIconView (com.android.launcher3.views.FloatingIconView.getFloatingIconView)1 FloatingView (com.android.launcher3.views.FloatingView)1