Loading core/java/android/view/View.java +5 −0 Original line number Diff line number Diff line Loading @@ -3788,6 +3788,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal onFocusChanged(false, 0, null); refreshDrawableState(); // The view cleared focus and invoked the callbacks, so now is the // time to give focus to the the first focusable from the top to // ensure that the gain focus is announced after clear focus. getRootView().requestFocus(FOCUS_FORWARD); } } Loading core/java/android/view/ViewGroup.java +11 −8 Original line number Diff line number Diff line Loading @@ -675,11 +675,14 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager */ @Override public void clearFocus() { if (DBG) { System.out.println(this + " clearFocus()"); } if (mFocused == null) { super.clearFocus(); // clear any child focus if it exists if (mFocused != null) { } else { mFocused.clearFocus(); mFocused = null; } } Loading @@ -691,13 +694,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (DBG) { System.out.println(this + " unFocus()"); } if (mFocused == null) { super.unFocus(); if (mFocused != null) { } else { mFocused.unFocus(); } mFocused = null; } } /** * Returns the focused child of this view, if any. The child may have focus Loading core/java/android/view/ViewRootImpl.java +19 −16 Original line number Diff line number Diff line Loading @@ -174,6 +174,7 @@ 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; Loading Loading @@ -2272,32 +2273,33 @@ public final class ViewRootImpl extends Handler implements ViewParent, public void requestChildFocus(View child, View focused) { checkThread(); if (mFocusedView != focused) { mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mFocusedView, focused); scheduleTraversals(); if (DEBUG_INPUT_RESIZE) { Log.v(TAG, "Request child focus: focus now " + focused); } 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(); 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); 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); } mFocusedView = mRealFocusedView = null; } public void focusableViewAvailable(View v) { checkThread(); Loading Loading @@ -2770,6 +2772,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, mView.unFocus(); mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null); mFocusedView = null; mOldFocusedView = null; return true; } } Loading core/tests/coretests/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ LOCAL_SRC_FILES := \ $(call all-java-files-under, EnabledTestApp/src) LOCAL_DX_FLAGS := --core-library LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava littlemock LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_PACKAGE_NAME := FrameworksCoreTests Loading core/tests/coretests/src/android/widget/focus/RequestFocus.java +0 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ import com.android.frameworks.coretests.R; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.widget.LinearLayout; import android.widget.Button; import android.view.View; /** * Exercises cases where elements of the UI are requestFocus()ed. Loading Loading
core/java/android/view/View.java +5 −0 Original line number Diff line number Diff line Loading @@ -3788,6 +3788,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal onFocusChanged(false, 0, null); refreshDrawableState(); // The view cleared focus and invoked the callbacks, so now is the // time to give focus to the the first focusable from the top to // ensure that the gain focus is announced after clear focus. getRootView().requestFocus(FOCUS_FORWARD); } } Loading
core/java/android/view/ViewGroup.java +11 −8 Original line number Diff line number Diff line Loading @@ -675,11 +675,14 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager */ @Override public void clearFocus() { if (DBG) { System.out.println(this + " clearFocus()"); } if (mFocused == null) { super.clearFocus(); // clear any child focus if it exists if (mFocused != null) { } else { mFocused.clearFocus(); mFocused = null; } } Loading @@ -691,13 +694,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (DBG) { System.out.println(this + " unFocus()"); } if (mFocused == null) { super.unFocus(); if (mFocused != null) { } else { mFocused.unFocus(); } mFocused = null; } } /** * Returns the focused child of this view, if any. The child may have focus Loading
core/java/android/view/ViewRootImpl.java +19 −16 Original line number Diff line number Diff line Loading @@ -174,6 +174,7 @@ 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; Loading Loading @@ -2272,32 +2273,33 @@ public final class ViewRootImpl extends Handler implements ViewParent, public void requestChildFocus(View child, View focused) { checkThread(); if (mFocusedView != focused) { mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mFocusedView, focused); scheduleTraversals(); if (DEBUG_INPUT_RESIZE) { Log.v(TAG, "Request child focus: focus now " + focused); } 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(); 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); 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); } mFocusedView = mRealFocusedView = null; } public void focusableViewAvailable(View v) { checkThread(); Loading Loading @@ -2770,6 +2772,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, mView.unFocus(); mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null); mFocusedView = null; mOldFocusedView = null; return true; } } Loading
core/tests/coretests/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ LOCAL_SRC_FILES := \ $(call all-java-files-under, EnabledTestApp/src) LOCAL_DX_FLAGS := --core-library LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava littlemock LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_PACKAGE_NAME := FrameworksCoreTests Loading
core/tests/coretests/src/android/widget/focus/RequestFocus.java +0 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ import com.android.frameworks.coretests.R; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.widget.LinearLayout; import android.widget.Button; import android.view.View; /** * Exercises cases where elements of the UI are requestFocus()ed. Loading