diff options
| author | 2022-12-19 18:26:04 +0800 | |
|---|---|---|
| committer | 2023-01-05 04:50:43 +0000 | |
| commit | 166d53bdb97e34b39a9d2b57ce661f32e60d64fb (patch) | |
| tree | 0906cb89cc9c426d60906cc77279c9ec91aeec16 | |
| parent | 1b1f9f6c88b8a511421ddb721aaba3483d52e8c5 (diff) | |
Override animation background with app override color
Order of color to use:
1. Color set with Activity.overridePendingTransition.
2. Color set with the new Jetpack APIs.
3. Task background color.
Bug: 263047900
Test: verify with demo app
Change-Id: I3441ef3705f5a2dd54e855999a8a0c0055f677bc
| -rw-r--r-- | services/core/java/com/android/server/wm/Transition.java | 27 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowContainer.java | 28 |
2 files changed, 40 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index c874747b0b5a..5ad44b326aec 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1730,13 +1730,26 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } if (activityRecord != null || (taskFragment != null && taskFragment.isEmbedded())) { - // Set background color to Task theme color for activity and embedded TaskFragment - // in case we want to show background during the animation. - final Task parentTask = activityRecord != null - ? activityRecord.getTask() - : taskFragment.getTask(); - final int backgroundColor = ColorUtils.setAlphaComponent( - parentTask.getTaskDescription().getBackgroundColor(), 255); + final int backgroundColor; + final TaskFragment organizedTf = activityRecord != null + ? activityRecord.getOrganizedTaskFragment() + : taskFragment.getOrganizedTaskFragment(); + if (organizedTf != null && organizedTf.getAnimationParams() + .getAnimationBackgroundColor() != 0) { + // This window is embedded and has an animation background color set on the + // TaskFragment. Pass this color with this window, so the handler can use it as + // the animation background color if needed, + backgroundColor = organizedTf.getAnimationParams() + .getAnimationBackgroundColor(); + } else { + // Set background color to Task theme color for activity and embedded + // TaskFragment in case we want to show background during the animation. + final Task parentTask = activityRecord != null + ? activityRecord.getTask() + : taskFragment.getTask(); + backgroundColor = ColorUtils.setAlphaComponent( + parentTask.getTaskDescription().getBackgroundColor(), 255); + } change.setBackgroundColor(backgroundColor); } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index cb5a4338c567..700016be62f8 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3145,14 +3145,26 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // which if set originates from a call to overridePendingAppTransition. backgroundColorForTransition = adapter.getBackgroundColor(); } else { - // Otherwise default to the window's background color if provided through - // the theme as the background color for the animation - the top most window - // with a valid background color and showBackground set takes precedence. - final Task parentTask = activityRecord != null - ? activityRecord.getTask() - : taskFragment.getTask(); - backgroundColorForTransition = ColorUtils.setAlphaComponent( - parentTask.getTaskDescription().getBackgroundColor(), 255); + final TaskFragment organizedTf = activityRecord != null + ? activityRecord.getOrganizedTaskFragment() + : taskFragment.getOrganizedTaskFragment(); + if (organizedTf != null && organizedTf.getAnimationParams() + .getAnimationBackgroundColor() != 0) { + // This window is embedded and has an animation background color set on the + // TaskFragment. Pass this color with this window, so the handler can use it + // as the animation background color if needed, + backgroundColorForTransition = organizedTf.getAnimationParams() + .getAnimationBackgroundColor(); + } else { + // Otherwise default to the window's background color if provided through + // the theme as the background color for the animation - the top most window + // with a valid background color and showBackground set takes precedence. + final Task parentTask = activityRecord != null + ? activityRecord.getTask() + : taskFragment.getTask(); + backgroundColorForTransition = ColorUtils.setAlphaComponent( + parentTask.getTaskDescription().getBackgroundColor(), 255); + } } animationRunnerBuilder.setTaskBackgroundColor(backgroundColorForTransition); } |