summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Svetoslav Ganov <svetoslavganov@google.com> 2012-04-30 13:15:21 -0700
committer Svetoslav Ganov <svetoslavganov@google.com> 2012-04-30 13:19:22 -0700
commit951bb421668b82ca014f75d265b161f6ff64d36b (patch)
tree1b705ca6340b25a4e21d8bc559f12c67522e9bb0
parent427db9b3d10d5c203d0351e683c3cddfd270250c (diff)
Finding focus for from rectangle now working.
1. The FocusFinder code was ignoring the rectangle. bug:6400513 Change-Id: I218425182b9cc2cda01fc4b5d75e9ac94a22561c
-rw-r--r--core/java/android/view/FocusFinder.java52
1 files changed, 29 insertions, 23 deletions
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java
index 98375aeacf24..6bf1888cc2c2 100644
--- a/core/java/android/view/FocusFinder.java
+++ b/core/java/android/view/FocusFinder.java
@@ -62,7 +62,7 @@ public class FocusFinder {
* @return The next focusable view, or null if none exists.
*/
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) {
final int directionMasked = (direction & ~View.FOCUS_ACCESSIBILITY);
if (focused != null) {
+ if (focusedRect == null) {
+ focusedRect = mFocusedRect;
+ }
// fill in interesting rect from focused
focused.getFocusedRect(focusedRect);
root.offsetDescendantRectToMyCoords(focused, focusedRect);
} else {
- // make up a rect at top left or bottom right of root
- switch (directionMasked) {
- case View.FOCUS_RIGHT:
- case View.FOCUS_DOWN:
- setFocusTopLeft(root, focusedRect);
- break;
- case View.FOCUS_FORWARD:
- if (root.isLayoutRtl()) {
- setFocusBottomRight(root, focusedRect);
- } else {
- setFocusTopLeft(root, focusedRect);
- }
- break;
-
- case View.FOCUS_LEFT:
- case View.FOCUS_UP:
- setFocusBottomRight(root, focusedRect);
- break;
- case View.FOCUS_BACKWARD:
- if (root.isLayoutRtl()) {
+ if (focusedRect == null) {
+ focusedRect = mFocusedRect;
+ // make up a rect at top left or bottom right of root
+ switch (directionMasked) {
+ case View.FOCUS_RIGHT:
+ case View.FOCUS_DOWN:
setFocusTopLeft(root, focusedRect);
- } else {
+ break;
+ case View.FOCUS_FORWARD:
+ if (root.isLayoutRtl()) {
+ setFocusBottomRight(root, focusedRect);
+ } else {
+ setFocusTopLeft(root, focusedRect);
+ }
+ break;
+
+ case View.FOCUS_LEFT:
+ case View.FOCUS_UP:
setFocusBottomRight(root, focusedRect);
- break;
+ break;
+ case View.FOCUS_BACKWARD:
+ if (root.isLayoutRtl()) {
+ setFocusTopLeft(root, focusedRect);
+ } else {
+ setFocusBottomRight(root, focusedRect);
+ break;
+ }
}
}
}