Loading core/java/android/view/FocusFinder.java +16 −5 Original line number Diff line number Diff line Loading @@ -314,13 +314,20 @@ public class FocusFinder { if (count < 2) { return null; } View next = null; final boolean[] looped = new boolean[1]; switch (direction) { case View.FOCUS_FORWARD: return getNextFocusable(focused, focusables, count); next = getNextFocusable(focused, focusables, count, looped); break; case View.FOCUS_BACKWARD: return getPreviousFocusable(focused, focusables, count); next = getPreviousFocusable(focused, focusables, count, looped); break; } return focusables.get(count - 1); if (root != null && root.mAttachInfo != null && root == root.getRootView()) { root.mAttachInfo.mNextFocusLooped = looped[0]; } return next != null ? next : focusables.get(count - 1); } private void setFocusBottomRight(ViewGroup root, Rect focusedRect) { Loading Loading @@ -375,7 +382,8 @@ public class FocusFinder { return closest; } private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) { private static View getNextFocusable(View focused, ArrayList<View> focusables, int count, boolean[] outLooped) { if (count < 2) { return null; } Loading @@ -385,10 +393,12 @@ public class FocusFinder { return focusables.get(position + 1); } } outLooped[0] = true; return focusables.get(0); } private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) { private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count, boolean[] outLooped) { if (count < 2) { return null; } Loading @@ -398,6 +408,7 @@ public class FocusFinder { return focusables.get(position - 1); } } outLooped[0] = true; return focusables.get(count - 1); } Loading core/java/android/view/View.java +7 −0 Original line number Diff line number Diff line Loading @@ -31335,6 +31335,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ final ArrayList<View> mTempArrayList = new ArrayList<View>(24); /** * Indicates if the next focus will be looped back to the first focusable view of the entire * hierarchy when finding in the direction of {@link #FOCUS_FORWARD} or to the last * focusable view when finding in the direction of {@link #FOCUS_BACKWARD}. */ boolean mNextFocusLooped = false; /** * The id of the window for accessibility purposes. */ core/java/android/view/ViewRootImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -7283,8 +7283,18 @@ public final class ViewRootImpl implements ViewParent, if (direction != 0) { View focused = mView.findFocus(); if (focused != null) { mAttachInfo.mNextFocusLooped = false; View v = focused.focusSearch(direction); if (v != null && v != focused) { if (mAttachInfo.mNextFocusLooped) { // The next focus is looped. Let's try to move the focus to the adjacent // window. Note: we still need to move the focus in this window // regardless of what moveFocusToAdjacentWindow returns, so the focus // can be looped back from the focus in the adjacent window to next // focus of this window. moveFocusToAdjacentWindow(direction); } // do the math the get the interesting rect // of previous focused into the coord system of // newly focused view Loading Loading
core/java/android/view/FocusFinder.java +16 −5 Original line number Diff line number Diff line Loading @@ -314,13 +314,20 @@ public class FocusFinder { if (count < 2) { return null; } View next = null; final boolean[] looped = new boolean[1]; switch (direction) { case View.FOCUS_FORWARD: return getNextFocusable(focused, focusables, count); next = getNextFocusable(focused, focusables, count, looped); break; case View.FOCUS_BACKWARD: return getPreviousFocusable(focused, focusables, count); next = getPreviousFocusable(focused, focusables, count, looped); break; } return focusables.get(count - 1); if (root != null && root.mAttachInfo != null && root == root.getRootView()) { root.mAttachInfo.mNextFocusLooped = looped[0]; } return next != null ? next : focusables.get(count - 1); } private void setFocusBottomRight(ViewGroup root, Rect focusedRect) { Loading Loading @@ -375,7 +382,8 @@ public class FocusFinder { return closest; } private static View getNextFocusable(View focused, ArrayList<View> focusables, int count) { private static View getNextFocusable(View focused, ArrayList<View> focusables, int count, boolean[] outLooped) { if (count < 2) { return null; } Loading @@ -385,10 +393,12 @@ public class FocusFinder { return focusables.get(position + 1); } } outLooped[0] = true; return focusables.get(0); } private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count) { private static View getPreviousFocusable(View focused, ArrayList<View> focusables, int count, boolean[] outLooped) { if (count < 2) { return null; } Loading @@ -398,6 +408,7 @@ public class FocusFinder { return focusables.get(position - 1); } } outLooped[0] = true; return focusables.get(count - 1); } Loading
core/java/android/view/View.java +7 −0 Original line number Diff line number Diff line Loading @@ -31335,6 +31335,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ final ArrayList<View> mTempArrayList = new ArrayList<View>(24); /** * Indicates if the next focus will be looped back to the first focusable view of the entire * hierarchy when finding in the direction of {@link #FOCUS_FORWARD} or to the last * focusable view when finding in the direction of {@link #FOCUS_BACKWARD}. */ boolean mNextFocusLooped = false; /** * The id of the window for accessibility purposes. */
core/java/android/view/ViewRootImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -7283,8 +7283,18 @@ public final class ViewRootImpl implements ViewParent, if (direction != 0) { View focused = mView.findFocus(); if (focused != null) { mAttachInfo.mNextFocusLooped = false; View v = focused.focusSearch(direction); if (v != null && v != focused) { if (mAttachInfo.mNextFocusLooped) { // The next focus is looped. Let's try to move the focus to the adjacent // window. Note: we still need to move the focus in this window // regardless of what moveFocusToAdjacentWindow returns, so the focus // can be looped back from the focus in the adjacent window to next // focus of this window. moveFocusToAdjacentWindow(direction); } // do the math the get the interesting rect // of previous focused into the coord system of // newly focused view Loading