Merge "Apply rounded corners to startWindow" into tm-qpr-dev am: 6db1ce2740

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20222491

Change-Id: I3ad8e6719a64c63ac911f66debf50bdf91ae045c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Massimo Carli
2022-12-05 09:47:51 +00:00
committed by Automerger Merge Worker
6 changed files with 48 additions and 15 deletions

View File

@@ -61,6 +61,12 @@ public final class StartingWindowRemovalInfo implements Parcelable {
*/ */
public boolean deferRemoveForIme; public boolean deferRemoveForIme;
/**
* The rounded corner radius
* @hide
*/
public float roundedCornerRadius;
public StartingWindowRemovalInfo() { public StartingWindowRemovalInfo() {
} }
@@ -80,6 +86,7 @@ public final class StartingWindowRemovalInfo implements Parcelable {
mainFrame = source.readTypedObject(Rect.CREATOR); mainFrame = source.readTypedObject(Rect.CREATOR);
playRevealAnimation = source.readBoolean(); playRevealAnimation = source.readBoolean();
deferRemoveForIme = source.readBoolean(); deferRemoveForIme = source.readBoolean();
roundedCornerRadius = source.readFloat();
} }
@Override @Override
@@ -89,6 +96,7 @@ public final class StartingWindowRemovalInfo implements Parcelable {
dest.writeTypedObject(mainFrame, flags); dest.writeTypedObject(mainFrame, flags);
dest.writeBoolean(playRevealAnimation); dest.writeBoolean(playRevealAnimation);
dest.writeBoolean(deferRemoveForIme); dest.writeBoolean(deferRemoveForIme);
dest.writeFloat(roundedCornerRadius);
} }
@Override @Override
@@ -96,6 +104,7 @@ public final class StartingWindowRemovalInfo implements Parcelable {
return "StartingWindowRemovalInfo{taskId=" + taskId return "StartingWindowRemovalInfo{taskId=" + taskId
+ " frame=" + mainFrame + " frame=" + mainFrame
+ " playRevealAnimation=" + playRevealAnimation + " playRevealAnimation=" + playRevealAnimation
+ " roundedCornerRadius=" + roundedCornerRadius
+ " deferRemoveForIme=" + deferRemoveForIme + "}"; + " deferRemoveForIme=" + deferRemoveForIme + "}";
} }

View File

