From 833fcd10ab28d783a039c3785eb24c4799f2c83b Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 11 May 2015 01:18:11 -0700 Subject: [PATCH] Fix for when a stored contact's name field is empty. Display # instead of + in the avatar. Closes #3141 // FREEBIE --- .../thoughtcrime/securesms/contacts/ContactPhotoFactory.java | 2 +- .../thoughtcrime/securesms/recipients/RecipientProvider.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/contacts/ContactPhotoFactory.java b/src/org/thoughtcrime/securesms/contacts/ContactPhotoFactory.java index a3ae382e43..93c418f144 100644 --- a/src/org/thoughtcrime/securesms/contacts/ContactPhotoFactory.java +++ b/src/org/thoughtcrime/securesms/contacts/ContactPhotoFactory.java @@ -62,7 +62,7 @@ public class ContactPhotoFactory { .height(targetSize) .endConfig() .buildRound(String.valueOf(name.charAt(0)), - COLOR_GENERATOR.getColor(name)); + COLOR_GENERATOR.getColor(name)); } synchronized (defaultPhotoLock) { diff --git a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java index 4f70437b5d..02866c00c9 100644 --- a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java +++ b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java @@ -133,9 +133,10 @@ public class RecipientProvider { try { if (cursor != null && cursor.moveToFirst()) { Uri contactUri = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1)); + String name = cursor.getString(3).equals(cursor.getString(0)) ? null : cursor.getString(0); Drawable contactPhoto = ContactPhotoFactory.getContactPhoto(context, - Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2)+""), - cursor.getString(0)); + Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""), + name); return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto); } } finally {