Search in sources :

Example 51 with PendingAnimation

use of com.android.launcher3.anim.PendingAnimation in project Neo-Launcher by NeoApplications.

the class RecentsView method createTaskDismissAnimation.

public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView, boolean shouldRemoveTask, long duration) {
    if (mPendingAnimation != null) {
        mPendingAnimation.finish(false, Touch.SWIPE);
    }
    AnimatorSet anim = new AnimatorSet();
    PendingAnimation pendingAnimation = new PendingAnimation(anim);
    int count = getPageCount();
    if (count == 0) {
        return pendingAnimation;
    }
    int[] oldScroll = new int[count];
    getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC);
    int[] newScroll = new int[count];
    getPageScrolls(newScroll, false, (v) -> v.getVisibility() != GONE && v != taskView);
    int taskCount = getTaskViewCount();
    int scrollDiffPerPage = 0;
    if (count > 1) {
        scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
    }
    int draggedIndex = indexOfChild(taskView);
    boolean needsCurveUpdates = false;
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        if (child == taskView) {
            if (animateTaskView) {
                addDismissedTaskAnimations(taskView, anim, duration);
            }
        } else {
            // If we just take newScroll - oldScroll, everything to the right of dragged task
            // translates to the left. We need to offset this in some cases:
            // - In RTL, add page offset to all pages, since we want pages to move to the right
            // Additionally, add a page offset if:
            // - Current page is rightmost page (leftmost for RTL)
            // - Dragging an adjacent page on the left side (right side for RTL)
            int offset = mIsRtl ? scrollDiffPerPage : 0;
            if (mCurrentPage == draggedIndex) {
                int lastPage = taskCount - 1;
                if (mCurrentPage == lastPage) {
                    offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
                }
            } else {
                // Dragging an adjacent page.
                // (Right in RTL, left in LTR)
                int negativeAdjacent = mCurrentPage - 1;
                if (draggedIndex == negativeAdjacent) {
                    offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
                }
            }
            int scrollDiff = newScroll[i] - oldScroll[i] + offset;
            if (scrollDiff != 0) {
                if (QUICKSTEP_SPRINGS.get() && child instanceof TaskView) {
                    addAnim(new SpringObjectAnimator<>(child, VIEW_TRANSLATE_X, MIN_VISIBLE_CHANGE_PIXELS, SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY, SpringForce.STIFFNESS_MEDIUM, 0, scrollDiff), duration, ACCEL, anim);
                } else {
                    addAnim(ObjectAnimator.ofFloat(child, TRANSLATION_X, scrollDiff), duration, ACCEL, anim);
                }
                needsCurveUpdates = true;
            }
        }
    }
    if (needsCurveUpdates) {
        ValueAnimator va = ValueAnimator.ofFloat(0, 1);
        va.addUpdateListener((a) -> updateCurveProperties());
        anim.play(va);
    }
    // Add a tiny bit of translation Z, so that it draws on top of other views
    if (animateTaskView) {
        taskView.setTranslationZ(0.1f);
    }
    mPendingAnimation = pendingAnimation;
    mPendingAnimation.addEndListener(new Consumer<PendingAnimation.OnEndListener>() {

        @Override
        public void accept(PendingAnimation.OnEndListener onEndListener) {
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && taskView.isRunningTask() && onEndListener.isSuccess) {
                finishRecentsAnimation(true, /* toHome */
                () -> onEnd(onEndListener));
            } else {
                onEnd(onEndListener);
            }
        }

        private void onEnd(PendingAnimation.OnEndListener onEndListener) {
            if (onEndListener.isSuccess) {
                if (shouldRemoveTask) {
                    removeTask(taskView.getTask(), draggedIndex, onEndListener, true);
                }
                int pageToSnapTo = mCurrentPage;
                if (draggedIndex < pageToSnapTo || pageToSnapTo == (getTaskViewCount() - 1)) {
                    pageToSnapTo -= 1;
                }
                removeView(taskView);
                if (getTaskViewCount() == 0) {
                    removeView(mClearAllButton);
                    startHome();
                } else {
                    snapToPageImmediately(pageToSnapTo);
                }
            }
            resetTaskVisuals();
            mPendingAnimation = null;
        }
    });
    return pendingAnimation;
}
Also used : PendingAnimation(com.android.launcher3.util.PendingAnimation) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 52 with PendingAnimation

