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) {
|
participantDisplayItem.getActorType() == Participant.ActorType.EMAILS) {
|
||||||
ImageViewExtensionsKt.loadFirstLetterAvatar(
|
ImageViewExtensionsKt.loadFirstLetterAvatar(
|
||||||
imageView,
|
imageView,
|
||||||
String.valueOf(participantDisplayItem.getNick().charAt(0))
|
String.valueOf(participantDisplayItem.getNick())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
|
ImageViewExtensionsKt.loadAvatarWithUrl(imageView,null, participantDisplayItem.getUrlForAvatar());
|
||||||
|
|
|
@ -211,12 +211,11 @@ class ParticipantItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
|
Participant.ActorType.GUESTS, Participant.ActorType.EMAILS -> {
|
||||||
if (model.displayName.isNullOrEmpty()) {
|
val actorName = model.displayName
|
||||||
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
if (!actorName.isNullOrBlank()) {
|
||||||
|
holder.binding.avatarView.loadFirstLetterAvatar(actorName)
|
||||||
} else {
|
} else {
|
||||||
holder.binding.avatarView.loadFirstLetterAvatar(
|
holder.binding.avatarView.loadDefaultAvatar(viewThemeUtils)
|
||||||
model.displayName!!.first().toString()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
val layers = arrayOfNulls<Drawable>(2)
|
||||||
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
|
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 layerDrawable = LayerDrawable(layers)
|
||||||
val data: Any = layerDrawable
|
val data: Any = layerDrawable
|
||||||
|
|
|
@ -21,8 +21,9 @@ class ChatMessageUtils {
|
||||||
fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) {
|
fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) {
|
||||||
view.visibility = View.VISIBLE
|
view.visibility = View.VISIBLE
|
||||||
if (message.actorType == "guests" || message.actorType == "emails") {
|
if (message.actorType == "guests" || message.actorType == "emails") {
|
||||||
if (message.actorDisplayName?.isNotEmpty() == true) {
|
val actorName = message.actorDisplayName
|
||||||
view.loadFirstLetterAvatar(message.actorDisplayName?.first().toString())
|
if (!actorName.isNullOrBlank()) {
|
||||||
|
view.loadFirstLetterAvatar(actorName)
|
||||||
} else {
|
} else {
|
||||||
view.loadDefaultAvatar(viewThemeUtils)
|
view.loadDefaultAvatar(viewThemeUtils)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue