Skip to content

Commit

Permalink
Merge pull request #725 from Marchuck/feat/custom-contact-labels
Browse files Browse the repository at this point in the history
support for custom user defined contact labels
  • Loading branch information
morenoh149 authored Dec 14, 2023
2 parents 0258847 + 32e5ccd commit 9d13ef8
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,22 +390,13 @@ private Map<String, Contact> loadContactsFrom(Cursor cursor) {
int phoneType = cursor.getInt(cursor.getColumnIndex(Phone.TYPE));

if (!TextUtils.isEmpty(phoneNumber)) {
String label;
switch (phoneType) {
case Phone.TYPE_HOME:
label = "home";
break;
case Phone.TYPE_WORK:
label = "work";
break;
case Phone.TYPE_MOBILE:
label = "mobile";
break;
case Phone.TYPE_OTHER:
label = "other";
break;
default:
label = "other";
final String label;
int labelIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
if (labelIndex >= 0) {
String typeLabel = cursor.getString(labelIndex);
label = ContactsContract.CommonDataKinds.Phone..getTypeLabel(Resources.getSystem(), phoneType, typeLabel).toString();
} else {
label = "other";
}
contact.phones.add(new Contact.Item(label, phoneNumber, id));
}
Expand Down

0 comments on commit 9d13ef8

Please sign in to comment.