Loading core/java/android/view/View.java +46 −11 Original line number Diff line number Diff line Loading @@ -4769,6 +4769,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @UnsupportedAppUsage ListenerInfo mListenerInfo; private boolean mPreferKeepClearForFocus; private Runnable mMarkPreferKeepClearForFocus; private static class TooltipInfo { /** * Text to be displayed in a tooltip popup. Loading Loading @@ -8171,6 +8174,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } notifyEnterOrExitForAutoFillIfNeeded(gainFocus); updatePreferKeepClearForFocus(); } /** Loading Loading @@ -11934,19 +11938,46 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @NonNull List<Rect> collectPreferKeepClearRects() { final ListenerInfo info = mListenerInfo; if (info != null) { final List<Rect> list = new ArrayList(); if (info.mPreferKeepClear) { ListenerInfo info = mListenerInfo; final List<Rect> list = new ArrayList<>(); if ((info != null && info.mPreferKeepClear) || mPreferKeepClearForFocus) { list.add(new Rect(0, 0, getWidth(), getHeight())); } if (info.mKeepClearRects != null) { if (info != null && info.mKeepClearRects != null) { list.addAll(info.mKeepClearRects); } return list; } return Collections.emptyList(); private void updatePreferKeepClearForFocus() { if (mMarkPreferKeepClearForFocus != null) { removeCallbacks(mMarkPreferKeepClearForFocus); mMarkPreferKeepClearForFocus = null; } final ViewConfiguration configuration = ViewConfiguration.get(mContext); final int delay = configuration.getPreferKeepClearForFocusDelay(); if (delay >= 0) { mMarkPreferKeepClearForFocus = () -> { mPreferKeepClearForFocus = isFocused(); mMarkPreferKeepClearForFocus = null; updatePositionUpdateListener(); post(this::updateKeepClearRects); }; postDelayed(mMarkPreferKeepClearForFocus, delay); } } private void cancelMarkPreferKeepClearForFocus() { if (mMarkPreferKeepClearForFocus != null) { removeCallbacks(mMarkPreferKeepClearForFocus); mMarkPreferKeepClearForFocus = null; } mPreferKeepClearForFocus = false; } /** Loading Loading @@ -13656,6 +13687,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } invalidate(); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); updatePreferKeepClearForFocus(); return true; } return false; Loading Loading @@ -13735,6 +13767,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sendAccessibilityEventUnchecked(event); } } updatePreferKeepClearForFocus(); } } Loading Loading @@ -20987,6 +21021,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, removePerformClickCallback(); clearAccessibilityThrottles(); stopNestedScroll(); cancelMarkPreferKeepClearForFocus(); // Anything that started animating right before detach should already // be in its final state when re-attached. core/java/android/view/ViewConfiguration.java +13 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,7 @@ public class ViewConfiguration { private final long mScreenshotChordKeyTimeout; private final int mSmartSelectionInitializedTimeout; private final int mSmartSelectionInitializingTimeout; private final int mPreferKeepClearForFocusDelay; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915) private boolean sHasPermanentMenuKey; Loading Loading @@ -392,6 +393,7 @@ public class ViewConfiguration { mMinScalingSpan = 0; mSmartSelectionInitializedTimeout = SMART_SELECTION_INITIALIZED_TIMEOUT_IN_MILLISECOND; mSmartSelectionInitializingTimeout = SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND; mPreferKeepClearForFocusDelay = -1; } /** Loading Loading @@ -506,6 +508,8 @@ public class ViewConfiguration { com.android.internal.R.integer.config_smartSelectionInitializedTimeoutMillis); mSmartSelectionInitializingTimeout = res.getInteger( com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis); mPreferKeepClearForFocusDelay = res.getInteger( com.android.internal.R.integer.config_preferKeepClearForFocusDelayMillis); } /** Loading Loading @@ -1095,6 +1099,15 @@ public class ViewConfiguration { return mSmartSelectionInitializingTimeout; } /** * @return The delay in milliseconds before focused Views set themselves as preferred to keep * clear, or -1 if Views should not set themselves as preferred to keep clear. * @hide */ public int getPreferKeepClearForFocusDelay() { return mPreferKeepClearForFocusDelay; } /** * @return the duration in milliseconds before an end of a long press causes a tooltip to be * hidden Loading core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -5192,6 +5192,10 @@ when TextClassifier has not been initialized. --> <integer name="config_smartSelectionInitializingTimeoutMillis">500</integer> <!-- The delay in milliseconds before focused Views set themselves as preferred to keep clear. Set to -1 if Views should not set themselves as preferred to keep clear. --> <integer name="config_preferKeepClearForFocusDelayMillis">-1</integer> <!-- Indicates that default fitness tracker app needs to request sensor and location permissions. --> <bool name="config_trackerAppNeedsPermissions">false</bool> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -493,6 +493,7 @@ <java-symbol type="string" name="config_bandwidthEstimateSource" /> <java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" /> <java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" /> <java-symbol type="integer" name="config_preferKeepClearForFocusDelayMillis" /> <java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/> <java-symbol type="integer" name="config_defaultAnalogClockSecondsHandFps"/> Loading Loading
core/java/android/view/View.java +46 −11 Original line number Diff line number Diff line Loading @@ -4769,6 +4769,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @UnsupportedAppUsage ListenerInfo mListenerInfo; private boolean mPreferKeepClearForFocus; private Runnable mMarkPreferKeepClearForFocus; private static class TooltipInfo { /** * Text to be displayed in a tooltip popup. Loading Loading @@ -8171,6 +8174,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } notifyEnterOrExitForAutoFillIfNeeded(gainFocus); updatePreferKeepClearForFocus(); } /** Loading Loading @@ -11934,19 +11938,46 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @NonNull List<Rect> collectPreferKeepClearRects() { final ListenerInfo info = mListenerInfo; if (info != null) { final List<Rect> list = new ArrayList(); if (info.mPreferKeepClear) { ListenerInfo info = mListenerInfo; final List<Rect> list = new ArrayList<>(); if ((info != null && info.mPreferKeepClear) || mPreferKeepClearForFocus) { list.add(new Rect(0, 0, getWidth(), getHeight())); } if (info.mKeepClearRects != null) { if (info != null && info.mKeepClearRects != null) { list.addAll(info.mKeepClearRects); } return list; } return Collections.emptyList(); private void updatePreferKeepClearForFocus() { if (mMarkPreferKeepClearForFocus != null) { removeCallbacks(mMarkPreferKeepClearForFocus); mMarkPreferKeepClearForFocus = null; } final ViewConfiguration configuration = ViewConfiguration.get(mContext); final int delay = configuration.getPreferKeepClearForFocusDelay(); if (delay >= 0) { mMarkPreferKeepClearForFocus = () -> { mPreferKeepClearForFocus = isFocused(); mMarkPreferKeepClearForFocus = null; updatePositionUpdateListener(); post(this::updateKeepClearRects); }; postDelayed(mMarkPreferKeepClearForFocus, delay); } } private void cancelMarkPreferKeepClearForFocus() { if (mMarkPreferKeepClearForFocus != null) { removeCallbacks(mMarkPreferKeepClearForFocus); mMarkPreferKeepClearForFocus = null; } mPreferKeepClearForFocus = false; } /** Loading Loading @@ -13656,6 +13687,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } invalidate(); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); updatePreferKeepClearForFocus(); return true; } return false; Loading Loading @@ -13735,6 +13767,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sendAccessibilityEventUnchecked(event); } } updatePreferKeepClearForFocus(); } } Loading Loading @@ -20987,6 +21021,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, removePerformClickCallback(); clearAccessibilityThrottles(); stopNestedScroll(); cancelMarkPreferKeepClearForFocus(); // Anything that started animating right before detach should already // be in its final state when re-attached.
core/java/android/view/ViewConfiguration.java +13 −0 Original line number Diff line number Diff line Loading @@ -347,6 +347,7 @@ public class ViewConfiguration { private final long mScreenshotChordKeyTimeout; private final int mSmartSelectionInitializedTimeout; private final int mSmartSelectionInitializingTimeout; private final int mPreferKeepClearForFocusDelay; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915) private boolean sHasPermanentMenuKey; Loading Loading @@ -392,6 +393,7 @@ public class ViewConfiguration { mMinScalingSpan = 0; mSmartSelectionInitializedTimeout = SMART_SELECTION_INITIALIZED_TIMEOUT_IN_MILLISECOND; mSmartSelectionInitializingTimeout = SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND; mPreferKeepClearForFocusDelay = -1; } /** Loading Loading @@ -506,6 +508,8 @@ public class ViewConfiguration { com.android.internal.R.integer.config_smartSelectionInitializedTimeoutMillis); mSmartSelectionInitializingTimeout = res.getInteger( com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis); mPreferKeepClearForFocusDelay = res.getInteger( com.android.internal.R.integer.config_preferKeepClearForFocusDelayMillis); } /** Loading Loading @@ -1095,6 +1099,15 @@ public class ViewConfiguration { return mSmartSelectionInitializingTimeout; } /** * @return The delay in milliseconds before focused Views set themselves as preferred to keep * clear, or -1 if Views should not set themselves as preferred to keep clear. * @hide */ public int getPreferKeepClearForFocusDelay() { return mPreferKeepClearForFocusDelay; } /** * @return the duration in milliseconds before an end of a long press causes a tooltip to be * hidden Loading
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -5192,6 +5192,10 @@ when TextClassifier has not been initialized. --> <integer name="config_smartSelectionInitializingTimeoutMillis">500</integer> <!-- The delay in milliseconds before focused Views set themselves as preferred to keep clear. Set to -1 if Views should not set themselves as preferred to keep clear. --> <integer name="config_preferKeepClearForFocusDelayMillis">-1</integer> <!-- Indicates that default fitness tracker app needs to request sensor and location permissions. --> <bool name="config_trackerAppNeedsPermissions">false</bool> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -493,6 +493,7 @@ <java-symbol type="string" name="config_bandwidthEstimateSource" /> <java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" /> <java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" /> <java-symbol type="integer" name="config_preferKeepClearForFocusDelayMillis" /> <java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/> <java-symbol type="integer" name="config_defaultAnalogClockSecondsHandFps"/> Loading