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
This commit is contained in:
Gustav Sennton
2024-11-14 15:47:37 +00:00
parent 7a609d8f1b
commit 8e4cae1258
2 changed files with 23 additions and 3 deletions
@@ -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));
}