diff options
| author | 2017-08-02 22:42:21 +0000 | |
|---|---|---|
| committer | 2017-08-02 22:42:21 +0000 | |
| commit | 64dd913f689da9ef38cbe5d4465494da25455bba (patch) | |
| tree | 003b65497f4e9e5115dd20ebab1923440ef22823 | |
| parent | be0b8cdfa97f59b1e72931c1305eb52ea092e5e3 (diff) | |
| parent | ae938cee71124776d5987868eaa5789ef5049c7a (diff) | |
Merge "Gracefully handle focus loops created by app dev." into oc-dr1-dev
am: ae938cee71
Change-Id: I0b0fe6f7cc07362e98f7a5a2b54aa66bbd5ffc7f
| -rw-r--r-- | core/java/android/view/FocusFinder.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java index 48e5ca9a20f4..af26a88e877c 100644 --- a/core/java/android/view/FocusFinder.java +++ b/core/java/android/view/FocusFinder.java @@ -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; } |