diff options
author | Tony Wickham <twickham@google.com> | 2015-11-11 09:25:38 -0800 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2015-12-03 14:18:06 -0800 |
commit | af78b59af19264105b8ce856defa5342d6fd584a (patch) | |
tree | 3c5625b918c2c2eeaf867f09147b37543c3e9a0d /src/com/android/launcher3/util | |
parent | b879abd2747c1c1473c8d2b9d9c97707da8218f3 (diff) | |
download | android_packages_apps_Trebuchet-af78b59af19264105b8ce856defa5342d6fd584a.tar.gz android_packages_apps_Trebuchet-af78b59af19264105b8ce856defa5342d6fd584a.tar.bz2 android_packages_apps_Trebuchet-af78b59af19264105b8ce856defa5342d6fd584a.zip |
Make sure pages are always accessible via left/right arrow keys.
- Handle NextPageFirstItem as first focusable item in reading order
- Handle PreviousPageLastItem as last focusable item in reading order
- Check the hotseat after the workspace in both cases above
- Dpad horizontal navigation (left/right) uses these as a last
resort (Rule3) to guarantee an item takes focus if a page exists
Note that it is necessary to search for a focusable item because
widgets are not yet focusable.
Bug: 25591057
Change-Id: I953648bd76c657d660a38427fdd4108bf9963c23
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r-- | src/com/android/launcher3/util/FocusLogic.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java index f56d16222..22e0cadea 100644 --- a/src/com/android/launcher3/util/FocusLogic.java +++ b/src/com/android/launcher3/util/FocusLogic.java @@ -92,7 +92,7 @@ public class FocusLogic { int newIndex = NOOP; switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: - newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/); + newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/, isRtl); if (!isRtl && newIndex == NOOP && pageIndex > 0) { newIndex = PREVIOUS_PAGE_RIGHT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { @@ -100,7 +100,7 @@ public class FocusLogic { } break; case KeyEvent.KEYCODE_DPAD_RIGHT: - newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/); + newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/, isRtl); if (!isRtl && newIndex == NOOP && pageIndex < pageCount - 1) { newIndex = NEXT_PAGE_LEFT_COLUMN; } else if (isRtl && newIndex == NOOP && pageIndex > 0) { @@ -314,7 +314,7 @@ public class FocusLogic { */ // TODO: add unit tests to verify all permutation. private static int handleDpadHorizontal(int iconIdx, int cntX, int cntY, - int[][] matrix, int increment) { + int[][] matrix, int increment, boolean isRtl) { if(matrix == null) { throw new IllegalStateException("Dpad navigation requires a matrix."); } @@ -370,17 +370,13 @@ public class FocusLogic { } } - // Rule 3: if switching between pages, do a brute-force search to find an item that was - // missed by rules 1 and 2 (such as when going from a bottom right icon to top left) + // Rule3: if switching between pages, do a brute-force search to find an item that was + // missed by rules 1 and 2 (such as when going from a bottom right icon to top left) if (iconIdx == PIVOT) { - for (x = xPos + increment; 0 <= x && x < cntX; x += increment) { - for (int y = 0; y < cntY; y++) { - if ((newIconIndex = inspectMatrix(x, y, cntX, cntY, matrix)) != NOOP - && newIconIndex != ALL_APPS_COLUMN) { - return newIconIndex; - } - } + if (isRtl) { + return increment < 0 ? NEXT_PAGE_FIRST_ITEM : PREVIOUS_PAGE_LAST_ITEM; } + return increment < 0 ? PREVIOUS_PAGE_LAST_ITEM : NEXT_PAGE_FIRST_ITEM; } return newIconIndex; } |