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