Search in sources :

Example 1 with SHAPE_PROGRESS_DURATION

use of com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherSwipeHandlerV2 method createIconHomeAnimationFactory.

private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) {
    final ResourceProvider rp = DynamicResource.provider(mActivity);
    final float transY = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
    RectF iconLocation = new RectF();
    FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView, true, /* hideOriginal */
    iconLocation, false);
    // We want the window alpha to be 0 once this threshold is met, so that the
    // FolderIconView can be seen morphing into the icon shape.
    float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
    return new FloatingViewHomeAnimationFactory(floatingIconView) {

        // There is a delay in loading the icon, so we need to keep the window
        // opaque until it is ready.
        private boolean mIsFloatingIconReady = false;

        @Override
        public RectF getWindowTargetRect() {
            super.getWindowTargetRect();
            return iconLocation;
        }

        @Override
        public void setAnimation(RectFSpringAnim anim) {
            super.setAnimation(anim);
            anim.addAnimatorListener(floatingIconView);
            floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
            floatingIconView.setFastFinishRunnable(anim::end);
        }

        @Override
        public boolean keepWindowOpaque() {
            if (mIsFloatingIconReady || floatingIconView.isVisibleToUser()) {
                mIsFloatingIconReady = true;
                return false;
            }
            return true;
        }

        @Override
        public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, float radius) {
            super.update(config, currentRect, progress, radius);
            int fgAlpha = 255;
            if (config != null && PROTOTYPE_APP_CLOSE.get()) {
                progress = config.getInterpolatedProgress();
                fgAlpha = config.getFgAlpha();
            }
            floatingIconView.update(1f, fgAlpha, currentRect, progress, windowAlphaThreshold, radius, false);
        }
    };
}
Also used : RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) FloatingIconView(com.android.launcher3.views.FloatingIconView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView) ResourceProvider(com.android.systemui.plugins.ResourceProvider) AppCloseConfig(com.android.quickstep.util.AppCloseConfig) Nullable(androidx.annotation.Nullable)

Example 2 with SHAPE_PROGRESS_DURATION

use of com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherSwipeHandlerV2 method createHomeAnimationFactory.

@Override
protected HomeAnimationFactory createHomeAnimationFactory(long duration) {
    HomeAnimationFactory homeAnimFactory;
    if (mActivity != null) {
        final TaskView runningTaskView = mRecentsView.getRunningTaskView();
        final View workspaceView;
        if (runningTaskView != null && runningTaskView.getTask().key.getComponent() != null) {
            workspaceView = mActivity.getWorkspace().getFirstMatchForAppClose(runningTaskView.getTask().key.getComponent().getPackageName(), UserHandle.of(runningTaskView.getTask().key.userId));
        } else {
            workspaceView = null;
        }
        final RectF iconLocation = new RectF();
        boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
        FloatingIconView floatingIconView = canUseWorkspaceView ? FloatingIconView.getFloatingIconView(mActivity, workspaceView, true, /* hideOriginal */
        iconLocation, false) : null;
        mActivity.getRootView().setForceHideBackArrow(true);
        mActivity.setHintUserWillBeActive();
        if (canUseWorkspaceView) {
            // We want the window alpha to be 0 once this threshold is met, so that the
            // FolderIconView can be seen morphing into the icon shape.
            float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
            homeAnimFactory = new LauncherHomeAnimationFactory() {

                @Override
                public RectF getWindowTargetRect() {
                    return iconLocation;
                }

                @Override
                public void setAnimation(RectFSpringAnim anim) {
                    anim.addAnimatorListener(floatingIconView);
                    floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
                    floatingIconView.setFastFinishRunnable(anim::end);
                }

                @Override
                public void update(RectF currentRect, float progress, float radius) {
                    floatingIconView.update(currentRect, 1f, progress, windowAlphaThreshold, radius, false);
                }

                @Override
                public void onCancel() {
                    floatingIconView.fastFinish();
                }
            };
        } else {
            homeAnimFactory = new LauncherHomeAnimationFactory();
        }
    } else {
        homeAnimFactory = new HomeAnimationFactory() {

            @Override
            public AnimatorPlaybackController createActivityAnimationToHome() {
                return AnimatorPlaybackController.wrap(new AnimatorSet(), duration);
            }
        };
        mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED, isPresent -> mRecentsView.startHome());
    }
    return homeAnimFactory;
}
Also used : RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) TaskView(com.android.quickstep.views.TaskView) FloatingIconView(com.android.launcher3.views.FloatingIconView) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorSet(android.animation.AnimatorSet) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView)

Example 3 with SHAPE_PROGRESS_DURATION

use of com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION in project Neo-Launcher by NeoApplications.

