Merge "Gracefully handle focus loops created by app dev." into oc-dr1-dev am: ae938cee71
am: 756685b506
Change-Id: I097489465c8bc066ddba04ea858c32f4af463a66
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