Search in sources :

Example 6 with EXAGGERATED_EASE

use of com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE 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

Animator (android.animation.Animator)6 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)6 ObjectAnimator (android.animation.ObjectAnimator)6 ValueAnimator (android.animation.ValueAnimator)6 Rect (android.graphics.Rect)6 RectF (android.graphics.RectF)6 FloatingIconView (com.android.launcher3.views.FloatingIconView)6 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)6 Point (android.graphics.Point)5 Size (android.util.Size)4 FloatingIconView.getFloatingIconView (com.android.launcher3.views.FloatingIconView.getFloatingIconView)4 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)4 RectFSpringAnim (com.android.quickstep.util.RectFSpringAnim)4 FloatingWidgetView (com.android.quickstep.views.FloatingWidgetView)4 Matrix (android.graphics.Matrix)2 Drawable (android.graphics.drawable.Drawable)2 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)2 MultiValueUpdateListener (com.android.quickstep.util.MultiValueUpdateListener)2 SurfaceParams (com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)2 AnimatorSet (android.animation.AnimatorSet)1