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

Commit c47d0540 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactor createAnimationParamsOrDefault." into main

parents 91b69014 bbb64ea0
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package androidx.window.extensions.embedding;

import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.window.TaskFragmentAnimationParams.DEFAULT_ANIMATION_BACKGROUND_COLOR;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_FRONT;
import static android.window.TaskFragmentOperation.OP_TYPE_SET_ANIMATION_PARAMS;
import static android.window.TaskFragmentOperation.OP_TYPE_SET_DIM_ON_TASK;
@@ -29,6 +30,7 @@ import static androidx.window.extensions.embedding.SplitContainer.shouldFinishAs
import static androidx.window.extensions.embedding.SplitContainer.shouldFinishPrimaryWithSecondary;
import static androidx.window.extensions.embedding.SplitContainer.shouldFinishSecondaryWithPrimary;

import android.annotation.ColorInt;
import android.app.Activity;
import android.app.WindowConfiguration.WindowingMode;
import android.content.Intent;
@@ -391,13 +393,22 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
        if (splitAttributes == null) {
            return TaskFragmentAnimationParams.DEFAULT;
        }
        final int animationBackgroundColor = getAnimationBackgroundColor(splitAttributes);
        TaskFragmentAnimationParams.Builder builder = new TaskFragmentAnimationParams.Builder();
        if (animationBackgroundColor != DEFAULT_ANIMATION_BACKGROUND_COLOR) {
            builder.setAnimationBackgroundColor(animationBackgroundColor);
        }
        // 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();
        if (animationBackground instanceof AnimationBackground.ColorBackground colorBackground) {
            return new TaskFragmentAnimationParams.Builder()
                    .setAnimationBackgroundColor(colorBackground.getColor())
                    .build();
        } else {
            return TaskFragmentAnimationParams.DEFAULT;
            animationBackgroundColor = colorBackground.getColor();
        }
        return animationBackgroundColor;
    }
}