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

Commit a6a0d130 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "New Autofill API: notifyViewClicked()"

parents 75d6bedf 67e6209f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -49803,6 +49803,8 @@ package android.view.autofill {
    method public boolean isFieldClassificationEnabled();
    method public void notifyValueChanged(android.view.View);
    method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
    method public void notifyViewClicked(android.view.View);
    method public void notifyViewClicked(android.view.View, int);
    method public void notifyViewEntered(android.view.View);
    method public void notifyViewEntered(android.view.View, int, android.graphics.Rect);
    method public void notifyViewExited(android.view.View);
+1 −0
Original line number Diff line number Diff line
@@ -1061,6 +1061,7 @@ package android.view.autofill {

  public final class AutofillId implements android.os.Parcelable {
    ctor public AutofillId(int);
    ctor public AutofillId(android.view.autofill.AutofillId, int);
  }

}
+3 −0
Original line number Diff line number Diff line
@@ -8010,6 +8010,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *   <li>Call {@link
     *    android.view.autofill.AutofillManager#notifyViewVisibilityChanged(View, int, boolean)}
     *       when the visibility of a virtual child changed.
     *   <li>Call
     *    {@link android.view.autofill.AutofillManager#notifyViewClicked(View, int)} when a virtual
     *       child is clicked.
     *   <li>Call {@link AutofillManager#commit()} when the autofill context of the view structure
     *       changed and the current context should be committed (for example, when the user tapped
     *       a {@code SUBMIT} button in an HTML page).
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public final class AutofillId implements Parcelable {
    }

    /** @hide */
    @TestApi
    public AutofillId(AutofillId parent, int virtualChildId) {
        mVirtual = true;
        mViewId = parent.mViewId;
+23 −6
Original line number Diff line number Diff line
@@ -71,9 +71,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;

import sun.misc.Cleaner;

//TODO: use java.lang.ref.Cleaner once Android supports Java 9
import sun.misc.Cleaner;

/**
 * The {@link AutofillManager} provides ways for apps and custom views to integrate with the
@@ -1065,16 +1064,34 @@ public final class AutofillManager {
    }

    /**
     * Called when a {@link View} is clicked. Currently only used by views that should trigger save.
     * Called to indicate a {@link View} is clicked.
     *
     * @hide
     * @param view view that has been clicked.
     */
    public void notifyViewClicked(@NonNull View view) {
        notifyViewClicked(view.getAutofillId());
    }

    /**
     * Called to indicate a virtual view has been clicked.
     *
     * @param view the virtual view parent.
     * @param virtualId id identifying the virtual child inside the parent view.
     */
    public void notifyViewClicked(View view) {
        final AutofillId id = view.getAutofillId();
    public void notifyViewClicked(@NonNull View view, int virtualId) {
        notifyViewClicked(getAutofillId(view, virtualId));
    }

    private void notifyViewClicked(AutofillId id) {
        if (!hasAutofillFeature()) {
            return;
        }
        if (sVerbose) Log.v(TAG, "notifyViewClicked(): id=" + id + ", trigger=" + mSaveTriggerId);

        synchronized (mLock) {
            if (!mEnabled || !isActiveLocked()) {
                return;
            }
            if (mSaveTriggerId != null && mSaveTriggerId.equals(id)) {
                if (sDebug) Log.d(TAG, "triggering commit by click of " + id);
                commitLocked();