use of com.android.quickstep.util.ClipAnimationHelper in project Neo-Launcher by NeoApplications.
the class TaskViewUtils method getRecentsWindowAnimator.
/**
* @return Animator that controls the window of the opening targets for the recents launch
* animation.
*/
public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges, RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
SyncRtSurfaceTransactionApplierCompat applier = new SyncRtSurfaceTransactionApplierCompat(v);
ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams().setSyncTransactionApplier(applier);
final RemoteAnimationTargetSet targetSet = new RemoteAnimationTargetSet(targets, MODE_OPENING);
targetSet.addDependentTransactionApplier(applier);
final RecentsView recentsView = v.getRecentsView();
final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
// Defer fading out the view until after the app window gets faded in
final FloatProp mViewAlpha = new FloatProp(1f, 0f, 75, 75, LINEAR);
final FloatProp mTaskAlpha = new FloatProp(0f, 1f, 0, 75, LINEAR);
final RectF mThumbnailRect;
{
inOutHelper.setTaskAlphaCallback((t, alpha) -> mTaskAlpha.value);
inOutHelper.prepareAnimation(BaseActivity.fromContext(v.getContext()).getDeviceProfile(), true);
inOutHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), targetSet.apps.length == 0 ? null : targetSet.apps[0]);
mThumbnailRect = new RectF(inOutHelper.getTargetRect());
mThumbnailRect.offset(-v.getTranslationX(), -v.getTranslationY());
Utilities.scaleRectFAboutCenter(mThumbnailRect, 1 / v.getScaleX());
}
@Override
public void onUpdate(float percent) {
// TODO: Take into account the current fullscreen progress for animating the insets
params.setProgress(1 - percent);
RectF taskBounds = inOutHelper.applyTransform(targetSet, params);
int taskIndex = recentsView.indexOfChild(v);
int centerTaskIndex = recentsView.getCurrentPage();
boolean parallaxCenterAndAdjacentTask = taskIndex != centerTaskIndex;
if (!skipViewChanges && parallaxCenterAndAdjacentTask) {
float scale = taskBounds.width() / mThumbnailRect.width();
v.setScaleX(scale);
v.setScaleY(scale);
v.setTranslationX(taskBounds.centerX() - mThumbnailRect.centerX());
v.setTranslationY(taskBounds.centerY() - mThumbnailRect.centerY());
v.setAlpha(mViewAlpha.value);
}
}
});
appAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
targetSet.release();
}
});
return appAnimator;
}
use of com.android.quickstep.util.ClipAnimationHelper in project Neo-Launcher by NeoApplications.
the class RecentsActivity method composeRecentsLaunchAnimator.
/**
* Composes the animations for a launch from the recents list if possible.
*/
private AnimatorSet composeRecentsLaunchAnimator(TaskView taskView, RemoteAnimationTargetCompat[] targets) {
AnimatorSet target = new AnimatorSet();
boolean activityClosing = taskIsATargetWithMode(targets, getTaskId(), MODE_CLOSING);
ClipAnimationHelper helper = new ClipAnimationHelper(this);
target.play(getRecentsWindowAnimator(taskView, !activityClosing, targets, helper).setDuration(RECENTS_LAUNCH_DURATION));
// Found a visible recents task that matches the opening app, lets launch the app from there
if (activityClosing) {
Animator adjacentAnimation = mFallbackRecentsView.createAdjacentPageAnimForTaskLaunch(taskView, helper);
adjacentAnimation.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
adjacentAnimation.setDuration(RECENTS_LAUNCH_DURATION);
adjacentAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mFallbackRecentsView.resetTaskVisuals();
}
});
target.play(adjacentAnimation);
}
return target;
}
use of com.android.quickstep.util.ClipAnimationHelper in project Neo-Launcher by NeoApplications.
the class RecentsView method createTaskLauncherAnimation.
public PendingAnimation createTaskLauncherAnimation(TaskView tv, long duration) {
if (FeatureFlags.IS_DOGFOOD_BUILD && mPendingAnimation != null) {
throw new IllegalStateException("Another pending animation is still running");
}
int count = getTaskViewCount();
if (count == 0) {
return new PendingAnimation(new AnimatorSet());
}
int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
final boolean[] passedOverviewThreshold = new boolean[] { false };
ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
progressAnim.setInterpolator(LINEAR);
progressAnim.addUpdateListener(animator -> {
// Once we pass a certain threshold, update the sysui flags to match the target
// tasks' flags
mActivity.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD ? targetSysUiFlags : 0);
onTaskLaunchAnimationUpdate(animator.getAnimatedFraction(), tv);
// Passing the threshold from taskview to fullscreen app will vibrate
final boolean passed = animator.getAnimatedFraction() >= SUCCESS_TRANSITION_PROGRESS;
if (passed != passedOverviewThreshold[0]) {
passedOverviewThreshold[0] = passed;
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
});
ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(mActivity);
clipAnimationHelper.fromTaskThumbnailView(tv.getThumbnail(), this);
clipAnimationHelper.prepareAnimation(mActivity.getDeviceProfile(), true);
AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv, clipAnimationHelper);
anim.play(progressAnim);
anim.setDuration(duration);
Consumer<Boolean> onTaskLaunchFinish = this::onTaskLaunched;
mPendingAnimation = new PendingAnimation(anim);
mPendingAnimation.addEndListener((onEndListener) -> {
if (onEndListener.isSuccess) {
Consumer<Boolean> onLaunchResult = (result) -> {
onTaskLaunchFinish.accept(result);
if (!result) {
tv.notifyTaskLaunchFailed(TAG);
}
};
tv.launchTask(false, onLaunchResult, getHandler());
Task task = tv.getTask();
if (task != null) {
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(onEndListener.logAction, Direction.DOWN, indexOfChild(tv), TaskUtils.getLaunchComponentKeyForTask(task.key));
}
} else {
onTaskLaunchFinish.accept(false);
}
mPendingAnimation = null;
});
return mPendingAnimation;
}
use of com.android.quickstep.util.ClipAnimationHelper in project Neo-Launcher by NeoApplications.
the class AppToOverviewAnimationProvider method createWindowAnimation.
/**
* Create remote window animation from the currently running app to the overview panel.
*
* @param targetCompats the target apps
* @return animation from app to overview
*/
@Override
public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targetCompats) {
if (mRecentsView != null) {
mRecentsView.setRunningTaskIconScaledDown(true);
}
AnimatorSet anim = new AnimatorSet();
anim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mHelper.onSwipeUpToRecentsComplete(mActivity);
if (mRecentsView != null) {
mRecentsView.animateUpRunningTaskIconScale();
}
}
});
if (mActivity == null) {
Log.e(TAG, "Animation created, before activity");
anim.play(ValueAnimator.ofInt(0, 1).setDuration(RECENTS_LAUNCH_DURATION));
return anim;
}
RemoteAnimationTargetSet targetSet = new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING);
// Use the top closing app to determine the insets for the animation
RemoteAnimationTargetCompat runningTaskTarget = targetSet.findTask(mTargetTaskId);
if (runningTaskTarget == null) {
Log.e(TAG, "No closing app");
anim.play(ValueAnimator.ofInt(0, 1).setDuration(RECENTS_LAUNCH_DURATION));
return anim;
}
final ClipAnimationHelper clipHelper = new ClipAnimationHelper(mActivity);
// At this point, the activity is already started and laid-out. Get the home-bounds
// relative to the screen using the rootView of the activity.
int[] loc = new int[2];
View rootView = mActivity.getRootView();
rootView.getLocationOnScreen(loc);
Rect homeBounds = new Rect(loc[0], loc[1], loc[0] + rootView.getWidth(), loc[1] + rootView.getHeight());
clipHelper.updateSource(homeBounds, runningTaskTarget);
Rect targetRect = new Rect();
mHelper.getSwipeUpDestinationAndLength(mActivity.getDeviceProfile(), mActivity, targetRect);
clipHelper.updateTargetRect(targetRect);
clipHelper.prepareAnimation(mActivity.getDeviceProfile(), false);
ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams().setSyncTransactionApplier(new SyncRtSurfaceTransactionApplierCompat(rootView));
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
valueAnimator.addUpdateListener((v) -> {
params.setProgress((float) v.getAnimatedValue());
clipHelper.applyTransform(targetSet, params);
});
if (targetSet.isAnimatingHome()) {
// If we are animating home, fade in the opening targets
RemoteAnimationTargetSet openingSet = new RemoteAnimationTargetSet(targetCompats, MODE_OPENING);
TransactionCompat transaction = new TransactionCompat();
valueAnimator.addUpdateListener((v) -> {
for (RemoteAnimationTargetCompat app : openingSet.apps) {
transaction.setAlpha(app.leash, (float) v.getAnimatedValue());
}
transaction.apply();
});
}
anim.play(valueAnimator);
return anim;
}
use of com.android.quickstep.util.ClipAnimationHelper in project Neo-Launcher by NeoApplications.
the class LauncherAppTransitionManagerImpl method composeRecentsLaunchAnimator.
@Override
protected void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, @NonNull RemoteAnimationTargetCompat[] targets, boolean launcherClosing) {
RecentsView recentsView = mLauncher.getOverviewPanel();
boolean skipLauncherChanges = !launcherClosing;
TaskView taskView = findTaskViewToLaunch(mLauncher, v, targets);
ClipAnimationHelper helper = new ClipAnimationHelper(mLauncher);
anim.play(getRecentsWindowAnimator(taskView, skipLauncherChanges, targets, helper).setDuration(RECENTS_LAUNCH_DURATION));
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) {
launcherAnim = recentsView.createAdjacentPageAnimForTaskLaunch(taskView, helper);
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) {
mLauncher.getStateManager().moveToRestState();
mLauncher.getStateManager().reapplyState();
}
};
} else {
AnimatorPlaybackController controller = mLauncher.getStateManager().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) {
mLauncher.getStateManager().goToState(NORMAL, false);
}
};
}
anim.play(launcherAnim);
// 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).
mLauncher.getStateManager().setCurrentAnimation(anim, childStateAnimation);
anim.addListener(windowAnimEndListener);
}
Aggregations