the class BaseSwipeUpHandler method createWindowAnimationToHome.

/**
 * Creates an animation that transforms the current app window into the home app.
 * @param startProgress The progress of {@link #mCurrentShift} to start the window from.
 * @param homeAnimationFactory The home animation factory.
 */
protected RectFSpringAnim createWindowAnimationToHome(float startProgress, HomeAnimationFactory homeAnimationFactory) {
    final RemoteAnimationTargetSet targetSet = mRecentsAnimationWrapper.targetSet;
    final RectF startRect = new RectF(mClipAnimationHelper.applyTransform(targetSet, mTransformParams.setProgress(startProgress), false));
    final RectF targetRect = homeAnimationFactory.getWindowTargetRect();
    final View floatingView = homeAnimationFactory.getFloatingView();
    final boolean isFloatingIconView = floatingView instanceof FloatingIconView;
    RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mContext.getResources());
    if (isFloatingIconView) {
        FloatingIconView fiv = (FloatingIconView) floatingView;
        anim.addAnimatorListener(fiv);
        fiv.setOnTargetChangeListener(anim::onTargetPositionChanged);
    }
    AnimatorPlaybackController homeAnim = homeAnimationFactory.createActivityAnimationToHome();
    // End on a "round-enough" radius so that the shape reveal doesn't have to do too much
    // rounding at the end of the animation.
    float startRadius = mClipAnimationHelper.getCurrentCornerRadius();
    float endRadius = startRect.width() / 6f;
    // We want the window alpha to be 0 once this threshold is met, so that the
    // FolderIconView can be seen morphing into the icon shape.
    final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
    anim.addOnUpdateListener(new RectFSpringAnim.OnUpdateListener() {

        // Alpha interpolates between [1, 0] between progress values [start, end]
        final float start = 0f;

        final float end = 0.85f;

        private float getWindowAlpha(float progress) {
            if (progress <= start) {
                return 1f;
            }
            if (progress >= end) {
                return 0f;
            }
            return Utilities.mapToRange(progress, start, end, 1, 0, ACCEL_1_5);
        }

        @Override
        public void onUpdate(RectF currentRect, float progress) {
            homeAnim.setPlayFraction(progress);
            mTransformParams.setProgress(progress).setCurrentRectAndTargetAlpha(currentRect, getWindowAlpha(progress));
            if (isFloatingIconView) {
                mTransformParams.setCornerRadius(endRadius * progress + startRadius * (1f - progress));
            }
            mClipAnimationHelper.applyTransform(targetSet, mTransformParams, false);
            if (isFloatingIconView) {
                ((FloatingIconView) floatingView).update(currentRect, 1f, progress, windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
            }
        }

        @Override
        public void onCancel() {
            if (isFloatingIconView) {
                ((FloatingIconView) floatingView).fastFinish();
            }
        }
    });
    anim.addAnimatorListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            homeAnim.dispatchOnStart();
        }

        @Override
        public void onAnimationSuccess(Animator animator) {
            homeAnim.getAnimationPlayer().end();
        }
    });
    return anim;
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) View(android.view.View) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskView(com.android.quickstep.views.TaskView) RecentsView(com.android.quickstep.views.RecentsView) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) Animator(android.animation.Animator) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 4 with SHAPE_PROGRESS_DURATION

use of com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherSwipeHandlerV2 method createIconHomeAnimationFactory.

private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) {
    RectF iconLocation = new RectF();
    FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView, true, /* hideOriginal */
    iconLocation, false);
    // We want the window alpha to be 0 once this threshold is met, so that the
    // FolderIconView can be seen morphing into the icon shape.
    float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
    return new FloatingViewHomeAnimationFactory(floatingIconView) {

        @Nullable
        @Override
        protected View getViewIgnoredInWorkspaceRevealAnimation() {
            return workspaceView;
        }

        @NonNull
        @Override
        public RectF getWindowTargetRect() {
            return iconLocation;
        }

        @Override
        public void setAnimation(RectFSpringAnim anim) {
            super.setAnimation(anim);
            anim.addAnimatorListener(floatingIconView);
            floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
            floatingIconView.setFastFinishRunnable(anim::end);
        }

        @Override
        public void update(RectF currentRect, float progress, float radius) {
            super.update(currentRect, progress, radius);
            floatingIconView.update(1f, /* alpha */
            255, /* fgAlpha */
            currentRect, progress, windowAlphaThreshold, radius, false);
        }
    };
}
Also used : RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) FloatingIconView(com.android.launcher3.views.FloatingIconView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView)

Example 5 with SHAPE_PROGRESS_DURATION

