properly handle generating contact uri for local contacts
This commit is contained in:
parent
8fa8e05a7c
commit
a8c3dcf23a
|
@ -128,7 +128,11 @@ class EditContactActivity : ContactActivity() {
|
|||
val data = intent.data
|
||||
if (data != null) {
|
||||
val rawId = if (data.path.contains("lookup")) {
|
||||
getLookupUriRawId(data)
|
||||
if (data.pathSegments.last().startsWith("local_")) {
|
||||
data.path.substringAfter("local_").toInt()
|
||||
} else {
|
||||
getLookupUriRawId(data)
|
||||
}
|
||||
} else {
|
||||
getContactUriRawId(data)
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ import com.simplemobiletools.contacts.pro.R
|
|||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.contacts.pro.extensions.config
|
||||
import com.simplemobiletools.contacts.pro.extensions.getContactPublicUri
|
||||
import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER
|
||||
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.pro.helpers.KEY_PHONE
|
||||
import com.simplemobiletools.contacts.pro.helpers.LOCATION_INSERT_OR_EDIT
|
||||
import com.simplemobiletools.contacts.pro.helpers.*
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
||||
|
||||
|
@ -59,10 +56,12 @@ class InsertOrEditContactActivity : SimpleActivity() {
|
|||
|
||||
private fun gotContacts(contacts: ArrayList<Contact>) {
|
||||
ContactsAdapter(this, contacts, null, LOCATION_INSERT_OR_EDIT, null, existing_contact_list, existing_contact_fastscroller) {
|
||||
val contact = it as Contact
|
||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||
data = getContactPublicUri(it as Contact)
|
||||
data = getContactPublicUri(contact)
|
||||
action = ADD_NEW_CONTACT_NUMBER
|
||||
putExtra(KEY_PHONE, getPhoneNumberFromIntent(intent))
|
||||
putExtra(IS_PRIVATE, contact.source == SMT_PRIVATE)
|
||||
startActivityForResult(this, START_EDIT_ACTIVITY)
|
||||
}
|
||||
}.apply {
|
||||
|
|
|
@ -278,7 +278,11 @@ fun Context.removeContactsFromGroup(contacts: ArrayList<Contact>, groupId: Long)
|
|||
}
|
||||
|
||||
fun Context.getContactPublicUri(contact: Contact): Uri {
|
||||
val lookupKey = ContactsHelper(this).getContactLookupKey(contact.id.toString())
|
||||
val lookupKey = if (contact.source == SMT_PRIVATE) {
|
||||
"local_${contact.id}"
|
||||
} else {
|
||||
ContactsHelper(this).getContactLookupKey(contact.id.toString())
|
||||
}
|
||||
return Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue