add support for group mentions

Resolves #2860

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2023-04-18 11:53:24 +02:00 committed by Marcel Hibbe
parent 62e8b1a9ba
commit 12a9f9b159
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 13 additions and 7 deletions

View File

@ -58,6 +58,8 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
public static final String SOURCE_CALLS = "calls";
public static final String SOURCE_GUESTS = "guests";
public static final String SOURCE_GROUPS = "groups";
private String source;
private final String objectId;
private final String displayName;
@ -153,7 +155,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
holder.binding.secondaryText.setText("@" + objectId);
}
if (SOURCE_CALLS.equals(source)) {
if (SOURCE_CALLS.equals(source) || SOURCE_GROUPS.equals(source)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ImageViewExtensionsKt.loadAvatar(
holder.binding.avatarView,

View File

@ -226,7 +226,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
val individualHashMap = message.messageParameters!![key]
if (individualHashMap != null) {
when (individualHashMap["type"]) {
"user", "guest", "call" -> {
"user", "guest", "call", "user-group" -> {
val chip = if (individualHashMap["id"] == message.activeUser!!.userId) {
R.xml.chip_you
} else {

View File

@ -190,7 +190,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
val individualHashMap: HashMap<String?, String?>? = message.messageParameters!![key]
if (individualHashMap != null) {
when (individualHashMap["type"]) {
"user", "guest", "call" -> {
"user", "guest", "call", "user-group" -> {
val chip = if (individualHashMap["id"] == message.activeUser!!.userId) {
R.xml.chip_you
} else {

View File

@ -2188,7 +2188,10 @@ class ChatActivity :
for (i in mentionSpans.indices) {
mentionSpan = mentionSpans[i]
var mentionId = mentionSpan.id
if (mentionId.contains(" ") || mentionId.startsWith("guest/")) {
if (mentionId.contains(" ") ||
mentionId.startsWith("guest/") ||
mentionId.startsWith("group/")
) {
mentionId = "\"" + mentionId + "\""
}
editable.replace(editable.getSpanStart(mentionSpan), editable.getSpanEnd(mentionSpan), "@$mentionId")

View File

@ -182,9 +182,10 @@ public class DisplayUtils {
int drawable;
boolean isCall = "call".equals(type) || "calls".equals(type);
boolean isCallOrGroup =
"call".equals(type) || "calls".equals(type) || "groups".equals(type) || "user-group".equals(type);
if (!isCall) {
if (!isCallOrGroup) {
if (chipResource == R.xml.chip_you) {
drawable = R.drawable.mention_chip;
} else {
@ -198,7 +199,7 @@ public class DisplayUtils {
chip.setBounds(0, 0, chip.getIntrinsicWidth(), chip.getIntrinsicHeight());
if (!isCall) {
if (!isCallOrGroup) {
String url = ApiUtils.getUrlForAvatar(conversationUser.getBaseUrl(), id, true);
if ("guests".equals(type) || "guest".equals(type)) {
url = ApiUtils.getUrlForGuestAvatar(