Fix displayname color by power level in reply composer

Change-Id: Iae7f4018c4c467493f240265b75abcea4e01898c
This commit is contained in:
SpiritCroc 2021-11-24 10:30:40 +01:00
parent 0c7cc81830
commit 65602e89c4
2 changed files with 14 additions and 1 deletions

View file

@ -1058,6 +1058,17 @@ class RoomDetailFragment @Inject constructor(
views.composerLayout.views.sendButton.contentDescription = getString(R.string.send)
}
private fun getMemberNameColor(matrixItem: MatrixItem) = matrixItemColorProvider.getColor(
matrixItem,
withState(roomDetailViewModel) {
MatrixItemColorProvider.UserInRoomInformation(
it.isDm(),
it.isPublic(),
it.powerLevelsHelper?.getUserPowerLevelValue(matrixItem.id)
)
}
)
private fun renderSpecialMode(event: TimelineEvent,
@DrawableRes iconRes: Int,
@StringRes descriptionRes: Int,
@ -1066,7 +1077,7 @@ class RoomDetailFragment @Inject constructor(
// switch to expanded bar
views.composerLayout.views.composerRelatedMessageTitle.apply {
text = event.senderInfo.disambiguatedDisplayName
setTextColor(matrixItemColorProvider.getColor(MatrixItem.UserItem(event.root.senderId ?: "@")))
setTextColor(getMemberNameColor(MatrixItem.UserItem(event.root.senderId ?: "@")))
}
val messageContent: MessageContent? = event.getLastMessageContent()

View file

@ -86,4 +86,6 @@ data class RoomDetailViewState(
fun hasActiveJitsiWidget() = activeRoomWidgets()?.any { it.type == WidgetType.Jitsi && it.isActive }.orFalse()
fun isDm() = asyncRoomSummary()?.isDirect == true
fun isPublic() = asyncRoomSummary()?.isPublic == true
}