From c2964cb6cd87746dd1e44da90e62813ccb47cecf Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 5 Nov 2015 12:14:26 -0800 Subject: [PATCH] Make sure user can always get to next page with keyboard. There's a case where hitting the left/right arrow in the first/last column wouldn't give focus to an icon on the next page because it is vertically too far from the first icon to be considered. This makes for a bad user experience, because there is no way to switch pages with the keyboard. So now we brute-force search for an appropriate icon if none was found in this case. Bug: 25434120 Change-Id: Ifdead0e3b458717ccb33e2f0ec7c15f1fcce4b95 --- src/com/android/launcher3/util/FocusLogic.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java index 7f0da77e45..66da85c547 100644 --- a/src/com/android/launcher3/util/FocusLogic.java +++ b/src/com/android/launcher3/util/FocusLogic.java @@ -346,6 +346,18 @@ 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) + if (iconIdx == PIVOT) { + for (int x = xPos + increment; 0 <= x && x < cntX; x = x + increment) { + for (int y = 0; y < cntY; y++) { + if ((newIconIndex = inspectMatrix(x, y, cntX, cntY, matrix)) != NOOP) { + return newIconIndex; + } + } + } + } return newIconIndex; }