Search in sources :

Example 1 with SwipePipToHomeAnimator

use of com.android.quickstep.util.SwipePipToHomeAnimator 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)

Aggregations

Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ValueAnimator (android.animation.ValueAnimator)1 ActivityManager (android.app.ActivityManager)1 Matrix (android.graphics.Matrix)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)1 RecentsOrientedState (com.android.quickstep.util.RecentsOrientedState)1 SwipePipToHomeAnimator (com.android.quickstep.util.SwipePipToHomeAnimator)1