create a new activity for handling ACTION_INSERT_OR_EDIT intent

This commit is contained in:
tibbi
2018-09-26 10:11:13 +02:00
parent 282594c125
commit eb914ddfdf
4 changed files with 42 additions and 11 deletions

View File

@ -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_OR_EDIT || action == Intent.ACTION_INSERT
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT
val isFromSimpleContacts = intent.getBooleanExtra(IS_FROM_SIMPLE_CONTACTS, false)
if (isThirdPartyIntent && !isFromSimpleContacts) {
handlePermission(PERMISSION_READ_CONTACTS) {
@ -149,7 +149,7 @@ class EditContactActivity : ContactActivity() {
setupEditContact()
}
if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && (action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT)) {
if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) {
val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: ""
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, ""))

View File

@ -0,0 +1,17 @@
package com.simplemobiletools.contacts.activities
import android.os.Bundle
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
import com.simplemobiletools.contacts.R
class InsertOrEditContactActivity : ContactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_insert_edit_contact)
handlePermission(PERMISSION_READ_CONTACTS) {
// we do not really care about the permission request result. Even if it was denied, load private contacts
}
}
}