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

Commit 9500bd06 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Allow TaskView to move windows

Adds the ability to mark that a task view is moving windows. When
marked, visibility changes and attach detach events are ignored
in order to preserve the existing surface. This allows users of
TaskView to reparent the surface into the new window as needed.

Bug: 392893178
Flag: EXEMPT new API no-op change
Test: EXEMPT new API that isn't currently triggered

Change-Id: I3ecebccafec9acdfd27feac014eac44cefe64c18
parent 95ca764c
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
    private Region mObscuredTouchRegion;
    private Insets mCaptionInsets;
    private Handler mHandler;
    private boolean mIsMovingWindows;

    public TaskView(Context context, TaskViewController taskViewController,
            TaskViewTaskController taskViewTaskController) {
@@ -96,6 +97,24 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        return mTaskViewTaskController;
    }

    /**
     * Sets whether this task view is starting to move windows or just finished moving windows.
     *
     * <p>This is intended to be used temporarily while the task view is moving between windows to
     * avoid having its surface destroyed. Call this method with {@code true} before removing it
     * from the old window and again with {@code false} before adding it to the new window.
     */
    public void setIsMovingWindows(boolean isMovingWindows) {
        mIsMovingWindows = isMovingWindows;
        if (isMovingWindows) {
            getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
            mHandler = Handler.getMain();
        } else {
            getViewTreeObserver().addOnComputeInternalInsetsListener(this);
            mHandler = getHandler();
        }
    }

    /**
     * Launch a new activity.
     *
@@ -311,8 +330,19 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        }
    }

    @Override
    protected void onWindowVisibilityChanged(int visibility) {
        if (mIsMovingWindows) {
            return;
        }
        super.onWindowVisibilityChanged(visibility);
    }

    @Override
    protected void onAttachedToWindow() {
        if (mIsMovingWindows) {
            return;
        }
        super.onAttachedToWindow();
        getViewTreeObserver().addOnComputeInternalInsetsListener(this);
        mHandler = getHandler();
@@ -320,6 +350,9 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,

    @Override
    protected void onDetachedFromWindow() {
        if (mIsMovingWindows) {
            return;
        }
        super.onDetachedFromWindow();
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
        mHandler = Handler.getMain();