Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8762faf authored by Robert Horvath's avatar Robert Horvath Committed by Automerger Merge Worker
Browse files

Merge "Mark focused Views as keep clear areas" into tm-dev am: 1b0ffb5b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16932089

Change-Id: If8eb89111f47145e9ea4d25cce4f7068230f0f65
parents f6c68897 1b0ffb5b
Loading
Loading
Loading
Loading
+46 −11
Original line number Diff line number Diff line
@@ -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.
@@ -8171,6 +8174,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        notifyEnterOrExitForAutoFillIfNeeded(gainFocus);
        updatePreferKeepClearForFocus();
    }
    /**
@@ -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;
    }
    /**
@@ -13656,6 +13687,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            invalidate();
            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
            updatePreferKeepClearForFocus();
            return true;
        }
        return false;
@@ -13735,6 +13767,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    sendAccessibilityEventUnchecked(event);
                }
            }
            updatePreferKeepClearForFocus();
        }
    }
@@ -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.
+13 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
    }

    /**
@@ -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);
    }

    /**
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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>

+1 −0
Original line number Diff line number Diff line
@@ -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"/>