use of com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION in project android_packages_apps_Launcher3 by ProtonAOSP.

the class QuickstepTransitionManager method getClosingWindowAnimators.

/**
 * Closing animator that animates the window into its final location on the workspace.
 */
private void getClosingWindowAnimators(AnimatorSet animation, RemoteAnimationTargetCompat[] targets, View launcherView, PointF velocityPxPerS) {
    FloatingIconView floatingIconView = null;
    FloatingWidgetView floatingWidget = null;
    RectF targetRect = new RectF();
    RemoteAnimationTargetCompat runningTaskTarget = null;
    boolean isTransluscent = false;
    for (RemoteAnimationTargetCompat target : targets) {
        if (target.mode == MODE_CLOSING) {
            runningTaskTarget = target;
            isTransluscent = runningTaskTarget.isTranslucent;
            break;
        }
    }
    // Get floating view and target rect.
    if (launcherView instanceof LauncherAppWidgetHostView) {
        Size windowSize = new Size(mDeviceProfile.availableWidthPx, mDeviceProfile.availableHeightPx);
        int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mLauncher, runningTaskTarget);
        floatingWidget = FloatingWidgetView.getFloatingWidgetView(mLauncher, (LauncherAppWidgetHostView) launcherView, targetRect, windowSize, mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher), isTransluscent, fallbackBackgroundColor);
    } else if (launcherView != null) {
        floatingIconView = getFloatingIconView(mLauncher, launcherView, true, /* hideOriginal */
        targetRect, false);
    } else {
        targetRect.set(getDefaultWindowTargetRect());
    }
    final RectF startRect = new RectF(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx);
    RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mLauncher, mDeviceProfile);
    // Hook up floating views to the closing window animators.
    final int rotationChange = getRotationChange(targets);
    Rect windowTargetBounds = getWindowTargetBounds(targets, rotationChange);
    if (floatingIconView != null) {
        anim.addAnimatorListener(floatingIconView);
        floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
        floatingIconView.setFastFinishRunnable(anim::end);
        FloatingIconView finalFloatingIconView = floatingIconView;
        // We want the window alpha to be 0 once this threshold is met, so that the
        // FolderIconView can be seen morphing into the icon shape.
        final float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
        RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect, windowTargetBounds) {

            @Override
            public void onUpdate(RectF currentRectF, float progress) {
                finalFloatingIconView.update(1f, 255, /* fgAlpha */
                currentRectF, progress, windowAlphaThreshold, getCornerRadius(progress), false);
                super.onUpdate(currentRectF, progress);
            }
        };
        anim.addOnUpdateListener(runner);
    } else if (floatingWidget != null) {
        anim.addAnimatorListener(floatingWidget);
        floatingWidget.setOnTargetChangeListener(anim::onTargetPositionChanged);
        floatingWidget.setFastFinishRunnable(anim::end);
        final float floatingWidgetAlpha = isTransluscent ? 0 : 1;
        FloatingWidgetView finalFloatingWidget = floatingWidget;
        RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect, windowTargetBounds) {

            @Override
            public void onUpdate(RectF currentRectF, float progress) {
                final float fallbackBackgroundAlpha = 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE);
                final float foregroundAlpha = mapBoundToRange(progress, 0.5f, 1, 0, 1, EXAGGERATED_EASE);
                finalFloatingWidget.update(currentRectF, floatingWidgetAlpha, foregroundAlpha, fallbackBackgroundAlpha, 1 - progress);
                super.onUpdate(currentRectF, progress);
            }
        };
        anim.addOnUpdateListener(runner);
    }
    // Use a fixed velocity to start the animation.
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            anim.start(mLauncher, velocityPxPerS);
        }
    });
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView) Rect(android.graphics.Rect) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) Size(android.util.Size) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Point(android.graphics.Point) RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Aggregations

RectF (android.graphics.RectF)13 FloatingIconView (com.android.launcher3.views.FloatingIconView)13 RectFSpringAnim (com.android.quickstep.util.RectFSpringAnim)11 FloatingIconView.getFloatingIconView (com.android.launcher3.views.FloatingIconView.getFloatingIconView)9 Animator (android.animation.Animator)8 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 ObjectAnimator (android.animation.ObjectAnimator)7 ValueAnimator (android.animation.ValueAnimator)7 Rect (android.graphics.Rect)6 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)6 Point (android.graphics.Point)5 Size (android.util.Size)4 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)4 FloatingWidgetView (com.android.quickstep.views.FloatingWidgetView)4 AnimatorSet (android.animation.AnimatorSet)2 Matrix (android.graphics.Matrix)2 Drawable (android.graphics.drawable.Drawable)2 View (android.view.View)2 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)2 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)2