diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-04-30 16:49:59 -0700 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-04-30 16:50:14 -0700 |
| commit | cf8a3b82241a320f568f8448184df6da5bbcf152 (patch) | |
| tree | bb14a178994cfe3460777b038a40d079ebf2fee7 /core/java/android/view/ViewRootImpl.java | |
| parent | 427db9b3d10d5c203d0351e683c3cddfd270250c (diff) | |
Accessibility should not change input focus behavior.
1. Removed a change in the input focus behavior I forgot
to take out when submitted the main accessibility focus
patch. Ugh..
bug:6320098
Change-Id: Id7942e8aac64ba4bf6df7e19f733fa70b368d1bb
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index c5c7746d4d11..510e4d804680 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3013,24 +3013,23 @@ public final class ViewRootImpl implements ViewParent, // be when the window is first being added, and mFocused isn't // set yet. final View focused = mView.findFocus(); - if (focused != null) { - if (focused.isFocusableInTouchMode()) { - return true; - } + 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 + mView.unFocus(); + mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null); + mFocusedView = null; + mOldFocusedView = null; + return true; } } - // nothing appropriate to have focus in touch mode, clear it out - mView.unFocus(); - mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null); - mFocusedView = null; - mOldFocusedView = null; - return true; } } return false; @@ -3061,45 +3060,25 @@ public final class ViewRootImpl implements ViewParent, private boolean leaveTouchMode() { if (mView != null) { - boolean inputFocusValid = false; if (mView.hasFocus()) { // i learned the hard way to not trust mFocusedView :) mFocusedView = mView.findFocus(); if (!(mFocusedView instanceof ViewGroup)) { // some view has focus, let it keep it - inputFocusValid = true; - } else if (((ViewGroup) mFocusedView).getDescendantFocusability() != + return false; + } else if (((ViewGroup)mFocusedView).getDescendantFocusability() != ViewGroup.FOCUS_AFTER_DESCENDANTS) { // some view group has focus, and doesn't prefer its children // over itself for focus, so let them keep it. - inputFocusValid = true; + return false; } } - // In accessibility mode we always have a view that has the - // accessibility focus and input focus follows it, i.e. we - // try to give input focus to the accessibility focused view. - if (!AccessibilityManager.getInstance(mView.mContext).isEnabled()) { - // If the current input focus is not valid, find the best view to give - // focus to in this brave new non-touch-mode world. - if (!inputFocusValid) { - final View focused = focusSearch(null, View.FOCUS_DOWN); - if (focused != null) { - return focused.requestFocus(View.FOCUS_DOWN); - } - } - } else { - // If the current input focus is not valid clear it but do not - // give it to another view since the accessibility focus is - // leading now and the input one follows. - if (!inputFocusValid) { - if (mFocusedView != null) { - mView.unFocus(); - mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mFocusedView, null); - mFocusedView = null; - mOldFocusedView = null; - return true; - } - } + + // find the best view to give focus to in this brave new non-touch-mode + // world + final View focused = focusSearch(null, View.FOCUS_DOWN); + if (focused != null) { + return focused.requestFocus(View.FOCUS_DOWN); } } return false; |
