show proper custom address types too
This commit is contained in:
parent
a96949ffb5
commit
297b7b3be8
|
@ -137,10 +137,16 @@ abstract class ContactActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAddressTypeText(type: Int) = when (type) {
|
fun getAddressTypeText(type: Int, label: String): String {
|
||||||
|
return if (type == ContactsContract.CommonDataKinds.BaseTypes.TYPE_CUSTOM) {
|
||||||
|
label
|
||||||
|
} else {
|
||||||
|
getString(when (type) {
|
||||||
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> R.string.home
|
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> R.string.home
|
||||||
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> R.string.work
|
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> R.string.work
|
||||||
else -> R.string.other
|
else -> R.string.other
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEventTextId(type: Int) = when (type) {
|
fun getEventTextId(type: Int) = when (type) {
|
||||||
|
|
|
@ -391,7 +391,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
|
|
||||||
addressHolder!!.apply {
|
addressHolder!!.apply {
|
||||||
contact_address.setText(address.value)
|
contact_address.setText(address.value)
|
||||||
setupAddressTypePicker(contact_address_type, address.type)
|
setupAddressTypePicker(contact_address_type, address.type, address.label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
if (contact!!.addresses.isEmpty()) {
|
if (contact!!.addresses.isEmpty()) {
|
||||||
val addressHolder = contact_addresses_holder.getChildAt(0)
|
val addressHolder = contact_addresses_holder.getChildAt(0)
|
||||||
(addressHolder as? ViewGroup)?.contact_address_type?.apply {
|
(addressHolder as? ViewGroup)?.contact_address_type?.apply {
|
||||||
setupAddressTypePicker(this)
|
setupAddressTypePicker(this, DEFAULT_ADDRESS_TYPE, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,9 +565,9 @@ class EditContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAddressTypePicker(addressTypeField: TextView, type: Int = DEFAULT_ADDRESS_TYPE) {
|
private fun setupAddressTypePicker(addressTypeField: TextView, type: Int, label: String) {
|
||||||
addressTypeField.apply {
|
addressTypeField.apply {
|
||||||
setText(getAddressTypeText(type))
|
text = getAddressTypeText(type, label)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showAddressTypePicker(it as TextView)
|
showAddressTypePicker(it as TextView)
|
||||||
}
|
}
|
||||||
|
@ -660,7 +660,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
|
|
||||||
val currentEmailTypeId = getEmailTypeId(emailTypeField.value)
|
val currentEmailTypeId = getEmailTypeId(emailTypeField.value)
|
||||||
RadioGroupDialog(this, items, currentEmailTypeId) {
|
RadioGroupDialog(this, items, currentEmailTypeId) {
|
||||||
emailTypeField.setText(getEmailTypeText(it as Int, ""))
|
emailTypeField.text = getEmailTypeText(it as Int, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
|
|
||||||
val currentAddressTypeId = getAddressTypeId(addressTypeField.value)
|
val currentAddressTypeId = getAddressTypeId(addressTypeField.value)
|
||||||
RadioGroupDialog(this, items, currentAddressTypeId) {
|
RadioGroupDialog(this, items, currentAddressTypeId) {
|
||||||
addressTypeField.setText(getAddressTypeText(it as Int))
|
addressTypeField.text = getAddressTypeText(it as Int, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,7 +882,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
private fun addNewAddressField() {
|
private fun addNewAddressField() {
|
||||||
val addressHolder = layoutInflater.inflate(R.layout.item_edit_address, contact_addresses_holder, false) as ViewGroup
|
val addressHolder = layoutInflater.inflate(R.layout.item_edit_address, contact_addresses_holder, false) as ViewGroup
|
||||||
updateTextColors(addressHolder)
|
updateTextColors(addressHolder)
|
||||||
setupAddressTypePicker(addressHolder.contact_address_type)
|
setupAddressTypePicker(addressHolder.contact_address_type, DEFAULT_ADDRESS_TYPE, "")
|
||||||
contact_addresses_holder.addView(addressHolder)
|
contact_addresses_holder.addView(addressHolder)
|
||||||
contact_addresses_holder.onGlobalLayout {
|
contact_addresses_holder.onGlobalLayout {
|
||||||
addressHolder.contact_address.requestFocus()
|
addressHolder.contact_address.requestFocus()
|
||||||
|
|
|
@ -276,7 +276,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val address = it
|
val address = it
|
||||||
contact_addresses_holder.addView(this)
|
contact_addresses_holder.addView(this)
|
||||||
contact_address.text = address.value
|
contact_address.text = address.value
|
||||||
contact_address_type.setText(getAddressTypeText(address.type))
|
contact_address_type.text = getAddressTypeText(address.type, address.label)
|
||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
sendAddressIntent(address.value)
|
sendAddressIntent(address.value)
|
||||||
|
|
Loading…
Reference in New Issue