Strip phone number punctuation when validating for autofill

Strip out any phone number separator characters when calculating
the length of the phone number for validation in the autofill
profile editor.

Change-Id: Ic5f9792a8da8d0d1914b1cdd831a018c64d12ace
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index 389be1f..3a7ae12 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -65,11 +65,18 @@
     private class PhoneNumberValidator implements TextWatcher {
         // Keep in sync with kPhoneNumberLength in chrome/browser/autofill/phone_number.cc
         private static final int PHONE_NUMBER_LENGTH = 7;
+        private static final String PHONE_NUMBER_SEPARATORS_REGEX = "[\\s\\.\\(\\)-]";
 
         public void afterTextChanged(Editable s) {
-            int phoneNumberLength = s.toString().length();
+            String phoneNumber = s.toString();
+            int phoneNumberLength = phoneNumber.length();
 
-            if (phoneNumberLength > 0 && phoneNumberLength < PHONE_NUMBER_LENGTH) {
+            // Strip out any phone number separators.
+            phoneNumber = phoneNumber.replaceAll(PHONE_NUMBER_SEPARATORS_REGEX, "");
+
+            int strippedPhoneNumberLength = phoneNumber.length();
+
+            if (phoneNumberLength > 0 && strippedPhoneNumberLength < PHONE_NUMBER_LENGTH) {
                 mPhoneEdit.setError(getResources().getText(
                         R.string.autofill_profile_editor_phone_number_invalid));
             } else {