From 65602e89c427fa0357ac684a0e9c5c94838196a7 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 24 Nov 2021 10:30:40 +0100 Subject: [PATCH] Fix displayname color by power level in reply composer Change-Id: Iae7f4018c4c467493f240265b75abcea4e01898c --- .../features/home/room/detail/RoomDetailFragment.kt | 13 ++++++++++++- .../home/room/detail/RoomDetailViewState.kt | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index b403e2ee03..0946582f6b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -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() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index d67604bee4..ed3114c842 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -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 }