handle send SMS intent
This commit is contained in:
parent
829897b5e1
commit
20bd9cf01c
|
@ -18,7 +18,8 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.sendEmail
|
||||
import com.simplemobiletools.contacts.extensions.sendEmailIntent
|
||||
import com.simplemobiletools.contacts.extensions.sendSMSIntent
|
||||
import com.simplemobiletools.contacts.helpers.CONTACT_ID
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
|
@ -94,10 +95,12 @@ class ContactActivity : SimpleActivity() {
|
|||
contact_email_image.applyColorFilter(textColor)
|
||||
|
||||
contact_photo.setOnClickListener { }
|
||||
contact_send_sms.setOnClickListener { }
|
||||
contact_send_sms.setOnClickListener {
|
||||
sendSMSIntent(contact!!.number)
|
||||
}
|
||||
contact_start_call.setOnClickListener { }
|
||||
contact_send_email.setOnClickListener {
|
||||
sendEmail(contact!!.email)
|
||||
sendEmailIntent(contact!!.email)
|
||||
}
|
||||
|
||||
updateTextColors(contact_scrollview)
|
||||
|
|
|
@ -9,8 +9,20 @@ import com.simplemobiletools.contacts.helpers.Config
|
|||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
fun Context.sendEmail(recipient: String) {
|
||||
Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", recipient, null)).apply {
|
||||
fun Context.sendEmailIntent(recipient: String) {
|
||||
Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = Uri.fromParts("mailto", recipient, null)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.sendSMSIntent(recipient: String) {
|
||||
Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = Uri.fromParts("smsto", recipient, null)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue