Loading api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -55262,6 +55262,7 @@ package android.view.textclassifier { method public int describeContents(); method @NonNull public android.os.Bundle getExtras(); method @NonNull public java.util.Collection<android.view.textclassifier.TextLinks.TextLink> getLinks(); method @NonNull public String getText(); method public void writeToParcel(android.os.Parcel, int); field public static final int APPLY_STRATEGY_IGNORE = 0; // 0x0 field public static final int APPLY_STRATEGY_REPLACE = 1; // 0x1 Loading @@ -55288,6 +55289,7 @@ package android.view.textclassifier { method @Nullable public android.os.LocaleList getDefaultLocales(); method @Nullable public android.view.textclassifier.TextClassifier.EntityConfig getEntityConfig(); method @NonNull public android.os.Bundle getExtras(); method @Nullable public java.time.ZonedDateTime getReferenceTime(); method @NonNull public CharSequence getText(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.textclassifier.TextLinks.Request> CREATOR; Loading @@ -55299,6 +55301,7 @@ package android.view.textclassifier { method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setDefaultLocales(@Nullable android.os.LocaleList); method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setEntityConfig(@Nullable android.view.textclassifier.TextClassifier.EntityConfig); method public android.view.textclassifier.TextLinks.Request.Builder setExtras(@Nullable android.os.Bundle); method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setReferenceTime(@Nullable java.time.ZonedDateTime); } public static final class TextLinks.TextLink implements android.os.Parcelable { core/java/android/view/textclassifier/TextLinks.java +33 −3 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; Loading Loading @@ -110,7 +111,6 @@ public final class TextLinks implements Parcelable { /** * Returns the text that was used to generate these links. * @hide */ @NonNull public String getText() { Loading Loading @@ -342,6 +342,7 @@ public final class TextLinks implements Parcelable { private final boolean mLegacyFallback; @Nullable private String mCallingPackageName; private final Bundle mExtras; @Nullable private final ZonedDateTime mReferenceTime; @UserIdInt private int mUserId = UserHandle.USER_NULL; Loading @@ -350,11 +351,13 @@ public final class TextLinks implements Parcelable { LocaleList defaultLocales, EntityConfig entityConfig, boolean legacyFallback, ZonedDateTime referenceTime, Bundle extras) { mText = text; mDefaultLocales = defaultLocales; mEntityConfig = entityConfig; mLegacyFallback = legacyFallback; mReferenceTime = referenceTime; mExtras = extras; } Loading Loading @@ -394,6 +397,15 @@ public final class TextLinks implements Parcelable { return mLegacyFallback; } /** * @return reference time based on which relative dates (e.g. "tomorrow") should be * interpreted. */ @Nullable public ZonedDateTime getReferenceTime() { return mReferenceTime; } /** * Sets the name of the package that is sending this request. * <p> Loading Loading @@ -454,6 +466,7 @@ public final class TextLinks implements Parcelable { @Nullable private EntityConfig mEntityConfig; private boolean mLegacyFallback = true; // Use legacy fall back by default. @Nullable private Bundle mExtras; @Nullable private ZonedDateTime mReferenceTime; public Builder(@NonNull CharSequence text) { mText = Objects.requireNonNull(text); Loading Loading @@ -510,6 +523,19 @@ public final class TextLinks implements Parcelable { return this; } /** * @param referenceTime reference time based on which relative dates (e.g. "tomorrow" * should be interpreted. This should usually be the time when the text was * originally composed. * * @return this builder */ @NonNull public Builder setReferenceTime(@Nullable ZonedDateTime referenceTime) { mReferenceTime = referenceTime; return this; } /** * Builds and returns the request object. */ Loading @@ -517,7 +543,7 @@ public final class TextLinks implements Parcelable { public Request build() { return new Request( mText, mDefaultLocales, mEntityConfig, mLegacyFallback, mLegacyFallback, mReferenceTime, mExtras == null ? Bundle.EMPTY : mExtras); } } Loading @@ -535,6 +561,7 @@ public final class TextLinks implements Parcelable { dest.writeString(mCallingPackageName); dest.writeInt(mUserId); dest.writeBundle(mExtras); dest.writeString(mReferenceTime == null ? null : mReferenceTime.toString()); } private static Request readFromParcel(Parcel in) { Loading @@ -544,9 +571,12 @@ public final class TextLinks implements Parcelable { final String callingPackageName = in.readString(); final int userId = in.readInt(); final Bundle extras = in.readBundle(); final String referenceTimeString = in.readString(); final ZonedDateTime referenceTime = referenceTimeString == null ? null : ZonedDateTime.parse(referenceTimeString); final Request request = new Request(text, defaultLocales, entityConfig, /* legacyFallback= */ true, extras); /* legacyFallback= */ true, referenceTime, extras); request.setCallingPackageName(callingPackageName); request.setUserId(userId); return request; Loading core/tests/coretests/src/android/view/textclassifier/TextLinksTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -77,6 +80,7 @@ public class TextLinksTest { final TextLinks result = TextLinks.CREATOR.createFromParcel(parcel); final List<TextLinks.TextLink> resultList = new ArrayList<>(result.getLinks()); assertEquals(fullText, result.getText()); assertEquals(2, resultList.size()); assertEquals(0, resultList.get(0).getStart()); assertEquals(4, resultList.get(0).getEnd()); Loading @@ -103,10 +107,13 @@ public class TextLinksTest { Arrays.asList(TextClassifier.HINT_TEXT_IS_EDITABLE), Arrays.asList("a", "b", "c"), Arrays.asList("b")); final ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(1000L), ZoneId.of("UTC")); final TextLinks.Request reference = new TextLinks.Request.Builder("text") .setDefaultLocales(new LocaleList(Locale.US, Locale.GERMANY)) .setEntityConfig(entityConfig) .setExtras(BUNDLE) .setReferenceTime(referenceTime) .build(); reference.setCallingPackageName(packageName); Loading @@ -124,5 +131,6 @@ public class TextLinksTest { result.getEntityConfig().resolveEntityListModifications(Collections.emptyList())); assertEquals(BUNDLE_VALUE, result.getExtras().getString(BUNDLE_KEY)); assertEquals(packageName, result.getCallingPackageName()); assertEquals(referenceTime, result.getReferenceTime()); } } Loading
api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -55262,6 +55262,7 @@ package android.view.textclassifier { method public int describeContents(); method @NonNull public android.os.Bundle getExtras(); method @NonNull public java.util.Collection<android.view.textclassifier.TextLinks.TextLink> getLinks(); method @NonNull public String getText(); method public void writeToParcel(android.os.Parcel, int); field public static final int APPLY_STRATEGY_IGNORE = 0; // 0x0 field public static final int APPLY_STRATEGY_REPLACE = 1; // 0x1 Loading @@ -55288,6 +55289,7 @@ package android.view.textclassifier { method @Nullable public android.os.LocaleList getDefaultLocales(); method @Nullable public android.view.textclassifier.TextClassifier.EntityConfig getEntityConfig(); method @NonNull public android.os.Bundle getExtras(); method @Nullable public java.time.ZonedDateTime getReferenceTime(); method @NonNull public CharSequence getText(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.textclassifier.TextLinks.Request> CREATOR; Loading @@ -55299,6 +55301,7 @@ package android.view.textclassifier { method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setDefaultLocales(@Nullable android.os.LocaleList); method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setEntityConfig(@Nullable android.view.textclassifier.TextClassifier.EntityConfig); method public android.view.textclassifier.TextLinks.Request.Builder setExtras(@Nullable android.os.Bundle); method @NonNull public android.view.textclassifier.TextLinks.Request.Builder setReferenceTime(@Nullable java.time.ZonedDateTime); } public static final class TextLinks.TextLink implements android.os.Parcelable {
core/java/android/view/textclassifier/TextLinks.java +33 −3 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; Loading Loading @@ -110,7 +111,6 @@ public final class TextLinks implements Parcelable { /** * Returns the text that was used to generate these links. * @hide */ @NonNull public String getText() { Loading Loading @@ -342,6 +342,7 @@ public final class TextLinks implements Parcelable { private final boolean mLegacyFallback; @Nullable private String mCallingPackageName; private final Bundle mExtras; @Nullable private final ZonedDateTime mReferenceTime; @UserIdInt private int mUserId = UserHandle.USER_NULL; Loading @@ -350,11 +351,13 @@ public final class TextLinks implements Parcelable { LocaleList defaultLocales, EntityConfig entityConfig, boolean legacyFallback, ZonedDateTime referenceTime, Bundle extras) { mText = text; mDefaultLocales = defaultLocales; mEntityConfig = entityConfig; mLegacyFallback = legacyFallback; mReferenceTime = referenceTime; mExtras = extras; } Loading Loading @@ -394,6 +397,15 @@ public final class TextLinks implements Parcelable { return mLegacyFallback; } /** * @return reference time based on which relative dates (e.g. "tomorrow") should be * interpreted. */ @Nullable public ZonedDateTime getReferenceTime() { return mReferenceTime; } /** * Sets the name of the package that is sending this request. * <p> Loading Loading @@ -454,6 +466,7 @@ public final class TextLinks implements Parcelable { @Nullable private EntityConfig mEntityConfig; private boolean mLegacyFallback = true; // Use legacy fall back by default. @Nullable private Bundle mExtras; @Nullable private ZonedDateTime mReferenceTime; public Builder(@NonNull CharSequence text) { mText = Objects.requireNonNull(text); Loading Loading @@ -510,6 +523,19 @@ public final class TextLinks implements Parcelable { return this; } /** * @param referenceTime reference time based on which relative dates (e.g. "tomorrow" * should be interpreted. This should usually be the time when the text was * originally composed. * * @return this builder */ @NonNull public Builder setReferenceTime(@Nullable ZonedDateTime referenceTime) { mReferenceTime = referenceTime; return this; } /** * Builds and returns the request object. */ Loading @@ -517,7 +543,7 @@ public final class TextLinks implements Parcelable { public Request build() { return new Request( mText, mDefaultLocales, mEntityConfig, mLegacyFallback, mLegacyFallback, mReferenceTime, mExtras == null ? Bundle.EMPTY : mExtras); } } Loading @@ -535,6 +561,7 @@ public final class TextLinks implements Parcelable { dest.writeString(mCallingPackageName); dest.writeInt(mUserId); dest.writeBundle(mExtras); dest.writeString(mReferenceTime == null ? null : mReferenceTime.toString()); } private static Request readFromParcel(Parcel in) { Loading @@ -544,9 +571,12 @@ public final class TextLinks implements Parcelable { final String callingPackageName = in.readString(); final int userId = in.readInt(); final Bundle extras = in.readBundle(); final String referenceTimeString = in.readString(); final ZonedDateTime referenceTime = referenceTimeString == null ? null : ZonedDateTime.parse(referenceTimeString); final Request request = new Request(text, defaultLocales, entityConfig, /* legacyFallback= */ true, extras); /* legacyFallback= */ true, referenceTime, extras); request.setCallingPackageName(callingPackageName); request.setUserId(userId); return request; Loading
core/tests/coretests/src/android/view/textclassifier/TextLinksTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -77,6 +80,7 @@ public class TextLinksTest { final TextLinks result = TextLinks.CREATOR.createFromParcel(parcel); final List<TextLinks.TextLink> resultList = new ArrayList<>(result.getLinks()); assertEquals(fullText, result.getText()); assertEquals(2, resultList.size()); assertEquals(0, resultList.get(0).getStart()); assertEquals(4, resultList.get(0).getEnd()); Loading @@ -103,10 +107,13 @@ public class TextLinksTest { Arrays.asList(TextClassifier.HINT_TEXT_IS_EDITABLE), Arrays.asList("a", "b", "c"), Arrays.asList("b")); final ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(1000L), ZoneId.of("UTC")); final TextLinks.Request reference = new TextLinks.Request.Builder("text") .setDefaultLocales(new LocaleList(Locale.US, Locale.GERMANY)) .setEntityConfig(entityConfig) .setExtras(BUNDLE) .setReferenceTime(referenceTime) .build(); reference.setCallingPackageName(packageName); Loading @@ -124,5 +131,6 @@ public class TextLinksTest { result.getEntityConfig().resolveEntityListModifications(Collections.emptyList())); assertEquals(BUNDLE_VALUE, result.getExtras().getString(BUNDLE_KEY)); assertEquals(packageName, result.getCallingPackageName()); assertEquals(referenceTime, result.getReferenceTime()); } }