display custom phone number type label when appropriate
This commit is contained in:
parent
f74cc8cd31
commit
ccd995dc44
|
@ -107,7 +107,11 @@ abstract class ContactActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun getPhoneNumberTextId(type: Int) = when (type) {
|
||||
fun getPhoneNumberText(type: Int, label: String): String {
|
||||
return if (type == ContactsContract.CommonDataKinds.BaseTypes.TYPE_CUSTOM) {
|
||||
label
|
||||
} else {
|
||||
getString(when (type) {
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE -> R.string.mobile
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_HOME -> R.string.home
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_WORK -> R.string.work
|
||||
|
@ -116,6 +120,8 @@ abstract class ContactActivity : SimpleActivity() {
|
|||
ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> R.string.home_fax
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_PAGER -> R.string.pager
|
||||
else -> R.string.other
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun getEmailTextId(type: Int) = when (type) {
|
||||
|
|
|
@ -361,7 +361,7 @@ class EditContactActivity : ContactActivity() {
|
|||
|
||||
numberHolder!!.apply {
|
||||
contact_number.setText(number.value)
|
||||
setupPhoneNumberTypePicker(contact_number_type, number.type)
|
||||
setupPhoneNumberTypePicker(contact_number_type, number.type, number.label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ class EditContactActivity : ContactActivity() {
|
|||
if (contact!!.phoneNumbers.isEmpty()) {
|
||||
val numberHolder = contact_numbers_holder.getChildAt(0)
|
||||
(numberHolder as? ViewGroup)?.contact_number_type?.apply {
|
||||
setupPhoneNumberTypePicker(this)
|
||||
setupPhoneNumberTypePicker(this, DEFAULT_PHONE_NUMBER_TYPE, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -547,9 +547,9 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupPhoneNumberTypePicker(numberTypeField: TextView, type: Int = DEFAULT_PHONE_NUMBER_TYPE) {
|
||||
private fun setupPhoneNumberTypePicker(numberTypeField: TextView, type: Int, label: String) {
|
||||
numberTypeField.apply {
|
||||
setText(getPhoneNumberTextId(type))
|
||||
text = getPhoneNumberText(type, label)
|
||||
setOnClickListener {
|
||||
showNumberTypePicker(it as TextView)
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ class EditContactActivity : ContactActivity() {
|
|||
|
||||
val currentNumberTypeId = getPhoneNumberTypeId(numberTypeField.value)
|
||||
RadioGroupDialog(this, items, currentNumberTypeId) {
|
||||
numberTypeField.setText(getPhoneNumberTextId(it as Int))
|
||||
numberTypeField.text = getPhoneNumberText(it as Int, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -860,7 +860,7 @@ class EditContactActivity : ContactActivity() {
|
|||
private fun addNewPhoneNumberField() {
|
||||
val numberHolder = layoutInflater.inflate(R.layout.item_edit_phone_number, contact_numbers_holder, false) as ViewGroup
|
||||
updateTextColors(numberHolder)
|
||||
setupPhoneNumberTypePicker(numberHolder.contact_number_type)
|
||||
setupPhoneNumberTypePicker(numberHolder.contact_number_type, DEFAULT_PHONE_NUMBER_TYPE, "")
|
||||
contact_numbers_holder.addView(numberHolder)
|
||||
contact_numbers_holder.onGlobalLayout {
|
||||
numberHolder.contact_number.requestFocus()
|
||||
|
|
|
@ -222,7 +222,7 @@ class ViewContactActivity : ContactActivity() {
|
|||
val phoneNumber = it
|
||||
contact_numbers_holder.addView(this)
|
||||
contact_number.text = phoneNumber.value
|
||||
contact_number_type.setText(getPhoneNumberTextId(phoneNumber.type))
|
||||
contact_number_type.text = getPhoneNumberText(phoneNumber.type, phoneNumber.label)
|
||||
|
||||
setOnClickListener {
|
||||
if (config.showCallConfirmation) {
|
||||
|
|
Loading…
Reference in New Issue