diff --git a/CHANGES.md b/CHANGES.md index ce10d8cc9a..0af92bf211 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ Features ✨: - Improvements 🙌: - - + - Show confirmation dialog before deleting a message (#967) Other changes: - @@ -24,7 +24,7 @@ Changes in RiotX 0.15.0 (2020-02-10) Improvements 🙌: - Improve navigation to the timeline (#789, #862) - - Improve network detection. It is now based on the sync request status (#873, #882) + - Improve network detection. It is now based on the sync request status (#873, #882) Other changes: - Support SSO login with Firefox account (#606) 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 9e4d7d8163..5a905a2e93 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 @@ -61,6 +61,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.github.piasy.biv.BigImageViewer import com.github.piasy.biv.loader.ImageLoader +import com.google.android.material.checkbox.MaterialCheckBox import com.google.android.material.snackbar.Snackbar import com.google.android.material.textfield.TextInputEditText import com.jakewharton.rxbinding3.widget.textChanges @@ -786,6 +787,26 @@ class RoomDetailFragment @Inject constructor( .show() } + private fun promptReasonToDeleteEvent(eventId: String) { + val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null) + val reasonCheckBox = layout.findViewById(R.id.deleteEventReasonCheck) + val reasonInput = layout.findViewById(R.id.deleteEventReasonInput) + + reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonInput.isEnabled = isChecked } + + AlertDialog.Builder(requireActivity()) + .setView(layout) + .setTitle(R.string.delete_event_dialog_title) + .setPositiveButton(R.string.remove) { _, _ -> + val reason = reasonInput.text.toString() + .takeIf { reasonCheckBox.isChecked } + ?.takeIf { it.isNotBlank() } + roomDetailViewModel.handle(RoomDetailAction.RedactAction(eventId, reason)) + } + .setNegativeButton(R.string.cancel, null) + .show() + } + private fun displayRoomDetailActionFailure(result: RoomDetailViewEvents.ActionFailure) { AlertDialog.Builder(requireActivity()) .setTitle(R.string.dialog_title_error) @@ -1098,7 +1119,7 @@ class RoomDetailFragment @Inject constructor( showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT) } is EventSharedAction.Delete -> { - roomDetailViewModel.handle(RoomDetailAction.RedactAction(action.eventId, context?.getString(R.string.event_redacted_by_user_reason))) + promptReasonToDeleteEvent(action.eventId) } is EventSharedAction.Share -> { // TODO current data communication is too limited diff --git a/vector/src/main/res/layout/dialog_delete_event.xml b/vector/src/main/res/layout/dialog_delete_event.xml new file mode 100644 index 0000000000..eee3cc9df5 --- /dev/null +++ b/vector/src/main/res/layout/dialog_delete_event.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 95e66e68be..914d3a1ddf 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -19,6 +19,13 @@ + + Confirm Removal + Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change. + Include a reason + Reason for redacting + +