summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2013-07-24 15:49:23 -0700
committerAlan Viverette <alanv@google.com>2013-07-24 15:49:23 -0700
commited7821a60ca80197384b2a4678b6c4ea307457e6 (patch)
treea0b0012b595c63e42ef530990719a9a44f739258 /core/java/android/view/ViewRootImpl.java
parent616dfe37f5a1f67f97d151f0fbefa4020ddfdec6 (diff)
Use clearFocus() when entering touch mode
Calling unFocus() leaves the view hierarchy in an inconsistent state. This is okay in ViewGroup, where the state is manually updated, but causes issues in ViewRootImpl. BUG: 9983358 Change-Id: Id63e62962d895e6bd4f816f202dcf77254ceab4e
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 075719c68e15..1f7ff9b7abf9 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3250,24 +3250,23 @@ public final class ViewRootImpl implements ViewParent,
}
private boolean enterTouchMode() {
- if (mView != null) {
- if (mView.hasFocus()) {
- // note: not relying on mFocusedView here because this could
- // be when the window is first being added, and mFocused isn't
- // set yet.
- final View focused = mView.findFocus();
- if (focused != null && !focused.isFocusableInTouchMode()) {
- final ViewGroup ancestorToTakeFocus =
- findAncestorToTakeFocusInTouchMode(focused);
- if (ancestorToTakeFocus != null) {
- // there is an ancestor that wants focus after its descendants that
- // is focusable in touch mode.. give it focus
- return ancestorToTakeFocus.requestFocus();
- } else {
- // nothing appropriate to have focus in touch mode, clear it out
- focused.unFocus();
- return true;
- }
+ if (mView != null && mView.hasFocus()) {
+ // note: not relying on mFocusedView here because this could
+ // be when the window is first being added, and mFocused isn't
+ // set yet.
+ final View focused = mView.findFocus();
+ if (focused != null && !focused.isFocusableInTouchMode()) {
+ final ViewGroup ancestorToTakeFocus = findAncestorToTakeFocusInTouchMode(focused);
+ if (ancestorToTakeFocus != null) {
+ // there is an ancestor that wants focus after its
+ // descendants that is focusable in touch mode.. give it
+ // focus
+ return ancestorToTakeFocus.requestFocus();
+ } else {
+ // nothing appropriate to have focus in touch mode, clear it
+ // out
+ focused.clearFocus();
+ return true;
}
}
}