浏览代码

show simple person icon when conversation-info when guest did not set any name

However this is only possible for the conversation info.
In other parts, the info if a guest changed the name or not is not available (like in the chat or in autocomplete)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 8 月之前
父节点
当前提交
b71218973e

+ 7 - 16
app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt

@@ -21,10 +21,10 @@ import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHold
 import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
 import com.nextcloud.talk.data.user.model.User
 import com.nextcloud.talk.databinding.RvItemConversationInfoParticipantBinding
+import com.nextcloud.talk.extensions.loadDefaultAvatar
 import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
 import com.nextcloud.talk.extensions.loadFederatedUserAvatar
 import com.nextcloud.talk.extensions.loadGuestAvatar
-import com.nextcloud.talk.extensions.loadMailAvatar
 import com.nextcloud.talk.extensions.loadUserAvatar
 import com.nextcloud.talk.models.domain.ConversationModel
 import com.nextcloud.talk.models.json.participants.Participant
@@ -173,6 +173,7 @@ class ParticipantItem(
         }
     }
 
+    @SuppressLint("StringFormatInvalid")
     private fun showCallIcons(holder: ParticipantItemViewHolder) {
         val resources = sharedApplication!!.resources
         val inCallFlag = model.inCall
@@ -205,26 +206,16 @@ class ParticipantItem(
                 holder.binding.avatarView.loadDefaultGroupCallAvatar(viewThemeUtils)
             }
 
-            Participant.ActorType.EMAILS -> {
-                model.displayName?.let {
-                    if (TextUtils.isEmpty(it)) {
-                        holder.binding.avatarView.loadMailAvatar(viewThemeUtils)
-                    } else {
-                        holder.binding.avatarView.loadGuestAvatar(user, it, false)
-                    }
-                }
-            }
-
             Participant.ActorType.USERS -> {
                 holder.binding.avatarView.loadUserAvatar(user, model.calculatedActorId!!, true, false)
             }
 
-            Participant.ActorType.GUESTS -> {
-                var displayName: String? = sharedApplication!!.resources.getString(R.string.nc_guest)
-                if (!TextUtils.isEmpty(model.displayName)) {
-                    displayName = model.displayName
+            Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
+                if (model.displayName.isNullOrEmpty()) {
+                    holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
+                } else {
+                    holder.binding.avatarView.loadGuestAvatar(user, model.displayName!!, false)
                 }
-                holder.binding.avatarView.loadGuestAvatar(user, displayName!!, false)
             }
 
             Participant.ActorType.FEDERATED -> {

+ 9 - 0
app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt

@@ -320,6 +320,15 @@ fun ImageView.loadDefaultGroupCallAvatar(viewThemeUtils: ViewThemeUtils): io.rea
     return loadUserAvatar(data)
 }
 
+fun ImageView.loadDefaultAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
+    val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+        viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.account_circle_96dp) as Any
+    } else {
+        R.drawable.account_circle_96dp
+    }
+    return loadUserAvatar(data)
+}
+
 fun ImageView.loadDefaultPublicCallAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
     val data: Any = viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.ic_avatar_link) as Any
     return loadUserAvatar(data)