Add phone type to contact preference summary
Bug:27533454
Change-Id: I49448d5056cbe1931477e5c222d003b6dd57b7be
diff --git a/src/com/android/emergency/EmergencyContactManager.java b/src/com/android/emergency/EmergencyContactManager.java
index 342ff2d..85c2ca6 100644
--- a/src/com/android/emergency/EmergencyContactManager.java
+++ b/src/com/android/emergency/EmergencyContactManager.java
@@ -36,6 +36,7 @@
*/
public static Contact getContact(Context context, Uri contactUri) {
String phoneNumber = null;
+ String phoneType = null;
String name = null;
Bitmap photo = null;
final Uri contactLookupUri =
@@ -45,13 +46,19 @@
contactUri,
new String[]{ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
+ ContactsContract.CommonDataKinds.Phone.TYPE,
+ ContactsContract.CommonDataKinds.Phone.LABEL,
ContactsContract.CommonDataKinds.Photo.PHOTO_ID},
null, null, null);
try {
if (cursor.moveToNext()) {
name = cursor.getString(0);
phoneNumber = cursor.getString(1);
- Long photoId = cursor.getLong(2);
+ phoneType = ContactsContract.CommonDataKinds.Phone.getTypeLabel(
+ context.getResources(),
+ cursor.getInt(2),
+ cursor.getString(3)).toString();
+ Long photoId = cursor.getLong(4);
if (photoId != null && photoId > 0) {
Uri photoUri = ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI,
photoId);
@@ -76,7 +83,7 @@
cursor.close();
}
}
- return new Contact(contactLookupUri, contactUri, name, phoneNumber, photo);
+ return new Contact(contactLookupUri, contactUri, name, phoneNumber, phoneType, photo);
}
/** Returns whether the contact uri is not null and corresponds to an existing contact. */
@@ -111,6 +118,8 @@
private final String mName;
/** The emergency contact's phone number selected by the user. */
private final String mPhoneNumber;
+ /** The emergency contact's phone number type (mobile, work, home, etc). */
+ private final String mPhoneType;
/** The contact's photo. */
private final Bitmap mPhoto;
@@ -119,11 +128,13 @@
Uri contactUri,
String name,
String phoneNumber,
+ String phoneType,
Bitmap photo) {
mContactLookupUri = contactLookupUri;
mContactUri = contactUri;
mName = name;
mPhoneNumber = phoneNumber;
+ mPhoneType = phoneType;
mPhoto = photo;
}
@@ -151,6 +162,11 @@
return mPhoneNumber;
}
+ /** Returns the phone type (e.g. mobile, work, home, etc.) . */
+ public String getPhoneType() {
+ return mPhoneType;
+ }
+
/** Returns the photo assigned to this contact. */
public Bitmap getPhoto() {
return mPhoto;