@@ -50,13 +50,17 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
private final float mIconStartAlpha; private final float mIconStartAlpha;
private final float mBrandingStartAlpha; private final float mBrandingStartAlpha;
private final TransactionPool mTransactionPool; private final TransactionPool mTransactionPool;
// TODO(b/261167708): Clean enter animation code after moving Letterbox code to Shell
private final float mRoundedCornerRadius;
private Runnable mFinishCallback; private Runnable mFinishCallback;
SplashScreenExitAnimation(Context context, SplashScreenView view, SurfaceControl leash, SplashScreenExitAnimation(Context context, SplashScreenView view, SurfaceControl leash,
Rect frame, int mainWindowShiftLength, TransactionPool pool, Runnable handleFinish) { Rect frame, int mainWindowShiftLength, TransactionPool pool, Runnable handleFinish,
float roundedCornerRadius) {
mSplashScreenView = view; mSplashScreenView = view;
mFirstWindowSurface = leash; mFirstWindowSurface = leash;
mRoundedCornerRadius = roundedCornerRadius;
if (frame != null) { if (frame != null) {
mFirstWindowFrame.set(frame); mFirstWindowFrame.set(frame);
} }
@@ -97,7 +101,7 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
SplashScreenExitAnimationUtils.startAnimations(mSplashScreenView, mFirstWindowSurface, SplashScreenExitAnimationUtils.startAnimations(mSplashScreenView, mFirstWindowSurface,
mMainWindowShiftLength, mTransactionPool, mFirstWindowFrame, mAnimationDuration, mMainWindowShiftLength, mTransactionPool, mFirstWindowFrame, mAnimationDuration,
mIconFadeOutDuration, mIconStartAlpha, mBrandingStartAlpha, mAppRevealDelay, mIconFadeOutDuration, mIconStartAlpha, mBrandingStartAlpha, mAppRevealDelay,
mAppRevealDuration, this); mAppRevealDuration, this, mRoundedCornerRadius);
} }
private void reset() { private void reset() {

View File

@@ -61,6 +61,24 @@ public class SplashScreenExitAnimationUtils {
new PathInterpolator(0f, 0f, 0.4f, 1f); new PathInterpolator(0f, 0f, 0.4f, 1f);
private static final Interpolator SHIFT_UP_INTERPOLATOR = new PathInterpolator(0f, 0f, 0f, 1f); private static final Interpolator SHIFT_UP_INTERPOLATOR = new PathInterpolator(0f, 0f, 0f, 1f);
/**
* Creates and starts the animator to fade out the icon, reveal the app, and shift up main
* window with rounded corner radius.
*/
static void startAnimations(ViewGroup splashScreenView,
SurfaceControl firstWindowSurface, int mainWindowShiftLength,
TransactionPool transactionPool, Rect firstWindowFrame, int animationDuration,
int iconFadeOutDuration, float iconStartAlpha, float brandingStartAlpha,
int appRevealDelay, int appRevealDuration, Animator.AnimatorListener animatorListener,
float roundedCornerRadius) {
ValueAnimator animator =
createAnimator(splashScreenView, firstWindowSurface, mainWindowShiftLength,
transactionPool, firstWindowFrame, animationDuration, iconFadeOutDuration,
iconStartAlpha, brandingStartAlpha, appRevealDelay, appRevealDuration,
animatorListener, roundedCornerRadius);
animator.start();
}
/** /**
* Creates and starts the animator to fade out the icon, reveal the app, and shift up main * Creates and starts the animator to fade out the icon, reveal the app, and shift up main
* window. * window.
@@ -71,12 +89,10 @@ public class SplashScreenExitAnimationUtils {
TransactionPool transactionPool, Rect firstWindowFrame, int animationDuration, TransactionPool transactionPool, Rect firstWindowFrame, int animationDuration,
int iconFadeOutDuration, float iconStartAlpha, float brandingStartAlpha, int iconFadeOutDuration, float iconStartAlpha, float brandingStartAlpha,
int appRevealDelay, int appRevealDuration, Animator.AnimatorListener animatorListener) { int appRevealDelay, int appRevealDuration, Animator.AnimatorListener animatorListener) {
ValueAnimator animator = startAnimations(splashScreenView, firstWindowSurface, mainWindowShiftLength,
createAnimator(splashScreenView, firstWindowSurface, mainWindowShiftLength,
transactionPool, firstWindowFrame, animationDuration, iconFadeOutDuration, transactionPool, firstWindowFrame, animationDuration, iconFadeOutDuration,
iconStartAlpha, brandingStartAlpha, appRevealDelay, appRevealDuration, iconStartAlpha, brandingStartAlpha, appRevealDelay, appRevealDuration,
animatorListener); animatorListener, 0f /* roundedCornerRadius */);
animator.start();
} }
/** /**
@@ -87,7 +103,8 @@ public class SplashScreenExitAnimationUtils {
SurfaceControl firstWindowSurface, int mMainWindowShiftLength, SurfaceControl firstWindowSurface, int mMainWindowShiftLength,
TransactionPool transactionPool, Rect firstWindowFrame, int animationDuration, TransactionPool transactionPool, Rect firstWindowFrame, int animationDuration,
int iconFadeOutDuration, float iconStartAlpha, float brandingStartAlpha, int iconFadeOutDuration, float iconStartAlpha, float brandingStartAlpha,
int appRevealDelay, int appRevealDuration, Animator.AnimatorListener animatorListener) { int appRevealDelay, int appRevealDuration, Animator.AnimatorListener animatorListener,
float roundedCornerRadius) {
// reveal app // reveal app
final float transparentRatio = 0.8f; final float transparentRatio = 0.8f;
final int globalHeight = splashScreenView.getHeight(); final int globalHeight = splashScreenView.getHeight();
@@ -124,7 +141,7 @@ public class SplashScreenExitAnimationUtils {
shiftUpAnimation = new ShiftUpAnimation(0, -mMainWindowShiftLength, occludeHoleView, shiftUpAnimation = new ShiftUpAnimation(0, -mMainWindowShiftLength, occludeHoleView,
firstWindowSurface, splashScreenView, transactionPool, firstWindowFrame, firstWindowSurface, splashScreenView, transactionPool, firstWindowFrame,
mMainWindowShiftLength); mMainWindowShiftLength, roundedCornerRadius);
} }
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
@@ -289,8 +306,8 @@ public class SplashScreenExitAnimationUtils {
public ShiftUpAnimation(float fromYDelta, float toYDelta, View occludeHoleView, public ShiftUpAnimation(float fromYDelta, float toYDelta, View occludeHoleView,
SurfaceControl firstWindowSurface, ViewGroup splashScreenView, SurfaceControl firstWindowSurface, ViewGroup splashScreenView,
TransactionPool transactionPool, Rect firstWindowFrame, TransactionPool transactionPool, Rect firstWindowFrame,
int mainWindowShiftLength) { int mainWindowShiftLength, float roundedCornerRadius) {
mFromYDelta = fromYDelta; mFromYDelta = fromYDelta - roundedCornerRadius;
mToYDelta = toYDelta; mToYDelta = toYDelta;
mOccludeHoleView = occludeHoleView; mOccludeHoleView = occludeHoleView;
mApplier = new SyncRtSurfaceTransactionApplier(occludeHoleView); mApplier = new SyncRtSurfaceTransactionApplier(occludeHoleView);

View File

@@ -993,10 +993,11 @@ public class SplashscreenContentDrawer {
* Create and play the default exit animation for splash screen view. * Create and play the default exit animation for splash screen view.
*/ */
void applyExitAnimation(SplashScreenView view, SurfaceControl leash, void applyExitAnimation(SplashScreenView view, SurfaceControl leash,
Rect frame, Runnable finishCallback, long createTime) { Rect frame, Runnable finishCallback, long createTime, float roundedCornerRadius) {
final Runnable playAnimation = () -> { final Runnable playAnimation = () -> {
final SplashScreenExitAnimation animation = new SplashScreenExitAnimation(mContext, final SplashScreenExitAnimation animation = new SplashScreenExitAnimation(mContext,
view, leash, frame, mMainWindowShiftLength, mTransactionPool, finishCallback); view, leash, frame, mMainWindowShiftLength, mTransactionPool, finishCallback,
roundedCornerRadius);
animation.startAnimations(); animation.startAnimations();
}; };
if (view.getIconView() == null) { if (view.getIconView() == null) {

View File

@@ -646,7 +646,7 @@ public class StartingSurfaceDrawer {
mSplashscreenContentDrawer.applyExitAnimation(record.mContentView, mSplashscreenContentDrawer.applyExitAnimation(record.mContentView,
removalInfo.windowAnimationLeash, removalInfo.mainFrame, removalInfo.windowAnimationLeash, removalInfo.mainFrame,
() -> removeWindowInner(record.mDecorView, true), () -> removeWindowInner(record.mDecorView, true),
record.mCreateTime); record.mCreateTime, removalInfo.roundedCornerRadius);
} else { } else {
// the SplashScreenView has been copied to client, hide the view to skip // the SplashScreenView has been copied to client, hide the view to skip
// default exit animation // default exit animation

View File

@@ -691,6 +691,8 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
if (mainWindow == null || mainWindow.mRemoved) { if (mainWindow == null || mainWindow.mRemoved) {
removalInfo.playRevealAnimation = false; removalInfo.playRevealAnimation = false;
} else if (removalInfo.playRevealAnimation && playShiftUpAnimation) { } else if (removalInfo.playRevealAnimation && playShiftUpAnimation) {
removalInfo.roundedCornerRadius =
topActivity.mLetterboxUiController.getRoundedCornersRadius(mainWindow);
removalInfo.windowAnimationLeash = applyStartingWindowAnimation(mainWindow); removalInfo.windowAnimationLeash = applyStartingWindowAnimation(mainWindow);
removalInfo.mainFrame = mainWindow.getRelativeFrame(); removalInfo.mainFrame = mainWindow.getRelativeFrame();
} }