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

Commit 4209c716 authored by Gustav Sennton's avatar Gustav Sennton Committed by Android (Google) Code Review
Browse files

Merge "Set Launcher alpha to 0 during Desktop exit transition." into main

parents f24f268b 269eef85
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -22,8 +22,14 @@ import static android.view.WindowManager.TRANSIT_OLD_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS;
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;

import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.wm.shell.shared.TransitionUtil.isClosingMode;
import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningMode;

import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
@@ -157,6 +163,9 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                        t.show(wallpapers[i].leash);
                        t.setAlpha(wallpapers[i].leash, 1.f);
                    }
                    if (ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue()) {
                        resetLauncherAlphaOnDesktopExit(info, launcherTask, leashMap, t);
                    }
                } else {
                    if (launcherTask != null) {
                        counterLauncher.addChild(t, leashMap.get(launcherTask.getLeash()));
@@ -236,4 +245,33 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
            }
        };
    }

    /**
     * Reset the alpha of the Launcher leash to give the Launcher time to hide its Views before the
     * exit-desktop animation starts.
     *
     * This method should only be called if the current transition is opening Launcher, otherwise we
     * might not be exiting Desktop Mode.
     */
    private static void resetLauncherAlphaOnDesktopExit(
            TransitionInfo info,
            TransitionInfo.Change launcherChange,
            ArrayMap<SurfaceControl, SurfaceControl> leashMap,
            SurfaceControl.Transaction startTransaction
    ) {
        checkArgument(isOpeningMode(launcherChange.getMode()));
        if (!isClosingType(info.getType())) {
            return;
        }
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            final TransitionInfo.Change change = info.getChanges().get(i);
            // skip changes that we didn't wrap
            if (!leashMap.containsKey(change.getLeash())) continue;
            // Only make the update if we are closing Desktop tasks.
            if (change.getTaskInfo().isFreeform() && isClosingMode(change.getMode())) {
                startTransaction.setAlpha(leashMap.get(launcherChange.getLeash()), 0f);
                return;
            }
        }
    }
}