Merge "Minor Autofill changes after API council review." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
be3e4a6285
@@ -37082,6 +37082,13 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.LuhnChecksumValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class RegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public RegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.RegexValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class SaveCallback {
|
||||
method public void onFailure(java.lang.CharSequence);
|
||||
method public void onSuccess();
|
||||
@@ -37122,13 +37129,6 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveRequest> CREATOR;
|
||||
}
|
||||
|
||||
public final class SimpleRegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public SimpleRegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.SimpleRegexValidator> CREATOR;
|
||||
}
|
||||
|
||||
public abstract interface Transformation {
|
||||
}
|
||||
|
||||
|
||||
@@ -40272,6 +40272,13 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.LuhnChecksumValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class RegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public RegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.RegexValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class SaveCallback {
|
||||
method public void onFailure(java.lang.CharSequence);
|
||||
method public void onSuccess();
|
||||
@@ -40312,13 +40319,6 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveRequest> CREATOR;
|
||||
}
|
||||
|
||||
public final class SimpleRegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public SimpleRegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.SimpleRegexValidator> CREATOR;
|
||||
}
|
||||
|
||||
public abstract interface Transformation {
|
||||
}
|
||||
|
||||
|
||||
@@ -37274,6 +37274,14 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.LuhnChecksumValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class RegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public RegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
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.RegexValidator> CREATOR;
|
||||
}
|
||||
|
||||
public final class SaveCallback {
|
||||
method public void onFailure(java.lang.CharSequence);
|
||||
method public void onSuccess();
|
||||
@@ -37314,14 +37322,6 @@ package android.service.autofill {
|
||||
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveRequest> CREATOR;
|
||||
}
|
||||
|
||||
public final class SimpleRegexValidator implements android.os.Parcelable android.service.autofill.Validator {
|
||||
ctor public SimpleRegexValidator(android.view.autofill.AutofillId, java.util.regex.Pattern);
|
||||
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;
|
||||
}
|
||||
|
||||
public abstract interface Transformation {
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.android.internal.util.Preconditions;
|
||||
*
|
||||
* <p>This is useful when the autofill service needs to show a detailed view of what would be saved;
|
||||
* for example, when the screen contains a credit card, it could display a logo of the credit card
|
||||
* bank, the last for digits of the credit card number, and its expiration number.
|
||||
* bank, the last four digits of the credit card number, and its expiration number.
|
||||
*
|
||||
* <p>A custom description is made of 2 parts:
|
||||
* <ul>
|
||||
@@ -63,16 +63,16 @@ import com.android.internal.util.Preconditions;
|
||||
* // Image child - different logo for each bank, based on credit card prefix
|
||||
* builder.addChild(R.id.templateccLogo,
|
||||
* new ImageTransformation.Builder(ccNumberId)
|
||||
* .addOption("^4815.*$", R.drawable.ic_credit_card_logo1)
|
||||
* .addOption("^1623.*$", R.drawable.ic_credit_card_logo2)
|
||||
* .addOption("^42.*$", R.drawable.ic_credit_card_logo3);
|
||||
* .addOption(Pattern.compile(""^4815.*$"), R.drawable.ic_credit_card_logo1)
|
||||
* .addOption(Pattern.compile(""^1623.*$"), R.drawable.ic_credit_card_logo2)
|
||||
* .addOption(Pattern.compile(""^42.*$"), R.drawable.ic_credit_card_logo3);
|
||||
* // Masked credit card number (as .....LAST_4_DIGITS)
|
||||
* builder.addChild(R.id.templateCcNumber, new CharSequenceTransformation.Builder()
|
||||
* .addField(ccNumberId, "^.*(\\d\\d\\d\\d)$", "...$1")
|
||||
* .addField(ccNumberId, Pattern.compile(""^.*(\\d\\d\\d\\d)$"), "...$1")
|
||||
* // Expiration date as MM / YYYY:
|
||||
* builder.addChild(R.id.templateExpDate, new CharSequenceTransformation.Builder()
|
||||
* .addField(ccExpMonthId, "^(\\d\\d)$", "Exp: $1")
|
||||
* .addField(ccExpYearId, "^(\\d\\d)$", "/$1");
|
||||
* .addField(ccExpMonthId, Pattern.compile(""^(\\d\\d)$"), "Exp: $1")
|
||||
* .addField(ccExpYearId, Pattern.compile(""^(\\d\\d)$"), "/$1");
|
||||
* </pre>
|
||||
*
|
||||
* <p>See {@link ImageTransformation}, {@link CharSequenceTransformation} for more info about these
|
||||
|
||||
@@ -34,9 +34,9 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* <p>See {@link SaveInfo.Builder#setValidator(Validator)} for examples.
|
||||
*/
|
||||
public final class SimpleRegexValidator extends InternalValidator implements Validator, Parcelable {
|
||||
public final class RegexValidator extends InternalValidator implements Validator, Parcelable {
|
||||
|
||||
private static final String TAG = "SimpleRegexValidator";
|
||||
private static final String TAG = "RegexValidator";
|
||||
|
||||
private final AutofillId mId;
|
||||
private final Pattern mRegex;
|
||||
@@ -49,7 +49,7 @@ public final class SimpleRegexValidator extends InternalValidator implements Val
|
||||
* matches the contents of the field identified by {@code id}, it returns {@code true};
|
||||
* otherwise, it returns {@code false}.
|
||||
*/
|
||||
public SimpleRegexValidator(@NonNull AutofillId id, @NonNull Pattern regex) {
|
||||
public RegexValidator(@NonNull AutofillId id, @NonNull Pattern regex) {
|
||||
mId = Preconditions.checkNotNull(id);
|
||||
mRegex = Preconditions.checkNotNull(regex);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public final class SimpleRegexValidator extends InternalValidator implements Val
|
||||
public String toString() {
|
||||
if (!sDebug) return super.toString();
|
||||
|
||||
return "SimpleRegexValidator: [id=" + mId + ", regex=" + mRegex + "]";
|
||||
return "RegexValidator: [id=" + mId + ", regex=" + mRegex + "]";
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
@@ -93,17 +93,17 @@ public final class SimpleRegexValidator extends InternalValidator implements Val
|
||||
parcel.writeSerializable(mRegex);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SimpleRegexValidator> CREATOR =
|
||||
new Parcelable.Creator<SimpleRegexValidator>() {
|
||||
public static final Parcelable.Creator<RegexValidator> CREATOR =
|
||||
new Parcelable.Creator<RegexValidator>() {
|
||||
@Override
|
||||
public SimpleRegexValidator createFromParcel(Parcel parcel) {
|
||||
return new SimpleRegexValidator(parcel.readParcelable(null),
|
||||
public RegexValidator createFromParcel(Parcel parcel) {
|
||||
return new RegexValidator(parcel.readParcelable(null),
|
||||
(Pattern) parcel.readSerializable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleRegexValidator[] newArray(int size) {
|
||||
return new SimpleRegexValidator[size];
|
||||
public RegexValidator[] newArray(int size) {
|
||||
return new RegexValidator[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -470,7 +470,7 @@ public final class SaveInfo implements Parcelable {
|
||||
* <p>Validator for a credit number that must have exactly 16 digits:
|
||||
*
|
||||
* <pre class="prettyprint">
|
||||
* Validator validator = new SimpleRegexValidator(ccNumberId, "^\\d{16}$")
|
||||
* Validator validator = new RegexValidator(ccNumberId, Pattern.compile(""^\\d{16}$"))
|
||||
* </pre>
|
||||
*
|
||||
* <p>Validator for a credit number that must pass a Luhn checksum and either have
|
||||
@@ -483,8 +483,8 @@ public final class SaveInfo implements Parcelable {
|
||||
* and(
|
||||
* new LuhnChecksumValidator(ccNumberId),
|
||||
* or(
|
||||
* new SimpleRegexValidator(ccNumberId, "^\\d{16}$"),
|
||||
* new SimpleRegexValidator(ccNumberId, "^108\\d{12}$")
|
||||
* new RegexValidator(ccNumberId, Pattern.compile(""^\\d{16}$")),
|
||||
* new RegexValidator(ccNumberId, Pattern.compile(""^108\\d{12}$"))
|
||||
* )
|
||||
* );
|
||||
* </pre>
|
||||
@@ -496,7 +496,7 @@ public final class SaveInfo implements Parcelable {
|
||||
* Validator validator =
|
||||
* and(
|
||||
* new LuhnChecksumValidator(ccNumberId),
|
||||
* new SimpleRegexValidator(ccNumberId, "^(\\d{16}|108\\d{12})$")
|
||||
* new RegexValidator(ccNumberId, Pattern.compile(""^(\\d{16}|108\\d{12})$"))
|
||||
* );
|
||||
* </pre>
|
||||
*
|
||||
@@ -508,10 +508,10 @@ public final class SaveInfo implements Parcelable {
|
||||
*
|
||||
* Validator validator =
|
||||
* and(
|
||||
* new SimpleRegexValidator(ccNumberId1, "^\\d{4}$"),
|
||||
* new SimpleRegexValidator(ccNumberId2, "^\\d{4}$"),
|
||||
* new SimpleRegexValidator(ccNumberId3, "^\\d{4}$"),
|
||||
* new SimpleRegexValidator(ccNumberId4, "^\\d{4}$")
|
||||
* new RegexValidator(ccNumberId1, Pattern.compile(""^\\d{4}$")),
|
||||
* new RegexValidator(ccNumberId2, Pattern.compile(""^\\d{4}$")),
|
||||
* new RegexValidator(ccNumberId3, Pattern.compile(""^\\d{4}$")),
|
||||
* new RegexValidator(ccNumberId4, Pattern.compile(""^\\d{4}$"))
|
||||
* );
|
||||
* </pre>
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user