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

Commit 127b3a42 authored by Mady Mellor's avatar Mady Mellor
Browse files

Add an option to move tasks in TaskView to fullscreen

* Update TaskView to support moving tasks to fullscreen

Flag: com.android.wm.shell.enable_bubble_to_fullscreen
Test: atest TaskViewTest
Test: manual - turn on flag, make a bubble, open the manage menu
               and move it to fullscreen (with other CL)
Bug: 363326492
Change-Id: I274360245b33e8dcd7ac6b1f22a1b1a625a72887
parent 5af566d6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -118,6 +118,13 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        mTaskViewTaskController.startShortcutActivity(shortcut, options, launchBounds);
    }

    /**
     * Moves the current task in taskview out of the view and back to fullscreen.
     */
    public void moveToFullscreen() {
        mTaskViewTaskController.moveToFullscreen();
    }

    @Override
    public void onTaskAppeared(ActivityManager.RunningTaskInfo taskInfo, SurfaceControl leash) {
        if (mTaskViewTaskController.isUsingShellTransitions()) {
+19 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.taskview;

import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.WindowManager.TRANSIT_CHANGE;

import android.annotation.NonNull;
@@ -256,6 +257,24 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
        mTaskViewTransitions.startInstantTransition(TRANSIT_CHANGE, wct);
    }

    /**
     * Moves the current task in TaskView out of the view and back to fullscreen.
     */
    public void moveToFullscreen() {
        if (mTaskToken == null) return;
        mShellExecutor.execute(() -> {
            WindowContainerTransaction wct = new WindowContainerTransaction();
            wct.setWindowingMode(mTaskToken, WINDOWING_MODE_UNDEFINED);
            wct.setAlwaysOnTop(mTaskToken, false);
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, false);
            mTaskViewTransitions.moveTaskViewToFullscreen(wct, this);
            if (mListener != null) {
                // Task is being "removed" from the clients perspective
                mListener.onTaskRemovalStarted(mTaskInfo.taskId);
            }
        });
    }

    private void prepareActivityOptions(ActivityOptions options, Rect launchBounds) {
        final Binder launchCookie = new Binder();
        mShellExecutor.execute(() -> {
+6 −0
Original line number Diff line number Diff line
@@ -236,6 +236,12 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
        startNextTransition();
    }

    void moveTaskViewToFullscreen(@NonNull WindowContainerTransaction wct,
            @NonNull TaskViewTaskController taskView) {
        mPending.add(new PendingTransition(TRANSIT_CHANGE, wct, taskView, null /* cookie */));
        startNextTransition();
    }

    /** Starts a new transition to make the given {@code taskView} visible. */
    public void setTaskViewVisible(TaskViewTaskController taskView, boolean visible) {
        setTaskViewVisible(taskView, visible, false /* reorder */);
+12 −0
Original line number Diff line number Diff line
@@ -713,4 +713,16 @@ public class TaskViewTest extends ShellTestCase {
        verify(mViewHandler).post(any());
        verify(mTaskView).setResizeBackgroundColor(eq(Color.BLUE));
    }

    @Test
    public void testMoveToFullscreen_callsTaskRemovalStarted() {
        WindowContainerTransaction wct = new WindowContainerTransaction();
        mTaskViewTaskController.prepareOpenAnimation(true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);
        mTaskView.surfaceCreated(mock(SurfaceHolder.class));
        mTaskViewTaskController.moveToFullscreen();

        verify(mViewListener).onTaskRemovalStarted(eq(mTaskInfo.taskId));
    }
}