diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt index 771001cca..17486dc82 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt @@ -157,10 +157,10 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt index 53f6506a6..d450213b9 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt @@ -135,10 +135,10 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) : } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt index 69c6e6c29..e5ba4f2d8 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt @@ -35,6 +35,7 @@ import com.nextcloud.talk.extensions.loadChangelogBotAvatar import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils +import com.nextcloud.talk.utils.ChatMessageUtils import com.nextcloud.talk.utils.DateUtils import com.nextcloud.talk.utils.UriUtils import com.nextcloud.talk.utils.message.MessageUtils @@ -119,10 +120,10 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) } @@ -131,16 +132,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : } if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { - binding.messageUserAvatar.visibility = View.VISIBLE - if (message.actorType == "guests") { - // do nothing, avatar is set - } else if (message.actorType == "bots" && message.actorId == "changelog") { - binding.messageUserAvatar.loadChangelogBotAvatar() - } else if (message.actorType == "bots") { - binding.messageUserAvatar.loadBotsAvatar() - } else if (message.actorType == "federated_users") { - binding.messageUserAvatar.loadFederatedUserAvatar(message) - } + ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils) } else { if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt index 59b626df8..56b0936bc 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt @@ -142,10 +142,10 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt index b3565de23..2a587270c 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt @@ -144,10 +144,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt index 36155bf09..9413e1720 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt @@ -238,10 +238,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : } private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { - val author: String = message.actorDisplayName!! - if (!TextUtils.isEmpty(author)) { + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { binding.messageAuthor.visibility = View.VISIBLE - binding.messageAuthor.text = author + binding.messageAuthor.text = actorName binding.messageUserAvatar.setOnClickListener { (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) }