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

Commit 640c3b4f authored by Adam He's avatar Adam He Committed by Android (Google) Code Review
Browse files

Merge "Hide autofill highlight if filling only the focused field." into rvc-dev

parents 2f70bc55 5061db8a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4970,7 +4970,7 @@ package android.view {
    method public void resetRtlProperties();
    method public boolean restoreFocusInCluster(int);
    method public boolean restoreFocusNotInCluster();
    method public void setAutofilled(boolean);
    method public void setAutofilled(boolean, boolean);
    method public final void setFocusedInCluster();
    method public void setIsRootNamespace(boolean);
    method public final void setShowingLayoutBounds(boolean);
+2 −1
Original line number Diff line number Diff line
@@ -488,7 +488,8 @@ public abstract class AugmentedAutofillService extends Service {
                ids.add(pair.first);
                values.add(pair.second);
            }
            mClient.autofill(mSessionId, ids, values);
            final boolean hideHighlight = size == 1 && ids.get(0).equals(mFocusedId);
            mClient.autofill(mSessionId, ids, values, hideHighlight);
        }

        public void setFillWindow(@NonNull FillWindow fillWindow) {
+29 −5
Original line number Diff line number Diff line
@@ -3318,7 +3318,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Flag indicating that the view is autofilled
     *
     * @see #isAutofilled()
     * @see #setAutofilled(boolean)
     * @see #setAutofilled(boolean, boolean)
     */
    private static final int PFLAG3_IS_AUTOFILLED = 0x10000;
@@ -3428,6 +3428,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *                         1        PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE
     *                         11       PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK
     *                        1         PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS
     *                       1          PFLAG4_AUTOFILL_HIDE_HIGHLIGHT
     * |-------|-------|-------|-------|
     */
@@ -3470,6 +3471,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    static final int PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS = 0x000000100;
    /**
     * Flag indicating the field should not have yellow highlight when autofilled.
     */
    private static final int PFLAG4_AUTOFILL_HIDE_HIGHLIGHT = 0x100;
    /* End of masks for mPrivateFlags4 */
    /** @hide */
@@ -9169,6 +9175,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return (mPrivateFlags3 & PFLAG3_IS_AUTOFILLED) != 0;
    }
    /**
     * @hide
     */
    public boolean hideAutofillHighlight() {
        return (mPrivateFlags4 & PFLAG4_AUTOFILL_HIDE_HIGHLIGHT) != 0;
    }
    /**
     * Gets the {@link View}'s current autofill value.
     *
@@ -11750,7 +11763,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    @TestApi
    public void setAutofilled(boolean isAutofilled) {
    public void setAutofilled(boolean isAutofilled, boolean hideHighlight) {
        boolean wasChanged = isAutofilled != isAutofilled();
        if (wasChanged) {
@@ -11760,6 +11773,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                mPrivateFlags3 &= ~PFLAG3_IS_AUTOFILLED;
            }
            if (hideHighlight) {
                mPrivateFlags4 |= PFLAG4_AUTOFILL_HIDE_HIGHLIGHT;
            } else {
                mPrivateFlags4 &= ~PFLAG4_AUTOFILL_HIDE_HIGHLIGHT;
            }
            invalidate();
        }
    }
@@ -20578,6 +20597,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            state.mStartActivityRequestWhoSaved = mStartActivityRequestWho;
            state.mIsAutofilled = isAutofilled();
            state.mHideHighlight = hideAutofillHighlight();
            state.mAutofillViewId = mAutofillViewId;
            return state;
        }
@@ -20654,7 +20674,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                mStartActivityRequestWho = baseState.mStartActivityRequestWhoSaved;
            }
            if ((baseState.mSavedData & BaseSavedState.IS_AUTOFILLED) != 0) {
                setAutofilled(baseState.mIsAutofilled);
                setAutofilled(baseState.mIsAutofilled, baseState.mHideHighlight);
            }
            if ((baseState.mSavedData & BaseSavedState.AUTOFILL_ID) != 0) {
                // It can happen that views have the same view id and the restoration path will not
@@ -24087,12 +24107,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * Draw {@link View#isAutofilled()} highlight over view if the view is autofilled.
     * Draw {@link View#isAutofilled()} highlight over view if the view is autofilled, unless
     * {@link #PFLAG4_AUTOFILL_HIDE_HIGHLIGHT} is enabled.
     *
     * @param canvas The canvas to draw on
     */
    private void drawAutofilledHighlight(@NonNull Canvas canvas) {
        if (isAutofilled()) {
        if (isAutofilled() && !hideAutofillHighlight()) {
            Drawable autofilledHighlight = getAutofilledDrawable();
            if (autofilledHighlight != null) {
@@ -28535,6 +28556,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        int mSavedData;
        String mStartActivityRequestWhoSaved;
        boolean mIsAutofilled;
        boolean mHideHighlight;
        int mAutofillViewId;
        /**
@@ -28558,6 +28580,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            mSavedData = source.readInt();
            mStartActivityRequestWhoSaved = source.readString();
            mIsAutofilled = source.readBoolean();
            mHideHighlight = source.readBoolean();
            mAutofillViewId = source.readInt();
        }
@@ -28577,6 +28600,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            out.writeInt(mSavedData);
            out.writeString(mStartActivityRequestWhoSaved);
            out.writeBoolean(mIsAutofilled);
            out.writeBoolean(mHideHighlight);
            out.writeInt(mAutofillViewId);
        }
+16 −12
Original line number Diff line number Diff line
@@ -1236,7 +1236,7 @@ public final class AutofillManager {
            // If the session is gone some fields might still be highlighted, hence we have to
            // remove the isAutofilled property even if no sessions are active.
            if (mLastAutofilledData == null) {
                view.setAutofilled(false);
                view.setAutofilled(false, false);
            } else {
                id = view.getAutofillId();
                if (mLastAutofilledData.containsKey(id)) {
@@ -1244,13 +1244,13 @@ public final class AutofillManager {
                    valueWasRead = true;

                    if (Objects.equals(mLastAutofilledData.get(id), value)) {
                        view.setAutofilled(true);
                        view.setAutofilled(true, false);
                    } else {
                        view.setAutofilled(false);
                        view.setAutofilled(false, false);
                        mLastAutofilledData.remove(id);
                    }
                } else {
                    view.setAutofilled(false);
                    view.setAutofilled(false, false);
                }
            }

@@ -2166,7 +2166,8 @@ public final class AutofillManager {
     * @param view The view that is to be autofilled
     * @param targetValue The value we want to fill into view
     */
    private void setAutofilledIfValuesIs(@NonNull View view, @Nullable AutofillValue targetValue) {
    private void setAutofilledIfValuesIs(@NonNull View view, @Nullable AutofillValue targetValue,
            boolean hideHighlight) {
        AutofillValue currentValue = view.getAutofillValue();
        if (Objects.equals(currentValue, targetValue)) {
            synchronized (mLock) {
@@ -2175,11 +2176,12 @@ public final class AutofillManager {
                }
                mLastAutofilledData.put(view.getAutofillId(), targetValue);
            }
            view.setAutofilled(true);
            view.setAutofilled(true, hideHighlight);
        }
    }

    private void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values) {
    private void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values,
            boolean hideHighlight) {
        synchronized (mLock) {
            if (sessionId != mSessionId) {
                return;
@@ -2238,7 +2240,7 @@ public final class AutofillManager {
                    // synchronously.
                    // If autofill happens async, the view is set to autofilled in
                    // notifyValueChanged.
                    setAutofilledIfValuesIs(view, value);
                    setAutofilledIfValuesIs(view, value, hideHighlight);

                    numApplied++;
                }
@@ -3256,10 +3258,11 @@ public final class AutofillManager {
        }

        @Override
        public void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values) {
        public void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values,
                boolean hideHighlight) {
            final AutofillManager afm = mAfm.get();
            if (afm != null) {
                afm.post(() -> afm.autofill(sessionId, ids, values));
                afm.post(() -> afm.autofill(sessionId, ids, values, hideHighlight));
            }
        }

@@ -3397,10 +3400,11 @@ public final class AutofillManager {
        }

        @Override
        public void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values) {
        public void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values,
                boolean hideHighlight) {
            final AutofillManager afm = mAfm.get();
            if (afm != null) {
                afm.post(() -> afm.autofill(sessionId, ids, values));
                afm.post(() -> afm.autofill(sessionId, ids, values, hideHighlight));
            }
        }

+2 −1
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ interface IAugmentedAutofillManagerClient {
    /**
     * Autofills the activity with the contents of the values.
     */
    void autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values);
    void autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values,
            boolean hideHighlight);

    /**
      * Requests showing the fill UI.
Loading