Loading core/java/android/view/View.java +11 −3 Original line number Diff line number Diff line Loading @@ -4210,6 +4210,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private static boolean sCanFocusZeroSized; /** * Always assign focus if a focusable View is available. */ private static boolean sAlwaysAssignFocus; private String mTransitionName; static class TintInfo { Loading Loading @@ -4827,6 +4832,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sCanFocusZeroSized = targetSdkVersion < Build.VERSION_CODES.P; sAlwaysAssignFocus = targetSdkVersion < Build.VERSION_CODES.P; sCompatibilityDone = true; } } Loading Loading @@ -7017,8 +7024,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Called when this view wants to give up focus. If focus is cleared * {@link #onFocusChanged(boolean, int, android.graphics.Rect)} is called. * <p> * <strong>Note:</strong> When a View clears focus the framework is trying * to give focus to the first focusable View from the top. Hence, if this * <strong>Note:</strong> When not in touch-mode, the framework will try to give focus * to the first focusable View from the top after focus is cleared. Hence, if this * View is the first from the top that can take focus, then all callbacks * related to clearing focus will be invoked after which the framework will * give focus to this view. Loading @@ -7029,7 +7036,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, System.out.println(this + " clearFocus()"); } clearFocusInternal(null, true, true); final boolean refocus = sAlwaysAssignFocus || !isInTouchMode(); clearFocusInternal(null, true, refocus); } /** core/java/android/view/ViewRootImpl.java +4 −7 Original line number Diff line number Diff line Loading @@ -530,7 +530,7 @@ public final class ViewRootImpl implements ViewParent, mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE); if (!sCompatibilityDone) { sAlwaysAssignFocus = true; sAlwaysAssignFocus = mTargetSdkVersion < Build.VERSION_CODES.P; sCompatibilityDone = true; } Loading Loading @@ -2337,7 +2337,7 @@ public final class ViewRootImpl implements ViewParent, } if (mFirst) { if (sAlwaysAssignFocus) { if (sAlwaysAssignFocus || !isInTouchMode()) { // handle first focus request if (DEBUG_INPUT_RESIZE) { Log.v(mTag, "First: mView.hasFocus()=" + mView.hasFocus()); Loading Loading @@ -3608,7 +3608,7 @@ public final class ViewRootImpl implements ViewParent, checkThread(); if (mView != null) { if (!mView.hasFocus()) { if (sAlwaysAssignFocus) { if (sAlwaysAssignFocus || !isInTouchMode()) { v.requestFocus(); } } else { Loading Loading @@ -4211,10 +4211,7 @@ public final class ViewRootImpl implements ViewParent, // 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 mView.restoreDefaultFocus(); } return false; } Loading Loading
core/java/android/view/View.java +11 −3 Original line number Diff line number Diff line Loading @@ -4210,6 +4210,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private static boolean sCanFocusZeroSized; /** * Always assign focus if a focusable View is available. */ private static boolean sAlwaysAssignFocus; private String mTransitionName; static class TintInfo { Loading Loading @@ -4827,6 +4832,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sCanFocusZeroSized = targetSdkVersion < Build.VERSION_CODES.P; sAlwaysAssignFocus = targetSdkVersion < Build.VERSION_CODES.P; sCompatibilityDone = true; } } Loading Loading @@ -7017,8 +7024,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Called when this view wants to give up focus. If focus is cleared * {@link #onFocusChanged(boolean, int, android.graphics.Rect)} is called. * <p> * <strong>Note:</strong> When a View clears focus the framework is trying * to give focus to the first focusable View from the top. Hence, if this * <strong>Note:</strong> When not in touch-mode, the framework will try to give focus * to the first focusable View from the top after focus is cleared. Hence, if this * View is the first from the top that can take focus, then all callbacks * related to clearing focus will be invoked after which the framework will * give focus to this view. Loading @@ -7029,7 +7036,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, System.out.println(this + " clearFocus()"); } clearFocusInternal(null, true, true); final boolean refocus = sAlwaysAssignFocus || !isInTouchMode(); clearFocusInternal(null, true, refocus); } /**
core/java/android/view/ViewRootImpl.java +4 −7 Original line number Diff line number Diff line Loading @@ -530,7 +530,7 @@ public final class ViewRootImpl implements ViewParent, mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE); if (!sCompatibilityDone) { sAlwaysAssignFocus = true; sAlwaysAssignFocus = mTargetSdkVersion < Build.VERSION_CODES.P; sCompatibilityDone = true; } Loading Loading @@ -2337,7 +2337,7 @@ public final class ViewRootImpl implements ViewParent, } if (mFirst) { if (sAlwaysAssignFocus) { if (sAlwaysAssignFocus || !isInTouchMode()) { // handle first focus request if (DEBUG_INPUT_RESIZE) { Log.v(mTag, "First: mView.hasFocus()=" + mView.hasFocus()); Loading Loading @@ -3608,7 +3608,7 @@ public final class ViewRootImpl implements ViewParent, checkThread(); if (mView != null) { if (!mView.hasFocus()) { if (sAlwaysAssignFocus) { if (sAlwaysAssignFocus || !isInTouchMode()) { v.requestFocus(); } } else { Loading Loading @@ -4211,10 +4211,7 @@ public final class ViewRootImpl implements ViewParent, // 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 mView.restoreDefaultFocus(); } return false; } Loading