use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.
the class SwipeUpGestureTutorialController method resetFakeTaskView.
void resetFakeTaskView(boolean animateFromHome) {
mFakeTaskView.setVisibility(View.VISIBLE);
PendingAnimation anim = new PendingAnimation(300);
anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
anim.setViewAlpha(mFakeTaskView, 1, ACCEL);
anim.addListener(mResetTaskView);
AnimatorSet animset = anim.buildAnim();
showFakeTaskbar(animateFromHome);
animset.start();
mRunningWindowAnim = RunningWindowAnim.wrap(animset);
}
use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.
the class SwipeUpGestureTutorialController method fadeOutFakeTaskView.
/**
* Fades the task view, optionally after animating to a fake Overview.
*/
void fadeOutFakeTaskView(boolean toOverviewFirst, boolean reset, @Nullable Runnable onEndRunnable) {
cancelRunningAnimation();
PendingAnimation anim = new PendingAnimation(300);
if (toOverviewFirst) {
anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 1, ACCEL);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation, boolean isReverse) {
PendingAnimation fadeAnim = new PendingAnimation(TASK_VIEW_END_ANIMATION_DURATION_MILLIS);
if (reset) {
fadeAnim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
fadeAnim.addListener(mResetTaskView);
} else {
fadeAnim.setViewAlpha(mFakeTaskView, 0, ACCEL);
fadeAnim.setViewAlpha(mFakePreviousTaskView, 0, ACCEL);
}
if (onEndRunnable != null) {
fadeAnim.addListener(AnimatorListeners.forSuccessCallback(onEndRunnable));
}
AnimatorSet animset = fadeAnim.buildAnim();
if (reset && mTutorialFragment.isLargeScreen()) {
animset.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
Animator multiRowAnimation = mFakePreviousTaskView.createAnimationToMultiRowLayout();
if (multiRowAnimation != null) {
multiRowAnimation.setDuration(TASK_VIEW_END_ANIMATION_DURATION_MILLIS).start();
}
}
});
}
animset.setStartDelay(100);
animset.start();
mRunningWindowAnim = RunningWindowAnim.wrap(animset);
}
});
} else {
if (reset) {
anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
anim.addListener(mResetTaskView);
} else {
anim.setViewAlpha(mFakeTaskView, 0, ACCEL);
anim.setViewAlpha(mFakePreviousTaskView, 0, ACCEL);
}
if (onEndRunnable != null) {
anim.addListener(AnimatorListeners.forSuccessCallback(onEndRunnable));
}
}
AnimatorSet animset = anim.buildAnim();
hideFakeTaskbar(/* animateToHotseat= */
false);
animset.start();
mRunningWindowAnim = RunningWindowAnim.wrap(animset);
}
use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.
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);
}
use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.
the class AnimatorControllerWithResistance method createRecentsResistanceAnim.
/**
* Creates the resistance animation for {@link #createForRecents}, or can be used separately
* when starting from recents, i.e. {@link #createRecentsResistanceFromOverviewAnim}.
*/
public static <SCALE, TRANSLATION> PendingAnimation createRecentsResistanceAnim(RecentsParams<SCALE, TRANSLATION> params) {
Rect startRect = new Rect();
PagedOrientationHandler orientationHandler = params.recentsOrientedState.getOrientationHandler();
LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect);
long distanceToCover = startRect.bottom;
PendingAnimation resistAnim = params.resistAnim != null ? params.resistAnim : new PendingAnimation(distanceToCover * 2);
PointF pivot = new PointF();
float fullscreenScale = params.recentsOrientedState.getFullScreenScaleAndPivot(startRect, params.dp, pivot);
// Compute where the task view would be based on the end scale.
RectF endRectF = new RectF(startRect);
Matrix temp = new Matrix();
temp.setScale(params.resistanceParams.scaleMaxResist, params.resistanceParams.scaleMaxResist, pivot.x, pivot.y);
temp.mapRect(endRectF);
// Translate such that the task view touches the top of the screen when drag does.
float endTranslation = endRectF.top * orientationHandler.getSecondaryTranslationDirectionFactor() * params.resistanceParams.translationFactor;
resistAnim.addFloat(params.translationTarget, params.translationProperty, params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR);
float prevScaleRate = (fullscreenScale - params.startScale) / (params.dp.heightPx - startRect.bottom);
// This is what the scale would be at the end of the drag if we didn't apply resistance.
float endScale = params.startScale - prevScaleRate * distanceToCover;
// Create an interpolator that resists the scale so the scale doesn't get smaller than
// RECENTS_SCALE_MAX_RESIST.
float startResist = Utilities.getProgress(params.resistanceParams.scaleStartResist, params.startScale, endScale);
float maxResist = Utilities.getProgress(params.resistanceParams.scaleMaxResist, params.startScale, endScale);
float stopResist = params.resistanceParams.stopScalingAtTop ? 1f - startRect.top / endRectF.top : 1f;
final TimeInterpolator scaleInterpolator = t -> {
if (t < startResist) {
return t;
}
if (t > stopResist) {
return maxResist;
}
float resistProgress = Utilities.getProgress(t, startResist, stopResist);
resistProgress = RECENTS_SCALE_RESIST_INTERPOLATOR.getInterpolation(resistProgress);
return startResist + resistProgress * (maxResist - startResist);
};
resistAnim.addFloat(params.scaleTarget, params.scaleProperty, params.startScale, endScale, scaleInterpolator);
return resistAnim;
}
use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.
the class SwipeUpAnimationLogic method initTransitionEndpoints.
protected void initTransitionEndpoints(DeviceProfile dp) {
mDp = dp;
mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState().getOrientationHandler());
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
PendingAnimation pendingAnimation = new PendingAnimation(mTransitionDragLength * 2);
TaskViewSimulator taskViewSimulator = remoteHandle.getTaskViewSimulator();
taskViewSimulator.setDp(dp);
taskViewSimulator.addAppToOverviewAnim(pendingAnimation, LINEAR);
AnimatorPlaybackController playbackController = pendingAnimation.createPlaybackController();
remoteHandle.setPlaybackController(AnimatorControllerWithResistance.createForRecents(playbackController, mContext, taskViewSimulator.getOrientationState(), mDp, taskViewSimulator.recentsViewScale, AnimatedFloat.VALUE, taskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE));
}
}
Aggregations