OSDN Git Service

Fixing issue with regression with launching focused task.
authorWinson <winsonc@google.com>
Mon, 9 Nov 2015 18:39:57 +0000 (10:39 -0800)
committerWinson <winsonc@google.com>
Tue, 10 Nov 2015 16:53:44 +0000 (08:53 -0800)
- 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

packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java

index 8729aa0..af30268 100644 (file)
@@ -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<TaskView> 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;
index 39c45cc..4a11b93 100644 (file)
@@ -116,6 +116,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
     List<TaskView> 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);