Search in sources :

Example 1 with AppCloseConfig

use of com.android.quickstep.util.AppCloseConfig 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 AppCloseConfig

use of com.android.quickstep.util.AppCloseConfig in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherSwipeHandlerV2 method createWidgetHomeAnimationFactory.

private HomeAnimationFactory createWidgetHomeAnimationFactory(LauncherAppWidgetHostView hostView, boolean isTargetTranslucent, RemoteAnimationTargetCompat runningTaskTarget) {
    final float floatingWidgetAlpha = isTargetTranslucent ? 0 : 1;
    RectF backgroundLocation = new RectF();
    Rect crop = new Rect();
    mTaskViewSimulator.getCurrentCropRect().roundOut(crop);
    Size windowSize = new Size(crop.width(), crop.height());
    int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mContext, runningTaskTarget);
    FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity, hostView, backgroundLocation, windowSize, mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent, fallbackBackgroundColor);
    return new FloatingViewHomeAnimationFactory(floatingWidgetView) {

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

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

        @Override
        public float getEndRadius(RectF cropRectF) {
            return floatingWidgetView.getInitialCornerRadius();
        }

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

        @Override
        public boolean keepWindowOpaque() {
            return false;
        }

        @Override
        public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress, float radius) {
            super.update(config, currentRect, progress, radius);
            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);
            floatingWidgetView.update(currentRect, floatingWidgetAlpha, foregroundAlpha, fallbackBackgroundAlpha, 1 - progress);
        }

        @Override
        protected float getWindowAlpha(float progress) {
            return 1 - mapBoundToRange(progress, 0, 0.5f, 0, 1, LINEAR);
        }
    };
}
Also used : RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) Rect(android.graphics.Rect) Size(android.util.Size) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) AppCloseConfig(com.android.quickstep.util.AppCloseConfig) Nullable(androidx.annotation.Nullable)

Aggregations

RectF (android.graphics.RectF)2 Nullable (androidx.annotation.Nullable)2 AppCloseConfig (com.android.quickstep.util.AppCloseConfig)2 RectFSpringAnim (com.android.quickstep.util.RectFSpringAnim)2 Rect (android.graphics.Rect)1 Size (android.util.Size)1 FloatingIconView (com.android.launcher3.views.FloatingIconView)1 FloatingIconView.getFloatingIconView (com.android.launcher3.views.FloatingIconView.getFloatingIconView)1 FloatingWidgetView (com.android.quickstep.views.FloatingWidgetView)1 ResourceProvider (com.android.systemui.plugins.ResourceProvider)1