diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java index df49f5293..4bb634b54 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java @@ -20,6 +20,7 @@ package com.nextcloud.talk.adapters.items; +import android.annotation.SuppressLint; import android.view.View; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.model.GlideUrl; @@ -30,6 +31,7 @@ import com.nextcloud.talk.R; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.utils.ApiUtils; +import com.nextcloud.talk.utils.DisplayUtils; import com.nextcloud.talk.utils.glide.GlideApp; import eu.davidea.flexibleadapter.FlexibleAdapter; import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; @@ -82,6 +84,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem adapter, UserItem.UserItemViewHolder holder, int position, List payloads) { @@ -89,31 +92,39 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem 0) { for (String key : messageParameters.keySet()) { Map individualHashMap = message.getMessageParameters().get(key); - if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) { - int color; + if (individualHashMap != null) { + if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) { + int color; + + if (individualHashMap.get("id").equals(message.getActiveUserId())) { + color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color + .nc_incoming_text_mention_you); + } else { + color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color + .nc_incoming_text_mention_others); + } + + messageString = DisplayUtils.searchAndColor(message.getText(), "@" + individualHashMap.get("name"), color); + } else if (individualHashMap.get("type").equals("file")) { + itemView.setOnClickListener(v -> { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link"))); + context.startActivity(browserIntent); + }); - if (individualHashMap.get("id").equals(message.getActiveUserId())) { - color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color - .nc_incoming_text_mention_you); - } else { - color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color - .nc_incoming_text_mention_others); } - - messageString = DisplayUtils.searchAndColor(message.getText(), "@" + individualHashMap.get("name"), color); - } else if (individualHashMap.get("type").equals("file")) { - itemView.setOnClickListener(v -> { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link"))); - context.startActivity(browserIntent); - }); - } } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.java index da3dd2c52..559ab5d09 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.java @@ -88,20 +88,22 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin if (messageParameters != null && messageParameters.size() > 0) { for (String key : messageParameters.keySet()) { Map individualHashMap = message.getMessageParameters().get(key); - if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) { - if (!individualHashMap.get("id").equals(message.getActiveUserId())) { - messageString = - DisplayUtils.searchAndColor(message.getText(), - "@" + individualHashMap.get("name"), NextcloudTalkApplication - .getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default)); + if (individualHashMap != null) { + if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) { + if (!individualHashMap.get("id").equals(message.getActiveUserId())) { + messageString = + DisplayUtils.searchAndColor(message.getText(), + "@" + individualHashMap.get("name"), NextcloudTalkApplication + .getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default)); + } + + } else if (individualHashMap.get("type").equals("file")) { + itemView.setOnClickListener(v -> { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link"))); + context.startActivity(browserIntent); + }); + } - - } else if (individualHashMap.get("type").equals("file")) { - itemView.setOnClickListener(v -> { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link"))); - context.startActivity(browserIntent); - }); - } } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicSystemMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicSystemMessageViewHolder.java index 7d11602e1..0f09ab820 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicSystemMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/MagicSystemMessageViewHolder.java @@ -59,7 +59,7 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes for (String key : message.getMessageParameters().keySet()) { Map individualHashMap = message.getMessageParameters().get(key); int color; - if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) { + if (individualHashMap != null && (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call"))) { if (individualHashMap.get("id").equals(message.getActiveUserId())) { color = context.getResources().getColor(R.color.nc_incoming_text_mention_you);