mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-09 08:08:49 +01:00
automatically choose the first group account, if only one is available
This commit is contained in:
parent
ac058c4e7b
commit
79d9e2045b
@ -47,13 +47,13 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
RadioGroupDialog(activity, items, titleId = R.string.create_group_under_account) {
|
||||
val contactSource = contactSources[it as Int]
|
||||
val newGroup = ContactsHelper(activity).createNewGroup(name, contactSource.name, contactSource.type)
|
||||
if (newGroup != null) {
|
||||
callback(newGroup)
|
||||
if (items.size == 1) {
|
||||
createGroupUnder(name, contactSources.first(), this)
|
||||
} else {
|
||||
RadioGroupDialog(activity, items, titleId = R.string.create_group_under_account) {
|
||||
val contactSource = contactSources[it as Int]
|
||||
createGroupUnder(name, contactSource, this)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,4 +61,12 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createGroupUnder(name: String, contactSource: ContactSource, dialog: AlertDialog) {
|
||||
val newGroup = ContactsHelper(activity).createNewGroup(name, contactSource.name, contactSource.type)
|
||||
if (newGroup != null) {
|
||||
callback(newGroup)
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user