Search in sources :

Example 11 with SHAPE_PROGRESS_DURATION

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

the class QuickstepAppTransitionManagerImpl method getOpeningWindowAnimators.

/**
 * @return Animator that controls the window of the opening targets from app icons.
 */
private Animator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, Rect windowTargetBounds, boolean toggleVisibility) {
    RectF bounds = new RectF();
    FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility, bounds, true);
    Rect crop = new Rect();
    Matrix matrix = new Matrix();
    RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets, wallpaperTargets, MODE_OPENING);
    SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
    openingTargets.addReleaseCheck(surfaceApplier);
    // Scale the app icon to take up the entire screen. This simplifies the math when
    // animating the app window position / scale.
    float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width());
    float maxScaleX = smallestSize / bounds.width();
    float maxScaleY = smallestSize / bounds.height();
    float scale = Math.max(maxScaleX, maxScaleY);
    float startScale = 1f;
    if (v instanceof BubbleTextView && !(v.getParent() instanceof DeepShortcutView)) {
        Drawable dr = ((BubbleTextView) v).getIcon();
        if (dr instanceof FastBitmapDrawable) {
            startScale = ((FastBitmapDrawable) dr).getAnimatedScale();
        }
    }
    final float initialStartScale = startScale;
    int[] dragLayerBounds = new int[2];
    mDragLayer.getLocationOnScreen(dragLayerBounds);
    // Animate the app icon to the center of the window bounds in screen coordinates.
    float centerX = windowTargetBounds.centerX() - dragLayerBounds[0];
    float centerY = windowTargetBounds.centerY() - dragLayerBounds[1];
    float dX = centerX - bounds.centerX();
    float dY = centerY - bounds.centerY();
    boolean useUpwardAnimation = bounds.top > centerY || Math.abs(dY) < mLauncher.getDeviceProfile().cellHeightPx;
    final long xDuration = useUpwardAnimation ? APP_LAUNCH_CURVED_DURATION : APP_LAUNCH_DOWN_DURATION;
    final long yDuration = useUpwardAnimation ? APP_LAUNCH_DURATION : APP_LAUNCH_DOWN_CURVED_DURATION;
    final long alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION : APP_LAUNCH_ALPHA_DOWN_DURATION;
    RectF targetBounds = new RectF(windowTargetBounds);
    RectF iconBounds = new RectF();
    RectF temp = new RectF();
    Point tmpPos = new Point();
    AnimatorSet animatorSet = new AnimatorSet();
    ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
    appAnimator.setDuration(APP_LAUNCH_DURATION);
    appAnimator.setInterpolator(LINEAR);
    appAnimator.addListener(floatingView);
    appAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (v instanceof BubbleTextView) {
                ((BubbleTextView) v).setStayPressed(false);
            }
            openingTargets.release();
        }
    });
    float shapeRevealDuration = APP_LAUNCH_DURATION * SHAPE_PROGRESS_DURATION;
    final float startCrop;
    final float endCrop;
    if (mDeviceProfile.isVerticalBarLayout()) {
        startCrop = windowTargetBounds.height();
        endCrop = windowTargetBounds.width();
    } else {
        startCrop = windowTargetBounds.width();
        endCrop = windowTargetBounds.height();
    }
    final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? startCrop / 2f : 0f;
    final float windowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources());
    appAnimator.addUpdateListener(new MultiValueUpdateListener() {

        FloatProp mDx = new FloatProp(0, dX, 0, xDuration, AGGRESSIVE_EASE);

        FloatProp mDy = new FloatProp(0, dY, 0, yDuration, AGGRESSIVE_EASE);

        FloatProp mScale = new FloatProp(initialStartScale, scale, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE);

        FloatProp mIconAlpha = new FloatProp(1f, 0f, APP_LAUNCH_ALPHA_START_DELAY, alphaDuration, LINEAR);

        FloatProp mCroppedSize = new FloatProp(startCrop, endCrop, 0, CROP_DURATION, EXAGGERATED_EASE);

        FloatProp mWindowRadius = new FloatProp(initialWindowRadius, windowRadius, 0, RADIUS_DURATION, EXAGGERATED_EASE);

        @Override
        public void onUpdate(float percent) {
            // Calculate the size.
            float width = bounds.width() * mScale.value;
            float height = bounds.height() * mScale.value;
            // Animate the crop so that it starts off as a square.
            final int cropWidth;
            final int cropHeight;
            if (mDeviceProfile.isVerticalBarLayout()) {
                cropWidth = (int) mCroppedSize.value;
                cropHeight = windowTargetBounds.height();
            } else {
                cropWidth = windowTargetBounds.width();
                cropHeight = (int) mCroppedSize.value;
            }
            crop.set(0, 0, cropWidth, cropHeight);
            // Scale the size to match the crop.
            float scaleX = width / cropWidth;
            float scaleY = height / cropHeight;
            float scale = Math.min(1f, Math.max(scaleX, scaleY));
            float scaledCropWidth = cropWidth * scale;
            float scaledCropHeight = cropHeight * scale;
            float offsetX = (scaledCropWidth - width) / 2;
            float offsetY = (scaledCropHeight - height) / 2;
            // Calculate the window position.
            temp.set(bounds);
            temp.offset(dragLayerBounds[0], dragLayerBounds[1]);
            temp.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(temp, mScale.value);
            float windowTransX0 = temp.left - offsetX;
            float windowTransY0 = temp.top - offsetY;
            // Calculate the icon position.
            iconBounds.set(bounds);
            iconBounds.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(iconBounds, mScale.value);
            iconBounds.left -= offsetX;
            iconBounds.top -= offsetY;
            iconBounds.right += offsetX;
            iconBounds.bottom += offsetY;
            float croppedHeight = (windowTargetBounds.height() - crop.height()) * scale;
            float croppedWidth = (windowTargetBounds.width() - crop.width()) * scale;
            SurfaceParams[] params = new SurfaceParams[appTargets.length];
            for (int i = appTargets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = appTargets[i];
                SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash);
                if (target.mode == MODE_OPENING) {
                    matrix.setScale(scale, scale);
                    matrix.postTranslate(windowTransX0, windowTransY0);
                    floatingView.update(iconBounds, mIconAlpha.value, percent, 0f, mWindowRadius.value * scale, true);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f - mIconAlpha.value).withCornerRadius(mWindowRadius.value);
                } else {
                    tmpPos.set(target.position.x, target.position.y);
                    if (target.localBounds != null) {
                        final Rect localBounds = target.localBounds;
                        tmpPos.set(target.localBounds.left, target.localBounds.top);
                    }
                    matrix.setTranslate(tmpPos.x, tmpPos.y);
                    final Rect crop = new Rect(target.screenSpaceBounds);
                    crop.offsetTo(0, 0);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f);
                }
                params[i] = builder.build();
            }
            surfaceApplier.scheduleApply(params);
        }
    });
    // When launching an app from overview that doesn't map to a task, we still want to just
    // blur the wallpaper instead of the launcher surface as well
    boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW;
    DepthController depthController = mLauncher.getDepthController();
    ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mLauncher)).setDuration(APP_LAUNCH_DURATION);
    if (allowBlurringLauncher) {
        depthController.setSurfaceToApp(RemoteAnimationProvider.findLowestOpaqueLayerTarget(appTargets, MODE_OPENING));
        backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                depthController.setSurfaceToApp(null);
            }
        });
    }
    animatorSet.playTogether(appAnimator, backgroundRadiusAnim);
    return animatorSet;
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) DepthController(com.android.launcher3.statehandlers.DepthController) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Matrix(android.graphics.Matrix) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Drawable(android.graphics.drawable.Drawable) Point(android.graphics.Point) RectF(android.graphics.RectF) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator)

Example 12 with SHAPE_PROGRESS_DURATION

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

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)

Example 13 with SHAPE_PROGRESS_DURATION

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

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 14 with SHAPE_PROGRESS_DURATION

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

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