From c48499253bcb4c04de053607e3cbecae38189b08 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 31 Aug 2020 13:05:10 +0200 Subject: [PATCH] set content description for all avatars --- .../eu/siacs/conversations/entities/Account.java | 5 +++++ .../eu/siacs/conversations/entities/Bookmark.java | 5 +++++ .../eu/siacs/conversations/entities/Contact.java | 5 +++++ .../siacs/conversations/entities/Conversation.java | 5 +++++ .../eu/siacs/conversations/entities/Message.java | 5 +++++ .../siacs/conversations/entities/MucOptions.java | 5 +++++ .../siacs/conversations/entities/RawBlockable.java | 5 +++++ .../java/eu/siacs/conversations/entities/Room.java | 5 +++++ .../conversations/services/AvatarService.java | 1 + .../conversations/ui/util/AvatarWorkerTask.java | 14 ++++++++++++-- src/main/res/values/strings.xml | 2 ++ 11 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 4b7e424a3..bd6e4e54e 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -615,6 +615,11 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable return UIHelper.getColorForName(jid.asBareJid().toString()); } + @Override + public String getAvatarName() { + throw new IllegalStateException("This method should not be called"); + } + public enum State { DISABLED(false, false), OFFLINE(false), diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java index e55622a06..e04328b1a 100644 --- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java +++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java @@ -248,4 +248,9 @@ public class Bookmark extends Element implements ListItem { public int getAvatarBackgroundColor() { return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName()); } + + @Override + public String getAvatarName() { + return getDisplayName(); + } } diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 07ffbc89c..4d62c2508 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -558,6 +558,11 @@ public class Contact implements ListItem, Blockable { return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName()); } + @Override + public String getAvatarName() { + return getDisplayName(); + } + public boolean hasAvatarOrPresenceName() { return (avatar != null && avatar.getFilename() != null) || presenceName != null; } diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 68ad4d316..1a28ba20e 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -1066,6 +1066,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return UIHelper.getColorForName(getName().toString()); } + @Override + public String getAvatarName() { + return getName().toString(); + } + public interface OnMessageFound { void onMessageFound(final Message message); } diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index a03166685..51a8438db 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -684,6 +684,11 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable } } + @Override + public String getAvatarName() { + return UIHelper.getMessageDisplayName(this); + } + public boolean isOOb() { return oob; } diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 33a62a07f..10caa4620 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -900,5 +900,10 @@ public class MucOptions { final String seed = realJid != null ? realJid.asBareJid().toString() : null; return UIHelper.getColorForName(seed == null ? getName() : seed); } + + @Override + public String getAvatarName() { + return getConversation().getName().toString(); + } } } diff --git a/src/main/java/eu/siacs/conversations/entities/RawBlockable.java b/src/main/java/eu/siacs/conversations/entities/RawBlockable.java index f4fb3346b..664a6a1c9 100644 --- a/src/main/java/eu/siacs/conversations/entities/RawBlockable.java +++ b/src/main/java/eu/siacs/conversations/entities/RawBlockable.java @@ -79,6 +79,11 @@ public class RawBlockable implements ListItem, Blockable { return UIHelper.getColorForName(jid.toEscapedString()); } + @Override + public String getAvatarName() { + return getDisplayName(); + } + @Override public int compareTo(ListItem o) { return this.getDisplayName().compareToIgnoreCase( diff --git a/src/main/java/eu/siacs/conversations/entities/Room.java b/src/main/java/eu/siacs/conversations/entities/Room.java index 551426b6b..9e1d61fc3 100644 --- a/src/main/java/eu/siacs/conversations/entities/Room.java +++ b/src/main/java/eu/siacs/conversations/entities/Room.java @@ -55,6 +55,11 @@ public class Room implements AvatarService.Avatarable, Comparable { return UIHelper.getColorForName(room != null ? room.asBareJid().toEscapedString() : name); } + @Override + public String getAvatarName() { + return name; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 92835b8a9..1b29194e6 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -685,5 +685,6 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { public interface Avatarable { @ColorInt int getAvatarBackgroundColor(); + String getAvatarName(); } } diff --git a/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java b/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java index 4e23f14f1..ad7da7189 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java +++ b/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java @@ -1,5 +1,6 @@ package eu.siacs.conversations.ui.util; +import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; @@ -11,11 +12,10 @@ import android.widget.ImageView; import java.lang.ref.WeakReference; import java.util.concurrent.RejectedExecutionException; +import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.ui.XmppActivity; -import eu.siacs.conversations.ui.adapter.AccountAdapter; -import eu.siacs.conversations.utils.UIHelper; public class AvatarWorkerTask extends AsyncTask { private final WeakReference imageViewReference; @@ -80,6 +80,7 @@ public class AvatarWorkerTask extends AsyncTask avatarWorkerTaskReference; diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 409039203..c04115ff6 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -929,6 +929,8 @@ Could not correct message All conversations This conversation + Your avatar + Avatar for %s View %1$d Participant View %1$d Participants