use of com.android.launcher3.anim.PendingAnimation in project Neo-Launcher by NeoApplications.

the class TaskView method createLaunchAnimationForRunningTask.

public AnimatorPlaybackController createLaunchAnimationForRunningTask() {
    final PendingAnimation pendingAnimation = getRecentsView().createTaskLauncherAnimation(this, RECENTS_LAUNCH_DURATION);
    pendingAnimation.anim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
    AnimatorPlaybackController currentAnimation = AnimatorPlaybackController.wrap(pendingAnimation.anim, RECENTS_LAUNCH_DURATION, null);
    currentAnimation.setEndAction(() -> {
        pendingAnimation.finish(true, Touch.SWIPE);
        launchTask(false);
    });
    return currentAnimation;
}
Also used : PendingAnimation(com.android.launcher3.util.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 53 with PendingAnimation

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

the class FloatingTaskView method addAnimation.

public void addAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, View viewToCover, boolean fadeWithThumbnail) {
    final BaseDragLayer dragLayer = mActivity.getDragLayer();
    int[] dragLayerBounds = new int[2];
    dragLayer.getLocationOnScreen(dragLayerBounds);
    SplitOverlayProperties prop = new SplitOverlayProperties(endBounds, startingBounds, viewToCover, dragLayerBounds[0], dragLayerBounds[1]);
    ValueAnimator transitionAnimator = ValueAnimator.ofFloat(0, 1);
    animation.add(transitionAnimator);
    long animDuration = animation.getDuration();
    Rect crop = new Rect();
    RectF floatingTaskViewBounds = new RectF();
    final float initialWindowRadius = supportsRoundedCornersOnWindows(getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f;
    if (fadeWithThumbnail) {
        animation.addFloat(mSplitPlaceholderView, SplitPlaceholderView.ALPHA_FLOAT, 0, 1, ACCEL);
        animation.addFloat(mImageView, LauncherAnimUtils.VIEW_ALPHA, 1, 0, DEACCEL_3);
    }
    MultiValueUpdateListener listener = new MultiValueUpdateListener() {

        final FloatProp mWindowRadius = new FloatProp(initialWindowRadius, initialWindowRadius, 0, animDuration, LINEAR);

        final FloatProp mDx = new FloatProp(0, prop.dX, 0, animDuration, LINEAR);

        final FloatProp mDy = new FloatProp(0, prop.dY, 0, animDuration, LINEAR);

        final FloatProp mTaskViewScaleX = new FloatProp(prop.initialTaskViewScaleX, prop.finalTaskViewScaleX, 0, animDuration, LINEAR);

        final FloatProp mTaskViewScaleY = new FloatProp(prop.initialTaskViewScaleY, prop.finalTaskViewScaleY, 0, animDuration, LINEAR);

        @Override
        public void onUpdate(float percent, boolean initOnly) {
            // Calculate the icon position.
            floatingTaskViewBounds.set(startingBounds);
            floatingTaskViewBounds.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(floatingTaskViewBounds, mTaskViewScaleX.value, mTaskViewScaleY.value);
            update(floatingTaskViewBounds, percent, mWindowRadius.value * 1);
        }
    };
    transitionAnimator.addUpdateListener(listener);
}
Also used : RectF(android.graphics.RectF) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Rect(android.graphics.Rect) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 54 with PendingAnimation

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

the class StaggeredWorkspaceAnim method addDepthAnimationForState.

private void addDepthAnimationForState(Launcher launcher, LauncherState state, long duration) {
    if (!(launcher instanceof BaseQuickstepLauncher)) {
        return;
    }
    PendingAnimation builder = new PendingAnimation(duration);
    DepthController depthController = ((BaseQuickstepLauncher) launcher).getDepthController();
    depthController.setStateWithAnimation(state, new StateAnimationConfig(), builder);
    mAnimators.play(builder.buildAnim());
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) DepthController(com.android.launcher3.statehandlers.DepthController)

Example 55 with PendingAnimation

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

the class RecentsView method runDismissAnimation.

private void runDismissAnimation(PendingAnimation pendingAnim) {
    AnimatorPlaybackController controller = pendingAnim.createPlaybackController();
    controller.dispatchOnStart();
    controller.getAnimationPlayer().setInterpolator(FAST_OUT_SLOW_IN);
    controller.start();
}
Also used : 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