Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 941a9e4f authored by vinayjoglekar's avatar vinayjoglekar
Browse files

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
parent 05084e2e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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.
     *
+16 −16
Original line number Diff line number Diff line
@@ -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);

        // Add the focused task to the beginning of both arrays if it exists.
        if (hasFocusedTask) {
            topRowIdArray.add(0, mFocusedTaskId);
            bottomRowIdArray.add(0, mFocusedTaskId);
    private void generateTaskViewIdGrid(IntArray topRowIdArray, IntArray bottomRowIdArray,
            List<Integer> largeTileIds) {

        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.
+1 −2
Original line number Diff line number Diff line
@@ -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();
+0 −510

File deleted.

Preview size limit exceeded, changes collapsed.

+638 −0

File added.

Preview size limit exceeded, changes collapsed.