Add keyboard navigation for all large tiles

Currently large tiles are excluded from adding into collection which is used for keyboard navigation. This cl adds them if desktop windowing tile is enabled.

Test: TaskGridNavHelperTest
BUG: 361070854
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Change-Id: I63fbb6867c34bbd80df926d750a7a392860b70a0
This commit is contained in:
vinayjoglekar
2024-09-05 14:35:51 +01:00
parent 05084e2ef3
commit 941a9e4f98
5 changed files with 658 additions and 527 deletions
@@ -57,6 +57,10 @@ class RecentsViewUtils {
fun getDesktopTaskViewCount(taskViews: List<TaskView>): Int =
taskViews.count { it is DesktopTaskView }
/** Returns a list of all large TaskView Ids from [TaskView]s */
fun getLargeTaskViewIds(taskViews: Iterable<TaskView>): List<Int> =
taskViews.filter { it.isLargeTile }.map { it.taskViewId }
/**
* Returns the first TaskView that should be displayed as a large tile.
*
@@ -22,13 +22,13 @@ import androidx.annotation.IntDef;
import com.android.launcher3.util.IntArray;
import java.lang.annotation.Retention;
import java.util.List;
/**
* Helper class for navigating RecentsView grid tasks via arrow keys and tab.
*/
public class TaskGridNavHelper {
public static final int CLEAR_ALL_PLACEHOLDER_ID = -1;
public static final int INVALID_FOCUSED_TASK_ID = -1;
public static final int DIRECTION_UP = 0;
public static final int DIRECTION_DOWN = 1;
@@ -43,25 +43,25 @@ public class TaskGridNavHelper {
private final IntArray mOriginalTopRowIds;
private IntArray mTopRowIds;
private IntArray mBottomRowIds;
private final int mFocusedTaskId;
public TaskGridNavHelper(IntArray topIds, IntArray bottomIds, int focusedTaskId) {
mFocusedTaskId = focusedTaskId;
public TaskGridNavHelper(IntArray topIds, IntArray bottomIds,
List<Integer> largeTileIds) {
mOriginalTopRowIds = topIds.clone();
generateTaskViewIdGrid(topIds, bottomIds);
generateTaskViewIdGrid(topIds, bottomIds, largeTileIds);
}
private void generateTaskViewIdGrid(IntArray topRowIdArray, IntArray bottomRowIdArray) {
boolean hasFocusedTask = mFocusedTaskId != INVALID_FOCUSED_TASK_ID;
int maxSize =
Math.max(topRowIdArray.size(), bottomRowIdArray.size()) + (hasFocusedTask ? 1 : 0);
int minSize =
Math.min(topRowIdArray.size(), bottomRowIdArray.size()) + (hasFocusedTask ? 1 : 0);
private void generateTaskViewIdGrid(IntArray topRowIdArray, IntArray bottomRowIdArray,
List<Integer> largeTileIds) {
// Add the focused task to the beginning of both arrays if it exists.
if (hasFocusedTask) {
topRowIdArray.add(0, mFocusedTaskId);
bottomRowIdArray.add(0, mFocusedTaskId);
int maxSize = Math.max(topRowIdArray.size(), bottomRowIdArray.size())
+ largeTileIds.size();
int minSize = Math.min(topRowIdArray.size(), bottomRowIdArray.size())
+ largeTileIds.size();
// Add Large tile task views first at the beginning
for (int i = 0; i < largeTileIds.size(); i++) {
topRowIdArray.add(i, largeTileIds.get(i));
bottomRowIdArray.add(i, largeTileIds.get(i));
}
// Fill in the shorter array with the ids from the longer one.
@@ -4328,9 +4328,8 @@ public abstract class RecentsView<
}
// Init task grid nav helper with top/bottom id arrays.
// TODO(b/361070854): Add keyboard navigation for all large tiles.
TaskGridNavHelper taskGridNavHelper = new TaskGridNavHelper(getTopRowIdArray(),
getBottomRowIdArray(), mFocusedTaskViewId);
getBottomRowIdArray(), mUtils.getLargeTaskViewIds(getTaskViews()));
// Get current page's task view ID.
TaskView currentPageTaskView = getCurrentPageTaskView();