Skip to content

Commit

Permalink
fix #4655: Show Displayname when selecting contact
Browse files Browse the repository at this point in the history
Shows the "DisplayName" if it is present and not the same
as the foundName in the contact selection dialog.
  • Loading branch information
tobiasge committed Nov 27, 2015
1 parent 5847a8d commit 700fa80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cgeo-contacts/src/cgeo/contacts/ContactsActivity.java
Expand Up @@ -111,7 +111,7 @@ private void openContactAndFinish(final int id) {

@NonNull
private List<Pair<Integer, String>> getContacts(final @NonNull String searchName, final Uri uri, final @NonNull String idColumnName, final @NonNull String selectionColumnName, final boolean like) {
final String[] projection = new String[] { idColumnName, selectionColumnName };
final String[] projection = new String[] { idColumnName, selectionColumnName, ContactsContract.Contacts.DISPLAY_NAME };
final String selection = selectionColumnName + (like ? " LIKE" : " =") + " ? COLLATE NOCASE";
final String[] selectionArgs = new String[] { like ? "%" + searchName + "%" : searchName };
Cursor cursor = null;
Expand All @@ -122,7 +122,9 @@ private List<Pair<Integer, String>> getContacts(final @NonNull String searchName
while (cursor != null && cursor.moveToNext()) {
final int foundId = cursor.getInt(0);
final String foundName = cursor.getString(1);
result.add(new Pair<>(foundId, foundName));
final String displayName = cursor.getString(2);
result.add(new Pair<>(foundId, StringUtils.isNotEmpty(displayName) &&
!StringUtils.equalsIgnoreCase(foundName, displayName) ? foundName + " (" + displayName + ")" : foundName));
}
} catch (final Exception e) {
Log.e(LOG_TAG, "ContactsActivity.getContactId", e);
Expand Down

0 comments on commit 700fa80

Please sign in to comment.