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

Commit a5b6b765 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Intercept back press for TaskView"

parents 31943be2 81260f05
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
                // so go ahead and hide the task entirely
                updateTaskVisibility();
            }

            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, true);
            // TODO: Synchronize show with the resize
            onLocationChanged();
            setResizeBackgroundColor(taskInfo.taskDescription.getBackgroundColor());
@@ -257,6 +257,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
            if (mListener != null) {
                mListener.onTaskRemovalStarted(taskInfo.taskId);
            }
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, false);

            // Unparent the task when this surface is destroyed
            mTransaction.reparent(mTaskLeash, null).apply();
+15 −0
Original line number Diff line number Diff line
@@ -215,4 +215,19 @@ public class TaskViewTest extends ShellTestCase {

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

    @Test
    public void testSetOnBackPressedOnTaskRoot() {
        mTaskView.onTaskAppeared(mTaskInfo, mLeash);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
    }

    @Test
    public void testUnsetOnBackPressedOnTaskRoot() {
        mTaskView.onTaskAppeared(mTaskInfo, mLeash);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));

        mTaskView.onTaskVanished(mTaskInfo);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(false));
    }
}