Search in sources :

Example 56 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ArrowOS.

the class OverviewGestureTutorialController method animateTaskViewToOverview.

public void animateTaskViewToOverview() {
    PendingAnimation anim = new PendingAnimation(TASK_VIEW_END_ANIMATION_DURATION_MILLIS);
    anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 1, ACCEL);
    ArrayList<Animator> animators = new ArrayList<>();
    if (mTutorialFragment.isLargeScreen()) {
        Animator multiRowAnimation = mFakePreviousTaskView.createAnimationToMultiRowLayout();
        if (multiRowAnimation != null) {
            multiRowAnimation.setDuration(TASK_VIEW_END_ANIMATION_DURATION_MILLIS);
            animators.add(multiRowAnimation);
        }
    }
    animators.add(anim.buildAnim());
    AnimatorSet animset = new AnimatorSet();
    animset.playTogether(animators);
    hideFakeTaskbar(/* animateToHotseat= */
    false);
    animset.start();
    mRunningWindowAnim = SwipeUpAnimationLogic.RunningWindowAnim.wrap(animset);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Animator(android.animation.Animator) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet)

Example 57 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ArrowOS.

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 58 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ArrowOS.

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 59 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ArrowOS.

the class DragLayer method animateView.

/**
 * This method animates a view at the end of a drag and drop animation.
 * @param view The view to be animated. This view is drawn directly into DragLayer, and so
 *        doesn't need to be a child of DragLayer.
 * @param to The final location of the view. Only the left and top parameters are used. This
 *        location doesn't account for scaling, and so should be centered about the desired
 *        final location (including scaling).
 * @param finalAlpha The final alpha of the view, in case we want it to fade as it animates.
 * @param finalScaleX The final scale of the view. The view is scaled about its center.
 * @param finalScaleY The final scale of the view. The view is scaled about its center.
 * @param duration The duration of the animation.
 * @param motionInterpolator The interpolator to use for the location of the view.
 * @param onCompleteRunnable Optional runnable to run on animation completion.
 * @param animationEndStyle Whether or not to fade out the view once the animation completes.
 *        {@link #ANIMATION_END_DISAPPEAR} or {@link #ANIMATION_END_REMAIN_VISIBLE}.
 * @param anchorView If not null, this represents the view which the animated view stays
 */
public void animateView(final DragView view, final Rect to, final float finalAlpha, final float finalScaleX, final float finalScaleY, int duration, final Interpolator motionInterpolator, final Runnable onCompleteRunnable, final int animationEndStyle, View anchorView) {
    view.cancelAnimation();
    view.requestLayout();
    final int[] from = getViewLocationRelativeToSelf(view);
    // Calculate the duration of the animation based on the object's distance
    final float dist = (float) Math.hypot(to.left - from[0], to.top - from[1]);
    final Resources res = getResources();
    final float maxDist = (float) res.getInteger(R.integer.config_dropAnimMaxDist);
    // If duration < 0, this is a cue to compute the duration based on the distance
    if (duration < 0) {
        duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
        if (dist < maxDist) {
            duration *= DEACCEL_1_5.getInterpolation(dist / maxDist);
        }
        duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration));
    }
    // Fall back to cubic ease out interpolator for the animation if none is specified
    TimeInterpolator interpolator = motionInterpolator == null ? DEACCEL_1_5 : motionInterpolator;
    // Animate the view
    PendingAnimation anim = new PendingAnimation(duration);
    anim.add(ofFloat(view, View.SCALE_X, finalScaleX), interpolator, SpringProperty.DEFAULT);
    anim.add(ofFloat(view, View.SCALE_Y, finalScaleY), interpolator, SpringProperty.DEFAULT);
    anim.setViewAlpha(view, finalAlpha, interpolator);
    anim.setFloat(view, VIEW_TRANSLATE_Y, to.top, interpolator);
    ObjectAnimator xMotion = ofFloat(view, VIEW_TRANSLATE_X, to.left);
    if (anchorView != null) {
        final int startScroll = anchorView.getScrollX();
        TypeEvaluator<Float> evaluator = (f, s, e) -> mapRange(f, s, e) + (anchorView.getScaleX() * (startScroll - anchorView.getScrollX()));
        xMotion.setEvaluator(evaluator);
    }
    anim.add(xMotion, interpolator, SpringProperty.DEFAULT);
    if (onCompleteRunnable != null) {
        anim.addListener(forEndCallback(onCompleteRunnable));
    }
    playDropAnimation(view, anim.buildAnim(), animationEndStyle);
}
Also used : Folder(com.android.launcher3.folder.Folder) DEACCEL_1_5(com.android.launcher3.anim.Interpolators.DEACCEL_1_5) Context(android.content.Context) Rect(android.graphics.Rect) TimeInterpolator(android.animation.TimeInterpolator) ViewGroupFocusHelper(com.android.launcher3.keyboard.ViewGroupFocusHelper) KeyEvent(android.view.KeyEvent) Animator(android.animation.Animator) Scrim(com.android.launcher3.graphics.Scrim) AnimatorListeners.forEndCallback(com.android.launcher3.anim.AnimatorListeners.forEndCallback) ArrayList(java.util.ArrayList) TypeEvaluator(android.animation.TypeEvaluator) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityManagerCompat.sendCustomAccessibilityEvent(com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent) AttributeSet(android.util.AttributeSet) MotionEvent(android.view.MotionEvent) View(android.view.View) Canvas(android.graphics.Canvas) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Launcher(com.android.launcher3.Launcher) Interpolator(android.view.animation.Interpolator) VIEW_TRANSLATE_Y(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y) VIEW_TRANSLATE_X(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X) ObjectAnimator(android.animation.ObjectAnimator) SpringProperty(com.android.launcher3.anim.SpringProperty) Utilities.mapRange(com.android.launcher3.Utilities.mapRange) CellLayout(com.android.launcher3.CellLayout) ObjectAnimator.ofFloat(android.animation.ObjectAnimator.ofFloat) DropTargetBar(com.android.launcher3.DropTargetBar) TouchController(com.android.launcher3.util.TouchController) R(com.android.launcher3.R) ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) Workspace(com.android.launcher3.Workspace) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) PendingAnimation(com.android.launcher3.anim.PendingAnimation) Resources(android.content.res.Resources) PendingAnimation(com.android.launcher3.anim.PendingAnimation) ObjectAnimator.ofFloat(android.animation.ObjectAnimator.ofFloat) ObjectAnimator(android.animation.ObjectAnimator) Resources(android.content.res.Resources) TimeInterpolator(android.animation.TimeInterpolator)

Example 60 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ArrowOS.

the class StateManager method createAnimationToNewWorkspaceInternal.

private PendingAnimation createAnimationToNewWorkspaceInternal(final STATE_TYPE state) {
    PendingAnimation builder = new PendingAnimation(mConfig.duration);
    if (!mConfig.hasAnimationFlag(SKIP_ALL_ANIMATIONS)) {
        for (StateHandler handler : getStateHandlers()) {
            handler.setStateWithAnimation(state, mConfig, builder);
        }
    }
    builder.addListener(createStateAnimationListener(state));
    mConfig.setAnimation(builder.buildAnim(), state);
    return builder;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation)

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