diff --git a/core/api/current.txt b/core/api/current.txt index 326bb7353f08d..717e352721f52 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -47911,7 +47911,6 @@ package android.view { field public static final int AUTOFILL_TYPE_DATE = 4; // 0x4 field public static final int AUTOFILL_TYPE_LIST = 3; // 0x3 field public static final int AUTOFILL_TYPE_NONE = 0; // 0x0 - field public static final int AUTOFILL_TYPE_RICH_CONTENT = 5; // 0x5 field public static final int AUTOFILL_TYPE_TEXT = 1; // 0x1 field public static final int AUTOFILL_TYPE_TOGGLE = 2; // 0x2 field public static final int DRAG_FLAG_GLOBAL = 256; // 0x100 @@ -50184,17 +50183,14 @@ package android.view.autofill { method public int describeContents(); method public static android.view.autofill.AutofillValue forDate(long); method public static android.view.autofill.AutofillValue forList(int); - method @NonNull public static android.view.autofill.AutofillValue forRichContent(@NonNull android.content.ClipData); method public static android.view.autofill.AutofillValue forText(@Nullable CharSequence); method public static android.view.autofill.AutofillValue forToggle(boolean); method public long getDateValue(); method public int getListValue(); - method @NonNull public android.content.ClipData getRichContentValue(); method @NonNull public CharSequence getTextValue(); method public boolean getToggleValue(); method public boolean isDate(); method public boolean isList(); - method public boolean isRichContent(); method public boolean isText(); method public boolean isToggle(); method public void writeToParcel(android.os.Parcel, int); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1d1c87d069394..d0b3a13621669 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -1274,7 +1274,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, AUTOFILL_TYPE_TOGGLE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_DATE, - AUTOFILL_TYPE_RICH_CONTENT }) @Retention(RetentionPolicy.SOURCE) public @interface AutofillType {} @@ -1338,17 +1337,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public static final int AUTOFILL_TYPE_DATE = 4; - /** - * Autofill type for a field that can accept rich content (text, images, etc). - * - *

{@link AutofillValue} instances for autofilling a {@link View} can be obtained through - * {@link AutofillValue#forRichContent(ClipData)}, and the values passed to - * autofill a {@link View} can be fetched through {@link AutofillValue#getRichContentValue()}. - * - * @see #getAutofillType() - */ - public static final int AUTOFILL_TYPE_RICH_CONTENT = 5; - /** @hide */ @IntDef(prefix = { "IMPORTANT_FOR_AUTOFILL_" }, value = { diff --git a/core/java/android/view/autofill/AutofillValue.java b/core/java/android/view/autofill/AutofillValue.java index e92c30fcbc3b2..f5eef3513e305 100644 --- a/core/java/android/view/autofill/AutofillValue.java +++ b/core/java/android/view/autofill/AutofillValue.java @@ -18,7 +18,6 @@ package android.view.autofill; import static android.view.View.AUTOFILL_TYPE_DATE; import static android.view.View.AUTOFILL_TYPE_LIST; -import static android.view.View.AUTOFILL_TYPE_RICH_CONTENT; import static android.view.View.AUTOFILL_TYPE_TEXT; import static android.view.View.AUTOFILL_TYPE_TOGGLE; import static android.view.autofill.Helper.sDebug; @@ -26,7 +25,6 @@ import static android.view.autofill.Helper.sVerbose; import android.annotation.NonNull; import android.annotation.Nullable; -import android.content.ClipData; import android.os.Looper; import android.os.Parcel; import android.os.Parcelable; @@ -141,28 +139,6 @@ public final class AutofillValue implements Parcelable { return mType == AUTOFILL_TYPE_DATE; } - /** - * Gets the value to autofill a field that accepts rich content (text, images, etc). - * - *

See {@link View#AUTOFILL_TYPE_RICH_CONTENT} for more info.

- * - * @throws IllegalStateException if the value is not a content value - */ - public @NonNull ClipData getRichContentValue() { - Preconditions.checkState(isRichContent(), - "value must be a rich content value, not type=%d", mType); - return (ClipData) mValue; - } - - /** - * Checks if this is a rich content value (represented by {@link ClipData}). - * - *

See {@link View#AUTOFILL_TYPE_RICH_CONTENT} for more info.

- */ - public boolean isRichContent() { - return mType == AUTOFILL_TYPE_RICH_CONTENT; - } - /** * Used to define whether a field is empty so it's not sent to service on save. * @@ -208,10 +184,6 @@ public final class AutofillValue implements Parcelable { .append(", value="); if (isText()) { Helper.appendRedacted(string, (CharSequence) mValue); - } else if (isRichContent()) { - string.append("{"); - getRichContentValue().getDescription().toShortStringTypesOnly(string); - string.append("}"); } else { string.append(mValue); } @@ -244,9 +216,6 @@ public final class AutofillValue implements Parcelable { case AUTOFILL_TYPE_DATE: parcel.writeLong((Long) mValue); break; - case AUTOFILL_TYPE_RICH_CONTENT: - ((ClipData) mValue).writeToParcel(parcel, flags); - break; } } @@ -267,9 +236,6 @@ public final class AutofillValue implements Parcelable { case AUTOFILL_TYPE_DATE: mValue = parcel.readLong(); break; - case AUTOFILL_TYPE_RICH_CONTENT: - mValue = ClipData.CREATOR.createFromParcel(parcel); - break; default: throw new IllegalArgumentException("type=" + mType + " not valid"); } @@ -337,15 +303,4 @@ public final class AutofillValue implements Parcelable { public static AutofillValue forDate(long value) { return new AutofillValue(AUTOFILL_TYPE_DATE, value); } - - /** - * Creates a new {@link AutofillValue} to autofill a {@link View} that accepts rich content - * (text, images, etc). - * - *

See {@link View#AUTOFILL_TYPE_RICH_CONTENT} for more info. - */ - public static @NonNull AutofillValue forRichContent(@NonNull ClipData value) { - Objects.requireNonNull(value.getDescription(), "clip description must not be null"); - return new AutofillValue(AUTOFILL_TYPE_RICH_CONTENT, value); - } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 977a0e89a143d..4edfc5f309b2d 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -11862,16 +11862,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Log.w(LOG_TAG, "cannot autofill non-editable TextView: " + this); return; } - final ClipData clip; - if (value.isRichContent()) { - clip = value.getRichContentValue(); - } else if (value.isText()) { - clip = ClipData.newPlainText("", value.getTextValue()); - } else { + if (!value.isText()) { Log.w(LOG_TAG, "value of type " + value.describeContents() + " cannot be autofilled into " + this); return; } + final ClipData clip = ClipData.newPlainText("", value.getTextValue()); final ContentInfo payload = new ContentInfo.Builder(clip, SOURCE_AUTOFILL).build(); performReceiveContent(payload); } diff --git a/core/tests/coretests/src/android/view/autofill/AutofillValueTest.java b/core/tests/coretests/src/android/view/autofill/AutofillValueTest.java index 52373f0077d2e..7f24b0d90e2f2 100644 --- a/core/tests/coretests/src/android/view/autofill/AutofillValueTest.java +++ b/core/tests/coretests/src/android/view/autofill/AutofillValueTest.java @@ -18,7 +18,6 @@ package android.view.autofill; import static com.google.common.truth.Truth.assertThat; -import android.content.ClipData; import android.os.Parcel; import org.junit.Test; @@ -39,20 +38,4 @@ public class AutofillValueTest { assertThat(result.isText()).isTrue(); assertThat(result.getTextValue()).isEqualTo("hello"); } - - @Test - public void testWriteToParcel_richContent() throws Exception { - ClipData clip = ClipData.newPlainText("my label", "hello"); - AutofillValue value = AutofillValue.forRichContent(clip); - Parcel parcel = Parcel.obtain(); - value.writeToParcel(parcel, 0); - parcel.setDataPosition(0); - - AutofillValue result = AutofillValue.CREATOR.createFromParcel(parcel); - assertThat(result.isRichContent()).isTrue(); - ClipData resultClip = result.getRichContentValue(); - assertThat(resultClip.getDescription().getLabel()).isEqualTo("my label"); - assertThat(resultClip.getItemAt(0).getText()).isEqualTo("hello"); - assertThat(resultClip.getDescription().getMimeType(0)).isEqualTo("text/plain"); - } }