mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Do not ask for a reason if user wants to delete his own message.
Fixes (#1003)
This commit is contained in:
parent
5191cbaf93
commit
8a3e93ae96
4 changed files with 10 additions and 7 deletions
|
@ -788,12 +788,15 @@ class RoomDetailFragment @Inject constructor(
|
|||
.show()
|
||||
}
|
||||
|
||||
private fun promptReasonToRedactEvent(eventId: String) {
|
||||
private fun promptConfirmationToRedactEvent(eventId: String, askForReason: Boolean) {
|
||||
val layout = requireActivity().layoutInflater.inflate(R.layout.dialog_delete_event, null)
|
||||
val reasonCheckBox = layout.findViewById<MaterialCheckBox>(R.id.deleteEventReasonCheck)
|
||||
val reasonTextInputLayout = layout.findViewById<TextInputLayout>(R.id.deleteEventReasonTextInputLayout)
|
||||
val reasonInput = layout.findViewById<TextInputEditText>(R.id.deleteEventReasonInput)
|
||||
|
||||
reasonCheckBox.isVisible = askForReason
|
||||
reasonTextInputLayout.isVisible = askForReason
|
||||
|
||||
reasonCheckBox.setOnCheckedChangeListener { _, isChecked -> reasonTextInputLayout.isEnabled = isChecked }
|
||||
|
||||
AlertDialog.Builder(requireActivity())
|
||||
|
@ -801,7 +804,8 @@ class RoomDetailFragment @Inject constructor(
|
|||
.setView(layout)
|
||||
.setPositiveButton(R.string.remove) { _, _ ->
|
||||
val reason = reasonInput.text.toString()
|
||||
.takeIf { reasonCheckBox.isChecked }
|
||||
.takeIf { askForReason }
|
||||
?.takeIf { reasonCheckBox.isChecked }
|
||||
?.takeIf { it.isNotBlank() }
|
||||
roomDetailViewModel.handle(RoomDetailAction.RedactAction(eventId, reason))
|
||||
}
|
||||
|
@ -1121,7 +1125,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
showSnackWithMessage(getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
|
||||
}
|
||||
is EventSharedAction.Redact -> {
|
||||
promptReasonToRedactEvent(action.eventId)
|
||||
promptConfirmationToRedactEvent(action.eventId, action.askForReason)
|
||||
}
|
||||
is EventSharedAction.Share -> {
|
||||
// TODO current data communication is too limited
|
||||
|
|
|
@ -55,7 +55,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int,
|
|||
data class Remove(val eventId: String) :
|
||||
EventSharedAction(R.string.remove, R.drawable.ic_trash, true)
|
||||
|
||||
data class Redact(val eventId: String) :
|
||||
data class Redact(val eventId: String, val askForReason: Boolean) :
|
||||
EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true)
|
||||
|
||||
data class Cancel(val eventId: String) :
|
||||
|
|
|
@ -227,7 +227,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
|
||||
if (canRedact(timelineEvent, session.myUserId)) {
|
||||
add(EventSharedAction.Redact(eventId))
|
||||
add(EventSharedAction.Redact(eventId, askForReason = informationData.senderId != session.myUserId))
|
||||
}
|
||||
|
||||
if (canCopy(msgType)) {
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/deleteEventReasonInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/event_redacted_by_user_reason" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue