aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-27 14:07:08 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-27 14:07:08 +0100
commit3c59b2958f2ec2d707a9e7af10ecd5be7ae3d2a4 (patch)
tree9d6c2ce89bdeed7b62c247d22af0bf110b5e2383 /src/main/java/de/pixart/messenger/entities
parenta53f01ed7adaf3cd0e39c3c313d3427b2f978f2f (diff)
refactored avatar workers into single class
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Account.java9
-rw-r--r--src/main/java/de/pixart/messenger/entities/Bookmark.java5
-rw-r--r--src/main/java/de/pixart/messenger/entities/Contact.java5
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java9
-rw-r--r--src/main/java/de/pixart/messenger/entities/ListItem.java3
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java13
6 files changed, 40 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java
index 2c7dbfbdc..3ebb1fafa 100644
--- a/src/main/java/de/pixart/messenger/entities/Account.java
+++ b/src/main/java/de/pixart/messenger/entities/Account.java
@@ -29,12 +29,14 @@ import de.pixart.messenger.crypto.OtrService;
import de.pixart.messenger.crypto.PgpDecryptionService;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
+import de.pixart.messenger.services.AvatarService;
import de.pixart.messenger.services.XmppConnectionService;
+import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xmpp.XmppConnection;
import rocks.xmpp.addr.Jid;
-public class Account extends AbstractEntity {
+public class Account extends AbstractEntity implements AvatarService.Avatarable {
public static final String TABLENAME = "accounts";
@@ -616,6 +618,11 @@ public class Account extends AbstractEntity {
return this.getStatus() == State.ONLINE && this.getXmppConnection() != null;
}
+ @Override
+ public int getAvatarBackgroundColor() {
+ return UIHelper.getColorForName(jid.asBareJid().toString());
+ }
+
public enum State {
DISABLED(false, false),
OFFLINE(false),
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java
index e670673dd..0d1f5781d 100644
--- a/src/main/java/de/pixart/messenger/entities/Bookmark.java
+++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java
@@ -186,4 +186,9 @@ public class Bookmark extends Element implements ListItem {
}
return StringUtils.changed(before, name);
}
+
+ @Override
+ public int getAvatarBackgroundColor() {
+ return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
+ }
}
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java
index 3ee636fe4..ad9aeeb13 100644
--- a/src/main/java/de/pixart/messenger/entities/Contact.java
+++ b/src/main/java/de/pixart/messenger/entities/Contact.java
@@ -603,6 +603,11 @@ public class Contact implements ListItem, Blockable {
return Options.SYNCED_VIA_OTHER;
}
+ @Override
+ public int getAvatarBackgroundColor() {
+ return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
+ }
+
public final class Options {
public static final int TO = 0;
public static final int FROM = 1;
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 22c363f3a..ee882ebec 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -30,8 +30,10 @@ import de.pixart.messenger.crypto.OmemoSetting;
import de.pixart.messenger.crypto.PgpDecryptionService;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.persistance.DatabaseBackend;
+import de.pixart.messenger.services.AvatarService;
import de.pixart.messenger.services.QuickConversationsService;
import de.pixart.messenger.utils.JidHelper;
+import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xmpp.chatstate.ChatState;
import de.pixart.messenger.xmpp.mam.MamReference;
import rocks.xmpp.addr.Jid;
@@ -39,7 +41,7 @@ import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.entities.Bookmark.printableValue;
-public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation>, Conversational {
+public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation>, Conversational, AvatarService.Avatarable {
public static final String TABLENAME = "conversations";
public static final int STATUS_AVAILABLE = 0;
@@ -1189,6 +1191,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return 0;
}
+ @Override
+ public int getAvatarBackgroundColor() {
+ return UIHelper.getColorForName(getName().toString());
+ }
+
public interface OnMessageFound {
void onMessageFound(final Message message);
}
diff --git a/src/main/java/de/pixart/messenger/entities/ListItem.java b/src/main/java/de/pixart/messenger/entities/ListItem.java
index 21fb6c2b6..fba37cc4c 100644
--- a/src/main/java/de/pixart/messenger/entities/ListItem.java
+++ b/src/main/java/de/pixart/messenger/entities/ListItem.java
@@ -4,9 +4,10 @@ import android.content.Context;
import java.util.List;
+import de.pixart.messenger.services.AvatarService;
import rocks.xmpp.addr.Jid;
-public interface ListItem extends Comparable<ListItem> {
+public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable {
String getDisplayName();
int getOffline();
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index c5843d840..b32c440a5 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.entities;
import android.content.ContentValues;
import android.database.Cursor;
+import android.graphics.Color;
import android.text.SpannableStringBuilder;
import android.util.Log;
@@ -16,6 +17,7 @@ import java.util.Set;
import de.pixart.messenger.Config;
import de.pixart.messenger.crypto.axolotl.FingerprintStatus;
+import de.pixart.messenger.services.AvatarService;
import de.pixart.messenger.utils.CryptoHelper;
import de.pixart.messenger.utils.Emoticons;
import de.pixart.messenger.utils.GeoHelper;
@@ -25,7 +27,7 @@ import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.utils.XmppUri;
import rocks.xmpp.addr.Jid;
-public class Message extends AbstractEntity {
+public class Message extends AbstractEntity implements AvatarService.Avatarable {
public static final String TABLENAME = "messages";
@@ -633,6 +635,15 @@ public class Message extends AbstractEntity {
return this.counterparts;
}
+ @Override
+ public int getAvatarBackgroundColor() {
+ if (type == Message.TYPE_STATUS && getCounterparts() != null && getCounterparts().size() > 1) {
+ return Color.TRANSPARENT;
+ } else {
+ return UIHelper.getColorForName(UIHelper.getMessageDisplayName(this));
+ }
+ }
+
public static class MergeSeparator {
}