diff options
author | Tony Wickham <twickham@google.com> | 2015-12-03 22:23:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-12-03 22:23:11 +0000 |
commit | b90a9761ae1b914de380fe893efad628fff6386a (patch) | |
tree | b119514aa015b0d1d5aec511f1d4a3bf25afac64 /src/com/android/launcher3/util | |
parent | 800550d63f759f4d5d27000b7f8bfbc429ac8245 (diff) | |
parent | af78b59af19264105b8ce856defa5342d6fd584a (diff) | |
download | android_packages_apps_Trebuchet-b90a9761ae1b914de380fe893efad628fff6386a.tar.gz android_packages_apps_Trebuchet-b90a9761ae1b914de380fe893efad628fff6386a.tar.bz2 android_packages_apps_Trebuchet-b90a9761ae1b914de380fe893efad628fff6386a.zip |
Make sure pages are always accessible via left/right arrow keys.
am: af78b59af1
* commit 'af78b59af19264105b8ce856defa5342d6fd584a':
Make sure pages are always accessible via left/right arrow keys.
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; } |