Skip to content

Commit

Permalink
highlight new phone number at adding it to an existing contact
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Sep 27, 2018
1 parent 5a9513b commit 11349a3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
Expand Down Expand Up @@ -51,6 +52,8 @@ class EditContactActivity : ContactActivity() {
private var lastPhotoIntentUri: Uri? = null
private var isSaving = false
private var isThirdPartyIntent = false
private var highlightLastPhoneNumber = false
private var numberViewToColor: EditText? = null
private var originalContactSource = ""

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -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) {
val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: ""
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() ?: ""

Expand Down Expand Up @@ -231,6 +237,7 @@ class EditContactActivity : ContactActivity() {
}

updateTextColors(contact_scrollview)
numberViewToColor?.setTextColor(getAdjustedPrimaryColor())
wasActivityInitialized = true
invalidateOptionsMenu()
}
Expand Down Expand Up @@ -374,6 +381,9 @@ class EditContactActivity : ContactActivity() {
numberHolder!!.apply {
contact_number.setText(number.value)
setupPhoneNumberTypePicker(contact_number_type, number.type, number.label)
if (highlightLastPhoneNumber && index == contact!!.phoneNumbers.size - 1) {
numberViewToColor = contact_number
}
}
}
}
Expand Down

0 comments on commit 11349a3

Please sign in to comment.