diff options
| author | Amith Yamasani <yamasani@google.com> | 2012-02-14 15:52:17 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-14 15:52:17 -0800 |
| commit | dd29f8c4e3db3338bc055302145c3bc51a27566f (patch) | |
| tree | 5ae5f5c6fb6e6aa899bfbf6c63b72f3e19f16d80 /core/java/android/view/ViewRootImpl.java | |
| parent | 9ae763133238ad5a1963d99a69cf891293345cb3 (diff) | |
| parent | 73eb97f628b298c7bd032aa9db11dadf05f5b539 (diff) | |
| download | frameworks_base-dd29f8c4e3db3338bc055302145c3bc51a27566f.zip frameworks_base-dd29f8c4e3db3338bc055302145c3bc51a27566f.tar.gz frameworks_base-dd29f8c4e3db3338bc055302145c3bc51a27566f.tar.bz2 | |
Merge "Revert "Incorrect behavior of View clear focus.""
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 1930a5e..1c3bbfa 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -174,7 +174,6 @@ public final class ViewRootImpl extends Handler implements ViewParent, View mView; View mFocusedView; View mRealFocusedView; // this is not set to null in touch mode - View mOldFocusedView; int mViewVisibility; boolean mAppVisible = true; int mOrigWindowType = -1; @@ -2273,34 +2272,33 @@ public final class ViewRootImpl extends Handler implements ViewParent, public void requestChildFocus(View child, View focused) { checkThread(); - - if (DEBUG_INPUT_RESIZE) { - Log.v(TAG, "Request child focus: focus now " + focused); + if (mFocusedView != focused) { + mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mFocusedView, focused); + scheduleTraversals(); } - - mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, focused); - scheduleTraversals(); - mFocusedView = mRealFocusedView = focused; + if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Request child focus: focus now " + + mFocusedView); } public void clearChildFocus(View child) { checkThread(); - if (DEBUG_INPUT_RESIZE) { - Log.v(TAG, "Clearing child focus"); - } - - mOldFocusedView = mFocusedView; - - // Invoke the listener only if there is no view to take focus - if (focusSearch(null, View.FOCUS_FORWARD) == null) { - mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, null); - } + View oldFocus = mFocusedView; + if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Clearing child focus"); mFocusedView = mRealFocusedView = null; + if (mView != null && !mView.hasFocus()) { + // If a view gets the focus, the listener will be invoked from requestChildFocus() + if (!mView.requestFocus(View.FOCUS_FORWARD)) { + mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null); + } + } else if (oldFocus != null) { + mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null); + } } + public void focusableViewAvailable(View v) { checkThread(); @@ -2772,7 +2770,6 @@ public final class ViewRootImpl extends Handler implements ViewParent, mView.unFocus(); mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null); mFocusedView = null; - mOldFocusedView = null; return true; } } |
