diff options
5 files changed, 40 insertions, 17 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 06a72689..20d83961 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -164,8 +164,7 @@ public class ConversationActivity extends XmppActivity { ImageView imageView = (ImageView) view .findViewById(R.id.conversation_image); imageView.setImageBitmap(UIHelper.getContactPicture( - conv.getContact(), conv.getName(useSubject), 200, - activity.getApplicationContext())); + conv, 200, activity.getApplicationContext())); return view; } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 04fb6f92..3796f83e 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -614,7 +614,12 @@ public class ConversationFragment extends Fragment { if (bitmaps.containsKey(name)) { return bitmaps.get(name); } else { - Bitmap bm = UIHelper.getContactPicture(contact, name, 200, context); + Bitmap bm; + if (contact != null){ + bm = UIHelper.getContactPicture(contact, 200, context); + } else { + bm = UIHelper.getContactPicture(name, 200, context); + } bitmaps.put(name, bm); return bm; } diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java index bf36f156..b5ecd796 100644 --- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java @@ -179,7 +179,7 @@ public class MucDetailsActivity extends XmppActivity { role.setText(getReadableRole(contact.getRole())); ImageView imageView = (ImageView) view .findViewById(R.id.contact_photo); - imageView.setImageBitmap(UIHelper.getContactPicture(null,contact.getName(), 90,this.getApplicationContext())); + imageView.setImageBitmap(UIHelper.getContactPicture(contact.getName(), 89,this.getApplicationContext())); membersView.addView(view); } } diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java index 51bad721..3a630485 100644 --- a/src/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java @@ -81,7 +81,9 @@ public class ShareWithActivity extends XmppActivity { } }); for(final Conversation conversation : convList) { - View view = createContactView(conversation.getName(useSubject), conversation.getLatestMessage().getBody().trim(), UIHelper.getContactPicture(conversation.getContact(),conversation.getName(useSubject), 90,this.getApplicationContext())); + View view = createContactView(conversation.getName(useSubject), + conversation.getLatestMessage().getBody().trim(), + UIHelper.getContactPicture(conversation, 90,this.getApplicationContext())); view.setOnClickListener(new OnClickListener() { @Override @@ -115,7 +117,8 @@ public class ShareWithActivity extends XmppActivity { for(int i = 0; i < contactsList.size(); ++i) { final Contact con = contactsList.get(i); - View view = createContactView(con.getDisplayName(), con.getJid(), UIHelper.getContactPicture(con,null, 90,this.getApplicationContext())); + View view = createContactView(con.getDisplayName(), con.getJid(), + UIHelper.getContactPicture(con, 90, this.getApplicationContext())); view.setOnClickListener(new OnClickListener() { @Override diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 0d0e7b91..7654b33f 100644 --- a/src/eu/siacs/conversations/utils/UIHelper.java +++ b/src/eu/siacs/conversations/utils/UIHelper.java @@ -91,23 +91,39 @@ public class UIHelper { return bitmap; } - - public static Bitmap getContactPicture(Contact contact, String fallback, int size, Context context) { - if (contact==null) { - return getUnknownContactPicture(fallback, size); + + public static Bitmap getContactPicture(Conversation conversation, int size, Context context) { + if(conversation.getMode() == Conversation.MODE_SINGLE) { + if (conversation.getContact() != null){ + return getContactPicture(conversation.getContact(), size, context); + } else { + return getContactPicture(conversation.getName(false), size); + } + } else{ + return getContactPicture(conversation.getName(false), size); } + } + + public static Bitmap getContactPicture(Contact contact, int size, Context context) { String uri = contact.getProfilePhoto(); if (uri==null) { - return getUnknownContactPicture(contact.getDisplayName(), size); + return getContactPicture(contact.getDisplayName(), size); } try { Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(Uri.parse(uri))); return Bitmap.createScaledBitmap(bm, size, size, false); } catch (FileNotFoundException e) { - return getUnknownContactPicture(contact.getDisplayName(), size); + return getContactPicture(contact.getDisplayName(), size); } } + public static Bitmap getContactPicture(String name, int size, Context context) { + return getContactPicture(name, size); + } + + public static Bitmap getContactPicture(String name, int size) { + return getUnknownContactPicture(name, size); + } public static Bitmap getErrorPicture(int size) { Bitmap bitmap = Bitmap .createBitmap(size, size, Bitmap.Config.ARGB_8888); @@ -212,7 +228,7 @@ public class UIHelper { } else if (unread.size() == 1) { Conversation conversation = unread.get(0); targetUuid = conversation.getUuid(); - mBuilder.setLargeIcon(UIHelper.getContactPicture(conversation.getContact(), conversation.getName(useSubject), (int) res + mBuilder.setLargeIcon(UIHelper.getContactPicture(conversation, (int) res .getDimension(android.R.dimen.notification_large_icon_width), context)); mBuilder.setContentTitle(conversation.getName(useSubject)); if (notify) { @@ -313,7 +329,7 @@ public class UIHelper { long id = Long.parseLong(systemAccount[0]); badge.assignContactUri(Contacts.getLookupUri(id, systemAccount[1])); } - badge.setImageBitmap(UIHelper.getContactPicture(contact, "", 400, context)); + badge.setImageBitmap(UIHelper.getContactPicture(contact, 400, context)); } public static AlertDialog getVerifyFingerprintDialog( @@ -357,12 +373,12 @@ public class UIHelper { return BitmapFactory.decodeStream(activity .getContentResolver().openInputStream(selfiUri)); } catch (FileNotFoundException e) { - return getUnknownContactPicture(account.getJid(), size); + return getContactPicture(account.getJid(), size); } } - return getUnknownContactPicture(account.getJid(), size); + return getContactPicture(account.getJid(), size); } else { - return getUnknownContactPicture(account.getJid(), size); + return getContactPicture(account.getJid(), size); } } } |