mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-24 23:27:40 +01:00
handle exporting and importing contact nicknames
This commit is contained in:
parent
e0a38be028
commit
441a2ac3b1
@ -42,6 +42,10 @@ class VcfExporter {
|
|||||||
out.writeLn(VERSION_2_1)
|
out.writeLn(VERSION_2_1)
|
||||||
out.writeLn("$N${getNames(contact)}")
|
out.writeLn("$N${getNames(contact)}")
|
||||||
|
|
||||||
|
if (contact.nickname.isNotEmpty()) {
|
||||||
|
out.writeLn("$NICKNAME:${contact.nickname}")
|
||||||
|
}
|
||||||
|
|
||||||
contact.phoneNumbers.forEach {
|
contact.phoneNumbers.forEach {
|
||||||
out.writeLn("$TEL;${getPhoneNumberLabel(it.type)}:${it.value}")
|
out.writeLn("$TEL;${getPhoneNumberLabel(it.type)}:${it.value}")
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
when {
|
when {
|
||||||
line.toUpperCase() == BEGIN_VCARD -> resetValues()
|
line.toUpperCase() == BEGIN_VCARD -> resetValues()
|
||||||
line.toUpperCase().startsWith(NOTE) -> addNotes(line.substring(NOTE.length))
|
line.toUpperCase().startsWith(NOTE) -> addNotes(line.substring(NOTE.length))
|
||||||
line.toUpperCase().startsWith(NICKNAME) -> { }
|
line.toUpperCase().startsWith(NICKNAME) -> addNickname(line.substring(NICKNAME.length))
|
||||||
line.toUpperCase().startsWith(N) -> addNames(line.substring(N.length))
|
line.toUpperCase().startsWith(N) -> addNames(line.substring(N.length))
|
||||||
line.toUpperCase().startsWith(TEL) -> addPhoneNumber(line.substring(TEL.length))
|
line.toUpperCase().startsWith(TEL) -> addPhoneNumber(line.substring(TEL.length))
|
||||||
line.toUpperCase().startsWith(EMAIL) -> addEmail(line.substring(EMAIL.length))
|
line.toUpperCase().startsWith(EMAIL) -> addEmail(line.substring(EMAIL.length))
|
||||||
@ -148,6 +148,14 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addNickname(nickname: String) {
|
||||||
|
curNickname = if (nickname.startsWith(";CHARSET", true)) {
|
||||||
|
nickname.substringAfter(":")
|
||||||
|
} else {
|
||||||
|
nickname.substring(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun addPhoneNumber(phoneNumber: String) {
|
private fun addPhoneNumber(phoneNumber: String) {
|
||||||
val phoneParts = phoneNumber.trimStart(';').split(":")
|
val phoneParts = phoneNumber.trimStart(';').split(":")
|
||||||
var rawType = phoneParts[0]
|
var rawType = phoneParts[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user