Merge "Add API for creating AutofillId with virtual child id"

This commit is contained in:
TYM Tsai
2022-12-20 23:51:42 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 0 deletions

View File

@@ -53807,6 +53807,7 @@ package android.view.animation {
package android.view.autofill {
public final class AutofillId implements android.os.Parcelable {
method @NonNull public static android.view.autofill.AutofillId create(@NonNull android.view.View, int);
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.view.autofill.AutofillId> CREATOR;

View File

@@ -22,6 +22,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.View;
import java.util.Objects;
/**
* A unique identifier for an autofill node inside an {@link android.app.Activity}.
*/
@@ -76,6 +78,23 @@ public final class AutofillId implements Parcelable {
@NonNull
public static final AutofillId NO_AUTOFILL_ID = new AutofillId(0);
/**
* Creates an {@link AutofillId} with the virtual id.
*
* This method is used by a {@link View} that contains the virtual view hierarchy. Use this
* method to create the {@link AutofillId} for each virtual view.
*
* @param host the view hosting the virtual view hierarchy which is used to show autofill
* suggestions.
* @param virtualId id identifying the virtual view inside the host view.
* @return an {@link AutofillId} for the virtual view
*/
@NonNull
public static AutofillId create(@NonNull View host, int virtualId) {
Objects.requireNonNull(host);
return new AutofillId(host.getAutofillId(), virtualId);
}
/** @hide */
@NonNull
@TestApi