Merge pull request #2951 from nextcloud/feature/2860/groupMentions

Group mentions
This commit is contained in:
Andy Scherzinger 2023-04-19 12:51:08 +02:00 committed by GitHub
commit 907012e19a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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(