highlight new phone number at adding it to an existing contact

This commit is contained in:
tibbi 2018-09-27 10:32:28 +02:00
parent 5a9513b75d
commit 11349a3112
1 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.widget.EditText
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
@ -51,6 +52,8 @@ class EditContactActivity : ContactActivity() {
private var lastPhotoIntentUri: Uri? = null private var lastPhotoIntentUri: Uri? = null
private var isSaving = false private var isSaving = false
private var isThirdPartyIntent = false private var isThirdPartyIntent = false
private var highlightLastPhoneNumber = false
private var numberViewToColor: EditText? = null
private var originalContactSource = "" private var originalContactSource = ""
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -153,6 +156,9 @@ class EditContactActivity : ContactActivity() {
if ((contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) { 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() ?: "" val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: ""
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "")) contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, ""))
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true
}
contact!!.firstName = intent.extras.get(KEY_NAME)?.toString() ?: "" contact!!.firstName = intent.extras.get(KEY_NAME)?.toString() ?: ""
@ -231,6 +237,7 @@ class EditContactActivity : ContactActivity() {
} }
updateTextColors(contact_scrollview) updateTextColors(contact_scrollview)
numberViewToColor?.setTextColor(getAdjustedPrimaryColor())
wasActivityInitialized = true wasActivityInitialized = true
invalidateOptionsMenu() invalidateOptionsMenu()
} }
@ -374,6 +381,9 @@ class EditContactActivity : ContactActivity() {
numberHolder!!.apply { numberHolder!!.apply {
contact_number.setText(number.value) contact_number.setText(number.value)
setupPhoneNumberTypePicker(contact_number_type, number.type, number.label) setupPhoneNumberTypePicker(contact_number_type, number.type, number.label)
if (highlightLastPhoneNumber && index == contact!!.phoneNumbers.size - 1) {
numberViewToColor = contact_number
}
} }
} }
} }