Merge "Gracefully handle focus loops created by app dev." into oc-dr1-dev
am: ae938cee71
Change-Id: If8a2938a9f10a9c8b60b65323cd34713eeb95f40
This commit is contained in:
@@ -193,6 +193,8 @@ public class FocusFinder {
|
||||
private View findNextUserSpecifiedFocus(ViewGroup root, View focused, int direction) {
|
||||
// check for user specified next focus
|
||||
View userSetNextFocus = focused.findUserSetNextFocus(root, direction);
|
||||
View cycleCheck = userSetNextFocus;
|
||||
boolean cycleStep = true; // we want the first toggle to yield false
|
||||
while (userSetNextFocus != null) {
|
||||
if (userSetNextFocus.isFocusable()
|
||||
&& userSetNextFocus.getVisibility() == View.VISIBLE
|
||||
@@ -201,6 +203,14 @@ public class FocusFinder {
|
||||
return userSetNextFocus;
|
||||
}
|
||||
userSetNextFocus = userSetNextFocus.findUserSetNextFocus(root, direction);
|
||||
if (cycleStep = !cycleStep) {
|
||||
cycleCheck = cycleCheck.findUserSetNextFocus(root, direction);
|
||||
if (cycleCheck == userSetNextFocus) {
|
||||
// found a cycle, user-specified focus forms a loop and none of the views
|
||||
// are currently focusable.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user