Merge pull request #953 from Mylloon/fix/GH-952
Use PREF for the preference rather than the number type
This commit is contained in:
commit
85fa2fc5ac
|
@ -73,6 +73,9 @@ class VcfExporter {
|
|||
contact.phoneNumbers.forEach {
|
||||
val phoneNumber = Telephone(it.value)
|
||||
phoneNumber.parameters.addType(getPhoneNumberTypeLabel(it.type, it.label))
|
||||
if (it.isPrimary) {
|
||||
phoneNumber.parameters.addType(getPreferredType(1))
|
||||
}
|
||||
card.addTelephoneNumber(phoneNumber)
|
||||
}
|
||||
|
||||
|
@ -201,4 +204,6 @@ class VcfExporter {
|
|||
StructuredPostal.TYPE_OTHER -> OTHER
|
||||
else -> label
|
||||
}
|
||||
|
||||
private fun getPreferredType(value: Int) = "$PREF=$value"
|
||||
}
|
||||
|
|
|
@ -64,8 +64,9 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||
} else {
|
||||
""
|
||||
}
|
||||
val preferred = getPreferredValue(it.types.lastOrNull()?.value) == 1
|
||||
|
||||
phoneNumbers.add(PhoneNumber(number, type, label, number.normalizePhoneNumber()))
|
||||
phoneNumbers.add(PhoneNumber(number, type, label, number.normalizePhoneNumber(), preferred))
|
||||
}
|
||||
|
||||
val emails = ArrayList<Email>()
|
||||
|
@ -267,7 +268,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||
Phone.TYPE_WORK
|
||||
}
|
||||
}
|
||||
PREF, MAIN -> Phone.TYPE_MAIN
|
||||
MAIN -> Phone.TYPE_MAIN
|
||||
WORK_FAX -> Phone.TYPE_FAX_WORK
|
||||
HOME_FAX -> Phone.TYPE_FAX_HOME
|
||||
FAX -> Phone.TYPE_FAX_WORK
|
||||
|
@ -308,4 +309,14 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||
|
||||
return activity.getCachePhotoUri(file).toString()
|
||||
}
|
||||
|
||||
private fun getPreferredValue(type: String?): Int {
|
||||
if (type != null) {
|
||||
if (type.startsWith("$PREF=".lowercase())) {
|
||||
return type.split("=")[1].toInt()
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue