Display first letter of id if display name is empty

This commit is contained in:
Benoit Marty 2019-12-16 11:08:48 +01:00
parent cecef5b8da
commit 0a0eda3e34
1 changed files with 5 additions and 10 deletions

View File

@ -69,16 +69,11 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
is MatrixItem.UserItem -> ContextCompat.getColor(context, getColorFromUserId(matrixItem.id)) is MatrixItem.UserItem -> ContextCompat.getColor(context, getColorFromUserId(matrixItem.id))
else -> ContextCompat.getColor(context, getColorFromRoomId(matrixItem.id)) else -> ContextCompat.getColor(context, getColorFromRoomId(matrixItem.id))
} }
return if (matrixItem.displayName.isNullOrBlank()) { return TextDrawable.builder()
TextDrawable.builder().buildRound("", avatarColor) .beginConfig()
} else { .bold()
val firstLetter = matrixItem.firstLetterOfDisplayName() .endConfig()
TextDrawable.builder() .buildRound(matrixItem.firstLetterOfDisplayName(), avatarColor)
.beginConfig()
.bold()
.endConfig()
.buildRound(firstLetter, avatarColor)
}
} }
// PRIVATE API ********************************************************************************* // PRIVATE API *********************************************************************************