Updating "Add Contact" to pre-populate full contact info.
1. For recent call entries with a name and phone number, the name will
now also be added.
2. For recent call entries which have complete address information provided
by nearby places, all information except the contact photo will be added. The contact photo is
excluded, as the ContactsLoader would attempt to load the contact photo
while parsing the contact information. On a slow connection this could
cause a noticeable pause while adding the contact.
Bug: 17308163
Change-Id: If2e78bd1257096b344ff2dd266dcdbaeed4f1471
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 5e6f035..95b7215 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -1050,8 +1050,22 @@
}
public static Intent getAddNumberToContactIntent(CharSequence text) {
- final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
- intent.putExtra(Intents.Insert.PHONE, text);
+ return getAddToContactIntent(null /* name */, text /* phoneNumber */,
+ -1 /* phoneNumberType */);
+ }
+
+ public static Intent getAddToContactIntent(CharSequence name, CharSequence phoneNumber,
+ int phoneNumberType) {
+ Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
+ intent.putExtra(Intents.Insert.PHONE, phoneNumber);
+ // Only include the name and phone type extras if they are specified (the method
+ // getAddNumberToContactIntent does not use them).
+ if (name != null) {
+ intent.putExtra(Intents.Insert.NAME, name);
+ }
+ if (phoneNumberType != -1) {
+ intent.putExtra(Intents.Insert.PHONE_TYPE, phoneNumberType);
+ }
intent.setType(Contacts.CONTENT_ITEM_TYPE);
return intent;
}