Skip to content

Commit 8b29f9c

Browse files
committed
allow editing contacts without permissions if our app triggers the editor
1 parent 4077755 commit 8b29f9c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class EditContactActivity : ContactActivity() {
5858

5959
val action = intent.action
6060
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT
61-
if (isThirdPartyIntent) {
61+
val isFromSimpleContacts = intent.getBooleanExtra(IS_FROM_SIMPLE_CONTACTS, false)
62+
if (isThirdPartyIntent && !isFromSimpleContacts) {
6263
handlePermission(PERMISSION_READ_CONTACTS) {
6364
if (it) {
6465
handlePermission(PERMISSION_WRITE_CONTACTS) {

app/src/main/kotlin/com/simplemobiletools/contacts/fragments/RecentsFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CALL_LOG
1010
import com.simplemobiletools.contacts.activities.EditContactActivity
1111
import com.simplemobiletools.contacts.adapters.RecentCallsAdapter
1212
import com.simplemobiletools.contacts.extensions.contactClicked
13+
import com.simplemobiletools.contacts.helpers.IS_FROM_SIMPLE_CONTACTS
1314
import com.simplemobiletools.contacts.helpers.KEY_PHONE
1415
import com.simplemobiletools.contacts.helpers.PHONE_NUMBER_PATTERN
1516
import com.simplemobiletools.contacts.helpers.RECENTS_TAB_MASK
@@ -55,6 +56,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
5556
Intent(context, EditContactActivity::class.java).apply {
5657
action = Intent.ACTION_INSERT
5758
putExtra(KEY_PHONE, recentCall)
59+
putExtra(IS_FROM_SIMPLE_CONTACTS, true)
5860
context.startActivity(this)
5961
}
6062
}

app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const val IS_PRIVATE = "is_private"
2222
const val GROUP = "group"
2323
const val FIRST_GROUP_ID = 10000
2424
const val PHONE_NUMBER_PATTERN = "\\D+"
25+
const val IS_FROM_SIMPLE_CONTACTS = "is_from_simple_contacts"
2526

2627
// extras used at third party intents
2728
const val KEY_PHONE = "phone"

0 commit comments

Comments
 (0)