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

Commit 309fa7ba authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Improve dismiss split transition" into tm-qpr-dev

parents 32871f62 d656ee9d
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.R;
import com.android.wm.shell.common.SurfaceUtils;

import java.util.function.Consumer;

/**
 * Handles split decor like showing resizing hint for a specific split.
 */
@@ -212,7 +214,7 @@ public class SplitDecorManager extends WindowlessWindowManager {
                newBounds.height() / 2 - mIconSize / 2);

        if (animate) {
            startFadeAnimation(show, false /* isResized */);
            startFadeAnimation(show, null /* finishedConsumer */);
            mShown = show;
        }
    }
@@ -243,15 +245,29 @@ public class SplitDecorManager extends WindowlessWindowManager {
            mFadeAnimator.cancel();
        }
        if (mShown) {
            startFadeAnimation(false /* show */, true /* isResized */);
            mShown = false;
            fadeOutDecor(null /* finishedCallback */);
        } else {
            // Decor surface is hidden so release it directly.
            releaseDecor(t);
        }
    }

    private void startFadeAnimation(boolean show, boolean isResized) {
    /** Fade-out decor surface with animation end callback, if decor is hidden, run the callback
     * directly. */
    public void fadeOutDecor(Runnable finishedCallback) {
        if (mShown) {
            startFadeAnimation(false /* show */, transaction -> {
                releaseDecor(transaction);
                if (finishedCallback != null) finishedCallback.run();
            });
            mShown = false;
        } else {
            if (finishedCallback != null) finishedCallback.run();
        }
    }

    private void startFadeAnimation(boolean show,
            Consumer<SurfaceControl.Transaction> finishedConsumer) {
        final SurfaceControl.Transaction animT = new SurfaceControl.Transaction();
        mFadeAnimator = ValueAnimator.ofFloat(0f, 1f);
        mFadeAnimator.setDuration(FADE_DURATION);
@@ -285,8 +301,8 @@ public class SplitDecorManager extends WindowlessWindowManager {
                        animT.hide(mIconLeash);
                    }
                }
                if (isResized) {
                    releaseDecor(animT);
                if (finishedConsumer != null) {
                    finishedConsumer.accept(animT);
                }
                animT.apply();
                animT.close();
+14 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.wm.shell.animation.Interpolators.SLOWDOWN_INTERPOLATOR
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DRAG_DIVIDER;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -449,11 +450,13 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        switch (snapTarget.flag) {
            case FLAG_DISMISS_START:
                flingDividePosition(currentPosition, snapTarget.position,
                        () -> mSplitLayoutHandler.onSnappedToDismiss(false /* bottomOrRight */));
                        () -> mSplitLayoutHandler.onSnappedToDismiss(false /* bottomOrRight */,
                                EXIT_REASON_DRAG_DIVIDER));
                break;
            case FLAG_DISMISS_END:
                flingDividePosition(currentPosition, snapTarget.position,
                        () -> mSplitLayoutHandler.onSnappedToDismiss(true /* bottomOrRight */));
                        () -> mSplitLayoutHandler.onSnappedToDismiss(true /* bottomOrRight */,
                                EXIT_REASON_DRAG_DIVIDER));
                break;
            default:
                flingDividePosition(currentPosition, snapTarget.position,
@@ -509,6 +512,14 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                isLandscape ? DOCKED_LEFT : DOCKED_TOP /* dockSide */);
    }

    /** Fling divider from current position to end or start position then exit */
    public void flingDividerToDismiss(boolean toEnd, int reason) {
        final int target = toEnd ? mDividerSnapAlgorithm.getDismissEndTarget().position
                : mDividerSnapAlgorithm.getDismissStartTarget().position;
        flingDividePosition(getDividePosition(), target,
                () -> mSplitLayoutHandler.onSnappedToDismiss(toEnd, reason));
    }

    @VisibleForTesting
    void flingDividePosition(int from, int to, @Nullable Runnable flingFinishedCallback) {
        if (from == to) {
@@ -758,7 +769,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    public interface SplitLayoutHandler {

        /** Calls when dismissing split. */
        void onSnappedToDismiss(boolean snappedToEnd);
        void onSnappedToDismiss(boolean snappedToEnd, int reason);

        /**
         * Calls when resizing the split bounds.
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ class MainStage extends StageTaskListener {
                iconProvider);
    }

    @Override
    void dismiss(WindowContainerTransaction wct, boolean toTop) {
        deactivate(wct, toTop);
    }

    boolean isActive() {
        return mIsActive;
    }
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ class SideStage extends StageTaskListener {
                iconProvider);
    }

    @Override
    void dismiss(WindowContainerTransaction wct, boolean toTop) {
        removeAllTasks(wct, toTop);
    }

    boolean removeAllTasks(WindowContainerTransaction wct, boolean toTop) {
        if (mChildrenTaskInfo.size() == 0) return false;
        wct.reparentTasks(
+9 −11
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.wm.shell.splitscreen;

import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NO_USER_ACTION;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -107,15 +105,15 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        RemoteCallable<SplitScreenController>, ShellTaskOrganizer.FocusListener {
    private static final String TAG = SplitScreenController.class.getSimpleName();

    static final int EXIT_REASON_UNKNOWN = 0;
    static final int EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW = 1;
    static final int EXIT_REASON_APP_FINISHED = 2;
    static final int EXIT_REASON_DEVICE_FOLDED = 3;
    static final int EXIT_REASON_DRAG_DIVIDER = 4;
    static final int EXIT_REASON_RETURN_HOME = 5;
    static final int EXIT_REASON_ROOT_TASK_VANISHED = 6;
    static final int EXIT_REASON_SCREEN_LOCKED = 7;
    static final int EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP = 8;
    public static final int EXIT_REASON_UNKNOWN = 0;
    public static final int EXIT_REASON_APP_DOES_NOT_SUPPORT_MULTIWINDOW = 1;
    public static final int EXIT_REASON_APP_FINISHED = 2;
    public static final int EXIT_REASON_DEVICE_FOLDED = 3;
    public static final int EXIT_REASON_DRAG_DIVIDER = 4;
    public static final int EXIT_REASON_RETURN_HOME = 5;
    public static final int EXIT_REASON_ROOT_TASK_VANISHED = 6;
    public static final int EXIT_REASON_SCREEN_LOCKED = 7;
    public static final int EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP = 8;
    public static final int EXIT_REASON_CHILD_TASK_ENTER_PIP = 9;
    @IntDef(value = {
            EXIT_REASON_UNKNOWN,
Loading