try calling contact directly from the dialpad screen, do not trigger edit/view

This commit is contained in:
tibbi 2018-09-24 15:17:15 +02:00
parent 6718fb9a20
commit 284a5fb35f
2 changed files with 11 additions and 9 deletions

View File

@ -11,8 +11,8 @@ import com.simplemobiletools.commons.helpers.isLollipopPlus
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.adapters.ContactsAdapter
import com.simplemobiletools.contacts.extensions.afterTextChanged
import com.simplemobiletools.contacts.extensions.callContact
import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.extensions.contactClicked
import com.simplemobiletools.contacts.helpers.ContactsHelper
import com.simplemobiletools.contacts.helpers.LOCATION_DIALPAD
import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN
@ -103,7 +103,7 @@ class DialpadActivity : SimpleActivity() {
} as ArrayList<Contact>
ContactsAdapter(this, filtered, null, LOCATION_DIALPAD, null, dialpad_list, dialpad_fastscroller) {
contactClicked(it as Contact)
callContact(it as Contact)
}.apply {
addVerticalDividers(true)
dialpad_list.adapter = this

View File

@ -203,14 +203,16 @@ fun Activity.getVisibleContactSources(): ArrayList<String> {
fun SimpleActivity.contactClicked(contact: Contact) {
when (config.onContactClick) {
ON_CLICK_CALL_CONTACT -> {
if (contact.phoneNumbers.isNotEmpty()) {
tryStartCall(contact)
} else {
toast(R.string.no_phone_number_found)
}
}
ON_CLICK_CALL_CONTACT -> callContact(contact)
ON_CLICK_VIEW_CONTACT -> viewContact(contact)
ON_CLICK_EDIT_CONTACT -> editContact(contact)
}
}
fun SimpleActivity.callContact(contact: Contact) {
if (contact.phoneNumbers.isNotEmpty()) {
tryStartCall(contact)
} else {
toast(R.string.no_phone_number_found)
}
}