aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r--src/eu/siacs/conversations/entities/Bookmark.java40
-rw-r--r--src/eu/siacs/conversations/entities/Contact.java8
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java9
-rw-r--r--src/eu/siacs/conversations/entities/ListItem.java5
4 files changed, 50 insertions, 12 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;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java
index fc990274..8f8e38a5 100644
--- a/src/eu/siacs/conversations/entities/Contact.java
+++ b/src/eu/siacs/conversations/entities/Contact.java
@@ -8,9 +8,12 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xml.Element;
import android.content.ContentValues;
+import android.content.Context;
import android.database.Cursor;
+import android.graphics.Bitmap;
public class Contact implements ListItem {
public static final String TABLENAME = "contacts";
@@ -311,4 +314,9 @@ public class Contact implements ListItem {
return null;
}
}
+
+ @Override
+ public Bitmap getImage(int dpSize, Context context) {
+ return UIHelper.getContactPicture(this, dpSize, context, false);
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index fbd87f3f..8e2c1784 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -144,6 +144,8 @@ public class Conversation extends AbstractEntity {
if ((getMode() == MODE_MULTI) && (getMucOptions().getSubject() != null)
&& useSubject) {
return getMucOptions().getSubject();
+ } else if (getMode() == MODE_MULTI && bookmark!=null && bookmark.getName() != null) {
+ return bookmark.getName();
} else {
return this.getContact().getDisplayName();
}
@@ -380,5 +382,12 @@ public class Conversation extends AbstractEntity {
public void setBookmark(Bookmark bookmark) {
this.bookmark = bookmark;
+ this.bookmark.setConversation(this);
+ }
+
+ public void deregisterWithBookmark() {
+ if (this.bookmark != null) {
+ this.bookmark.setConversation(null);
+ }
}
}
diff --git a/src/eu/siacs/conversations/entities/ListItem.java b/src/eu/siacs/conversations/entities/ListItem.java
index ba47dff2..c89c85d9 100644
--- a/src/eu/siacs/conversations/entities/ListItem.java
+++ b/src/eu/siacs/conversations/entities/ListItem.java
@@ -1,7 +1,10 @@
package eu.siacs.conversations.entities;
+import android.content.Context;
+import android.graphics.Bitmap;
+
public interface ListItem extends Comparable<ListItem> {
public String getDisplayName();
public String getJid();
- public String getProfilePhoto();
+ public Bitmap getImage(int dpSize, Context context);
}