Skip to content

Commit

Permalink
#1221 - Display appropriate message when deleting multiple conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
moezbhatti committed Jul 24, 2018
1 parent 27ff7f1 commit 8a2df45
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
package com.moez.QKSMS.feature.conversationinfo

import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import android.text.InputFilter
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import com.jakewharton.rxbinding2.view.clicks
import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
Expand Down Expand Up @@ -137,7 +137,7 @@ class ConversationInfoActivity : QkThemedActivity(), ConversationInfoView {
override fun showDeleteDialog() {
AlertDialog.Builder(this)
.setTitle(R.string.dialog_delete_title)
.setMessage(R.string.dialog_delete_message)
.setMessage(resources.getQuantityString(R.plurals.dialog_delete_message, 1))
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(Unit) }
.setNegativeButton(R.string.button_cancel, null)
.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ class MainActivity : QkThemedActivity(), MainView {
conversationsAdapter.clearSelection()
}

override fun showDeleteDialog() {
override fun showDeleteDialog(count: Int) {
AlertDialog.Builder(this)
.setTitle(R.string.dialog_delete_title)
.setMessage(R.string.dialog_delete_message)
.setMessage(resources.getQuantityString(R.plurals.dialog_delete_message, count, count))
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(Unit) }
.setNegativeButton(R.string.button_cancel, null)
.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface MainView : QkView<MainState> {
fun requestPermissions()
fun clearSearch()
fun clearSelection()
fun showDeleteDialog()
fun showDeleteDialog(count: Int)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class MainViewModel @Inject constructor(
view.clearSelection()
}

R.id.delete -> view.showDeleteDialog()
R.id.delete -> view.showDeleteDialog(conversations.size)

R.id.pin -> {
markPinned.execute(conversations)
Expand Down
5 changes: 4 additions & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@
<string name="rate_dismiss">DISMISS</string>

<string name="dialog_delete_title">Delete</string>
<string name="dialog_delete_message">Are you sure you would like to delete this conversation?</string>
<plurals name="dialog_delete_message">
<item quantity="one">Are you sure you would like to delete this conversation?</item>
<item quantity="other">Are you sure you would like to delete %d conversations?</item>
</plurals>

<string-array name="message_options">
<item>Copy text</item>
Expand Down

0 comments on commit 8a2df45

Please sign in to comment.