From 99ec61e120bec0d3fefc5155a95a720325aaddcd Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 2 Apr 2024 15:11:27 +0200 Subject: [PATCH] Add action to report a user form the message detail bottom sheet. #8796 --- .../ui-strings/src/main/res/values/strings.xml | 3 +++ .../home/room/detail/RoomDetailAction.kt | 3 ++- .../home/room/detail/TimelineFragment.kt | 17 +++++++++++++++++ .../detail/timeline/action/EventSharedAction.kt | 3 +++ .../timeline/action/MessageActionsViewModel.kt | 6 ++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 577101b0d3..2a98069c2e 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -1953,8 +1953,11 @@ "This content was reported as spam.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages." "Reported as inappropriate" "This content was reported as inappropriate.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages." + "Reported user" + "The user has been reported.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages." Ignore user + Report user "All messages (noisy)" "All messages" diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt index 478ed4a58d..30bcf7f8eb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt @@ -61,7 +61,8 @@ sealed class RoomDetailAction : VectorViewModelAction { val senderId: String?, val reason: String, val spam: Boolean = false, - val inappropriate: Boolean = false + val inappropriate: Boolean = false, + val user: Boolean = false, ) : RoomDetailAction() data class IgnoreUser(val userId: String?) : RoomDetailAction() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index feaad386cb..f80855663f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -1345,6 +1345,16 @@ class TimelineFragment : } .show() } + data.user -> { + MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive) + .setTitle(R.string.user_reported_as_inappropriate_title) + .setMessage(R.string.user_reported_as_inappropriate_content) + .setPositiveButton(R.string.ok, null) + .setNegativeButton(R.string.block_user) { _, _ -> + timelineViewModel.handle(RoomDetailAction.IgnoreUser(data.senderId)) + } + .show() + } else -> { MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive) .setTitle(R.string.content_reported_title) @@ -1857,6 +1867,13 @@ class TimelineFragment : is EventSharedAction.IgnoreUser -> { action.senderId?.let { askConfirmationToIgnoreUser(it) } } + is EventSharedAction.ReportUser -> { + timelineViewModel.handle( + RoomDetailAction.ReportContent( + action.eventId, action.senderId, "Reporting user ${action.senderId}", user = true + ) + ) + } is EventSharedAction.OnUrlClicked -> { onUrlClicked(action.url, action.title) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/EventSharedAction.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/EventSharedAction.kt index 7bf9f536f2..18ff638390 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/EventSharedAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/EventSharedAction.kt @@ -98,6 +98,9 @@ sealed class EventSharedAction( data class IgnoreUser(val senderId: String?) : EventSharedAction(R.string.message_ignore_user, R.drawable.ic_alert_triangle, true) + data class ReportUser(val eventId: String, val senderId: String?) : + EventSharedAction(R.string.message_report_user, R.drawable.ic_flag, true) + data class QuickReact(val eventId: String, val clickedOn: String, val add: Boolean) : EventSharedAction(0, 0) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 62aed5c3c6..8809c4f0bf 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -430,6 +430,12 @@ class MessageActionsViewModel @AssistedInject constructor( add(EventSharedAction.Separator) add(EventSharedAction.IgnoreUser(timelineEvent.root.senderId)) + add( + EventSharedAction.ReportUser( + eventId = eventId, + senderId = timelineEvent.root.senderId, + ) + ) } }