From 8e4cae12584e899e25fd55945adb04114201eb73 Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Thu, 14 Nov 2024 15:47:37 +0000 Subject: [PATCH] Change fallback closing animators for Desktop Mode. The main changes are: 1. the amount to move the window horizontally (much less for Desktop Mode), and 2. the timing for when the alpha animation is applied - we remove the 25ms delay for freeform windows. Bug: 378675987 Test: manual Flag: com.android.window.flags.enable_desktop_windowing_exit_transitions Change-Id: Ieeb6b827eee2e6314ea9c79213cdf401f48d3c85 --- quickstep/res/values/dimens.xml | 1 + .../launcher3/QuickstepTransitionManager.java | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 782a705bfd..527ddf7d7c 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -118,6 +118,7 @@ 115dp + 36dp 100dp diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 18337d3991..3bf5f3b351 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -108,6 +108,7 @@ import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; +import android.window.DesktopModeFlags; import android.window.RemoteTransition; import android.window.TransitionFilter; import android.window.WindowAnimationState; @@ -166,11 +167,13 @@ import com.android.systemui.animation.RemoteAnimationRunnerCompat; import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.startingsurface.IStartingWindowListener; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -233,6 +236,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener protected final Handler mHandler; private final float mClosingWindowTransY; + private final float mClosingFreeformWindowTransY; private final float mMaxShadowRadius; private final StartingWindowListener mStartingWindowListener = @@ -290,6 +294,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Resources res = mLauncher.getResources(); mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y); + mClosingFreeformWindowTransY = + res.getDimensionPixelSize(R.dimen.closing_freeform_window_trans_y); mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius); mLauncher.addOnDeviceProfileChangeListener(this); @@ -1480,10 +1486,16 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener ? 0 : getWindowCornerRadius(mLauncher); float startShadowRadius = areAllTargetsTranslucent(appTargets) ? 0 : mMaxShadowRadius; closingAnimator.setDuration(duration); + boolean isFreeform = isFreeformAnimation(appTargets); + float translateY = isFreeform ? mClosingFreeformWindowTransY : mClosingWindowTransY; + float endScale = isFreeform ? 0.95f : 1f; + Interpolator alphaInterpolator = isFreeform + ? clampToDuration(LINEAR, 0, 100, duration) + : clampToDuration(LINEAR, 25, 125, duration); closingAnimator.addUpdateListener(new MultiValueUpdateListener() { - FloatProp mDy = new FloatProp(0, mClosingWindowTransY, DECELERATE_1_7); - FloatProp mScale = new FloatProp(1f, 1f, DECELERATE_1_7); - FloatProp mAlpha = new FloatProp(1f, 0f, clampToDuration(LINEAR, 25, 125, duration)); + FloatProp mDy = new FloatProp(0, translateY, DECELERATE_1_7); + FloatProp mScale = new FloatProp(1f, endScale, DECELERATE_1_7); + FloatProp mAlpha = new FloatProp(1f, 0f, alphaInterpolator); FloatProp mShadowRadius = new FloatProp(startShadowRadius, 0, DECELERATE_1_7); @Override @@ -1532,6 +1544,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener return closingAnimator; } + private boolean isFreeformAnimation(RemoteAnimationTarget[] appTargets) { + return DesktopModeStatus.canEnterDesktopMode(mLauncher.getApplicationContext()) + && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue() + && Arrays.stream(appTargets) + .anyMatch(app -> app.taskInfo != null && app.taskInfo.isFreeform()); + } + private void addCujInstrumentation(Animator anim, int cuj) { anim.addListener(getCujAnimationSuccessListener(cuj)); }