From 142af42fd683445b23c7d4e3878cd8b1c9d2e693 Mon Sep 17 00:00:00 2001 From: Winson Date: Mon, 9 Nov 2015 10:39:57 -0800 Subject: [PATCH] Fixing issue with regression with launching focused task. - Only update the focused task as you scroll if we are in touch exploration mode. - Use stack's notion of focused task as the currently focused task may not have a TaskView and can be scrolled offscreen. Bug: 25590404 Change-Id: I5ef1b66ec74aa1a3131993ed84905210f1e45f18 --- .../systemui/recents/views/RecentsView.java | 17 ++++++----------- .../systemui/recents/views/TaskStackView.java | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 8729aa0fbf6f1..af30268927254 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -198,17 +198,12 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV public boolean launchFocusedTask() { if (mTaskStackView != null) { TaskStack stack = mTaskStackView.getStack(); - // Iterate the stack views and try and find the focused task - List taskViews = mTaskStackView.getTaskViews(); - int taskViewCount = taskViews.size(); - for (int j = 0; j < taskViewCount; j++) { - TaskView tv = taskViews.get(j); - Task task = tv.getTask(); - if (tv.isFocusedTask()) { - onTaskViewClicked(mTaskStackView, tv, stack, task, false, false, null, - INVALID_STACK_ID); - return true; - } + Task task = mTaskStackView.getFocusedTask(); + if (task != null) { + TaskView taskView = mTaskStackView.getChildViewForTask(task); + onTaskViewClicked(mTaskStackView, taskView, stack, task, false, false, null, + INVALID_STACK_ID); + return true; } } return false; 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 39c45ccbb1c58..4a11b9327b1f5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -116,6 +116,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal List mImmutableTaskViews = new ArrayList<>(); LayoutInflater mInflater; boolean mLayersDisabled; + boolean mTouchExplorationEnabled; Interpolator mFastOutSlowInInterpolator; @@ -183,6 +184,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal @Override protected void onAttachedToWindow() { + SystemServicesProxy ssp = Recents.getSystemServices(); + mTouchExplorationEnabled = ssp.isTouchExplorationEnabled(); EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); super.onAttachedToWindow(); } @@ -425,7 +428,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) { mTmpTaskViewMap.put(task, tv); } else { - if (tv.isFocusedTask()) { + if (mTouchExplorationEnabled && tv.isFocusedTask()) { wasLastFocusedTaskAnimated = tv.isFocusAnimated(); lastFocusedTaskIndex = taskIndex; resetFocusedTask(); @@ -716,6 +719,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mFocusedTaskIndex = -1; } + /** + * Returns the focused task. + */ + Task getFocusedTask() { + if (mFocusedTaskIndex != -1) { + return mStack.getTasks().get(mFocusedTaskIndex); + } + return null; + } + @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event);