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;
}
Aggregations