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/Account.java22
-rw-r--r--src/eu/siacs/conversations/entities/Bookmark.java18
-rw-r--r--src/eu/siacs/conversations/entities/Contact.java22
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java16
-rw-r--r--src/eu/siacs/conversations/entities/ListItem.java5
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java17
-rw-r--r--src/eu/siacs/conversations/entities/Roster.java3
7 files changed, 26 insertions, 77 deletions
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index ff509ba1..80a9d62f 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -14,14 +14,10 @@ import org.json.JSONObject;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.OtrEngine;
-import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.XmppConnection;
import android.content.ContentValues;
-import android.content.Context;
import android.database.Cursor;
-import android.graphics.Bitmap;
import android.os.SystemClock;
public class Account extends AbstractEntity {
@@ -72,7 +68,7 @@ public class Account extends AbstractEntity {
private long mEndGracePeriod = 0L;
private String otrFingerprint;
private Roster roster = null;
-
+
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<Bookmark>();
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<Conversation>();
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<Conversation>();
@@ -345,20 +341,6 @@ public class Account extends AbstractEntity {
return false;
}
- public Bitmap getImage(Context context, int size) {
- if (this.avatar != null) {
- Bitmap bm = FileBackend.getAvatar(this.avatar, size, context);
- if (bm == null) {
- return UIHelper.getContactPicture(getJid(), size, context,
- false);
- } else {
- return bm;
- }
- } else {
- return UIHelper.getContactPicture(getJid(), size, context, false);
- }
- }
-
public boolean setAvatar(String filename) {
if (this.avatar != null && this.avatar.equals(filename)) {
return false;
@@ -401,7 +383,7 @@ public class Account extends AbstractEntity {
return R.string.account_status_unknown;
}
}
-
+
public void activateGracePeriod() {
this.mEndGracePeriod = SystemClock.elapsedRealtime()
+ (Config.CARBON_GRACE_PERIOD * 1000);
diff --git a/src/eu/siacs/conversations/entities/Bookmark.java b/src/eu/siacs/conversations/entities/Bookmark.java
index 722fb6d9..dd9e805c 100644
--- a/src/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/eu/siacs/conversations/entities/Bookmark.java
@@ -2,9 +2,6 @@ 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 extends Element implements ListItem {
@@ -120,21 +117,14 @@ public class Bookmark extends Element implements ListItem {
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 Conversation getConversation() {
+ return this.mJoinedConversation;
+ }
+
public String getName() {
return this.getAttribute("name");
}
diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java
index 40eee73d..60c31a42 100644
--- a/src/eu/siacs/conversations/entities/Contact.java
+++ b/src/eu/siacs/conversations/entities/Contact.java
@@ -8,13 +8,9 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import eu.siacs.conversations.persistance.FileBackend;
-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";
@@ -330,20 +326,6 @@ public class Contact implements ListItem {
}
}
- @Override
- public Bitmap getImage(int size, Context context) {
- if (this.avatar != null) {
- Bitmap bm = FileBackend.getAvatar(avatar, size, context);
- if (bm == null) {
- return UIHelper.getContactPicture(this, size, context, false);
- } else {
- return bm;
- }
- } else {
- return UIHelper.getContactPicture(this, size, context, false);
- }
- }
-
public boolean setAvatar(String filename) {
if (this.avatar != null && this.avatar.equals(filename)) {
return false;
@@ -353,6 +335,10 @@ public class Contact implements ListItem {
}
}
+ public String getAvatar() {
+ return this.avatar;
+ }
+
public boolean deleteOtrFingerprint(String fingerprint) {
boolean success = false;
try {
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index e9500a0c..9d4c36db 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -8,7 +8,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.utils.UIHelper;
import net.java.otr4j.OtrException;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
@@ -17,9 +16,7 @@ import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
import android.content.ContentValues;
-import android.content.Context;
import android.database.Cursor;
-import android.graphics.Bitmap;
import android.os.SystemClock;
public class Conversation extends AbstractEntity {
@@ -329,9 +326,8 @@ public class Conversation extends AbstractEntity {
public synchronized MucOptions getMucOptions() {
if (this.mucOptions == null) {
- this.mucOptions = new MucOptions(this.getAccount());
+ this.mucOptions = new MucOptions(this);
}
- this.mucOptions.setConversation(this);
return this.mucOptions;
}
@@ -428,14 +424,6 @@ public class Conversation extends AbstractEntity {
return this.bookmark;
}
- public Bitmap getImage(Context context, int size) {
- if (mode == MODE_SINGLE) {
- return getContact().getImage(size, context);
- } else {
- return UIHelper.getContactPicture(this, size, context, false);
- }
- }
-
public boolean hasDuplicateMessage(Message message) {
for (int i = this.getMessages().size() - 1; i >= 0; --i) {
if (this.messages.get(i).equals(message)) {
@@ -496,7 +484,7 @@ public class Conversation extends AbstractEntity {
}
}
}
-
+
public void add(Message message) {
message.setConversation(this);
synchronized (this.messages) {
diff --git a/src/eu/siacs/conversations/entities/ListItem.java b/src/eu/siacs/conversations/entities/ListItem.java
index 19089b28..a1872d2f 100644
--- a/src/eu/siacs/conversations/entities/ListItem.java
+++ b/src/eu/siacs/conversations/entities/ListItem.java
@@ -1,12 +1,7 @@
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 Bitmap getImage(int dpSize, Context context);
}
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index 12ea4e93..d7407cd5 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -102,6 +102,10 @@ public class MucOptions {
public long getPgpKeyId() {
return this.pgpKeyId;
}
+
+ public Contact getContact() {
+ return account.getRoster().getContactFromRoster(getJid());
+ }
}
private Account account;
@@ -116,8 +120,9 @@ public class MucOptions {
private String joinnick;
private String password = null;
- public MucOptions(Account account) {
- this.account = account;
+ public MucOptions(Conversation conversation) {
+ this.account = conversation.getAccount();
+ this.conversation = conversation;
}
public void deleteUser(String name) {
@@ -253,10 +258,6 @@ public class MucOptions {
this.joinnick = nick;
}
- public void setConversation(Conversation conversation) {
- this.conversation = conversation;
- }
-
public boolean online() {
return this.isOnline;
}
@@ -361,4 +362,8 @@ public class MucOptions {
conversation
.setAttribute(Conversation.ATTRIBUTE_MUC_PASSWORD, password);
}
+
+ public Conversation getConversation() {
+ return this.conversation;
+ }
} \ No newline at end of file
diff --git a/src/eu/siacs/conversations/entities/Roster.java b/src/eu/siacs/conversations/entities/Roster.java
index ef47c577..3267b15a 100644
--- a/src/eu/siacs/conversations/entities/Roster.java
+++ b/src/eu/siacs/conversations/entities/Roster.java
@@ -15,6 +15,9 @@ public class Roster {
}
public Contact getContactFromRoster(String jid) {
+ if (jid == null) {
+ return null;
+ }
String cleanJid = jid.split("/", 2)[0];
Contact contact = contacts.get(cleanJid);
if (contact != null && contact.showInRoster()) {