Merge "Intercept back press for TaskView"

This commit is contained in:
Mady Mellor
2020-12-16 16:07:04 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 1 deletions

View File

@@ -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();

View File

@@ -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));
}
}