mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
adding the Import Contacts dialog
This commit is contained in:
@ -8,6 +8,7 @@ import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_CALL_PHONE
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
|
||||
fun SimpleActivity.startCallIntent(recipient: String) {
|
||||
@ -40,3 +41,23 @@ fun SimpleActivity.tryStartCall(contact: Contact) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (newSource: String) -> Unit) {
|
||||
ContactsHelper(this).getContactSources {
|
||||
val items = ArrayList<RadioItem>()
|
||||
val sources = it
|
||||
var currentSourceIndex = -1
|
||||
sources.forEachIndexed { index, account ->
|
||||
items.add(RadioItem(index, account))
|
||||
if (account == currentSource) {
|
||||
currentSourceIndex = index
|
||||
}
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
RadioGroupDialog(this, items, currentSourceIndex) {
|
||||
callback(sources[it as Int])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user