From 9ebb08d22e8598eb6dc676a24bd34068cdc7a745 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 1 Dec 2021 14:22:13 +0100 Subject: [PATCH 1/2] Update default activity animations For T we will be using the cross fade animation proposed in go/t-activity-transitions (https://direct.googleplex.com/#/spec/241720001&247800001) - this is what we are implemented here This animation only works properly if shell transitions are enabled as it uses the edgeExtension effect currently only implemented in shell Test: atest FlickerTests Bug: 202844659 Change-Id: Ibb863815b8a25f8d6ad0201203f7d550948f7158 --- core/res/res/anim/activity_close_enter.xml | 37 +++++++++++++++++----- core/res/res/anim/activity_close_exit.xml | 37 ++++++++++++++-------- core/res/res/anim/activity_open_enter.xml | 29 +++++++++++------ core/res/res/anim/activity_open_exit.xml | 37 ++++++++++++++-------- 4 files changed, 96 insertions(+), 44 deletions(-) diff --git a/core/res/res/anim/activity_close_enter.xml b/core/res/res/anim/activity_close_enter.xml index 9fa7c5498ea6c..0fefb5113dfcf 100644 --- a/core/res/res/anim/activity_close_enter.xml +++ b/core/res/res/anim/activity_close_enter.xml @@ -19,16 +19,37 @@ - + + + android:startOffset="0" + android:duration="450" /> + + \ No newline at end of file diff --git a/core/res/res/anim/activity_close_exit.xml b/core/res/res/anim/activity_close_exit.xml index 1599ae8cb19fc..f807c26dda200 100644 --- a/core/res/res/anim/activity_close_exit.xml +++ b/core/res/res/anim/activity_close_exit.xml @@ -18,27 +18,38 @@ --> + android:shareInterpolator="false"> + - + + + android:startOffset="0" + android:duration="450" /> + + diff --git a/core/res/res/anim/activity_open_enter.xml b/core/res/res/anim/activity_open_enter.xml index 38d3e8ed06ce9..1674dab3040a3 100644 --- a/core/res/res/anim/activity_open_enter.xml +++ b/core/res/res/anim/activity_open_enter.xml @@ -18,6 +18,7 @@ + - + + + android:duration="450" /> + + diff --git a/core/res/res/anim/activity_open_exit.xml b/core/res/res/anim/activity_open_exit.xml index 3865d2149f42f..372f2c8e09f66 100644 --- a/core/res/res/anim/activity_open_exit.xml +++ b/core/res/res/anim/activity_open_exit.xml @@ -19,27 +19,36 @@ - + android:interpolator="@interpolator/standard_accelerate" + android:startOffset="0" + android:duration="450" /> - + android:startOffset="0" + android:duration="450" /> + + \ No newline at end of file From 6b600cf1a9b721876f3f9efddb02abc1b5d73452 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Thu, 20 Jan 2022 15:59:50 +0100 Subject: [PATCH 2/2] Use legacy transitions in legacy transition system The new activity transitions are currently only supported in shell so we want to replace them with the old transitions when running using the legacy transition system Fixes: 215512394 Test: Flash and make sure we are using the old activity transitions when shell transitions are disabled Change-Id: I602852b16effa150fe697262a7d7e506c464d62a --- .../internal/policy/TransitionAnimation.java | 25 +++++++++++ .../res/anim/activity_close_enter_legacy.xml | 34 ++++++++++++++ .../res/anim/activity_close_exit_legacy.xml | 44 ++++++++++++++++++ .../res/anim/activity_open_enter_legacy.xml | 42 +++++++++++++++++ .../res/anim/activity_open_exit_legacy.xml | 45 +++++++++++++++++++ core/res/res/values/symbols.xml | 6 +++ 6 files changed, 196 insertions(+) create mode 100644 core/res/res/anim/activity_close_enter_legacy.xml create mode 100644 core/res/res/anim/activity_close_exit_legacy.xml create mode 100644 core/res/res/anim/activity_open_enter_legacy.xml create mode 100644 core/res/res/anim/activity_open_exit_legacy.xml diff --git a/core/java/com/android/internal/policy/TransitionAnimation.java b/core/java/com/android/internal/policy/TransitionAnimation.java index ece6f2f3571be..37c96e71a0a8d 100644 --- a/core/java/com/android/internal/policy/TransitionAnimation.java +++ b/core/java/com/android/internal/policy/TransitionAnimation.java @@ -98,6 +98,10 @@ public class TransitionAnimation { private static final String DEFAULT_PACKAGE = "android"; + // TODO (b/215515255): remove once we full migrate to shell transitions + private static final boolean SHELL_TRANSITIONS_ENABLED = + SystemProperties.getBoolean("persist.debug.shell_transit", false); + private final Context mContext; private final String mTag; @@ -252,6 +256,9 @@ public class TransitionAnimation { resId = ent.array.getResourceId(animAttr, 0); } } + if (!SHELL_TRANSITIONS_ENABLED) { + resId = updateToLegacyIfNeeded(resId); + } resId = updateToTranslucentAnimIfNeeded(resId, transit); if (ResourceId.isValid(resId)) { return loadAnimationSafely(context, resId, mTag); @@ -259,6 +266,24 @@ public class TransitionAnimation { return null; } + /** + * Replace animations that are not compatible with the legacy transition system with ones that + * are compatible with it. + * TODO (b/215515255): remove once we full migrate to shell transitions + */ + private int updateToLegacyIfNeeded(int anim) { + if (anim == R.anim.activity_open_enter) { + return R.anim.activity_open_enter_legacy; + } else if (anim == R.anim.activity_open_exit) { + return R.anim.activity_open_exit_legacy; + } else if (anim == R.anim.activity_close_enter) { + return R.anim.activity_close_enter_legacy; + } else if (anim == R.anim.activity_close_exit) { + return R.anim.activity_close_exit_legacy; + } + return anim; + } + /** Load animation by attribute Id from a specific AnimationStyle resource. */ @Nullable public Animation loadAnimationAttr(String packageName, int animStyleResId, int animAttr, diff --git a/core/res/res/anim/activity_close_enter_legacy.xml b/core/res/res/anim/activity_close_enter_legacy.xml new file mode 100644 index 0000000000000..9fa7c5498ea6c --- /dev/null +++ b/core/res/res/anim/activity_close_enter_legacy.xml @@ -0,0 +1,34 @@ + + + + + + \ No newline at end of file diff --git a/core/res/res/anim/activity_close_exit_legacy.xml b/core/res/res/anim/activity_close_exit_legacy.xml new file mode 100644 index 0000000000000..1599ae8cb19fc --- /dev/null +++ b/core/res/res/anim/activity_close_exit_legacy.xml @@ -0,0 +1,44 @@ + + + + + + + diff --git a/core/res/res/anim/activity_open_enter_legacy.xml b/core/res/res/anim/activity_open_enter_legacy.xml new file mode 100644 index 0000000000000..38d3e8ed06ce9 --- /dev/null +++ b/core/res/res/anim/activity_open_enter_legacy.xml @@ -0,0 +1,42 @@ + + + + + + diff --git a/core/res/res/anim/activity_open_exit_legacy.xml b/core/res/res/anim/activity_open_exit_legacy.xml new file mode 100644 index 0000000000000..3865d2149f42f --- /dev/null +++ b/core/res/res/anim/activity_open_exit_legacy.xml @@ -0,0 +1,45 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index f86add6e4e3b6..3b9ae4b6d80d2 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1696,7 +1696,13 @@ + + + + + +