Merge "Finding focus for from rectangle now working." into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5fd72a2cce
@ -62,7 +62,7 @@ public class FocusFinder {
|
|||||||
* @return The next focusable view, or null if none exists.
|
* @return The next focusable view, or null if none exists.
|
||||||
*/
|
*/
|
||||||
public final View findNextFocus(ViewGroup root, View focused, int direction) {
|
public final View findNextFocus(ViewGroup root, View focused, int direction) {
|
||||||
return findNextFocus(root, focused, mFocusedRect, direction);
|
return findNextFocus(root, focused, null, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,34 +122,40 @@ public class FocusFinder {
|
|||||||
int direction, ArrayList<View> focusables) {
|
int direction, ArrayList<View> focusables) {
|
||||||
final int directionMasked = (direction & ~View.FOCUS_ACCESSIBILITY);
|
final int directionMasked = (direction & ~View.FOCUS_ACCESSIBILITY);
|
||||||
if (focused != null) {
|
if (focused != null) {
|
||||||
|
if (focusedRect == null) {
|
||||||
|
focusedRect = mFocusedRect;
|
||||||
|
}
|
||||||
// fill in interesting rect from focused
|
// fill in interesting rect from focused
|
||||||
focused.getFocusedRect(focusedRect);
|
focused.getFocusedRect(focusedRect);
|
||||||
root.offsetDescendantRectToMyCoords(focused, focusedRect);
|
root.offsetDescendantRectToMyCoords(focused, focusedRect);
|
||||||
} else {
|
} else {
|
||||||
// make up a rect at top left or bottom right of root
|
if (focusedRect == null) {
|
||||||
switch (directionMasked) {
|
focusedRect = mFocusedRect;
|
||||||
case View.FOCUS_RIGHT:
|
// make up a rect at top left or bottom right of root
|
||||||
case View.FOCUS_DOWN:
|
switch (directionMasked) {
|
||||||
setFocusTopLeft(root, focusedRect);
|
case View.FOCUS_RIGHT:
|
||||||
break;
|
case View.FOCUS_DOWN:
|
||||||
case View.FOCUS_FORWARD:
|
|
||||||
if (root.isLayoutRtl()) {
|
|
||||||
setFocusBottomRight(root, focusedRect);
|
|
||||||
} else {
|
|
||||||
setFocusTopLeft(root, focusedRect);
|
setFocusTopLeft(root, focusedRect);
|
||||||
}
|
break;
|
||||||
break;
|
case View.FOCUS_FORWARD:
|
||||||
|
if (root.isLayoutRtl()) {
|
||||||
|
setFocusBottomRight(root, focusedRect);
|
||||||
|
} else {
|
||||||
|
setFocusTopLeft(root, focusedRect);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case View.FOCUS_LEFT:
|
case View.FOCUS_LEFT:
|
||||||
case View.FOCUS_UP:
|
case View.FOCUS_UP:
|
||||||
setFocusBottomRight(root, focusedRect);
|
|
||||||
break;
|
|
||||||
case View.FOCUS_BACKWARD:
|
|
||||||
if (root.isLayoutRtl()) {
|
|
||||||
setFocusTopLeft(root, focusedRect);
|
|
||||||
} else {
|
|
||||||
setFocusBottomRight(root, focusedRect);
|
setFocusBottomRight(root, focusedRect);
|
||||||
break;
|
break;
|
||||||
|
case View.FOCUS_BACKWARD:
|
||||||
|
if (root.isLayoutRtl()) {
|
||||||
|
setFocusTopLeft(root, focusedRect);
|
||||||
|
} else {
|
||||||
|
setFocusBottomRight(root, focusedRect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user