properly handle inserting contact emails via third party intents

This commit is contained in:
tibbi 2019-12-05 12:00:38 +01:00
parent b1e7ab9c63
commit 7c6ed3504c
1 changed files with 14 additions and 1 deletions

View File

@ -54,7 +54,9 @@ class EditContactActivity : ContactActivity() {
private var isSaving = false
private var isThirdPartyIntent = false
private var highlightLastPhoneNumber = false
private var highlightLastEmail = false
private var numberViewToColor: EditText? = null
private var emailViewToColor: EditText? = null
private var originalContactSource = ""
override fun onCreate(savedInstanceState: Bundle?) {
@ -183,6 +185,13 @@ class EditContactActivity : ContactActivity() {
}
}
val email = intent.getStringExtra("email")
if (email != null) {
val newEmail = Email(email, DEFAULT_EMAIL_TYPE, "")
contact!!.emails.add(newEmail)
highlightLastEmail = true
}
val firstName = intent.extras!!.get(KEY_NAME)
if (firstName != null) {
contact!!.firstName = firstName.toString()
@ -265,7 +274,8 @@ class EditContactActivity : ContactActivity() {
}
updateTextColors(contact_scrollview)
numberViewToColor?.setTextColor(getAdjustedPrimaryColor())
numberViewToColor?.setTextColor(adjustedPrimaryColor)
emailViewToColor?.setTextColor(adjustedPrimaryColor)
wasActivityInitialized = true
invalidateOptionsMenu()
}
@ -440,6 +450,9 @@ class EditContactActivity : ContactActivity() {
emailHolder!!.apply {
contact_email.setText(email.value)
setupEmailTypePicker(contact_email_type, email.type, email.label)
if (highlightLastEmail && index == contact!!.emails.size - 1) {
emailViewToColor = contact_email
}
}
}
}