add handling for StartCall intent
This commit is contained in:
parent
20bd9cf01c
commit
2f815dfe38
|
@ -32,5 +32,5 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.2.13'
|
||||
implementation 'com.simplemobiletools:commons:3.2.14'
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package="com.simplemobiletools.contacts"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.CALL_PHONE"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.simplemobiletools.contacts.R
|
|||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.sendEmailIntent
|
||||
import com.simplemobiletools.contacts.extensions.sendSMSIntent
|
||||
import com.simplemobiletools.contacts.extensions.startCallIntent
|
||||
import com.simplemobiletools.contacts.helpers.CONTACT_ID
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
|
@ -95,13 +96,9 @@ class ContactActivity : SimpleActivity() {
|
|||
contact_email_image.applyColorFilter(textColor)
|
||||
|
||||
contact_photo.setOnClickListener { }
|
||||
contact_send_sms.setOnClickListener {
|
||||
sendSMSIntent(contact!!.number)
|
||||
}
|
||||
contact_start_call.setOnClickListener { }
|
||||
contact_send_email.setOnClickListener {
|
||||
sendEmailIntent(contact!!.email)
|
||||
}
|
||||
contact_send_sms.setOnClickListener { sendSMSIntent(contact!!.number) }
|
||||
contact_start_call.setOnClickListener { startCallIntent(contact!!.number) }
|
||||
contact_send_email.setOnClickListener { sendEmailIntent(contact!!.email) }
|
||||
|
||||
updateTextColors(contact_scrollview)
|
||||
wasActivityInitialized = true
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.simplemobiletools.contacts.extensions
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_CALL_PHONE
|
||||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||
|
||||
fun SimpleActivity.startCallIntent(recipient: String) {
|
||||
handlePermission(PERMISSION_CALL_PHONE) {
|
||||
if (it) {
|
||||
Intent(Intent.ACTION_CALL).apply {
|
||||
data = Uri.fromParts("tel", recipient, null)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue