Add action to block user in the message action bottom sheet (following Nad's design)
This commit is contained in:
parent
f2320f9571
commit
5449592422
@ -96,9 +96,9 @@ import im.vector.riotx.features.home.room.detail.composer.TextComposerViewModel
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerViewState
|
||||
import im.vector.riotx.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet
|
||||
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
|
||||
import im.vector.riotx.features.home.room.detail.timeline.action.EventSharedAction
|
||||
import im.vector.riotx.features.home.room.detail.timeline.action.MessageActionsBottomSheet
|
||||
import im.vector.riotx.features.home.room.detail.timeline.action.MessageSharedActionViewModel
|
||||
import im.vector.riotx.features.home.room.detail.timeline.action.EventSharedAction
|
||||
import im.vector.riotx.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet
|
||||
import im.vector.riotx.features.home.room.detail.timeline.item.*
|
||||
import im.vector.riotx.features.home.room.detail.timeline.reactions.ViewReactionsBottomSheet
|
||||
@ -1142,6 +1142,9 @@ class RoomDetailFragment @Inject constructor(
|
||||
is EventSharedAction.ReportContentCustom -> {
|
||||
promptReasonToReportContent(action)
|
||||
}
|
||||
is EventSharedAction.IgnoreUser -> {
|
||||
roomDetailViewModel.handle(RoomDetailAction.IgnoreUser(action.senderId))
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(context, "Action $action is not implemented yet", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ import im.vector.riotx.core.platform.VectorSharedAction
|
||||
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
|
||||
|
||||
sealed class EventSharedAction(@StringRes val titleRes: Int, @DrawableRes val iconResId: Int) : VectorSharedAction {
|
||||
object Separator :
|
||||
EventSharedAction(0, 0)
|
||||
|
||||
data class AddReaction(val eventId: String) :
|
||||
EventSharedAction(R.string.message_add_reaction, R.drawable.ic_add_reaction)
|
||||
|
||||
@ -74,6 +77,9 @@ sealed class EventSharedAction(@StringRes val titleRes: Int, @DrawableRes val ic
|
||||
data class ReportContentCustom(val eventId: String, val senderId: String?) :
|
||||
EventSharedAction(R.string.report_content_custom, R.drawable.ic_report_custom)
|
||||
|
||||
data class IgnoreUser(val senderId: String?) :
|
||||
EventSharedAction(R.string.message_ignore_user, R.drawable.ic_alert_triangle)
|
||||
|
||||
data class QuickReact(val eventId: String, val clickedOn: String, val add: Boolean) :
|
||||
EventSharedAction(0, 0)
|
||||
|
||||
|
@ -20,12 +20,7 @@ import com.airbnb.epoxy.TypedEpoxyController
|
||||
import com.airbnb.mvrx.Success
|
||||
import im.vector.riotx.EmojiCompatFontProvider
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.BottomSheetItemQuickReactions
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetItemAction
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetItemMessagePreview
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetItemQuickReactions
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetItemSendState
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.bottomSheetItemSeparator
|
||||
import im.vector.riotx.core.epoxy.bottomsheet.*
|
||||
import im.vector.riotx.core.resources.StringProvider
|
||||
import im.vector.riotx.features.home.AvatarRenderer
|
||||
import javax.inject.Inject
|
||||
@ -97,28 +92,35 @@ class MessageActionsEpoxyController @Inject constructor(private val stringProvid
|
||||
|
||||
// Action
|
||||
state.actions()?.forEachIndexed { index, action ->
|
||||
bottomSheetItemAction {
|
||||
id("action_$index")
|
||||
iconRes(action.iconResId)
|
||||
textRes(action.titleRes)
|
||||
showExpand(action is EventSharedAction.ReportContent)
|
||||
expanded(state.expendedReportContentMenu)
|
||||
listener(View.OnClickListener { listener?.didSelectMenuAction(action) })
|
||||
}
|
||||
if (action is EventSharedAction.Separator) {
|
||||
bottomSheetItemSeparator {
|
||||
id("separator_$index")
|
||||
}
|
||||
} else {
|
||||
bottomSheetItemAction {
|
||||
id("action_$index")
|
||||
iconRes(action.iconResId)
|
||||
textRes(action.titleRes)
|
||||
showExpand(action is EventSharedAction.ReportContent)
|
||||
expanded(state.expendedReportContentMenu)
|
||||
listener(View.OnClickListener { listener?.didSelectMenuAction(action) })
|
||||
destructive(action is EventSharedAction.IgnoreUser)
|
||||
}
|
||||
|
||||
if (action is EventSharedAction.ReportContent && state.expendedReportContentMenu) {
|
||||
// Special case for report content menu: add the submenu
|
||||
listOf(
|
||||
EventSharedAction.ReportContentSpam(action.eventId, action.senderId),
|
||||
EventSharedAction.ReportContentInappropriate(action.eventId, action.senderId),
|
||||
EventSharedAction.ReportContentCustom(action.eventId, action.senderId)
|
||||
).forEachIndexed { indexReport, actionReport ->
|
||||
bottomSheetItemAction {
|
||||
id("actionReport_$indexReport")
|
||||
subMenuItem(true)
|
||||
iconRes(actionReport.iconResId)
|
||||
textRes(actionReport.titleRes)
|
||||
listener(View.OnClickListener { listener?.didSelectMenuAction(actionReport) })
|
||||
if (action is EventSharedAction.ReportContent && state.expendedReportContentMenu) {
|
||||
// Special case for report content menu: add the submenu
|
||||
listOf(
|
||||
EventSharedAction.ReportContentSpam(action.eventId, action.senderId),
|
||||
EventSharedAction.ReportContentInappropriate(action.eventId, action.senderId),
|
||||
EventSharedAction.ReportContentCustom(action.eventId, action.senderId)
|
||||
).forEachIndexed { indexReport, actionReport ->
|
||||
bottomSheetItemAction {
|
||||
id("actionReport_$indexReport")
|
||||
subMenuItem(true)
|
||||
iconRes(actionReport.iconResId)
|
||||
textRes(actionReport.titleRes)
|
||||
listener(View.OnClickListener { listener?.didSelectMenuAction(actionReport) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,9 +266,14 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
}
|
||||
add(EventSharedAction.CopyPermalink(eventId))
|
||||
|
||||
if (session.myUserId != event.root.senderId && event.root.getClearType() == EventType.MESSAGE) {
|
||||
if (session.myUserId != event.root.senderId) {
|
||||
// not sent by me
|
||||
add(EventSharedAction.ReportContent(eventId, event.root.senderId))
|
||||
if (event.root.getClearType() == EventType.MESSAGE) {
|
||||
add(EventSharedAction.ReportContent(eventId, event.root.senderId))
|
||||
}
|
||||
|
||||
add(EventSharedAction.Separator)
|
||||
add(EventSharedAction.IgnoreUser(event.root.senderId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
vector/src/main/res/drawable/ic_alert_triangle.xml
Normal file
14
vector/src/main/res/drawable/ic_alert_triangle.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="21dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="21">
|
||||
<path
|
||||
android:pathData="M10.29,2.86L1.82,17a2,2 0,0 0,1.71 3h16.94a2,2 0,0 0,1.71 -3L13.71,2.86a2,2 0,0 0,-3.42 0zM12,8v4M12,15.5v0.5"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#FF4B55"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
@ -2,6 +2,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Strings not defined in Riot -->
|
||||
<string name="message_ignore_user">Block user</string>
|
||||
|
||||
<string name="room_list_quick_actions_notifications_all_noisy">"All messages (noisy)"</string>
|
||||
<string name="room_list_quick_actions_notifications_all">"All messages"</string>
|
||||
<string name="room_list_quick_actions_notifications_mentions">"Mentions only"</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user