Explorar o código

fix empty guest names for chat viewholders

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe hai 7 meses
pai
achega
b5a84b4a3f

+ 3 - 3
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)
             }

+ 3 - 3
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)
             }

+ 5 - 13
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

+ 3 - 3
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)
             }

+ 3 - 3
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)
             }

+ 3 - 3
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)
             }