Loading core/java/android/window/TaskFragmentAnimationParams.java +1 −1 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ public final class TaskFragmentAnimationParams implements Parcelable { */ public boolean hasOverrideAnimation() { return mOpenAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID || mChangeAnimationResId != DEFAULT_ANIMATION_BACKGROUND_COLOR || mChangeAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID || mCloseAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID; } Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +18 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.window.flags.Flags; import java.util.Map; import java.util.concurrent.Executor; Loading Loading @@ -393,19 +394,31 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { if (splitAttributes == null) { return TaskFragmentAnimationParams.DEFAULT; } final TaskFragmentAnimationParams.Builder builder = new TaskFragmentAnimationParams.Builder(); final int animationBackgroundColor = getAnimationBackgroundColor(splitAttributes); TaskFragmentAnimationParams.Builder builder = new TaskFragmentAnimationParams.Builder(); if (animationBackgroundColor != DEFAULT_ANIMATION_BACKGROUND_COLOR) { builder.setAnimationBackgroundColor(animationBackgroundColor); if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final int openAnimationResId = splitAttributes.getAnimationParams().getOpenAnimationResId(); builder.setOpenAnimationResId(openAnimationResId); final int closeAnimationResId = splitAttributes.getAnimationParams().getCloseAnimationResId(); builder.setCloseAnimationResId(closeAnimationResId); final int changeAnimationResId = splitAttributes.getAnimationParams().getChangeAnimationResId(); builder.setChangeAnimationResId(changeAnimationResId); } // TODO(b/293658614): Allow setting custom open/close/changeAnimationResId. return builder.build(); } @ColorInt private static int getAnimationBackgroundColor(@NonNull SplitAttributes splitAttributes) { int animationBackgroundColor = DEFAULT_ANIMATION_BACKGROUND_COLOR; final AnimationBackground animationBackground = splitAttributes.getAnimationBackground(); AnimationBackground animationBackground = splitAttributes.getAnimationBackground(); if (Flags.activityEmbeddingAnimationCustomizationFlag()) { animationBackground = splitAttributes.getAnimationParams().getAnimationBackground(); } if (animationBackground instanceof AnimationBackground.ColorBackground colorBackground) { animationBackgroundColor = colorBackground.getColor(); } Loading libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/WindowExtensionsTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import androidx.window.extensions.embedding.AnimationBackground; import androidx.window.extensions.embedding.AnimationParams; import androidx.window.extensions.embedding.SplitAttributes; import org.junit.Before; Loading Loading @@ -112,5 +113,13 @@ public class WindowExtensionsTest { .isEqualTo(new SplitAttributes.SplitType.RatioSplitType(0.5f)); assertThat(splitAttributes.getAnimationBackground()) .isEqualTo(AnimationBackground.ANIMATION_BACKGROUND_DEFAULT); assertThat(splitAttributes.getAnimationParams().getAnimationBackground()) .isEqualTo(AnimationBackground.ANIMATION_BACKGROUND_DEFAULT); assertThat(splitAttributes.getAnimationParams().getOpenAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); assertThat(splitAttributes.getAnimationParams().getCloseAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); assertThat(splitAttributes.getAnimationParams().getChangeAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); } } libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java +6 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,9 @@ class ActivityEmbeddingAnimationRunner { final Animation animation = animationProvider.get(info, change, openingWholeScreenBounds); if (shouldUseJumpCutForAnimation(animation)) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { return new ArrayList<>(); } continue; } final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter( Loading @@ -291,6 +294,9 @@ class ActivityEmbeddingAnimationRunner { final Animation animation = animationProvider.get(info, change, closingWholeScreenBounds); if (shouldUseJumpCutForAnimation(animation)) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { return new ArrayList<>(); } continue; } final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter( Loading libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java +15 −9 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ class ActivityEmbeddingAnimationSpec { Animation createChangeBoundsOpenAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return customAnimation; } Loading Loading @@ -131,7 +131,7 @@ class ActivityEmbeddingAnimationSpec { Animation createChangeBoundsCloseAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return customAnimation; } Loading Loading @@ -172,7 +172,7 @@ class ActivityEmbeddingAnimationSpec { // TODO(b/293658614): Support more complicated animations that may need more than a noop // animation as the start leash. final Animation noopAnimation = createNoopAnimation(change); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return new Animation[]{noopAnimation, customAnimation}; } Loading Loading @@ -227,7 +227,7 @@ class ActivityEmbeddingAnimationSpec { Animation loadOpenAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) { final boolean isEnter = TransitionUtil.isOpeningType(change.getMode()); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, change.getMode()); final Animation animation; if (customAnimation != null) { animation = customAnimation; Loading @@ -254,7 +254,7 @@ class ActivityEmbeddingAnimationSpec { Animation loadCloseAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) { final boolean isEnter = TransitionUtil.isOpeningType(change.getMode()); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, change.getMode()); final Animation animation; if (customAnimation != null) { animation = customAnimation; Loading Loading @@ -287,14 +287,14 @@ class ActivityEmbeddingAnimationSpec { @Nullable private Animation loadCustomAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change) { @NonNull TransitionInfo.Change change, @WindowManager.TransitionType int mode) { final TransitionInfo.AnimationOptions options; if (Flags.moveAnimationOptionsToChange()) { options = change.getAnimationOptions(); } else { options = info.getAnimationOptions(); } return loadCustomAnimationFromOptions(options, change.getMode()); return loadCustomAnimationFromOptions(options, mode); } @Nullable Loading @@ -319,8 +319,14 @@ class ActivityEmbeddingAnimationSpec { return null; } final Animation anim = mTransitionAnimation.loadAnimationRes(options.getPackageName(), resId); final Animation anim; if (Flags.activityEmbeddingAnimationCustomizationFlag()) { // TODO(b/293658614): Consider allowing custom animations from non-default packages. // Enforce limiting to animations from the default "android" package for now. anim = mTransitionAnimation.loadDefaultAnimationRes(resId); } else { anim = mTransitionAnimation.loadAnimationRes(options.getPackageName(), resId); } if (anim != null) { return anim; } Loading Loading
core/java/android/window/TaskFragmentAnimationParams.java +1 −1 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ public final class TaskFragmentAnimationParams implements Parcelable { */ public boolean hasOverrideAnimation() { return mOpenAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID || mChangeAnimationResId != DEFAULT_ANIMATION_BACKGROUND_COLOR || mChangeAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID || mCloseAnimationResId != DEFAULT_ANIMATION_RESOURCES_ID; } Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +18 −5 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.window.flags.Flags; import java.util.Map; import java.util.concurrent.Executor; Loading Loading @@ -393,19 +394,31 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { if (splitAttributes == null) { return TaskFragmentAnimationParams.DEFAULT; } final TaskFragmentAnimationParams.Builder builder = new TaskFragmentAnimationParams.Builder(); final int animationBackgroundColor = getAnimationBackgroundColor(splitAttributes); TaskFragmentAnimationParams.Builder builder = new TaskFragmentAnimationParams.Builder(); if (animationBackgroundColor != DEFAULT_ANIMATION_BACKGROUND_COLOR) { builder.setAnimationBackgroundColor(animationBackgroundColor); if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final int openAnimationResId = splitAttributes.getAnimationParams().getOpenAnimationResId(); builder.setOpenAnimationResId(openAnimationResId); final int closeAnimationResId = splitAttributes.getAnimationParams().getCloseAnimationResId(); builder.setCloseAnimationResId(closeAnimationResId); final int changeAnimationResId = splitAttributes.getAnimationParams().getChangeAnimationResId(); builder.setChangeAnimationResId(changeAnimationResId); } // TODO(b/293658614): Allow setting custom open/close/changeAnimationResId. return builder.build(); } @ColorInt private static int getAnimationBackgroundColor(@NonNull SplitAttributes splitAttributes) { int animationBackgroundColor = DEFAULT_ANIMATION_BACKGROUND_COLOR; final AnimationBackground animationBackground = splitAttributes.getAnimationBackground(); AnimationBackground animationBackground = splitAttributes.getAnimationBackground(); if (Flags.activityEmbeddingAnimationCustomizationFlag()) { animationBackground = splitAttributes.getAnimationParams().getAnimationBackground(); } if (animationBackground instanceof AnimationBackground.ColorBackground colorBackground) { animationBackgroundColor = colorBackground.getColor(); } Loading
libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/WindowExtensionsTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.view.WindowManager; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import androidx.window.extensions.embedding.AnimationBackground; import androidx.window.extensions.embedding.AnimationParams; import androidx.window.extensions.embedding.SplitAttributes; import org.junit.Before; Loading Loading @@ -112,5 +113,13 @@ public class WindowExtensionsTest { .isEqualTo(new SplitAttributes.SplitType.RatioSplitType(0.5f)); assertThat(splitAttributes.getAnimationBackground()) .isEqualTo(AnimationBackground.ANIMATION_BACKGROUND_DEFAULT); assertThat(splitAttributes.getAnimationParams().getAnimationBackground()) .isEqualTo(AnimationBackground.ANIMATION_BACKGROUND_DEFAULT); assertThat(splitAttributes.getAnimationParams().getOpenAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); assertThat(splitAttributes.getAnimationParams().getCloseAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); assertThat(splitAttributes.getAnimationParams().getChangeAnimationResId()) .isEqualTo(AnimationParams.DEFAULT_ANIMATION_RESOURCES_ID); } }
libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java +6 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,9 @@ class ActivityEmbeddingAnimationRunner { final Animation animation = animationProvider.get(info, change, openingWholeScreenBounds); if (shouldUseJumpCutForAnimation(animation)) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { return new ArrayList<>(); } continue; } final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter( Loading @@ -291,6 +294,9 @@ class ActivityEmbeddingAnimationRunner { final Animation animation = animationProvider.get(info, change, closingWholeScreenBounds); if (shouldUseJumpCutForAnimation(animation)) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { return new ArrayList<>(); } continue; } final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java +15 −9 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ class ActivityEmbeddingAnimationSpec { Animation createChangeBoundsOpenAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return customAnimation; } Loading Loading @@ -131,7 +131,7 @@ class ActivityEmbeddingAnimationSpec { Animation createChangeBoundsCloseAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) { if (Flags.activityEmbeddingAnimationCustomizationFlag()) { final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return customAnimation; } Loading Loading @@ -172,7 +172,7 @@ class ActivityEmbeddingAnimationSpec { // TODO(b/293658614): Support more complicated animations that may need more than a noop // animation as the start leash. final Animation noopAnimation = createNoopAnimation(change); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE); if (customAnimation != null) { return new Animation[]{noopAnimation, customAnimation}; } Loading Loading @@ -227,7 +227,7 @@ class ActivityEmbeddingAnimationSpec { Animation loadOpenAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) { final boolean isEnter = TransitionUtil.isOpeningType(change.getMode()); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, change.getMode()); final Animation animation; if (customAnimation != null) { animation = customAnimation; Loading @@ -254,7 +254,7 @@ class ActivityEmbeddingAnimationSpec { Animation loadCloseAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) { final boolean isEnter = TransitionUtil.isOpeningType(change.getMode()); final Animation customAnimation = loadCustomAnimation(info, change); final Animation customAnimation = loadCustomAnimation(info, change, change.getMode()); final Animation animation; if (customAnimation != null) { animation = customAnimation; Loading Loading @@ -287,14 +287,14 @@ class ActivityEmbeddingAnimationSpec { @Nullable private Animation loadCustomAnimation(@NonNull TransitionInfo info, @NonNull TransitionInfo.Change change) { @NonNull TransitionInfo.Change change, @WindowManager.TransitionType int mode) { final TransitionInfo.AnimationOptions options; if (Flags.moveAnimationOptionsToChange()) { options = change.getAnimationOptions(); } else { options = info.getAnimationOptions(); } return loadCustomAnimationFromOptions(options, change.getMode()); return loadCustomAnimationFromOptions(options, mode); } @Nullable Loading @@ -319,8 +319,14 @@ class ActivityEmbeddingAnimationSpec { return null; } final Animation anim = mTransitionAnimation.loadAnimationRes(options.getPackageName(), resId); final Animation anim; if (Flags.activityEmbeddingAnimationCustomizationFlag()) { // TODO(b/293658614): Consider allowing custom animations from non-default packages. // Enforce limiting to animations from the default "android" package for now. anim = mTransitionAnimation.loadDefaultAnimationRes(resId); } else { anim = mTransitionAnimation.loadAnimationRes(options.getPackageName(), resId); } if (anim != null) { return anim; } Loading