Snap to running task if it's offscreen when back is invoked

- If the user has scrolled the running task offscreen, then
  snap back to the task if back is invoked.

Bug: 233952141
Test: Swipe to overview, scroll away from the current task
      and then go back
Change-Id: Icc5040d4b38c97e0329f937e24bd517a71a32f13
This commit is contained in:
Winson Chung
2022-06-14 21:20:05 +00:00
parent 0b944f6a4d
commit 2345fee566
@@ -131,9 +131,14 @@ public class OverviewState extends LauncherState {
@Override
public void onBackPressed(Launcher launcher) {
TaskView taskView = launcher.<RecentsView>getOverviewPanel().getRunningTaskView();
RecentsView recentsView = launcher.getOverviewPanel();
TaskView taskView = recentsView.getRunningTaskView();
if (taskView != null) {
taskView.launchTasks();
if (recentsView.isTaskViewFullyVisible(taskView)) {
taskView.launchTasks();
} else {
recentsView.snapToPage(recentsView.indexOfChild(taskView));
}
} else {
super.onBackPressed(launcher);
}