fix importing fax type phone numbers

This commit is contained in:
tibbi 2018-09-03 14:06:35 +02:00
parent 349f3a1fc3
commit bf386f557b
1 changed files with 16 additions and 4 deletions

View File

@ -49,7 +49,7 @@ class VcfImporter(val activity: SimpleActivity) {
val phoneNumbers = ArrayList<PhoneNumber>() val phoneNumbers = ArrayList<PhoneNumber>()
ezContact.telephoneNumbers.forEach { ezContact.telephoneNumbers.forEach {
val number = it.text val number = it.text
val type = getPhoneNumberTypeId(it.types.firstOrNull()?.value ?: MOBILE) val type = getPhoneNumberTypeId(it.types.firstOrNull()?.value ?: MOBILE, it.types.getOrNull(1)?.value)
val label = if (type == CommonDataKinds.Phone.TYPE_CUSTOM) { val label = if (type == CommonDataKinds.Phone.TYPE_CUSTOM) {
it.types.firstOrNull()?.value ?: "" it.types.firstOrNull()?.value ?: ""
} else { } else {
@ -135,10 +135,22 @@ class VcfImporter(val activity: SimpleActivity) {
return dateTime.toString("yyyy-MM-dd") return dateTime.toString("yyyy-MM-dd")
} }
private fun getPhoneNumberTypeId(type: String) = when (type.toUpperCase()) { private fun getPhoneNumberTypeId(type: String, subtype: String?) = when (type.toUpperCase()) {
CELL -> CommonDataKinds.Phone.TYPE_MOBILE CELL -> CommonDataKinds.Phone.TYPE_MOBILE
HOME -> CommonDataKinds.Phone.TYPE_HOME HOME -> {
WORK -> CommonDataKinds.Phone.TYPE_WORK if (subtype?.toUpperCase() == FAX) {
CommonDataKinds.Phone.TYPE_FAX_HOME
} else {
CommonDataKinds.Phone.TYPE_HOME
}
}
WORK -> {
if (subtype?.toUpperCase() == FAX) {
CommonDataKinds.Phone.TYPE_FAX_WORK
} else {
CommonDataKinds.Phone.TYPE_WORK
}
}
PREF, MAIN -> CommonDataKinds.Phone.TYPE_MAIN PREF, MAIN -> CommonDataKinds.Phone.TYPE_MAIN
WORK_FAX -> CommonDataKinds.Phone.TYPE_FAX_WORK WORK_FAX -> CommonDataKinds.Phone.TYPE_FAX_WORK
HOME_FAX -> CommonDataKinds.Phone.TYPE_FAX_HOME HOME_FAX -> CommonDataKinds.Phone.TYPE_FAX_HOME