From afc744fd2fb082b2b24d39b7efad815434898a9b Mon Sep 17 00:00:00 2001 From: Adam He Date: Thu, 12 Mar 2020 16:20:16 -0700 Subject: [PATCH] Removed inlinePresentation from Dataset ctor and added setInlinePresentation. Fixes: 148380267 Test: atest android.autofillservice.cts.DatasetTest Change-Id: I32f5d4eab3b9d7d82020aaaccf734694303ffe0b --- api/current.txt | 3 +- api/system-current.txt | 2 +- api/test-current.txt | 2 +- .../android/service/autofill/Dataset.java | 36 +++++++++---------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/api/current.txt b/api/current.txt index d944d24d2993e..f75027a06fc83 100644 --- a/api/current.txt +++ b/api/current.txt @@ -43012,12 +43012,12 @@ package android.service.autofill { } public static final class Dataset.Builder { - ctor public Dataset.Builder(@NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation); ctor public Dataset.Builder(@NonNull android.widget.RemoteViews); ctor public Dataset.Builder(); method @NonNull public android.service.autofill.Dataset build(); method @NonNull public android.service.autofill.Dataset.Builder setAuthentication(@Nullable android.content.IntentSender); method @NonNull public android.service.autofill.Dataset.Builder setId(@Nullable String); + method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation); method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue); method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews); method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern); @@ -82233,3 +82233,4 @@ package org.xmlpull.v1.sax2 { } } + diff --git a/api/system-current.txt b/api/system-current.txt index 88aa2a7b1e358..40ba16f2c08de 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9808,7 +9808,7 @@ package android.service.autofill { public static final class Dataset.Builder { ctor public Dataset.Builder(@NonNull android.service.autofill.InlinePresentation); - method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation); + method @NonNull public android.service.autofill.Dataset.Builder setFieldInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation); } public abstract class InlineSuggestionRenderService extends android.app.Service { diff --git a/api/test-current.txt b/api/test-current.txt index 4f4c82b43e706..79bedc44ea62a 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3134,7 +3134,7 @@ package android.service.autofill { public static final class Dataset.Builder { ctor public Dataset.Builder(@NonNull android.service.autofill.InlinePresentation); - method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation); + method @NonNull public android.service.autofill.Dataset.Builder setFieldInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation); } public final class DateTransformation extends android.service.autofill.InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation { diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java index 886b433d4ade3..08aa534be1527 100644 --- a/core/java/android/service/autofill/Dataset.java +++ b/core/java/android/service/autofill/Dataset.java @@ -228,22 +228,6 @@ public final class Dataset implements Parcelable { private boolean mDestroyed; @Nullable private String mId; - /** - * Creates a new builder. - * - * @param presentation The presentation used to visualize this dataset. - * @param inlinePresentation The {@link InlinePresentation} used to visualize this dataset - * as inline suggestions. If the dataset supports inline suggestions, - * this should not be null. - */ - public Builder(@NonNull RemoteViews presentation, - @NonNull InlinePresentation inlinePresentation) { - Preconditions.checkNotNull(presentation, "presentation must be non-null"); - Preconditions.checkNotNull(inlinePresentation, "inlinePresentation must be non-null"); - mPresentation = presentation; - mInlinePresentation = inlinePresentation; - } - /** * Creates a new builder. * @@ -281,6 +265,22 @@ public final class Dataset implements Parcelable { public Builder() { } + /** + * Sets the {@link InlinePresentation} used to visualize this dataset as inline suggestions. + * If the dataset supports inline suggestions this should not be null. + * + * @throws IllegalStateException if {@link #build()} was already called. + * + * @return this builder. + */ + public @NonNull Builder setInlinePresentation( + @NonNull InlinePresentation inlinePresentation) { + throwIfDestroyed(); + Preconditions.checkNotNull(inlinePresentation, "inlinePresentation must be non-null"); + mInlinePresentation = inlinePresentation; + return this; + } + /** * Triggers a custom UI before before autofilling the screen with the contents of this * dataset. @@ -600,7 +600,7 @@ public final class Dataset implements Parcelable { */ @SystemApi @TestApi - public @NonNull Builder setInlinePresentation(@NonNull AutofillId id, + public @NonNull Builder setFieldInlinePresentation(@NonNull AutofillId id, @Nullable AutofillValue value, @Nullable Pattern filter, @NonNull InlinePresentation inlinePresentation) { throwIfDestroyed(); @@ -700,7 +700,7 @@ public final class Dataset implements Parcelable { final Builder builder = presentation != null ? inlinePresentation == null ? new Builder(presentation) - : new Builder(presentation, inlinePresentation) + : new Builder(presentation).setInlinePresentation(inlinePresentation) : inlinePresentation == null ? new Builder() : new Builder(inlinePresentation);