mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
move the SMS sending activity extension to Commons
This commit is contained in:
@ -24,7 +24,6 @@ import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.extensions.sendEmailIntent
|
||||
import com.simplemobiletools.contacts.pro.extensions.sendSMSIntent
|
||||
import com.simplemobiletools.contacts.pro.extensions.shareContacts
|
||||
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
@ -92,7 +91,7 @@ abstract class ContactActivity : SimpleActivity() {
|
||||
fun trySendSMS() {
|
||||
val numbers = contact!!.phoneNumbers
|
||||
if (numbers.size == 1) {
|
||||
sendSMSIntent(numbers.first().value)
|
||||
launchSendSMSIntent(numbers.first().value)
|
||||
} else if (numbers.size > 1) {
|
||||
val items = ArrayList<RadioItem>()
|
||||
numbers.forEachIndexed { index, phoneNumber ->
|
||||
@ -100,7 +99,7 @@ abstract class ContactActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
RadioGroupDialog(this, items) {
|
||||
sendSMSIntent(it as String)
|
||||
launchSendSMSIntent(it as String)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,17 +66,6 @@ fun Context.sendEmailIntent(recipient: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.sendSMSIntent(recipient: String) {
|
||||
Intent(Intent.ACTION_SENDTO).apply {
|
||||
data = Uri.fromParts("smsto", recipient, null)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.sendAddressIntent(address: String) {
|
||||
val location = Uri.encode(address)
|
||||
val uri = Uri.parse("geo:0,0?q=$location")
|
||||
|
@ -6,7 +6,6 @@ import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.provider.ContactsContract.CommonDataKinds.Event
|
||||
import android.provider.MediaStore
|
||||
import com.simplemobiletools.commons.extensions.getChoppedList
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.contacts.pro.extensions.contactsDB
|
||||
import com.simplemobiletools.contacts.pro.extensions.getByteArray
|
||||
@ -56,7 +55,7 @@ class LocalContactsHelper(val context: Context) {
|
||||
}
|
||||
|
||||
fun deleteContactIds(ids: MutableList<Long>) {
|
||||
ids.getChoppedList().forEach {
|
||||
ids.chunked(30).forEach {
|
||||
context.contactsDB.deleteContactIds(it)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user