Fix enter/exit horizontal ActivityEmbedding split with legacy transition

For animation spec, before, we only consider animation to/from
left/right. Now, we also check top/bottom.

Bug: 241043533
Test: Verify with launching activity into horizontal split.
Change-Id: Ia7b56105de167a13ada064fe7daf8f1dbae6aa34
This commit is contained in:
Chris Li
2022-11-22 17:02:56 +08:00
parent 4013b5600d
commit 57e9c36b72
2 changed files with 33 additions and 12 deletions

View File

@@ -86,13 +86,23 @@ class TaskFragmentAnimationSpec {
/** Animation for target that is opening in a change transition. */
@NonNull
Animation createChangeBoundsOpenAnimation(@NonNull RemoteAnimationTarget target) {
final Rect bounds = target.localBounds;
// The target will be animated in from left or right depends on its position.
final int startLeft = bounds.left == 0 ? -bounds.width() : bounds.width();
final Rect parentBounds = target.taskInfo.configuration.windowConfiguration.getBounds();
final Rect bounds = target.screenSpaceBounds;
final int startLeft;
final int startTop;
if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
// The window will be animated in from left or right depending on its position.
startTop = 0;
startLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
} else {
// The window will be animated in from top or bottom depending on its position.
startTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
startLeft = 0;
}
// The position should be 0-based as we will post translate in
// TaskFragmentAnimationAdapter#onAnimationUpdate
final Animation animation = new TranslateAnimation(startLeft, 0, 0, 0);
final Animation animation = new TranslateAnimation(startLeft, 0, startTop, 0);
animation.setInterpolator(mFastOutExtraSlowInInterpolator);
animation.setDuration(CHANGE_ANIMATION_DURATION);
animation.initialize(bounds.width(), bounds.height(), bounds.width(), bounds.height());
@@ -103,13 +113,24 @@ class TaskFragmentAnimationSpec {
/** Animation for target that is closing in a change transition. */
@NonNull
Animation createChangeBoundsCloseAnimation(@NonNull RemoteAnimationTarget target) {
final Rect bounds = target.localBounds;
// The target will be animated out to left or right depends on its position.
final int endLeft = bounds.left == 0 ? -bounds.width() : bounds.width();
final Rect parentBounds = target.taskInfo.configuration.windowConfiguration.getBounds();
// TODO(b/258126915): we want to keep track of the closing start bounds
final Rect bounds = target.screenSpaceBounds;
final int endTop;
final int endLeft;
if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
// The window will be animated out to left or right depending on its position.
endTop = 0;
endLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
} else {
// The window will be animated out to top or bottom depending on its position.
endTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
endLeft = 0;
}
// The position should be 0-based as we will post translate in
// TaskFragmentAnimationAdapter#onAnimationUpdate
final Animation animation = new TranslateAnimation(0, endLeft, 0, 0);
final Animation animation = new TranslateAnimation(0, endLeft, 0, endTop);
animation.setInterpolator(mFastOutExtraSlowInInterpolator);
animation.setDuration(CHANGE_ANIMATION_DURATION);
animation.initialize(bounds.width(), bounds.height(), bounds.width(), bounds.height());

View File

@@ -86,11 +86,11 @@ class ActivityEmbeddingAnimationSpec {
final int startLeft;
final int startTop;
if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
// The window will be animated in from left or right depends on its position.
// The window will be animated in from left or right depending on its position.
startTop = 0;
startLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
} else {
// The window will be animated in from top or bottom depends on its position.
// The window will be animated in from top or bottom depending on its position.
startTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
startLeft = 0;
}
@@ -114,11 +114,11 @@ class ActivityEmbeddingAnimationSpec {
final int endTop;
final int endLeft;
if (parentBounds.top == bounds.top && parentBounds.bottom == bounds.bottom) {
// The window will be animated out to left or right depends on its position.
// The window will be animated out to left or right depending on its position.
endTop = 0;
endLeft = parentBounds.left == bounds.left ? -bounds.width() : bounds.width();
} else {
// The window will be animated out to top or bottom depends on its position.
// The window will be animated out to top or bottom depending on its position.
endTop = parentBounds.top == bounds.top ? -bounds.height() : bounds.height();
endLeft = 0;
}