diff --git a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java index 2275a7f7d..c6c49773d 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java @@ -148,7 +148,7 @@ public class ParticipantsAdapter extends BaseAdapter { participantDisplayItem.getActorType() == Participant.ActorType.EMAILS) { ImageViewExtensionsKt.loadFirstLetterAvatar( imageView, - String.valueOf(participantDisplayItem.getNick().charAt(0)) + String.valueOf(participantDisplayItem.getNick()) ); } else { ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar()); diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt index 4b58041ab..b0f30402e 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt @@ -211,12 +211,11 @@ class ParticipantItem( } Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> { - if (model.displayName.isNullOrEmpty()) { - holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils) + val actorName = model.displayName + if (!actorName.isNullOrBlank()) { + holder.binding.avatarView.loadFirstLetterAvatar(actorName) } else { - holder.binding.avatarView.loadFirstLetterAvatar( - model.displayName!!.first().toString() - ) + holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils) } } diff --git a/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt b/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt index 1d70a986c..9411756c0 100644 --- a/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt +++ b/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt @@ -305,10 +305,10 @@ fun ImageView.loadNoteToSelfAvatar(): io.reactivex.disposables.Disposable { ) } -fun ImageView.loadFirstLetterAvatar(letter: String): io.reactivex.disposables.Disposable { +fun ImageView.loadFirstLetterAvatar(name: String): io.reactivex.disposables.Disposable { val layers = arrayOfNulls(2) layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background) - layers[1] = createTextDrawable(context, letter.uppercase(Locale.ROOT)) + layers[1] = createTextDrawable(context, name.trimStart().uppercase(Locale.ROOT)) val layerDrawable = LayerDrawable(layers) val data: Any = layerDrawable diff --git a/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt index 92a8827d8..1f0c5e13f 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt @@ -21,8 +21,9 @@ class ChatMessageUtils { fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) { view.visibility = View.VISIBLE if (message.actorType == "guests" || message.actorType == "emails") { - if (message.actorDisplayName?.isNotEmpty() == true) { - view.loadFirstLetterAvatar(message.actorDisplayName?.first().toString()) + val actorName = message.actorDisplayName + if (!actorName.isNullOrBlank()) { + view.loadFirstLetterAvatar(actorName) } else { view.loadDefaultAvatar(viewThemeUtils) }