mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-01-31 16:04:54 +01:00
Use PREF for the preference rather than the number type
Co-authored-by: Pachat2000 <relsegahy@gmail.com>
This commit is contained in:
parent
241a7a9cba
commit
3ae9bc2511
@ -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…
x
Reference in New Issue
Block a user