use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.
the class StateManager method createAnimationToNewWorkspace.
public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state, long duration, @AnimationFlags int animFlags) {
StateAnimationConfig config = new StateAnimationConfig();
config.duration = duration;
config.animFlags = animFlags;
return createAnimationToNewWorkspace(state, config);
}
use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.
the class NoButtonQuickSwitchTouchController method setupOverviewAnimators.
private void setupOverviewAnimators() {
final LauncherState fromState = QUICK_SWITCH;
final LauncherState toState = OVERVIEW;
// Set RecentView's initial properties.
RECENTS_SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
ADJACENT_PAGE_HORIZONTAL_OFFSET.set(mRecentsView, 1f);
mRecentsView.setContentAlpha(1);
mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
mLauncher.getActionsView().getVisibilityAlpha().setValue((fromState.getVisibleElements(mLauncher) & OVERVIEW_ACTIONS) != 0 ? 1f : 0f);
float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
// As we drag right, animate the following properties:
// - RecentsView translationX
// - OverviewScrim
// - RecentsView fade (if it's empty)
PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
xAnim.setViewBackgroundColor(mLauncher.getScrimView(), toState.getWorkspaceScrimColor(mLauncher), LINEAR);
if (mRecentsView.getTaskViewCount() == 0) {
xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
}
mXOverviewAnim = xAnim.createPlaybackController();
mXOverviewAnim.dispatchOnStart();
// As we drag up, animate the following properties:
// - RecentsView scale
// - RecentsView fullscreenProgress
PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
yAnim.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
AnimatorPlaybackController yNormalController = yAnim.createPlaybackController();
AnimatorControllerWithResistance yAnimWithResistance = AnimatorControllerWithResistance.createForRecents(yNormalController, mLauncher, mRecentsView.getPagedViewOrientedState(), mLauncher.getDeviceProfile(), mRecentsView, RECENTS_SCALE_PROPERTY, mRecentsView, TASK_SECONDARY_TRANSLATION);
mYOverviewAnim = new AnimatedFloat(() -> {
if (mYOverviewAnim != null) {
yAnimWithResistance.setProgress(mYOverviewAnim.value, mMaxYProgress);
}
});
yNormalController.dispatchOnStart();
}
use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherSwipeHandlerV2 method createHomeAnimationFactory.
@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent, boolean appCanEnterPip, RemoteAnimationTargetCompat runningTaskTarget) {
if (mActivity == null) {
mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED, isPresent -> mRecentsView.startHome());
return new HomeAnimationFactory() {
@Override
public AnimatorPlaybackController createActivityAnimationToHome() {
return AnimatorPlaybackController.wrap(new AnimatorSet(), duration);
}
};
}
final View workspaceView = findWorkspaceView(launchCookies, mRecentsView.getRunningTaskView());
boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
mActivity.getRootView().setForceHideBackArrow(true);
mActivity.setHintUserWillBeActive();
if (!canUseWorkspaceView || appCanEnterPip) {
return new LauncherHomeAnimationFactory();
}
if (workspaceView instanceof LauncherAppWidgetHostView) {
return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView, isTargetTranslucent, runningTaskTarget);
}
return createIconHomeAnimationFactory(workspaceView);
}
use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.
the class SwipeUpAnimationLogic method initTransitionEndpoints.
protected void initTransitionEndpoints(DeviceProfile dp) {
mDp = dp;
mTaskViewSimulator.setDp(dp);
mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, mTaskViewSimulator.getOrientationState().getOrientationHandler());
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
PendingAnimation pa = new PendingAnimation(mTransitionDragLength * 2);
mTaskViewSimulator.addAppToOverviewAnim(pa, LINEAR);
AnimatorPlaybackController normalController = pa.createPlaybackController();
mWindowTransitionController = AnimatorControllerWithResistance.createForRecents(normalController, mContext, mTaskViewSimulator.getOrientationState(), mDp, mTaskViewSimulator.recentsViewScale, AnimatedFloat.VALUE, mTaskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE);
}
use of com.android.launcher3.anim.AnimatorPlaybackController in project android_packages_apps_Launcher3 by crdroidandroid.
the class AllAppsEduView method playAnimation.
private void playAnimation() {
if (mAnimation != null) {
return;
}
mAnimation = new AnimatorSet();
final Rect circleBoundsOg = new Rect(mCircle.getBounds());
final Rect gradientBoundsOg = new Rect(mGradient.getBounds());
final Rect temp = new Rect();
final float transY = mMaxHeightPx - mCircleSizePx - mPaddingPx;
// 1st: Circle alpha/scale
int firstPart = 600;
// 2nd: Circle animates upwards, Gradient alpha fades in, Gradient grows, All Apps hint
int secondPart = 1200;
int introDuration = firstPart + secondPart;
AnimatorPlaybackController stateAnimationController = mTouchController.initAllAppsAnimation();
float maxAllAppsProgress = 0.75f;
ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
intro.setInterpolator(LINEAR);
intro.setDuration(introDuration);
intro.addUpdateListener((new MultiValueUpdateListener() {
FloatProp mCircleAlpha = new FloatProp(0, 255, 0, firstPart, LINEAR);
FloatProp mCircleScale = new FloatProp(2f, 1f, 0, firstPart, OVERSHOOT_1_7);
FloatProp mDeltaY = new FloatProp(0, transY, firstPart, secondPart, FAST_OUT_SLOW_IN);
FloatProp mGradientAlpha = new FloatProp(0, 255, firstPart, secondPart * 0.3f, LINEAR);
@Override
public void onUpdate(float progress, boolean initOnly) {
temp.set(circleBoundsOg);
temp.offset(0, (int) -mDeltaY.value);
Utilities.scaleRectAboutCenter(temp, mCircleScale.value);
mCircle.setBounds(temp);
mCircle.setAlpha((int) mCircleAlpha.value);
mGradient.setAlpha((int) mGradientAlpha.value);
temp.set(gradientBoundsOg);
temp.top -= mDeltaY.value;
mGradient.setBounds(temp);
invalidate();
float stateProgress = Utilities.mapToRange(mDeltaY.value, 0, transY, 0, maxAllAppsProgress, LINEAR);
stateAnimationController.setPlayFraction(stateProgress);
}
}));
intro.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCircle.setAlpha(0);
mGradient.setAlpha(0);
}
});
mLauncher.getAppsView().setVisibility(View.VISIBLE);
mAnimation.play(intro);
ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
closeAllApps.addUpdateListener(valueAnimator -> {
stateAnimationController.setPlayFraction((float) valueAnimator.getAnimatedValue());
});
closeAllApps.setInterpolator(FAST_OUT_SLOW_IN);
closeAllApps.setStartDelay(introDuration);
closeAllApps.setDuration(250);
mAnimation.play(closeAllApps);
mAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mAnimation = null;
// Handles cancelling the animation used to hint towards All Apps.
mLauncher.getStateManager().goToState(NORMAL, false);
handleClose(false);
}
});
mAnimation.start();
}
Aggregations