From 6013e1653b5979338ae5f05e789f2be3d08a6586 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Wed, 12 Feb 2020 17:57:49 +0300 Subject: [PATCH] Open room member profile from reactions and read receipts. (#990) Open room member profile from reactions and read receipts. Fixes #875 --- CHANGES.md | 1 + .../features/home/room/detail/RoomDetailFragment.kt | 4 ++-- .../detail/readreceipts/DisplayReadReceiptItem.kt | 2 ++ .../readreceipts/DisplayReadReceiptsBottomSheet.kt | 13 ++++++++++++- .../readreceipts/DisplayReadReceiptsController.kt | 7 +++++++ .../detail/timeline/action/EventSharedAction.kt | 2 +- .../timeline/reactions/ReactionInfoSimpleItem.kt | 3 +++ .../timeline/reactions/ViewReactionsBottomSheet.kt | 12 +++++++++++- .../reactions/ViewReactionsEpoxyController.kt | 7 +++++++ .../main/res/layout/item_display_read_receipt.xml | 1 + .../main/res/layout/item_simple_reaction_info.xml | 3 ++- 11 files changed, 49 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1ffa3c7ebe..de558125ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Features ✨: Improvements 🙌: - Show confirmation dialog before deleting a message (#967) + - Open room member profile from reactions list and read receipts list (#875) Other changes: - diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 7303b7ce7f..2fa2243060 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -1045,7 +1045,7 @@ class RoomDetailFragment @Inject constructor( } override fun onAvatarClicked(informationData: MessageInformationData) { - // roomDetailViewModel.handle(RoomDetailAction.RequestVerification(informationData.senderId)) + // roomDetailViewModel.handle(RoomDetailAction.RequestVerification(informationData.userId)) openRoomMemberProfile(informationData.senderId) } @@ -1106,7 +1106,7 @@ class RoomDetailFragment @Inject constructor( private fun handleActions(action: EventSharedAction) { when (action) { is EventSharedAction.OpenUserProfile -> { - openRoomMemberProfile(action.senderId) + openRoomMemberProfile(action.userId) } is EventSharedAction.AddReaction -> { startActivityForResult(EmojiReactionPickerActivity.intent(requireContext(), action.eventId), REACTION_SELECT_REQUEST_CODE) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptItem.kt index 6bc93f28dc..589be112dc 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptItem.kt @@ -33,6 +33,7 @@ abstract class DisplayReadReceiptItem : EpoxyModelWithHolder Unit)? = null override fun bind(holder: Holder) { avatarRenderer.render(matrixItem, holder.avatarView) @@ -43,6 +44,7 @@ abstract class DisplayReadReceiptItem : EpoxyModelWithHolder>() { + var listener: Listener? = null + override fun buildModels(readReceipts: List) { readReceipts.forEach { val timestamp = dateFormatter.formatRelativeDateTime(it.timestamp) @@ -40,7 +42,12 @@ class DisplayReadReceiptsController @Inject constructor(private val dateFormatte .matrixItem(it.toMatrixItem()) .avatarRenderer(avatarRender) .timestamp(timestamp) + .userClicked { listener?.didSelectUser(it.userId) } .addIf(session.myUserId != it.userId, this) } } + + interface Listener { + fun didSelectUser(userId: String) + } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/EventSharedAction.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/EventSharedAction.kt index 033199c88b..8a8766c3ef 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/EventSharedAction.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/EventSharedAction.kt @@ -28,7 +28,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int, object Separator : EventSharedAction(0, 0) - data class OpenUserProfile(val senderId: String) : + data class OpenUserProfile(val userId: String) : EventSharedAction(0, 0) data class AddReaction(val eventId: String) : diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ReactionInfoSimpleItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ReactionInfoSimpleItem.kt index 39392324aa..71855bfaf8 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ReactionInfoSimpleItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ReactionInfoSimpleItem.kt @@ -36,6 +36,8 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder Unit)? = null override fun bind(holder: Holder) { holder.emojiReactionView.text = reactionKey @@ -46,6 +48,7 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder() { + var listener: Listener? = null + override fun buildModels(state: DisplayReactionsViewState) { when (state.mapReactionKeyToMemberList) { is Incomplete -> { @@ -55,9 +57,14 @@ class ViewReactionsEpoxyController @Inject constructor( timeStamp(it.timestamp) reactionKey(emojiCompatWrapper.safeEmojiSpanify(it.reactionKey)) authorDisplayName(it.authorName ?: it.authorId) + userClicked { listener?.didSelectUser(it.authorId) } } } } } } + + interface Listener { + fun didSelectUser(userId: String) + } } diff --git a/vector/src/main/res/layout/item_display_read_receipt.xml b/vector/src/main/res/layout/item_display_read_receipt.xml index 2aa4485c4e..c78aaaed2b 100644 --- a/vector/src/main/res/layout/item_display_read_receipt.xml +++ b/vector/src/main/res/layout/item_display_read_receipt.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:foreground="?attr/selectableItemBackground" android:gravity="center_vertical" android:minHeight="40dp" android:orientation="horizontal" diff --git a/vector/src/main/res/layout/item_simple_reaction_info.xml b/vector/src/main/res/layout/item_simple_reaction_info.xml index 02a36fc6d0..0f1bc2e497 100644 --- a/vector/src/main/res/layout/item_simple_reaction_info.xml +++ b/vector/src/main/res/layout/item_simple_reaction_info.xml @@ -3,10 +3,11 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:foreground="?attr/selectableItemBackground" android:gravity="center_vertical" + android:minHeight="40dp" android:orientation="horizontal" android:paddingStart="8dp" - android:minHeight="40dp" android:paddingEnd="8dp">