allow editing contacts without permissions if our app triggers the editor

This commit is contained in:
tibbi 2018-08-04 23:16:05 +02:00
parent 40777553fe
commit 8b29f9c10f
3 changed files with 5 additions and 1 deletions

View File

@ -58,7 +58,8 @@ class EditContactActivity : ContactActivity() {
val action = intent.action
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT
if (isThirdPartyIntent) {
val isFromSimpleContacts = intent.getBooleanExtra(IS_FROM_SIMPLE_CONTACTS, false)
if (isThirdPartyIntent && !isFromSimpleContacts) {
handlePermission(PERMISSION_READ_CONTACTS) {
if (it) {
handlePermission(PERMISSION_WRITE_CONTACTS) {

View File

@ -10,6 +10,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALL_LOG
import com.simplemobiletools.contacts.activities.EditContactActivity
import com.simplemobiletools.contacts.adapters.RecentCallsAdapter
import com.simplemobiletools.contacts.extensions.contactClicked
import com.simplemobiletools.contacts.helpers.IS_FROM_SIMPLE_CONTACTS
import com.simplemobiletools.contacts.helpers.KEY_PHONE
import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN
import com.simplemobiletools.contacts.helpers.RECENTS_TAB_MASK
@ -55,6 +56,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
Intent(context, EditContactActivity::class.java).apply {
action = Intent.ACTION_INSERT
putExtra(KEY_PHONE, recentCall)
putExtra(IS_FROM_SIMPLE_CONTACTS, true)
context.startActivity(this)
}
}

View File

@ -22,6 +22,7 @@ const val IS_PRIVATE = "is_private"
const val GROUP = "group"
const val FIRST_GROUP_ID = 10000
const val PHONE_NUMBER_PATTERN = "\\D+"
const val IS_FROM_SIMPLE_CONTACTS = "is_from_simple_contacts"
// extras used at third party intents
const val KEY_PHONE = "phone"