Change wording adding "..." because there is now confirmation dialog

And make the item red because it is destructive. Also use "redact" terminology
This commit is contained in:
Benoit Marty 2020-02-11 11:04:21 +01:00
parent b40da4ef0f
commit 6fce2a3066
5 changed files with 14 additions and 12 deletions

View file

@ -788,7 +788,7 @@ class RoomDetailFragment @Inject constructor(
.show() .show()
} }
private fun promptReasonToDeleteEvent(eventId: String) { private fun promptReasonToRedactEvent(eventId: String) {
val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null) val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null)
val reasonCheckBox = layout.findViewById<MaterialCheckBox>(R.id.deleteEventReasonCheck) val reasonCheckBox = layout.findViewById<MaterialCheckBox>(R.id.deleteEventReasonCheck)
val reasonTextInputLayout = layout.findViewById<TextInputLayout>(R.id.deleteEventReasonTextInputLayout) val reasonTextInputLayout = layout.findViewById<TextInputLayout>(R.id.deleteEventReasonTextInputLayout)
@ -797,8 +797,8 @@ class RoomDetailFragment @Inject constructor(
reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonTextInputLayout.isEnabled = isChecked } reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonTextInputLayout.isEnabled = isChecked }
AlertDialog.Builder(requireActivity()) AlertDialog.Builder(requireActivity())
.setView(layout)
.setTitle(R.string.delete_event_dialog_title) .setTitle(R.string.delete_event_dialog_title)
.setView(layout)
.setPositiveButton(R.string.remove) { _, _ -> .setPositiveButton(R.string.remove) { _, _ ->
val reason = reasonInput.text.toString() val reason = reasonInput.text.toString()
.takeIf { reasonCheckBox.isChecked } .takeIf { reasonCheckBox.isChecked }
@ -1120,8 +1120,8 @@ class RoomDetailFragment @Inject constructor(
copyToClipboard(requireContext(), action.content, false) copyToClipboard(requireContext(), action.content, false)
showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT) showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
} }
is EventSharedAction.Delete -> { is EventSharedAction.Redact -> {
promptReasonToDeleteEvent(action.eventId) promptReasonToRedactEvent(action.eventId)
} }
is EventSharedAction.Share -> { is EventSharedAction.Share -> {
// TODO current data communication is too limited // TODO current data communication is too limited

View file

@ -22,7 +22,9 @@ import im.vector.riotx.R
import im.vector.riotx.core.platform.VectorSharedAction import im.vector.riotx.core.platform.VectorSharedAction
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
sealed class EventSharedAction(@StringRes val titleRes: Int, @DrawableRes val iconResId: Int) : VectorSharedAction { sealed class EventSharedAction(@StringRes val titleRes: Int,
@DrawableRes val iconResId: Int,
val destructive: Boolean = false) : VectorSharedAction {
object Separator : object Separator :
EventSharedAction(0, 0) EventSharedAction(0, 0)
@ -51,10 +53,10 @@ sealed class EventSharedAction(@StringRes val titleRes: Int, @DrawableRes val ic
EventSharedAction(R.string.global_retry, R.drawable.ic_refresh_cw) EventSharedAction(R.string.global_retry, R.drawable.ic_refresh_cw)
data class Remove(val eventId: String) : data class Remove(val eventId: String) :
EventSharedAction(R.string.remove, R.drawable.ic_trash) EventSharedAction(R.string.remove, R.drawable.ic_trash, true)
data class Delete(val eventId: String) : data class Redact(val eventId: String) :
EventSharedAction(R.string.delete, R.drawable.ic_delete) EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true)
data class Cancel(val eventId: String) : data class Cancel(val eventId: String) :
EventSharedAction(R.string.cancel, R.drawable.ic_close_round) EventSharedAction(R.string.cancel, R.drawable.ic_close_round)
@ -81,7 +83,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int, @DrawableRes val ic
EventSharedAction(R.string.report_content_custom, R.drawable.ic_report_custom) EventSharedAction(R.string.report_content_custom, R.drawable.ic_report_custom)
data class IgnoreUser(val senderId: String?) : data class IgnoreUser(val senderId: String?) :
EventSharedAction(R.string.message_ignore_user, R.drawable.ic_alert_triangle) EventSharedAction(R.string.message_ignore_user, R.drawable.ic_alert_triangle, true)
data class QuickReact(val eventId: String, val clickedOn: String, val add: Boolean) : data class QuickReact(val eventId: String, val clickedOn: String, val add: Boolean) :
EventSharedAction(0, 0) EventSharedAction(0, 0)

View file

@ -111,7 +111,7 @@ class MessageActionsEpoxyController @Inject constructor(
showExpand(action is EventSharedAction.ReportContent) showExpand(action is EventSharedAction.ReportContent)
expanded(state.expendedReportContentMenu) expanded(state.expendedReportContentMenu)
listener(View.OnClickListener { listener?.didSelectMenuAction(action) }) listener(View.OnClickListener { listener?.didSelectMenuAction(action) })
destructive(action is EventSharedAction.IgnoreUser) destructive(action.destructive)
} }
if (action is EventSharedAction.ReportContent && state.expendedReportContentMenu) { if (action is EventSharedAction.ReportContent && state.expendedReportContentMenu) {

View file

@ -227,7 +227,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
} }
if (canRedact(timelineEvent, session.myUserId)) { if (canRedact(timelineEvent, session.myUserId)) {
add(EventSharedAction.Delete(eventId)) add(EventSharedAction.Redact(eventId))
} }
if (canCopy(msgType)) { if (canCopy(msgType)) {

View file

@ -11,7 +11,7 @@
<!-- BEGIN Strings added by Benoit --> <!-- BEGIN Strings added by Benoit -->
<string name="message_action_item_redact">Remove…</string>
<!-- END Strings added by Benoit --> <!-- END Strings added by Benoit -->