diff options
| author | Evan Rosky <erosky@google.com> | 2017-04-19 17:23:32 -0700 |
|---|---|---|
| committer | Evan Rosky <erosky@google.com> | 2017-04-26 12:50:58 -0700 |
| commit | 6c286befa31480924cf1edd600b51d8f732f373c (patch) | |
| tree | 94189a43cc8bf5afd6b3689bba367daa7f9ad87f /core/java/android/view/ViewGroup.java | |
| parent | 2be0a532bf485988aba1b278f070259d9568d80a (diff) | |
Only save focus in keyboard navigation clusters when appropriate
- tabbing forward/backward should not save cluster focus. If
focus leaves a cluster due to normal forward/backward navigation
the cluster focus is cleared.
- directional arrows or cluster jumps (meta+tab) will save focus
in the cluster so that cluster-jumping back will restore it.
Also fixed a couple small bugs: focusable viewgroups wouldn't save
properly, focusIncluster wasn't cleared properly.
Bug: 35274351
Test: Added CTS test for this behavior.
Change-Id: Ie86218d70b0fc3aa1a709e613a2761a65ab12500
Diffstat (limited to 'core/java/android/view/ViewGroup.java')
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 1977ef5ae989..d3d46cb4f44b 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -143,7 +143,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // that is or contains a default-focus view. private View mDefaultFocus; // The last child of this ViewGroup which held focus within the current cluster - private View mFocusedInCluster; + View mFocusedInCluster; /** * A Transformation used when drawing children, to @@ -807,10 +807,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return mDefaultFocus != null || super.hasDefaultFocus(); } - void setFocusedInCluster(View child) { - mFocusedInCluster = child; - } - /** * Removes {@code child} (and associated focusedInCluster chain) from the cluster containing * it. @@ -826,8 +822,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager ViewParent parent = this; do { ((ViewGroup) parent).mFocusedInCluster = null; + if (parent == top) { + break; + } parent = parent.getParent(); - } while (parent != top && parent instanceof ViewGroup); + } while (parent instanceof ViewGroup); } @Override |
