diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.java index a7c0faa65..178c32276 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.java @@ -42,6 +42,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.rooms.Conversation; import com.nextcloud.talk.utils.ApiUtils; +import com.nextcloud.talk.utils.TextMatchers; import com.nextcloud.talk.utils.glide.GlideApp; import org.apache.commons.lang3.StringUtils; @@ -144,38 +145,45 @@ public class ConversationItem extends AbstractFlexibleItem 0) { + for (String key : messageParameters.keySet()) { + Map individualHashMap = messageParameters.get(key); + if (individualHashMap.get("type").equals("file")) { + return true; + } + } + } + + return false; + } + @Nullable @Override public String getImageUrl() { @@ -64,7 +78,8 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent } } - if (getSpecialURLType() != TextMatchers.SpecialURLType.NONE) { + if (!getSpecialURLType().equals(TextMatchers.SpecialURLType.NONE) && + !getSpecialURLType().equals(TextMatchers.SpecialURLType.REGULAR)) { return getMessage().trim(); } @@ -148,6 +163,25 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent return ChatUtils.getParsedMessage(getMessage(), getMessageParameters()); } + public String getLastMessageDisplayText() { + if (getSpecialURLType().equals(TextMatchers.SpecialURLType.NONE)) { + return getText(); + } else { + if (getSpecialURLType().equals(TextMatchers.SpecialURLType.GIPHY) + || getSpecialURLType().equals(TextMatchers.SpecialURLType.TENOR)) { + return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_gif)); + } else if (getSpecialURLType().equals(TextMatchers.SpecialURLType.REGULAR)) { + if (hasFileAttachment()) { + return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_attachment)); + } else { + return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_link)); + } + } + } + + return ""; + } + @Override public IUser getUser() { return new IUser() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 276fe8c69..ff84c2321 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -180,6 +180,9 @@ New messages No messages yet You + sent a link. + sent a GIF. + sent an attachment. No more items to load. Refresh to retry.