summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java3
3 files changed, 24 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
index 82e786140e77..aa1437b28ee8 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
@@ -75,7 +75,7 @@ public class RecentsActivityLaunchState {
}
// If coming from another app, focus the next task
- return numTasks - 2;
+ return Math.max(0, numTasks - 2);
} else {
if (!launchState.launchedWithAltTab && debugFlags.isFastToggleRecentsEnabled()) {
// If fast toggling, defer focusing until the next tap (which will automatically
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 0ee9caf5be72..1707c4f4ccd0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -964,10 +964,26 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
newIndex = (newIndex + (forward ? -1 : 1) + taskCount) % taskCount;
}
} else {
- // We don't have a focused task, so focus the first visible task view
- TaskView tv = getFrontMostTaskView(stackTasksOnly);
- if (tv != null) {
- newIndex = mStack.indexOfStackTask(tv.getTask());
+ // We don't have a focused task
+ float stackScroll = mStackScroller.getStackScroll();
+ ArrayList<Task> tasks = mStack.getStackTasks();
+ int taskCount = tasks.size();
+ if (forward) {
+ // Walk backwards and focus the next task smaller than the current stack scroll
+ for (newIndex = taskCount - 1; newIndex >= 0; newIndex--) {
+ float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
+ if (Float.compare(taskP, stackScroll) <= 0) {
+ break;
+ }
+ }
+ } else {
+ // Walk forwards and focus the next task larger than the current stack scroll
+ for (newIndex = 0; newIndex < taskCount; newIndex++) {
+ float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
+ if (Float.compare(taskP, stackScroll) >= 0) {
+ break;
+ }
+ }
}
}
if (newIndex != -1) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index 47072ba96b6b..fe504fefef26 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -280,6 +280,9 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
mOverscrollSize);
mSv.invalidate();
}
+
+ // Reset the focused task after the user has scrolled
+ mSv.resetFocusedTask(mSv.getFocusedTask());
} else if (mActiveTaskView == null) {
// This tap didn't start on a task.
maybeHideRecentsFromBackgroundTap((int) ev.getX(), (int) ev.getY());