diff options
| author | Alan Viverette <alanv@google.com> | 2013-08-14 17:07:35 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-14 17:07:35 -0700 |
| commit | cd63115ebc73b257a73ebf03eb3a8463532eb260 (patch) | |
| tree | 870c415448905c4eadb02ea9a7d454e807c2ffeb /core/java | |
| parent | 6d59c85c09a9eaf770c342a1751b760315ccb95d (diff) | |
| parent | 70e907f51f75bf8d481e11e0d6411e2974b83b06 (diff) | |
am 70e907f5: Merge "Prevent refocus after entering touch mode" into klp-dev
* commit '70e907f51f75bf8d481e11e0d6411e2974b83b06':
Prevent refocus after entering touch mode
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/View.java | 24 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 6 |
2 files changed, 19 insertions, 11 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index df2e09fcea96..747e8eae192b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4572,10 +4572,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, System.out.println(this + " clearFocus()"); } + clearFocusInternal(true, true); + } + + /** + * Clears focus from the view, optionally propagating the change up through + * the parent hierarchy and requesting that the root view place new focus. + * + * @param propagate whether to propagate the change up through the parent + * hierarchy + * @param refocus when propagate is true, specifies whether to request the + * root view place new focus + */ + void clearFocusInternal(boolean propagate, boolean refocus) { if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { mPrivateFlags &= ~PFLAG_FOCUSED; - if (mParent != null) { + if (propagate && mParent != null) { mParent.clearChildFocus(this); } @@ -4583,7 +4596,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, refreshDrawableState(); - if (!rootViewRequestFocus()) { + if (propagate && (!refocus || !rootViewRequestFocus())) { notifyGlobalFocusCleared(this); } } @@ -4613,12 +4626,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, System.out.println(this + " unFocus()"); } - if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { - mPrivateFlags &= ~PFLAG_FOCUSED; - - onFocusChanged(false, 0, null); - refreshDrawableState(); - } + clearFocusInternal(false, false); } /** diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3977a33f3197..e90705c1ed53 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3271,9 +3271,9 @@ public final class ViewRootImpl implements ViewParent, // focus return ancestorToTakeFocus.requestFocus(); } else { - // nothing appropriate to have focus in touch mode, clear it - // out - focused.clearFocus(); + // There's nothing to focus. Clear and propagate through the + // hierarchy, but don't attempt to place new focus. + focused.clearFocusInternal(true, false); return true; } } |
