fix #604, show the phone number type at the number picker

This commit is contained in:
tibbi 2020-09-19 10:58:33 +02:00
parent 8016f011f6
commit 749bbe55a6
2 changed files with 20 additions and 18 deletions

View File

@ -111,23 +111,6 @@ abstract class ContactActivity : SimpleActivity() {
}
}
fun getPhoneNumberTypeText(type: Int, label: String): String {
return if (type == BaseTypes.TYPE_CUSTOM) {
label
} else {
getString(when (type) {
Phone.TYPE_MOBILE -> R.string.mobile
Phone.TYPE_HOME -> R.string.home
Phone.TYPE_WORK -> R.string.work
Phone.TYPE_MAIN -> R.string.main_number
Phone.TYPE_FAX_WORK -> R.string.work_fax
Phone.TYPE_FAX_HOME -> R.string.home_fax
Phone.TYPE_PAGER -> R.string.pager
else -> R.string.other
})
}
}
fun getEmailTypeText(type: Int, label: String): String {
return if (type == BaseTypes.TYPE_CUSTOM) {
label

View File

@ -2,6 +2,8 @@ package com.simplemobiletools.contacts.pro.extensions
import android.content.Intent
import android.net.Uri
import android.provider.ContactsContract.CommonDataKinds.BaseTypes
import android.provider.ContactsContract.CommonDataKinds.Phone
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
@ -46,7 +48,7 @@ fun SimpleActivity.startCall(contact: Contact) {
} else if (numbers.size > 1) {
val items = ArrayList<RadioItem>()
numbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, phoneNumber.value, phoneNumber.value))
items.add(RadioItem(index, "${phoneNumber.value} (${getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)})", phoneNumber.value))
}
RadioGroupDialog(this, items) {
@ -110,3 +112,20 @@ fun SimpleActivity.callContact(contact: Contact) {
toast(R.string.no_phone_number_found)
}
}
fun SimpleActivity.getPhoneNumberTypeText(type: Int, label: String): String {
return if (type == BaseTypes.TYPE_CUSTOM) {
label
} else {
getString(when (type) {
Phone.TYPE_MOBILE -> R.string.mobile
Phone.TYPE_HOME -> R.string.home
Phone.TYPE_WORK -> R.string.work
Phone.TYPE_MAIN -> R.string.main_number
Phone.TYPE_FAX_WORK -> R.string.work_fax
Phone.TYPE_FAX_HOME -> R.string.home_fax
Phone.TYPE_PAGER -> R.string.pager
else -> R.string.other
})
}
}