mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Show confirmation dialog before deleting message.
This commit is contained in:
@@ -115,6 +115,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
override val sendIntent by lazy { send.clicks() }
|
||||
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||
|
||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
||||
|
||||
@@ -349,6 +350,16 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
}
|
||||
}
|
||||
|
||||
override fun showDeleteDialog(messages: List<Long>) {
|
||||
val count = messages.size
|
||||
android.app.AlertDialog.Builder(this)
|
||||
.setTitle(R.string.dialog_delete_title)
|
||||
.setMessage(resources.getQuantityString(R.plurals.dialog_delete_chat, count, count))
|
||||
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(messages) }
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.compose, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
||||
@@ -55,6 +55,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val sendIntent: Observable<Unit>
|
||||
val viewQksmsPlusIntent: Subject<Unit>
|
||||
val backPressedIntent: Observable<Unit>
|
||||
val confirmDeleteIntent: Observable<List<Long>>
|
||||
|
||||
fun clearSelection()
|
||||
fun showDetails(details: String)
|
||||
@@ -71,5 +72,6 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun setDraft(draft: String)
|
||||
fun scrollToMessage(id: Long)
|
||||
fun showQksmsPlusSnackbar(@StringRes message: Int)
|
||||
fun showDeleteDialog( messages: List<Long>)
|
||||
|
||||
}
|
||||
@@ -340,15 +340,15 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showDetails(it) }
|
||||
|
||||
// Delete the messages
|
||||
// Show the delete message dialog
|
||||
view.optionsItemIntent
|
||||
.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(messages)
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.clearSelection() }
|
||||
.subscribe()
|
||||
|
||||
// Forward the message
|
||||
view.optionsItemIntent
|
||||
@@ -728,6 +728,14 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
// Delete the message
|
||||
view.confirmDeleteIntent
|
||||
.withLatestFrom(view.messagesSelectedIntent, conversation) { _, messages, conversation ->
|
||||
deleteMessages.execute(DeleteMessages.Params(messages, conversation.id))
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.clearSelection() }
|
||||
|
||||
}
|
||||
|
||||
private fun getVCard(contactData: Uri): String? {
|
||||
|
||||
Reference in New Issue
Block a user