Merge "Migrate using TaskViewCount as the indices" into main

This commit is contained in:
Treehugger Robot
2024-12-18 15:43:25 -08:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 15 deletions
@@ -5824,19 +5824,19 @@ public abstract class RecentsView<
@Override
public void addChildrenForAccessibility(ArrayList<View> outChildren) {
// Add children in reverse order
for (int i = getChildCount() - 1; i >= 0; --i) {
outChildren.add(getChildAt(i));
}
outChildren.addAll(getAccessibilityChildren());
}
public List<View> getAccessibilityChildren() {
return mUtils.getAccessibilityChildren();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
final AccessibilityNodeInfo.CollectionInfo
collectionInfo = AccessibilityNodeInfo.CollectionInfo.obtain(
1, getTaskViewCount(), false,
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_NONE);
collectionInfo = new AccessibilityNodeInfo.CollectionInfo(
1, getAccessibilityChildren().size(), false);
info.setCollectionInfo(collectionInfo);
}
@@ -5845,14 +5845,12 @@ public abstract class RecentsView<
super.onInitializeAccessibilityEvent(event);
event.setScrollable(hasTaskViews());
// TODO(b/379942019): Revisit the logic below to make sure it does not rely on the
// `taskViewCount` to update the indices or make it indices free.
final int taskViewCount = getTaskViewCount();
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
final List<View> accessibilityChildren = getAccessibilityChildren();
final int[] visibleTasks = getVisibleChildrenRange();
event.setFromIndex(taskViewCount - visibleTasks[1]);
event.setToIndex(taskViewCount - visibleTasks[0]);
event.setItemCount(taskViewCount);
event.setFromIndex(accessibilityChildren.indexOf(getChildAt(visibleTasks[1])));
event.setToIndex(accessibilityChildren.indexOf(getChildAt(visibleTasks[0])));
event.setItemCount(accessibilityChildren.size());
}
}
@@ -16,6 +16,8 @@
package com.android.quickstep.views
import android.view.View
import androidx.core.view.children
import com.android.launcher3.Flags.enableLargeDesktopWindowingTile
import com.android.quickstep.util.GroupTask
import com.android.quickstep.views.RecentsView.RUNNING_TASK_ATTACH_ALPHA
@@ -94,6 +96,12 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) {
/** Returns the last TaskView that should be displayed as a large tile. */
fun getLastLargeTaskView(): TaskView? = recentsView.taskViews.lastOrNull { it.isLargeTile }
/**
* Gets the list of accessibility children. Currently all the children of RecentsViews are
* added, and in the reverse order to the list.
*/
fun getAccessibilityChildren(): List<View> = recentsView.children.toList().reversed()
@JvmOverloads
/** Returns the first [TaskView], with some tasks possibly hidden in the carousel. */
fun getFirstTaskViewInCarousel(
@@ -658,10 +658,10 @@ constructor(
recentsView?.let {
collectionItemInfo =
AccessibilityNodeInfo.CollectionItemInfo.obtain(
AccessibilityNodeInfo.CollectionItemInfo(
0,
1,
it.taskViewCount - it.indexOfChild(this@TaskView) - 1,
it.getAccessibilityChildren().indexOf(this@TaskView),
1,
false,
)