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

Commit a9ba230e authored by Evan Rosky's avatar Evan Rosky
Browse files

Move transition utility functions into shell.util

Things in shell.util can be used by systemui code (eg. the legacy
transition adapters).

Bug: 261418859
Test: no-logic changes, so just existing tests.
Change-Id: I3acf4f3b6d7dfd91d8a70b63fc2b6a043f4a9f16
parent 1a03b253
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.window.TransitionRequestInfo;
import android.window.WindowContainerTransaction;

import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;

import java.util.ArrayList;

@@ -115,7 +116,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
            boolean latest) {
        for (int i = mPending.size() - 1; i >= 0; --i) {
            if (mPending.get(i).mTaskView != taskView) continue;
            if (Transitions.isClosingType(mPending.get(i).mType) == closing) {
            if (TransitionUtil.isClosingType(mPending.get(i).mType) == closing) {
                return mPending.get(i);
            }
            if (latest) {
@@ -148,7 +149,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
        final TaskViewTaskController taskView = findTaskView(triggerTask);
        if (taskView == null) return null;
        // Opening types should all be initiated by shell
        if (!Transitions.isClosingType(request.getType())) return null;
        if (!TransitionUtil.isClosingType(request.getType())) return null;
        PendingTransition pending = findPending(taskView, true /* closing */, false /* latest */);
        if (pending == null) {
            pending = new PendingTransition(request.getType(), null, taskView, null /* cookie */);
@@ -238,7 +239,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
        for (int i = 0; i < info.getChanges().size(); ++i) {
            final TransitionInfo.Change chg = info.getChanges().get(i);
            if (chg.getTaskInfo() == null) continue;
            if (Transitions.isClosingType(chg.getMode())) {
            if (TransitionUtil.isClosingType(chg.getMode())) {
                final boolean isHide = chg.getMode() == TRANSIT_TO_BACK;
                TaskViewTaskController tv = findTaskView(chg.getTaskInfo());
                if (tv == null) {
@@ -255,7 +256,7 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
                    tv.prepareCloseAnimation();
                }
                changesHandled++;
            } else if (Transitions.isOpeningType(chg.getMode())) {
            } else if (TransitionUtil.isOpeningType(chg.getMode())) {
                final boolean taskIsNew = chg.getMode() == TRANSIT_OPEN;
                final TaskViewTaskController tv;
                if (taskIsNew) {
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.window.TransitionInfo;

import androidx.annotation.NonNull;

import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;

/**
 * Wrapper to handle the ActivityEmbedding animation update in one
@@ -90,7 +90,7 @@ class ActivityEmbeddingAnimationAdapter {
        mChange = change;
        mLeash = leash;
        mWholeAnimationBounds.set(wholeAnimationBounds);
        if (Transitions.isClosingType(change.getMode())) {
        if (TransitionUtil.isClosingType(change.getMode())) {
            // When it is closing, we want to show the content at the start position in case the
            // window is resizing as well. For example, when the activities is changing from split
            // to stack, the bottom TaskFragment will be resized to fullscreen when hiding.
+9 −9
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.wm.shell.common.ScreenshotUtils;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;

import java.util.ArrayList;
import java.util.List;
@@ -184,7 +184,7 @@ class ActivityEmbeddingAnimationRunner {
        if (isChangeTransition) {
            return createChangeAnimationAdapters(info, startTransaction);
        }
        if (Transitions.isClosingType(info.getType())) {
        if (TransitionUtil.isClosingType(info.getType())) {
            return createCloseAnimationAdapters(info);
        }
        return createOpenAnimationAdapters(info);
@@ -219,7 +219,7 @@ class ActivityEmbeddingAnimationRunner {
        final Rect openingWholeScreenBounds = new Rect();
        final Rect closingWholeScreenBounds = new Rect();
        for (TransitionInfo.Change change : info.getChanges()) {
            if (Transitions.isOpeningType(change.getMode())) {
            if (TransitionUtil.isOpeningType(change.getMode())) {
                openingChanges.add(change);
                openingWholeScreenBounds.union(change.getEndAbsBounds());
            } else {
@@ -271,7 +271,7 @@ class ActivityEmbeddingAnimationRunner {
                continue;
            }
            final TransitionInfo.Change change = adapter.mChange;
            if (Transitions.isOpeningType(adapter.mChange.getMode())) {
            if (TransitionUtil.isOpeningType(adapter.mChange.getMode())) {
                // Need to screenshot after startTransaction is applied otherwise activity
                // may not be visible or ready yet.
                postStartTransactionCallbacks.add(
@@ -343,7 +343,7 @@ class ActivityEmbeddingAnimationRunner {
                // When the parent window is also included in the transition as an opening window,
                // we would like to animate the parent window instead.
                final TransitionInfo.Change parentChange = info.getChange(parentToken);
                if (parentChange != null && Transitions.isOpeningType(parentChange.getMode())) {
                if (parentChange != null && TransitionUtil.isOpeningType(parentChange.getMode())) {
                    // We won't create a separate animation for the parent, but to animate the
                    // parent for the child resizing.
                    handledChanges.add(parentChange);
@@ -404,7 +404,7 @@ class ActivityEmbeddingAnimationRunner {
                // No-op if it will be covered by the changing parent window, or it is a changing
                // window without bounds change.
                animation = ActivityEmbeddingAnimationSpec.createNoopAnimation(change);
            } else if (Transitions.isClosingType(change.getMode())) {
            } else if (TransitionUtil.isClosingType(change.getMode())) {
                animation = mAnimationSpec.createChangeBoundsCloseAnimation(change, parentBounds);
                shouldShouldBackgroundColor = false;
            } else {
@@ -469,7 +469,7 @@ class ActivityEmbeddingAnimationRunner {
                // When the parent window is also included in the transition as an opening window,
                // we would like to animate the parent window instead.
                final TransitionInfo.Change parentChange = info.getChange(parentToken);
                if (parentChange != null && Transitions.isOpeningType(parentChange.getMode())) {
                if (parentChange != null && TransitionUtil.isOpeningType(parentChange.getMode())) {
                    changingChanges.add(parentChange);
                }
            }
@@ -491,8 +491,8 @@ class ActivityEmbeddingAnimationRunner {
                // No-op if it will be covered by the changing parent window.
                continue;
            }
            hasOpeningWindow |= Transitions.isOpeningType(change.getMode());
            hasClosingWindow |= Transitions.isClosingType(change.getMode());
            hasOpeningWindow |= TransitionUtil.isOpeningType(change.getMode());
            hasClosingWindow |= TransitionUtil.isClosingType(change.getMode());
        }
        return hasOpeningWindow && hasClosingWindow;
    }
+4 −4
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import android.window.TransitionInfo;
import androidx.annotation.NonNull;

import com.android.internal.policy.TransitionAnimation;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;

/** Animation spec for ActivityEmbedding transition. */
// TODO(b/206557124): provide an easier way to customize animation
@@ -73,7 +73,7 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    static Animation createNoopAnimation(@NonNull TransitionInfo.Change change) {
        // Noop but just keep the window showing/hiding.
        final float alpha = Transitions.isClosingType(change.getMode()) ? 0f : 1f;
        final float alpha = TransitionUtil.isClosingType(change.getMode()) ? 0f : 1f;
        return new AlphaAnimation(alpha, alpha);
    }

@@ -198,7 +198,7 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    Animation loadOpenAnimation(@NonNull TransitionInfo info,
            @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) {
        final boolean isEnter = Transitions.isOpeningType(change.getMode());
        final boolean isEnter = TransitionUtil.isOpeningType(change.getMode());
        final Animation animation;
        if (shouldShowBackdrop(info, change)) {
            animation = mTransitionAnimation.loadDefaultAnimationRes(isEnter
@@ -222,7 +222,7 @@ class ActivityEmbeddingAnimationSpec {
    @NonNull
    Animation loadCloseAnimation(@NonNull TransitionInfo info,
            @NonNull TransitionInfo.Change change, @NonNull Rect wholeAnimationBounds) {
        final boolean isEnter = Transitions.isOpeningType(change.getMode());
        final boolean isEnter = TransitionUtil.isOpeningType(change.getMode());
        final Animation animation;
        if (shouldShowBackdrop(info, change)) {
            animation = mTransitionAnimation.loadDefaultAnimationRes(isEnter
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import static com.android.wm.shell.pip.PipTransitionState.ENTERED_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP_TO_SPLIT;
import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;
import static com.android.wm.shell.transition.Transitions.isOpeningType;

import android.animation.Animator;
import android.app.ActivityManager;
@@ -72,6 +71,7 @@ import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.CounterRotatorHelper;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;

import java.util.Optional;

@@ -702,7 +702,7 @@ public class PipTransition extends PipTransitionController {
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            final TransitionInfo.Change change = info.getChanges().get(i);
            if (change == enterPip) continue;
            if (isOpeningType(change.getMode())) {
            if (TransitionUtil.isOpeningType(change.getMode())) {
                final SurfaceControl leash = change.getLeash();
                startTransaction.show(leash).setAlpha(leash, 1.f);
            }
@@ -873,7 +873,7 @@ public class PipTransition extends PipTransitionController {
                continue;
            }

            if (isOpeningType(mode) && change.getParent() == null) {
            if (TransitionUtil.isOpeningType(mode) && change.getParent() == null) {
                final SurfaceControl leash = change.getLeash();
                final Rect endBounds = change.getEndAbsBounds();
                startTransaction
Loading