diff options
Diffstat (limited to 'src/eu/siacs/conversations/entities/Bookmark.java')
-rw-r--r-- | src/eu/siacs/conversations/entities/Bookmark.java | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/eu/siacs/conversations/entities/Bookmark.java b/src/eu/siacs/conversations/entities/Bookmark.java index 1b97c573..6c1d7258 100644 --- a/src/eu/siacs/conversations/entities/Bookmark.java +++ b/src/eu/siacs/conversations/entities/Bookmark.java @@ -2,6 +2,9 @@ package eu.siacs.conversations.entities; import java.util.Locale; +import android.content.Context; +import android.graphics.Bitmap; +import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xml.Element; public class Bookmark implements ListItem { @@ -9,8 +12,9 @@ public class Bookmark implements ListItem { private Account account; private String jid; private String nick; - private String displayName; + private String name; private boolean autojoin; + private Conversation mJoinedConversation; public Bookmark(Account account) { this.account = account; @@ -19,7 +23,7 @@ public class Bookmark implements ListItem { public static Bookmark parse(Element element, Account account) { Bookmark bookmark = new Bookmark(account); bookmark.setJid(element.getAttribute("jid")); - bookmark.setDisplayName(element.getAttribute("name")); + bookmark.setName(element.getAttribute("name")); String autojoin = element.getAttribute("autojoin"); if (autojoin!=null && (autojoin.equals("true")||autojoin.equals("1"))) { bookmark.setAutojoin(true); @@ -37,8 +41,8 @@ public class Bookmark implements ListItem { this.autojoin = autojoin; } - public void setDisplayName(String name) { - this.displayName = name; + public void setName(String name) { + this.name = name; } public void setJid(String jid) { @@ -56,8 +60,10 @@ public class Bookmark implements ListItem { @Override public String getDisplayName() { - if (displayName!=null) { - return displayName; + if (this.mJoinedConversation!=null) { + return this.mJoinedConversation.getName(true); + } else if (name!=null) { + return name; } else { return this.jid.split("@")[0]; } @@ -76,11 +82,6 @@ public class Bookmark implements ListItem { return autojoin; } - @Override - public String getProfilePhoto() { - return null; - } - public boolean match(String needle) { return needle == null || getJid().contains(needle.toLowerCase(Locale.US)) @@ -91,4 +92,21 @@ public class Bookmark implements ListItem { public Account getAccount() { return this.account; } + + @Override + public Bitmap getImage(int dpSize, Context context) { + if (this.mJoinedConversation==null) { + return UIHelper.getContactPicture(getDisplayName(), dpSize, context, false); + } else { + return UIHelper.getContactPicture(this.mJoinedConversation, dpSize, context, false); + } + } + + public void setConversation(Conversation conversation) { + this.mJoinedConversation = conversation; + } + + public String getName() { + return name; + } } |