Loading api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -37284,6 +37284,7 @@ package android.service.autofill { public final class SimpleRegexValidator implements android.os.Parcelable android.service.autofill.Validator { ctor public SimpleRegexValidator(android.view.autofill.AutofillId, java.lang.String); method public int describeContents(); method public boolean isValid(android.service.autofill.ValueFinder); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.service.autofill.SimpleRegexValidator> CREATOR; } core/java/android/service/autofill/ImageTransformation.java +4 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,8 @@ public final class ImageTransformation extends InternalTransformation implements * * @param id id of the screen field that will be used to evaluate whether the image should * be used. * @param regex regular expression defining what should be matched to use this image. * @param regex regular expression defining what should be matched to use this image. The * pattern will be {@link Pattern#compile compiled} without setting any flags. * @param resId resource id of the image (in the autofill service's package). The * {@link RemoteViews presentation} must contain a {@link ImageView} child with that id. */ Loading @@ -115,7 +116,8 @@ public final class ImageTransformation extends InternalTransformation implements /** * Adds an option to replace the child view with a different image when the regex matches. * * @param regex regular expression defining what should be matched to use this image. * @param regex regular expression defining what should be matched to use this image. The * pattern will be {@link Pattern#compile compiled} without setting any flags. * @param resId resource id of the image (in the autofill service's package). The * {@link RemoteViews presentation} must contain a {@link ImageView} child with that id. * Loading core/java/android/service/autofill/SimpleRegexValidator.java +16 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.service.autofill; import static android.view.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; Loading @@ -26,6 +27,8 @@ import android.view.autofill.AutofillId; import com.android.internal.util.Preconditions; import java.util.regex.Pattern; /** * Defines if a field is valid based on a regular expression (regex). * Loading @@ -36,32 +39,33 @@ public final class SimpleRegexValidator extends InternalValidator implements Val private static final String TAG = "SimpleRegexValidator"; private final AutofillId mId; private final String mRegex; private final Pattern mRegex; /** * Default constructor. * * @param id id of the field whose regex is applied to. * @param regex regular expression that defines the result * of the validator: if the regex matches the contents of * the field identified by {@code id}, it returns {@code true}; otherwise, it * returns {@code false}. * @param regex regular expression that defines the result of the validator: if the regex * matches the contents of the field identified by {@code id}, it returns {@code true}; * otherwise, it returns {@code false}. The pattern will be {@link Pattern#compile compiled} * without setting any flags. */ public SimpleRegexValidator(@NonNull AutofillId id, @NonNull String regex) { mId = Preconditions.checkNotNull(id); //TODO(b/62534917): throw exception if regex is invalid mRegex = Preconditions.checkNotNull(regex); mRegex = Pattern.compile(regex); } /** @hide */ @Override @TestApi public boolean isValid(@NonNull ValueFinder finder) { final String value = finder.findByAutofillId(mId); if (value == null) { Log.w(TAG, "No view for id " + mId); return false; } final boolean valid = value.matches(mRegex); final boolean valid = mRegex.matcher(value).matches(); if (sDebug) Log.d(TAG, "isValid(): " + valid); return valid; } Loading @@ -87,7 +91,7 @@ public final class SimpleRegexValidator extends InternalValidator implements Val @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeParcelable(mId, flags); parcel.writeString(mRegex); parcel.writeString(mRegex.pattern()); } public static final Parcelable.Creator<SimpleRegexValidator> CREATOR = Loading Loading
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -37284,6 +37284,7 @@ package android.service.autofill { public final class SimpleRegexValidator implements android.os.Parcelable android.service.autofill.Validator { ctor public SimpleRegexValidator(android.view.autofill.AutofillId, java.lang.String); method public int describeContents(); method public boolean isValid(android.service.autofill.ValueFinder); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.service.autofill.SimpleRegexValidator> CREATOR; }
core/java/android/service/autofill/ImageTransformation.java +4 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,8 @@ public final class ImageTransformation extends InternalTransformation implements * * @param id id of the screen field that will be used to evaluate whether the image should * be used. * @param regex regular expression defining what should be matched to use this image. * @param regex regular expression defining what should be matched to use this image. The * pattern will be {@link Pattern#compile compiled} without setting any flags. * @param resId resource id of the image (in the autofill service's package). The * {@link RemoteViews presentation} must contain a {@link ImageView} child with that id. */ Loading @@ -115,7 +116,8 @@ public final class ImageTransformation extends InternalTransformation implements /** * Adds an option to replace the child view with a different image when the regex matches. * * @param regex regular expression defining what should be matched to use this image. * @param regex regular expression defining what should be matched to use this image. The * pattern will be {@link Pattern#compile compiled} without setting any flags. * @param resId resource id of the image (in the autofill service's package). The * {@link RemoteViews presentation} must contain a {@link ImageView} child with that id. * Loading
core/java/android/service/autofill/SimpleRegexValidator.java +16 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.service.autofill; import static android.view.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; Loading @@ -26,6 +27,8 @@ import android.view.autofill.AutofillId; import com.android.internal.util.Preconditions; import java.util.regex.Pattern; /** * Defines if a field is valid based on a regular expression (regex). * Loading @@ -36,32 +39,33 @@ public final class SimpleRegexValidator extends InternalValidator implements Val private static final String TAG = "SimpleRegexValidator"; private final AutofillId mId; private final String mRegex; private final Pattern mRegex; /** * Default constructor. * * @param id id of the field whose regex is applied to. * @param regex regular expression that defines the result * of the validator: if the regex matches the contents of * the field identified by {@code id}, it returns {@code true}; otherwise, it * returns {@code false}. * @param regex regular expression that defines the result of the validator: if the regex * matches the contents of the field identified by {@code id}, it returns {@code true}; * otherwise, it returns {@code false}. The pattern will be {@link Pattern#compile compiled} * without setting any flags. */ public SimpleRegexValidator(@NonNull AutofillId id, @NonNull String regex) { mId = Preconditions.checkNotNull(id); //TODO(b/62534917): throw exception if regex is invalid mRegex = Preconditions.checkNotNull(regex); mRegex = Pattern.compile(regex); } /** @hide */ @Override @TestApi public boolean isValid(@NonNull ValueFinder finder) { final String value = finder.findByAutofillId(mId); if (value == null) { Log.w(TAG, "No view for id " + mId); return false; } final boolean valid = value.matches(mRegex); final boolean valid = mRegex.matcher(value).matches(); if (sDebug) Log.d(TAG, "isValid(): " + valid); return valid; } Loading @@ -87,7 +91,7 @@ public final class SimpleRegexValidator extends InternalValidator implements Val @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeParcelable(mId, flags); parcel.writeString(mRegex); parcel.writeString(mRegex.pattern()); } public static final Parcelable.Creator<SimpleRegexValidator> CREATOR = Loading