diff options
2 files changed, 33 insertions, 12 deletions
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationSpec.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationSpec.java index a7d47ef81687..13afa4910ae1 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationSpec.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationSpec.java @@ -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()); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java index 65a7d09dafa3..d10a6744b5f1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java @@ -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; } |