Merge "Remove preferKeepClearAreaForFocusDelay, turn it into a flag" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-20 14:48:45 +00:00
committed by Android (Google) Code Review
5 changed files with 18 additions and 44 deletions

View File

@@ -2923,7 +2923,7 @@ package android.view {
method public static int getHoverTooltipHideTimeout(); method public static int getHoverTooltipHideTimeout();
method public static int getHoverTooltipShowTimeout(); method public static int getHoverTooltipShowTimeout();
method public static int getLongPressTooltipHideTimeout(); method public static int getLongPressTooltipHideTimeout();
method public int getPreferKeepClearForFocusDelay(); method public boolean isPreferKeepClearForFocusEnabled();
} }
public class ViewDebug { public class ViewDebug {

View File

@@ -4781,9 +4781,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@UnsupportedAppUsage @UnsupportedAppUsage
ListenerInfo mListenerInfo; ListenerInfo mListenerInfo;
private boolean mPreferKeepClearForFocus;
private Runnable mMarkPreferKeepClearForFocus;
private static class TooltipInfo { private static class TooltipInfo {
/** /**
* Text to be displayed in a tooltip popup. * Text to be displayed in a tooltip popup.
@@ -11962,8 +11959,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@NonNull @NonNull
List<Rect> collectPreferKeepClearRects() { List<Rect> collectPreferKeepClearRects() {
ListenerInfo info = mListenerInfo; ListenerInfo info = mListenerInfo;
boolean keepBoundsClear = boolean keepClearForFocus = isFocused()
(info != null && info.mPreferKeepClear) || mPreferKeepClearForFocus; && ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled();
boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus;
boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null;
if (!keepBoundsClear && !hasCustomKeepClearRects) { if (!keepBoundsClear && !hasCustomKeepClearRects) {
@@ -11985,31 +11983,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
private void updatePreferKeepClearForFocus() { private void updatePreferKeepClearForFocus() {
if (mMarkPreferKeepClearForFocus != null) { if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) {
removeCallbacks(mMarkPreferKeepClearForFocus); updatePositionUpdateListener();
mMarkPreferKeepClearForFocus = null; post(this::updateKeepClearRects);
} }
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;
} }
/** /**
@@ -13754,7 +13731,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
invalidate(); invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
updatePreferKeepClearForFocus();
return true; return true;
} }
return false; return false;
@@ -21154,7 +21130,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
removePerformClickCallback(); removePerformClickCallback();
clearAccessibilityThrottles(); clearAccessibilityThrottles();
stopNestedScroll(); stopNestedScroll();
cancelMarkPreferKeepClearForFocus();
// Anything that started animating right before detach should already // Anything that started animating right before detach should already
// be in its final state when re-attached. // be in its final state when re-attached.

View File

@@ -347,7 +347,7 @@ public class ViewConfiguration {
private final long mScreenshotChordKeyTimeout; private final long mScreenshotChordKeyTimeout;
private final int mSmartSelectionInitializedTimeout; private final int mSmartSelectionInitializedTimeout;
private final int mSmartSelectionInitializingTimeout; private final int mSmartSelectionInitializingTimeout;
private final int mPreferKeepClearForFocusDelay; private final boolean mPreferKeepClearForFocusEnabled;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915)
private boolean sHasPermanentMenuKey; private boolean sHasPermanentMenuKey;
@@ -393,7 +393,7 @@ public class ViewConfiguration {
mMinScalingSpan = 0; mMinScalingSpan = 0;
mSmartSelectionInitializedTimeout = SMART_SELECTION_INITIALIZED_TIMEOUT_IN_MILLISECOND; mSmartSelectionInitializedTimeout = SMART_SELECTION_INITIALIZED_TIMEOUT_IN_MILLISECOND;
mSmartSelectionInitializingTimeout = SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND; mSmartSelectionInitializingTimeout = SMART_SELECTION_INITIALIZING_TIMEOUT_IN_MILLISECOND;
mPreferKeepClearForFocusDelay = -1; mPreferKeepClearForFocusEnabled = false;
} }
/** /**
@@ -508,8 +508,8 @@ public class ViewConfiguration {
com.android.internal.R.integer.config_smartSelectionInitializedTimeoutMillis); com.android.internal.R.integer.config_smartSelectionInitializedTimeoutMillis);
mSmartSelectionInitializingTimeout = res.getInteger( mSmartSelectionInitializingTimeout = res.getInteger(
com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis); com.android.internal.R.integer.config_smartSelectionInitializingTimeoutMillis);
mPreferKeepClearForFocusDelay = res.getInteger( mPreferKeepClearForFocusEnabled = res.getBoolean(
com.android.internal.R.integer.config_preferKeepClearForFocusDelayMillis); com.android.internal.R.bool.config_preferKeepClearForFocus);
} }
/** /**
@@ -1100,13 +1100,13 @@ public class ViewConfiguration {
} }
/** /**
* @return The delay in milliseconds before focused Views set themselves as preferred to keep * @return {@code true} if Views should set themselves as preferred to keep clear when focused,
* clear, or -1 if Views should not set themselves as preferred to keep clear. * {@code false} otherwise.
* @hide * @hide
*/ */
@TestApi @TestApi
public int getPreferKeepClearForFocusDelay() { public boolean isPreferKeepClearForFocusEnabled() {
return mPreferKeepClearForFocusDelay; return mPreferKeepClearForFocusEnabled;
} }
/** /**

View File

@@ -5163,9 +5163,8 @@
when TextClassifier has not been initialized. --> when TextClassifier has not been initialized. -->
<integer name="config_smartSelectionInitializingTimeoutMillis">500</integer> <integer name="config_smartSelectionInitializingTimeoutMillis">500</integer>
<!-- The delay in milliseconds before focused Views set themselves as preferred to keep clear. <!-- If true, Views will declare they prefer to be kept clear from overlays when focused. -->
Set to -1 if Views should not set themselves as preferred to keep clear. --> <bool name="config_preferKeepClearForFocus">false</bool>
<integer name="config_preferKeepClearForFocusDelayMillis">-1</integer>
<!-- Indicates that default fitness tracker app needs to request sensor and location permissions. --> <!-- Indicates that default fitness tracker app needs to request sensor and location permissions. -->
<bool name="config_trackerAppNeedsPermissions">false</bool> <bool name="config_trackerAppNeedsPermissions">false</bool>

View File

@@ -479,7 +479,7 @@
<java-symbol type="bool" name="config_useAssistantVolume" /> <java-symbol type="bool" name="config_useAssistantVolume" />
<java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" /> <java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" />
<java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" /> <java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" />
<java-symbol type="integer" name="config_preferKeepClearForFocusDelayMillis" /> <java-symbol type="bool" name="config_preferKeepClearForFocus" />
<java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/> <java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/>
<java-symbol type="integer" name="config_defaultAnalogClockSecondsHandFps"/> <java-symbol type="integer" name="config_defaultAnalogClockSecondsHandFps"/>