diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 3b42535b6..e50575007 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -349,6 +349,15 @@ class ComposeActivity : QkThemedActivity(), ComposeView { } } + override fun showDeleteDialog(count: Int, onConfirm: () -> Unit) { + AlertDialog.Builder(this) + .setTitle(R.string.dialog_delete_title) + .setMessage(resources?.getQuantityString(R.plurals.dialog_delete_message, count, count)) + .setPositiveButton(R.string.button_delete) { _, _ -> onConfirm() } + .setNegativeButton(R.string.button_cancel, null) + .show() + } + override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.compose, menu) return super.onCreateOptionsMenu(menu) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt index d8a78eec2..aa6f20720 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt @@ -71,5 +71,5 @@ interface ComposeView : QkView<ComposeState> { fun setDraft(draft: String) fun scrollToMessage(id: Long) fun showQksmsPlusSnackbar(@StringRes message: Int) - + fun showDeleteDialog(count: Int, onConfirm: () -> Unit) } \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index ba601f2f7..8d2db2ecf 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -345,7 +345,12 @@ class ComposeViewModel @Inject constructor( .filter { it == R.id.delete } .filter { permissionManager.isDefaultSms().also { if (!it) view.requestDefaultSms() } } .withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation -> - deleteMessages.execute(DeleteMessages.Params(messages, conversation.id)) + view.showDeleteDialog( + count = messages.size, + onConfirm = { + deleteMessages.execute(DeleteMessages.Params(messages, conversation.id)) + } + ) } .autoDisposable(view.scope()) .subscribe { view.clearSelection() }