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

Commit bbb64ea0 authored by Annie Lin's avatar Annie Lin
Browse files

Refactor createAnimationParamsOrDefault.

This will make it easier to read other custom animations params from SplitAttributes later on.

Bug: 293658614
Test: Refactor - covered by existing tests
Flag: EXEMPT refactor
Change-Id: I3be9ed77a4ad5267c739f6ecf8264b2c89a948fd
parent e4b2d224
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;
    }
}