diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 75a3450ce6..280b9eb23c 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -120,6 +120,7 @@ import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import com.android.app.animation.Animations; +import com.android.app.animation.Interpolators; import com.android.internal.jank.Cuj; import com.android.internal.util.LatencyTracker; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; @@ -232,7 +233,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener private static final int MAX_NUM_TASKS = 5; // Cross-fade duration between App Widget and App - private static final int WIDGET_CROSSFADE_DURATION_MILLIS = 125; + private static final int WIDGET_CROSSFADE_DURATION_MILLIS = 666; protected final QuickstepLauncher mLauncher; protected final DragLayer mDragLayer; @@ -1488,15 +1489,20 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener 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. + // FloatingIconView can be seen morphing into the icon shape. final float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION; RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect, closingWindowStartRect, closingWindowOriginalRect, startWindowCornerRadius) { @Override public void onUpdate(RectF currentRectF, float progress) { - finalFloatingIconView.update(1f, currentRectF, progress, windowAlphaThreshold, - getCornerRadius(progress), false); + // We want the icon alpha to be 1 once this threshold is met, so that it can be + // seen morphing into the icon shape. But before the threshold, we want to limit + // the alpha to reduce the blur effect behind the window. + float iconAlpha = + Interpolators.clampToProgress(progress, 0f, windowAlphaThreshold); + finalFloatingIconView.update(iconAlpha, currentRectF, progress, + windowAlphaThreshold, getCornerRadius(progress), false); super.onUpdate(currentRectF, progress); } diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 25587b40cd..1120cce8be 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -36,6 +36,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.app.animation.Interpolators; import com.android.launcher3.LauncherState; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.model.data.ItemInfo; @@ -141,7 +142,7 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler< true /* hideOriginal */, iconLocation, false /* isOpening */); // 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. + // FloatingIconView can be seen morphing into the icon shape. float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION; return new FloatingViewHomeAnimationFactory(floatingIconView) { @@ -189,7 +190,11 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler< float progress, float radius, int overlayAlpha) { - floatingIconView.update(1f /* alpha */, currentRect, progress, windowAlphaThreshold, + // We want the icon alpha to be 1 once this threshold is met, so that it can be + // seen morphing into the icon shape. But before the threshold, we want to limit + // the alpha to reduce the blur effect behind the window. + float iconAlpha = Interpolators.clampToProgress(progress, 0f, windowAlphaThreshold); + floatingIconView.update(iconAlpha, currentRect, progress, windowAlphaThreshold, radius, false, overlayAlpha); } diff --git a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt index 273bba8b5f..4707d894e6 100644 --- a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt +++ b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt @@ -19,15 +19,19 @@ package com.android.quickstep.util import android.animation.Animator import android.animation.AnimatorListenerAdapter import android.animation.AnimatorSet +import android.animation.ValueAnimator import android.graphics.Matrix import android.graphics.Path +import android.graphics.PointF import android.graphics.RectF import android.util.Log +import android.view.SurfaceControl import android.view.View import android.view.animation.PathInterpolator import androidx.core.graphics.transform import com.android.app.animation.Animations import com.android.app.animation.Interpolators +import com.android.app.animation.Interpolators.EMPHASIZED import com.android.app.animation.Interpolators.LINEAR import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WORKSPACE_STATE @@ -41,7 +45,10 @@ import com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTROLLER import com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW import com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM import com.android.launcher3.uioverrides.QuickstepLauncher +import com.android.launcher3.R +import com.android.launcher3.Utilities import com.android.quickstep.views.RecentsView +import com.android.launcher3.Flags const val TAG = "ScalingWorkspaceRevealAnim" @@ -76,9 +83,13 @@ class ScalingWorkspaceRevealAnim( cubicTo(0.235f, 0.6855f, 0.235f, 1f, 1f, 1f) } ) + + val BLUR_INTERPOLATOR = Interpolators.clampToProgress(EMPHASIZED, 0f, 0.666f) } private val animation = PendingAnimation(SCALE_DURATION_MS) + private var blurLayer: SurfaceControl? = null + private var transaction: SurfaceControl.Transaction? = null init { // Make sure the starting state is right for the animation. @@ -96,6 +107,7 @@ class ScalingWorkspaceRevealAnim( LauncherState.BACKGROUND_APP, setupConfig, ) + addBlurLayer() val workspace = launcher.workspace val hotseat = launcher.hotseat @@ -149,14 +161,30 @@ class ScalingWorkspaceRevealAnim( val transitionConfig = StateAnimationConfig() transitionConfig.duration = SCALE_DURATION_MS - // Match the Wallpaper animation to the rest of the content. + // Match the Wallpaper depth to the rest of the content. val depthController = (launcher as? QuickstepLauncher)?.depthController transitionConfig.setInterpolator(StateAnimationConfig.ANIM_DEPTH, SCALE_INTERPOLATOR) + depthController?.pauseBlursOnWindows(true) // Blurring is handled by the scrim layer. depthController?.stateDepth?.value = LauncherState.BACKGROUND_APP.getDepth(launcher) depthController?.setStateWithAnimation(LauncherState.NORMAL, transitionConfig, animation) - // Make sure that the contrast scrim animates correctly if needed. - transitionConfig.setInterpolator(StateAnimationConfig.ANIM_SCRIM_FADE, SCALE_INTERPOLATOR) + // Add a blur animation to the scrim layer. + var maxBlurRadius = launcher.resources.getDimensionPixelSize( + if (Flags.allAppsBlur() || Flags.enableOverviewBackgroundWallpaperBlur()) { + R.dimen.max_depth_blur_radius_enhanced + } else { + R.integer.max_depth_blur_radius + } + ) + val blurAnimator = ValueAnimator.ofFloat(1f, 0f) + blurAnimator.setInterpolator(BLUR_INTERPOLATOR) + blurAnimator.addUpdateListener { + applyBlur(maxBlurRadius * blurAnimator.animatedValue as Float) + } + animation.add(blurAnimator) + + // Make sure that the contrast scrim animates correctly (alongside the blur) if needed. + transitionConfig.setInterpolator(StateAnimationConfig.ANIM_SCRIM_FADE, BLUR_INTERPOLATOR) launcher.workspace.stateTransitionAnimation.setScrim( animation, LauncherState.NORMAL, @@ -228,6 +256,8 @@ class ScalingWorkspaceRevealAnim( // Reset the cached animations. Animations.setOngoingAnimation(workspace, animation = null) Animations.setOngoingAnimation(hotseat, animation = null) + removeBlurLayer() + depthController?.pauseBlursOnWindows(false) Log.d(TAG, "alpha of workspace at the end of animation: ${workspace.alpha}") } @@ -249,4 +279,45 @@ class ScalingWorkspaceRevealAnim( launcher.stateManager.setCurrentAnimation(animators, LauncherState.NORMAL) animators.start() } + + private fun addBlurLayer() { + val parent = launcher.dragLayer.viewRootImpl?.surfaceControl ?: return + if (!parent.isValid) { + Log.e(TAG, "Parent surface is not ready at the moment. Can't apply blur.") + return + } + val blurLayer = + SurfaceControl.Builder() + .setName("Home to launcher blur layer") + .setCallsite("ScalingWorkspaceRevealAnim") + .setParent(parent) + .setOpaque(false) + .setHidden(false) + .build() + transaction = + SurfaceControl.Transaction().apply { + setAlpha(blurLayer, 0f) + show(blurLayer) + } + this.blurLayer = blurLayer + } + + private fun removeBlurLayer() { + blurLayer?.let { + if (it.isValid) { + transaction?.remove(it)?.apply() + } + } + blurLayer = null + transaction?.close() + transaction = null + } + + private fun applyBlur(blurRadius: Float) { + blurLayer?.let { + if (it.isValid) { + transaction?.setBackgroundBlurRadius(it, blurRadius.toInt())?.apply() + } + } + } }