diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt index 26b9e96a..b0156746 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt @@ -58,7 +58,7 @@ class EditContactActivity : ContactActivity() { supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross) val action = intent.action - isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT + isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT || action == ADD_NEW_CONTACT_NUMBER val isFromSimpleContacts = intent.getBooleanExtra(IS_FROM_SIMPLE_CONTACTS, false) if (isThirdPartyIntent && !isFromSimpleContacts) { handlePermission(PERMISSION_READ_CONTACTS) { @@ -119,7 +119,7 @@ class EditContactActivity : ContactActivity() { private fun initContact() { var contactId = intent.getIntExtra(CONTACT_ID, 0) val action = intent.action - if (contactId == 0 && action == Intent.ACTION_EDIT) { + if (contactId == 0 && (action == Intent.ACTION_EDIT || action == ADD_NEW_CONTACT_NUMBER)) { val data = intent.data if (data != null) { val rawId = if (data.path.contains("lookup")) { @@ -149,7 +149,7 @@ class EditContactActivity : ContactActivity() { setupEditContact() } - if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) { + if ((contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) { val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: "" contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "")) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/InsertOrEditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/InsertOrEditContactActivity.kt index 610f84b3..46b1131f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/InsertOrEditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/InsertOrEditContactActivity.kt @@ -11,6 +11,8 @@ import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.adapters.ContactsAdapter import com.simplemobiletools.contacts.extensions.config +import com.simplemobiletools.contacts.extensions.getContactPublicUri +import com.simplemobiletools.contacts.helpers.ADD_NEW_CONTACT_NUMBER import com.simplemobiletools.contacts.helpers.ContactsHelper import com.simplemobiletools.contacts.helpers.KEY_PHONE import com.simplemobiletools.contacts.helpers.LOCATION_INSERT_OR_EDIT @@ -57,7 +59,12 @@ class InsertOrEditContactActivity : SimpleActivity() { contacts.sort() ContactsAdapter(this, contacts, null, LOCATION_INSERT_OR_EDIT, null, existing_contact_list, existing_contact_fastscroller) { - + Intent(applicationContext, EditContactActivity::class.java).apply { + data = getContactPublicUri(it as Contact) + action = ADD_NEW_CONTACT_NUMBER + putExtra(KEY_PHONE, intent.getStringExtra(KEY_PHONE)) + startActivity(this) + } }.apply { addVerticalDividers(true) existing_contact_list.adapter = this diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index 58f5d9fa..936744bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -23,6 +23,7 @@ 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" +const val ADD_NEW_CONTACT_NUMBER = "add_new_contact_number" // extras used at third party intents const val KEY_PHONE = "phone"