mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-19 15:14:28 +03:00
fix to handle whitespaces for guest avatars
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
8162a73f7d
commit
b3b525bbc2
4 changed files with 10 additions and 10 deletions
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Drawable>(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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue