Merge "Fix scrim attachment and detachment issues." into main

This commit is contained in:
Shan Huang
2023-10-16 17:17:14 +00:00
committed by Android (Google) Code Review

View File

@@ -185,6 +185,13 @@ public class LauncherBackAnimationController {
@Override
public void onBackProgressed(BackMotionEvent backMotionEvent) {
mHandler.post(() -> {
LauncherBackAnimationController controller = mControllerRef.get();
if (controller == null
|| controller.mLauncher == null
|| !controller.mLauncher.isStarted()) {
// Skip animating back progress if Launcher isn't visible yet.
return;
}
mProgressAnimator.onBackProgressed(backMotionEvent);
});
}
@@ -294,6 +301,10 @@ public class LauncherBackAnimationController {
SurfaceControl parent = viewRootImpl != null
? viewRootImpl.getSurfaceControl()
: null;
if (parent == null || !parent.isValid()) {
// Parent surface is not ready at the moment. Retry later.
return;
}
boolean isDarkTheme = Utilities.isDarkTheme(mLauncher);
mScrimLayer = new SurfaceControl.Builder()
.setName("Back to launcher background scrim")
@@ -326,6 +337,10 @@ public class LauncherBackAnimationController {
if (!mBackInProgress || mBackTarget == null) {
return;
}
if (mScrimLayer == null) {
// Scrim hasn't been attached yet. Let's attach it.
addScrimLayer();
}
float screenWidth = mStartRect.width();
float screenHeight = mStartRect.height();
float width = Utilities.mapRange(progress, 1, MIN_WINDOW_SCALE) * screenWidth;
@@ -446,6 +461,9 @@ public class LauncherBackAnimationController {
mScrimAlphaAnimator.cancel();
mScrimAlphaAnimator = null;
}
if (mScrimLayer != null) {
removeScrimLayer();
}
}
private void startTransitionAnimations(RectFSpringAnim springAnim, AnimatorSet anim) {