Merge "Minor Autofill changes after API council review." into oc-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index 8d2e9c8..dc92604 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37082,6 +37082,13 @@
     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 @@
     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 {
   }
 
diff --git a/api/system-current.txt b/api/system-current.txt
index e2754fd..6eb10cc 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -40272,6 +40272,13 @@
     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 @@
     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 {
   }
 
diff --git a/api/test-current.txt b/api/test-current.txt
index fcb404e..3e27470 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37274,6 +37274,14 @@
     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 @@
     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 {
   }
 
diff --git a/core/java/android/service/autofill/CustomDescription.java b/core/java/android/service/autofill/CustomDescription.java
index 0edb154..3da0b5e 100644
--- a/core/java/android/service/autofill/CustomDescription.java
+++ b/core/java/android/service/autofill/CustomDescription.java
@@ -32,7 +32,7 @@
  *
  * <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 @@
  * // 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
diff --git a/core/java/android/service/autofill/SimpleRegexValidator.java b/core/java/android/service/autofill/RegexValidator.java
similarity index 79%
rename from core/java/android/service/autofill/SimpleRegexValidator.java
rename to core/java/android/service/autofill/RegexValidator.java
index ef8c52c9..9dfe78d 100644
--- a/core/java/android/service/autofill/SimpleRegexValidator.java
+++ b/core/java/android/service/autofill/RegexValidator.java
@@ -34,9 +34,9 @@
  *
  * <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 @@
      * 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 String toString() {
         if (!sDebug) return super.toString();
 
-        return "SimpleRegexValidator: [id=" + mId + ", regex=" + mRegex + "]";
+        return "RegexValidator: [id=" + mId + ", regex=" + mRegex + "]";
     }
 
     /////////////////////////////////////
@@ -93,17 +93,17 @@
         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];
         }
     };
 }
diff --git a/core/java/android/service/autofill/SaveInfo.java b/core/java/android/service/autofill/SaveInfo.java
index f8a94d6..e0a0730 100644
--- a/core/java/android/service/autofill/SaveInfo.java
+++ b/core/java/android/service/autofill/SaveInfo.java
@@ -470,7 +470,7 @@
          * <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 @@
          *   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 @@
          * 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 @@
          *
          * 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>
          *