mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-24 22:38:42 +02:00
properly handle importing organizations spanning across multiple lines
This commit is contained in:
parent
7acfde6bb0
commit
67d0b02280
@ -47,6 +47,10 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
private var isGettingNotes = false
|
private var isGettingNotes = false
|
||||||
private var currentNotesSB = StringBuilder()
|
private var currentNotesSB = StringBuilder()
|
||||||
|
|
||||||
|
private var isGettingCompany = false
|
||||||
|
private var currentCompanyIsANSI = false
|
||||||
|
private var currentCompany = StringBuilder()
|
||||||
|
|
||||||
private var contactsImported = 0
|
private var contactsImported = 0
|
||||||
private var contactsFailed = 0
|
private var contactsFailed = 0
|
||||||
|
|
||||||
@ -60,9 +64,9 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
|
|
||||||
inputStream.bufferedReader().use {
|
inputStream.bufferedReader().use {
|
||||||
while (true) {
|
while (true) {
|
||||||
var line = it.readLine() ?: break
|
val originalLine = it.readLine() ?: break
|
||||||
line = line.trim()
|
val line = originalLine.trim()
|
||||||
if (line.trim().isEmpty()) {
|
if (line.isEmpty()) {
|
||||||
if (isGettingPhoto) {
|
if (isGettingPhoto) {
|
||||||
savePhoto()
|
savePhoto()
|
||||||
isGettingPhoto = false
|
isGettingPhoto = false
|
||||||
@ -73,12 +77,16 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
isGettingName = false
|
isGettingName = false
|
||||||
parseNames()
|
parseNames()
|
||||||
} else if (isGettingNotes) {
|
} else if (isGettingNotes) {
|
||||||
if (line.startsWith(' ')) {
|
if (originalLine.startsWith(' ')) {
|
||||||
currentNotesSB.append(line.substring(1))
|
currentNotesSB.append(line.substring(1))
|
||||||
} else {
|
} else {
|
||||||
curNotes = currentNotesSB.toString().replace("\\n", "\n").replace("\\,", ",")
|
curNotes = currentNotesSB.toString().replace("\\n", "\n").replace("\\,", ",")
|
||||||
isGettingNotes = false
|
isGettingNotes = false
|
||||||
}
|
}
|
||||||
|
} else if (isGettingCompany && currentCompanyIsANSI && line.startsWith("=")) {
|
||||||
|
currentCompany.append(line)
|
||||||
|
curCompany = QuotedPrintable.decode(currentCompany.toString().replace("==", "="))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
@ -273,6 +281,10 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
} else {
|
} else {
|
||||||
company.trimStart(':')
|
company.trimStart(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentCompanyIsANSI = company.toUpperCase().contains("QUOTED-PRINTABLE")
|
||||||
|
currentCompany.append(curCompany)
|
||||||
|
isGettingCompany = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addJobPosition(jobPosition: String) {
|
private fun addJobPosition(jobPosition: String) {
|
||||||
@ -328,5 +340,9 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
|
|
||||||
isGettingNotes = false
|
isGettingNotes = false
|
||||||
currentNotesSB = StringBuilder()
|
currentNotesSB = StringBuilder()
|
||||||
|
|
||||||
|
isGettingCompany = false
|
||||||
|
currentCompanyIsANSI = false
|
||||||
|
currentCompany = StringBuilder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user