Change surface crop/visibilty on to-fullscreen animations
During to-fullscreen animations (either TRANSIT_EXIT_DESKTOP_MODE or TRANSIT_CANCEL_ENTERING_DESKTOP_MODE) hide the surface control when applying the start transaction so that it is not visible in fullscreen size for a frame before the animation from floating size to fullscreen starts immediately after. Test: drag freeform task to fullscreen from desktop mode or by cancelling a drag from fullscreen motion, verify it the task has the right crop and doesn't show a constant fullscreen white background as the app contents scale outwards. Bug: 278602859 Change-Id: I51c0dfc0ca24cd8c2aa3bde1920e51f485934477
This commit is contained in:
@@ -193,8 +193,11 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
|
||||
// This Transition animates a task to fullscreen after being dragged from the status
|
||||
// bar and then released back into the status bar area
|
||||
final SurfaceControl sc = change.getLeash();
|
||||
startT.setWindowCrop(sc, null);
|
||||
startT.apply();
|
||||
// Hide the first (fullscreen) frame because the animation will start from the smaller
|
||||
// scale size.
|
||||
startT.hide(sc)
|
||||
.setWindowCrop(sc, endBounds.width(), endBounds.height())
|
||||
.apply();
|
||||
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setFloatValues(DRAG_FREEFORM_SCALE, 1f);
|
||||
@@ -202,10 +205,10 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
|
||||
final SurfaceControl.Transaction t = mTransactionSupplier.get();
|
||||
animator.addUpdateListener(animation -> {
|
||||
final float scale = animation.getAnimatedFraction();
|
||||
t.setPosition(sc, mStartPosition.x * (1 - scale),
|
||||
mStartPosition.y * (1 - scale));
|
||||
t.setScale(sc, scale, scale);
|
||||
t.apply();
|
||||
t.setPosition(sc, mStartPosition.x * (1 - scale), mStartPosition.y * (1 - scale))
|
||||
.setScale(sc, scale, scale)
|
||||
.show(sc)
|
||||
.apply();
|
||||
});
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -129,8 +129,12 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
|
||||
final int screenWidth = metrics.widthPixels;
|
||||
final int screenHeight = metrics.heightPixels;
|
||||
final SurfaceControl sc = change.getLeash();
|
||||
startT.setCrop(sc, null);
|
||||
startT.apply();
|
||||
final Rect endBounds = change.getEndAbsBounds();
|
||||
// Hide the first (fullscreen) frame because the animation will start from the freeform
|
||||
// size.
|
||||
startT.hide(sc)
|
||||
.setWindowCrop(sc, endBounds.width(), endBounds.height())
|
||||
.apply();
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setFloatValues(0f, 1f);
|
||||
animator.setDuration(FULLSCREEN_ANIMATION_DURATION);
|
||||
@@ -144,9 +148,10 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
|
||||
float fraction = animation.getAnimatedFraction();
|
||||
float currentScaleX = scaleX + ((1 - scaleX) * fraction);
|
||||
float currentScaleY = scaleY + ((1 - scaleY) * fraction);
|
||||
t.setPosition(sc, startPos.x * (1 - fraction), startPos.y * (1 - fraction));
|
||||
t.setScale(sc, currentScaleX, currentScaleY);
|
||||
t.apply();
|
||||
t.setPosition(sc, startPos.x * (1 - fraction), startPos.y * (1 - fraction))
|
||||
.setScale(sc, currentScaleX, currentScaleY)
|
||||
.show(sc)
|
||||
.apply();
|
||||
});
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -71,12 +71,6 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
|
||||
@Mock
|
||||
Resources mResources;
|
||||
@Mock
|
||||
SurfaceControl.Transaction mStartT;
|
||||
@Mock
|
||||
SurfaceControl.Transaction mFinishT;
|
||||
@Mock
|
||||
SurfaceControl.Transaction mAnimationT;
|
||||
@Mock
|
||||
Transitions.TransitionFinishCallback mTransitionFinishCallback;
|
||||
@Mock
|
||||
ShellExecutor mExecutor;
|
||||
@@ -88,7 +82,7 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
doReturn(mExecutor).when(mTransitions).getMainExecutor();
|
||||
doReturn(mAnimationT).when(mTransactionFactory).get();
|
||||
doReturn(new SurfaceControl.Transaction()).when(mTransactionFactory).get();
|
||||
doReturn(mResources).when(mContext).getResources();
|
||||
doReturn(mDisplayMetrics).when(mResources).getDisplayMetrics();
|
||||
when(mResources.getDisplayMetrics())
|
||||
@@ -115,7 +109,9 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
assertTrue(mExitDesktopTaskTransitionHandler
|
||||
.startAnimation(mToken, info, mStartT, mFinishT,
|
||||
.startAnimation(mToken, info,
|
||||
new SurfaceControl.Transaction(),
|
||||
new SurfaceControl.Transaction(),
|
||||
mTransitionFinishCallback));
|
||||
} catch (Exception e) {
|
||||
exceptions.add(e);
|
||||
|
||||
Reference in New Issue
Block a user