Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64dd913f authored by Evan Rosky's avatar Evan Rosky Committed by android-build-merger
Browse files

Merge "Gracefully handle focus loops created by app dev." into oc-dr1-dev

am: ae938cee

Change-Id: I0b0fe6f7cc07362e98f7a5a2b54aa66bbd5ffc7f
parents be0b8cdf ae938cee
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;
    }