Stop explicitly snapping to page when navigating with keyboard.

When an icon grabs focus, it already snaps to its own page, so
the explicit snapToPage() is redundant. And in the case where no icon
will grab the focus, the explicit call puts us in a weird state
because the page snaps but the focus doesn't change (see bug).

(This happens, for instance, if you are moving from an icon on the
bottom right of page 1 and the only icon on page 2 is in the top
left. In this case, the second icon won't take focus because the
angle is too wide according to FocusLogic#handleDpadHorizontal().)

Bug: 25434120
Change-Id: I17b0ef7d86426a2599bc948bf2313dca7e112364
This commit is contained in:
Tony Wickham committed 2015-11-04 17:44:32 -08:00
1 parent 04e2c9ef56
commit 25189851ac
2 files changed
+4 -9

No files matched your search

+2 -7
View File
@@ -142,7 +142,8 @@ public class FocusHelper {
newParent = getCellLayoutChildrenForIndex(pagedView, pageIndex + 1);
if (newParent != null) {
pagedView.snapToPage(pageIndex + 1);
child = FocusLogic.getAdjacentChildInNextPage(newParent, v, newIconIndex);
child = FocusLogic.getAdjacentChildInNextFolderPage(
newParent, v, newIconIndex);
}
break;
case FocusLogic.CURRENT_PAGE_FIRST_ITEM:
@@ -364,9 +365,7 @@ public class FocusHelper {
}
int row = ((CellLayout.LayoutParams) v.getLayoutParams()).cellY;
parent = getCellLayoutChildrenForIndex(workspace, newPageIndex);
workspace.snapToPage(newPageIndex);
if (parent != null) {
workspace.snapToPage(newPageIndex);
iconLayout = (CellLayout) parent.getParent();
matrix = FocusLogic.createSparseMatrix(iconLayout,
iconLayout.getCountX(), row);
@@ -379,17 +378,14 @@ public class FocusHelper {
case FocusLogic.PREVIOUS_PAGE_FIRST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
newIcon = parent.getChildAt(0);
workspace.snapToPage(pageIndex - 1);
break;
case FocusLogic.PREVIOUS_PAGE_LAST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
newIcon = parent.getChildAt(parent.getChildCount() - 1);
workspace.snapToPage(pageIndex - 1);
break;
case FocusLogic.NEXT_PAGE_FIRST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex + 1);
newIcon = parent.getChildAt(0);
workspace.snapToPage(pageIndex + 1);
break;
case FocusLogic.NEXT_PAGE_LEFT_COLUMN:
case FocusLogic.PREVIOUS_PAGE_LEFT_COLUMN:
@@ -400,7 +396,6 @@ public class FocusHelper {
row = ((CellLayout.LayoutParams) v.getLayoutParams()).cellY;
parent = getCellLayoutChildrenForIndex(workspace, newPageIndex);
if (parent != null) {
workspace.snapToPage(newPageIndex);
iconLayout = (CellLayout) parent.getParent();
matrix = FocusLogic.createSparseMatrix(iconLayout, -1, row);
newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX + 1, countY,