mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
properly handle intents on Android 11+
This commit is contained in:
@ -123,11 +123,7 @@ class DialpadActivity : SimpleActivity() {
|
||||
action = Intent.ACTION_INSERT_OR_EDIT
|
||||
type = "vnd.android.cursor.item/contact"
|
||||
putExtra(KEY_PHONE, dialpad_input.value)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
launchActivityIntent(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,10 @@ import com.simplemobiletools.dialer.models.RecentCall
|
||||
import kotlinx.android.synthetic.main.item_recent_call.view.*
|
||||
import java.util.*
|
||||
|
||||
class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<RecentCall>, recyclerView: MyRecyclerView, val refreshItemsListener: RefreshItemsListener?,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
class RecentCallsAdapter(
|
||||
activity: SimpleActivity, var recentCalls: ArrayList<RecentCall>, recyclerView: MyRecyclerView, val refreshItemsListener: RefreshItemsListener?,
|
||||
itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
|
||||
private lateinit var outgoingCallIcon: Drawable
|
||||
private lateinit var incomingCallIcon: Drawable
|
||||
@ -167,12 +169,7 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
||||
action = Intent.ACTION_INSERT_OR_EDIT
|
||||
type = "vnd.android.cursor.item/contact"
|
||||
putExtra(KEY_PHONE, phoneNumber)
|
||||
|
||||
if (resolveActivity(activity.packageManager) != null) {
|
||||
activity.startActivity(this)
|
||||
} else {
|
||||
activity.toast(R.string.no_app_found)
|
||||
}
|
||||
activity.launchActivityIntent(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.dialogs.SelectSIMDialog
|
||||
|
||||
@ -39,18 +38,15 @@ fun Activity.startContactDetailsIntent(contact: SimpleContact) {
|
||||
val simpleContacts = "com.simplemobiletools.contacts.pro"
|
||||
val simpleContactsDebug = "com.simplemobiletools.contacts.pro.debug"
|
||||
if (contact.rawId > 1000000 && contact.contactId > 1000000 && contact.rawId == contact.contactId &&
|
||||
(isPackageInstalled(simpleContacts) || isPackageInstalled(simpleContactsDebug))) {
|
||||
(isPackageInstalled(simpleContacts) || isPackageInstalled(simpleContactsDebug))
|
||||
) {
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
putExtra(CONTACT_ID, contact.rawId)
|
||||
putExtra(IS_PRIVATE, true)
|
||||
`package` = if (isPackageInstalled(simpleContacts)) simpleContacts else simpleContactsDebug
|
||||
setDataAndType(ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person")
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
launchActivityIntent(this)
|
||||
}
|
||||
} else {
|
||||
ensureBackgroundThread {
|
||||
|
@ -166,11 +166,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_INSERT
|
||||
data = ContactsContract.Contacts.CONTENT_URI
|
||||
if (resolveActivity(context.packageManager) != null) {
|
||||
context.startActivity(this)
|
||||
} else {
|
||||
context.toast(R.string.no_app_found)
|
||||
}
|
||||
context.launchActivityIntent(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user