Search in sources :

Example 81 with PendingAnimation

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);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorSet(android.animation.AnimatorSet)

Example 82 with PendingAnimation

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);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Example 83 with PendingAnimation

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);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 84 with PendingAnimation

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;
}
Also used : RectF(android.graphics.RectF) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) Rect(android.graphics.Rect) TimeInterpolator(android.animation.TimeInterpolator) PointF(android.graphics.PointF) Launcher(com.android.launcher3.Launcher) DEACCEL(com.android.launcher3.anim.Interpolators.DEACCEL) FloatProperty(android.util.FloatProperty) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) DeviceProfile(com.android.launcher3.DeviceProfile) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) RECENTS_SCALE_PROPERTY(com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY) Nullable(androidx.annotation.Nullable) LauncherActivityInterface(com.android.quickstep.LauncherActivityInterface) RecentsView(com.android.quickstep.views.RecentsView) TASK_SECONDARY_TRANSLATION(com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION) Matrix(android.graphics.Matrix) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PointF(android.graphics.PointF) TimeInterpolator(android.animation.TimeInterpolator)

Example 85 with PendingAnimation

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));
    }
}
Also used : RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) PendingAnimation(com.android.launcher3.anim.PendingAnimation) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Aggregations

PendingAnimation (com.android.launcher3.anim.PendingAnimation)145 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)58 Animator (android.animation.Animator)46 AnimatorSet (android.animation.AnimatorSet)45 Rect (android.graphics.Rect)36 ValueAnimator (android.animation.ValueAnimator)34 Point (android.graphics.Point)32 TextPaint (android.text.TextPaint)32 ObjectAnimator (android.animation.ObjectAnimator)31 Context (android.content.Context)31 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)29 View (android.view.View)29 RecentsView (com.android.quickstep.views.RecentsView)29 DeviceProfile (com.android.launcher3.DeviceProfile)27 RectF (android.graphics.RectF)26 Interpolator (android.view.animation.Interpolator)26 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)25 FloatProperty (android.util.FloatProperty)23 Matrix (android.graphics.Matrix)21 SpringProperty (com.android.launcher3.anim.SpringProperty)21