Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9568ef9b authored by Annie Lin's avatar Annie Lin
Browse files

Clean up uses of activityEmbeddingAnimationCustomizationFlag.

Bug: 293658614
Test: SplitAttributesRuntimeApisTests
Flag: com.android.window.flags.activity_embedding_animation_customization_flag
Change-Id: I17622ce4712bbd54584f9d7071eba4f359157e1b
parent 7129dda4
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -398,7 +398,6 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
                new TaskFragmentAnimationParams.Builder();
        final int animationBackgroundColor = getAnimationBackgroundColor(splitAttributes);
        builder.setAnimationBackgroundColor(animationBackgroundColor);
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
        final int openAnimationResId =
                splitAttributes.getAnimationParams().getOpenAnimationResId();
        builder.setOpenAnimationResId(openAnimationResId);
@@ -408,17 +407,14 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
        final int changeAnimationResId =
                splitAttributes.getAnimationParams().getChangeAnimationResId();
        builder.setChangeAnimationResId(changeAnimationResId);
        }
        return builder.build();
    }

    @ColorInt
    private static int getAnimationBackgroundColor(@NonNull SplitAttributes splitAttributes) {
        int animationBackgroundColor = DEFAULT_ANIMATION_BACKGROUND_COLOR;
        AnimationBackground animationBackground = splitAttributes.getAnimationBackground();
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
            animationBackground = splitAttributes.getAnimationParams().getAnimationBackground();
        }
        final AnimationBackground animationBackground =
            splitAttributes.getAnimationParams().getAnimationBackground();
        if (animationBackground instanceof AnimationBackground.ColorBackground colorBackground) {
            animationBackgroundColor = colorBackground.getColor();
        }
+7 −17
Original line number Diff line number Diff line
@@ -268,11 +268,8 @@ class ActivityEmbeddingAnimationRunner {
            final Animation animation =
                    animationProvider.get(info, change, openingWholeScreenBounds);
            if (shouldUseJumpCutForAnimation(animation)) {
                if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
                return new ArrayList<>();
            }
                continue;
            }
            final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter(
                    info, change, animation, openingWholeScreenBounds);
            if (isOpening) {
@@ -296,11 +293,8 @@ class ActivityEmbeddingAnimationRunner {
            final Animation animation =
                    animationProvider.get(info, change, closingWholeScreenBounds);
            if (shouldUseJumpCutForAnimation(animation)) {
                if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
                return new ArrayList<>();
            }
                continue;
            }
            final ActivityEmbeddingAnimationAdapter adapter = createOpenCloseAnimationAdapter(
                    info, change, animation, closingWholeScreenBounds);
            if (!isOpening) {
@@ -455,13 +449,11 @@ class ActivityEmbeddingAnimationRunner {
            final Animation[] animations =
                    mAnimationSpec.createChangeBoundsChangeAnimations(info, change, parentBounds);
            // Jump cut if either animation has zero for duration.
            if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
            for (Animation animation : animations) {
                if (shouldUseJumpCutForAnimation(animation)) {
                    return new ArrayList<>();
                }
            }
            }
            // Keep track as we might need to add background color for the animation.
            // Although there may be multiple change animation, record one of them is sufficient
            // because the background color will be added to the root leash for the whole animation.
@@ -516,11 +508,9 @@ class ActivityEmbeddingAnimationRunner {
                        mAnimationSpec.createChangeBoundsOpenAnimation(info, change, parentBounds);
                shouldShowBackgroundColor = false;
            }
            if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
            if (shouldUseJumpCutForAnimation(animation)) {
                return new ArrayList<>();
            }
            }
            adapters.add(new ActivityEmbeddingAnimationAdapter(animation, change,
                    TransitionUtil.getRootFor(change, info)));
        }
+15 −25
Original line number Diff line number Diff line
@@ -96,12 +96,10 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    Animation createChangeBoundsOpenAnimation(@NonNull TransitionInfo info,
            @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) {
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
        final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE);
        if (customAnimation != null) {
            return customAnimation;
        }
        }
        // Use end bounds for opening.
        final Rect bounds = change.getEndAbsBounds();
        final int startLeft;
@@ -130,12 +128,10 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    Animation createChangeBoundsCloseAnimation(@NonNull TransitionInfo info,
            @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) {
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
        final Animation customAnimation = loadCustomAnimation(info, change, TRANSIT_CHANGE);
        if (customAnimation != null) {
            return customAnimation;
        }
        }
        // Use start bounds for closing.
        final Rect bounds = change.getStartAbsBounds();
        final int endTop;
@@ -168,7 +164,6 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    Animation[] createChangeBoundsChangeAnimations(@NonNull TransitionInfo info,
            @NonNull TransitionInfo.Change change, @NonNull Rect parentBounds) {
        if (Flags.activityEmbeddingAnimationCustomizationFlag()) {
        // TODO(b/293658614): Support more complicated animations that may need more than a noop
        // animation as the start leash.
        final Animation noopAnimation = createNoopAnimation(change);
@@ -176,7 +171,6 @@ class ActivityEmbeddingAnimationSpec {
        if (customAnimation != null) {
            return new Animation[]{noopAnimation, customAnimation};
        }
        }
        // Both start bounds and end bounds are in screen coordinates. We will post translate
        // to the local coordinates in ActivityEmbeddingAnimationAdapter#onAnimationUpdate
        final Rect startBounds = change.getStartAbsBounds();
@@ -320,13 +314,9 @@ class ActivityEmbeddingAnimationSpec {
        }

        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;
        }