diff options
| -rw-r--r-- | core/java/android/view/View.java | 17 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 7 |
2 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ec8ffd779282..73fc43731384 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -13249,6 +13249,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && ((privateFlags & PFLAG_FOCUSED) != 0)) { /* Give up focus if we are no longer focusable */ clearFocus(); + if (mParent instanceof ViewGroup) { + ((ViewGroup) mParent).clearFocusedInCluster(); + } } else if (((old & FOCUSABLE) == NOT_FOCUSABLE) && ((privateFlags & PFLAG_FOCUSED) == 0)) { /* @@ -13296,7 +13299,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, requestLayout(); if (((mViewFlags & VISIBILITY_MASK) == GONE)) { - if (hasFocus()) clearFocus(); + if (hasFocus()) { + clearFocus(); + if (mParent instanceof ViewGroup) { + ((ViewGroup) mParent).clearFocusedInCluster(); + } + } clearAccessibilityFocus(); destroyDrawingCache(); if (mParent instanceof View) { @@ -13324,7 +13332,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (((mViewFlags & VISIBILITY_MASK) == INVISIBLE)) { // root view becoming invisible shouldn't clear focus and accessibility focus if (getRootView() != this) { - if (hasFocus()) clearFocus(); + if (hasFocus()) { + clearFocus(); + if (mParent instanceof ViewGroup) { + ((ViewGroup) mParent).clearFocusedInCluster(); + } + } clearAccessibilityFocus(); } } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 18b7334c7adf..bf324070f5bf 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -818,6 +818,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (mFocusedInCluster != child) { return; } + clearFocusedInCluster(); + } + + /** + * Removes the focusedInCluster chain from this up to the cluster containing it. + */ + void clearFocusedInCluster() { View top = findKeyboardNavigationCluster(); ViewParent parent = this; do { |