Correctly load group avatars in RecipientPreferencesActivity

Fixes #7102
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-10-16 10:16:15 -07:00
parent e87aa85bae
commit 7a8bd0597a

View File

@ -216,10 +216,20 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
Uri contentUri = ContactsContract.Contacts.lookupContact(getContentResolver(), recipient.getContactUri()); Uri contentUri = ContactsContract.Contacts.lookupContact(getContentResolver(), recipient.getContactUri());
windowManager.getDefaultDisplay().getMetrics(metrics); windowManager.getDefaultDisplay().getMetrics(metrics);
if (recipient.isGroupRecipient()) {
Optional<GroupDatabase.GroupRecord> groupRecord = DatabaseFactory.getGroupDatabase(RecipientPreferenceActivity.this).getGroup(recipient.getAddress().toGroupString());
if (groupRecord.isPresent() && groupRecord.get().getAvatar() != null) {
return ContactPhotoFactory.getGroupContactPhoto(groupRecord.get().getAvatar());
} else {
return ContactPhotoFactory.getDefaultGroupPhoto();
}
} else {
return ContactPhotoFactory.getContactPhoto(RecipientPreferenceActivity.this, contentUri, return ContactPhotoFactory.getContactPhoto(RecipientPreferenceActivity.this, contentUri,
recipient.getAddress(), recipient.getName(), recipient.getAddress(), recipient.getName(),
metrics.widthPixels); metrics.widthPixels);
} }
}
protected void onPostExecute(@NonNull ContactPhoto contactPhoto) { protected void onPostExecute(@NonNull ContactPhoto contactPhoto) {
if (contactPhoto.isGenerated() || contactPhoto.isResource()) avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE); if (contactPhoto.isGenerated() || contactPhoto.isResource()) avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);