diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt index 77e4e764..20b8b188 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt @@ -107,15 +107,21 @@ abstract class ContactActivity : SimpleActivity() { } } - fun getPhoneNumberTextId(type: Int) = 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 - ContactsContract.CommonDataKinds.Phone.TYPE_MAIN -> R.string.main_number - ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> R.string.work_fax - ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> R.string.home_fax - ContactsContract.CommonDataKinds.Phone.TYPE_PAGER -> R.string.pager - else -> R.string.other + 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 + ContactsContract.CommonDataKinds.Phone.TYPE_MAIN -> R.string.main_number + ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> R.string.work_fax + 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) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt index 61bca85f..76db6966 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt index 6a27df01..ea5e77af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt @@ -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) {