Skip to content

Commit 853a6a8

Browse files
committed
fix #391, show more detailed info at deleting elements
1 parent cbead76 commit 853a6a8

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,18 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
151151
}
152152

153153
private fun askConfirmDelete() {
154-
ConfirmationDialog(activity) {
154+
val itemsCnt = selectedKeys.size
155+
val firstItem = getSelectedItems().first()
156+
val items = if (itemsCnt == 1) {
157+
"\"${firstItem.getNameToDisplay()}\""
158+
} else {
159+
resources.getQuantityString(R.plurals.delete_contacts, itemsCnt, itemsCnt)
160+
}
161+
162+
val baseString = R.string.delete_contacts_confirmation
163+
val question = String.format(resources.getString(baseString), items)
164+
165+
ConfirmationDialog(activity, question) {
155166
deleteContacts()
156167
}
157168
}

app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/GroupsAdapter.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,18 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
102102
}
103103

104104
private fun askConfirmDelete() {
105-
ConfirmationDialog(activity) {
105+
val itemsCnt = selectedKeys.size
106+
val firstItem = getSelectedItems().first()
107+
val items = if (itemsCnt == 1) {
108+
"\"${firstItem.title}\""
109+
} else {
110+
resources.getQuantityString(R.plurals.delete_groups, itemsCnt, itemsCnt)
111+
}
112+
113+
val baseString = R.string.delete_contacts_confirmation
114+
val question = String.format(resources.getString(baseString), items)
115+
116+
ConfirmationDialog(activity, question) {
106117
ensureBackgroundThread {
107118
deleteGroups()
108119
}
@@ -135,6 +146,8 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
135146
}
136147
}
137148

149+
private fun getSelectedItems() = groups.filter { selectedKeys.contains(it.id?.toInt()) } as ArrayList<Group>
150+
138151
private fun setupView(view: View, group: Group) {
139152
view.apply {
140153
group_frame?.isSelected = selectedKeys.contains(group.id!!.toInt())

0 commit comments

Comments
 (0)