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