Format phone numbers when inserting a new contact
Set formatAfterWatcherSet to true when inserting a new contact.
Test:
Tested opening and closing a contact with an unformatted number
doesn't prompt to discard changes.
Tested adding a new contact from Allo has formatted number.
Bug: 26754145
Change-Id: I82546e86aec1e901e9b508eeaf7b87cf9f28d22f
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index 77b584c..564a9f5 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -228,7 +228,8 @@
fieldView.setInputType(inputType);
if (inputType == InputType.TYPE_CLASS_PHONE) {
PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(
- getContext(), fieldView, /* formatAfterWatcherSet =*/ false);
+ getContext(), fieldView,
+ /* formatAfterWatcherSet =*/ state.isContactInsert());
fieldView.setTextDirection(View.TEXT_DIRECTION_LTR);
}
fieldView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);