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 551a1556d859..2265b9c0c31f 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -13240,6 +13240,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)) { /* @@ -13304,7 +13307,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) { @@ -13332,7 +13340,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 379ef5b18dc7..b2e5a163d872 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 { |