From 09abab6ce371c7bae2977edc38f53a74eca99f7c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 15 Apr 2022 14:12:57 +0200 Subject: [PATCH] Add a picto for ignored users in the room member list screen (#5764) --- changelog.d/5774.misc | 1 + .../core/epoxy/profiles/ProfileMatrixItem.kt | 1 + .../ProfileMatrixItemWithPowerLevel.kt | 2 ++ .../members/RoomMemberListController.kt | 1 + .../members/RoomMemberListViewModel.kt | 11 +++++++++++ .../members/RoomMemberListViewState.kt | 1 + .../res/layout/item_profile_matrix_item.xml | 18 ++++++++++++++++-- 7 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 changelog.d/5774.misc diff --git a/changelog.d/5774.misc b/changelog.d/5774.misc new file mode 100644 index 0000000000..795106381b --- /dev/null +++ b/changelog.d/5774.misc @@ -0,0 +1 @@ +Add a picto for ignored users in the room member list screen \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItem.kt index 0af342641e..90e81ceb26 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItem.kt @@ -32,6 +32,7 @@ abstract class ProfileMatrixItem : BaseProfileMatrixItem(R.id.matrixItemTitle) val subtitleView by bind(R.id.matrixItemSubtitle) + val ignoredUserView by bind(R.id.matrixItemIgnored) val powerLabel by bind(R.id.matrixItemPowerLevelLabel) val presenceImageView by bind(R.id.matrixItemPresenceImageView) val avatarImageView by bind(R.id.matrixItemAvatar) diff --git a/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItemWithPowerLevel.kt b/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItemWithPowerLevel.kt index 12189dc8f4..453f402496 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItemWithPowerLevel.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/profiles/ProfileMatrixItemWithPowerLevel.kt @@ -26,11 +26,13 @@ import im.vector.app.core.extensions.setTextOrHide @EpoxyModelClass(layout = R.layout.item_profile_matrix_item) abstract class ProfileMatrixItemWithPowerLevel : ProfileMatrixItem() { + @EpoxyAttribute var ignoredUser: Boolean = false @EpoxyAttribute var powerLevelLabel: CharSequence? = null override fun bind(holder: Holder) { super.bind(holder) holder.editableView.isVisible = false + holder.ignoredUserView.isVisible = ignoredUser holder.powerLabel.setTextOrHide(powerLevelLabel) } } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListController.kt index 07236fb397..ebcebfa470 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListController.kt @@ -133,6 +133,7 @@ class RoomMemberListController @Inject constructor( } showPresence(true) userPresence(roomMember.userPresence) + ignoredUser(roomMember.userId in data.ignoredUserIds) powerLevelLabel( span { span(powerLabel) { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewModel.kt index 1adf35a098..7a9dcb7178 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewModel.kt @@ -69,6 +69,7 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState observeThirdPartyInvites() observeRoomSummary() observePowerLevel() + observeIgnoredUsers() } private fun observeRoomMemberSummaries() { @@ -148,6 +149,16 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState } } + private fun observeIgnoredUsers() { + session.flow() + .liveIgnoredUsers() + .execute { async -> + copy( + ignoredUserIds = async.invoke().orEmpty().map { it.userId } + ) + } + } + private fun buildRoomMemberSummaries(powerLevelsContent: PowerLevelsContent, roomMembers: List): RoomMemberSummaries { val admins = ArrayList() val moderators = ArrayList() diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewState.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewState.kt index 93ed7fa719..47a89b523a 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewState.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListViewState.kt @@ -32,6 +32,7 @@ data class RoomMemberListViewState( val roomId: String, val roomSummary: Async = Uninitialized, val roomMemberSummaries: Async = Uninitialized, + val ignoredUserIds: List = emptyList(), val filter: String = "", val threePidInvites: Async> = Uninitialized, val trustLevelMap: Async> = Uninitialized, diff --git a/vector/src/main/res/layout/item_profile_matrix_item.xml b/vector/src/main/res/layout/item_profile_matrix_item.xml index c9354dec9a..85e3c2babb 100644 --- a/vector/src/main/res/layout/item_profile_matrix_item.xml +++ b/vector/src/main/res/layout/item_profile_matrix_item.xml @@ -64,7 +64,7 @@ android:textColor="?vctr_content_primary" app:layout_constrainedWidth="true" app:layout_constraintBottom_toTopOf="@id/matrixItemSubtitle" - app:layout_constraintEnd_toStartOf="@id/matrixItemPowerLevelLabel" + app:layout_constraintEnd_toStartOf="@id/matrixItemIgnored" app:layout_constraintStart_toEndOf="@id/matrixItemAvatarDecoration" app:layout_constraintTop_toTopOf="parent" app:layout_goneMarginEnd="80dp" @@ -83,12 +83,26 @@ android:textColor="?vctr_content_secondary" app:layout_constrainedWidth="true" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/matrixItemPowerLevelLabel" + app:layout_constraintEnd_toStartOf="@id/matrixItemIgnored" app:layout_constraintStart_toEndOf="@id/matrixItemAvatar" app:layout_constraintTop_toBottomOf="@id/matrixItemTitle" app:layout_goneMarginEnd="8dp" tools:text="@sample/users.json/data/id" /> + +