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;
List<TaskView> mImmutableTaskViews = new ArrayList<>();
LayoutInflater mInflater;
boolean mLayersDisabled;
+ boolean mTouchExplorationEnabled;
Interpolator mFastOutSlowInInterpolator;
@Override
protected void onAttachedToWindow() {
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ mTouchExplorationEnabled = ssp.isTouchExplorationEnabled();
EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1);
super.onAttachedToWindow();
}
visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) {
mTmpTaskViewMap.put(task, tv);
} else {
- if (tv.isFocusedTask()) {
+ if (mTouchExplorationEnabled && tv.isFocusedTask()) {
wasLastFocusedTaskAnimated = tv.isFocusAnimated();
lastFocusedTaskIndex = taskIndex;
resetFocusedTask();
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);