handle contact website import/export

This commit is contained in:
tibbi 2018-04-13 14:53:19 +02:00
parent cf15832dce
commit b7d7eb5e8a
3 changed files with 10 additions and 0 deletions

View File

@ -46,6 +46,7 @@ const val ADR = "ADR"
const val NOTE = "NOTE:" const val NOTE = "NOTE:"
const val ORG = "ORG:" const val ORG = "ORG:"
const val TITLE = "TITLE:" const val TITLE = "TITLE:"
const val URL = "URL:"
const val ENCODING = "ENCODING" const val ENCODING = "ENCODING"
const val BASE64 = "BASE64" const val BASE64 = "BASE64"
const val JPEG = "JPEG" const val JPEG = "JPEG"

View File

@ -71,6 +71,10 @@ class VcfExporter {
out.writeLn("$TITLE${contact.organization.jobPosition.replace("\n", "\\n")}") out.writeLn("$TITLE${contact.organization.jobPosition.replace("\n", "\\n")}")
} }
contact.websites.forEach {
out.writeLn("$URL$it")
}
if (contact.thumbnailUri.isNotEmpty()) { if (contact.thumbnailUri.isNotEmpty()) {
val bitmap = MediaStore.Images.Media.getBitmap(activity.contentResolver, Uri.parse(contact.thumbnailUri)) val bitmap = MediaStore.Images.Media.getBitmap(activity.contentResolver, Uri.parse(contact.thumbnailUri))
addBitmap(bitmap, out) addBitmap(bitmap, out)

View File

@ -91,6 +91,7 @@ class VcfImporter(val activity: SimpleActivity) {
line.toUpperCase().startsWith(PHOTO) -> addPhoto(line.substring(PHOTO.length)) line.toUpperCase().startsWith(PHOTO) -> addPhoto(line.substring(PHOTO.length))
line.toUpperCase().startsWith(ORG) -> addCompany(line.substring(ORG.length)) line.toUpperCase().startsWith(ORG) -> addCompany(line.substring(ORG.length))
line.toUpperCase().startsWith(TITLE) -> addJobPosition(line.substring(TITLE.length)) line.toUpperCase().startsWith(TITLE) -> addJobPosition(line.substring(TITLE.length))
line.toUpperCase().startsWith(URL) -> addWebsite(line.substring(URL.length))
line.toUpperCase() == END_VCARD -> saveContact(targetContactSource) line.toUpperCase() == END_VCARD -> saveContact(targetContactSource)
isGettingPhoto -> currentPhotoString.append(line.trim()) isGettingPhoto -> currentPhotoString.append(line.trim())
} }
@ -251,6 +252,10 @@ class VcfImporter(val activity: SimpleActivity) {
curJobPosition = jobPosition curJobPosition = jobPosition
} }
private fun addWebsite(website: String) {
curWebsites.add(website)
}
private fun saveContact(source: String) { private fun saveContact(source: String) {
val organization = Organization(curCompany, curJobPosition) val organization = Organization(curCompany, curJobPosition)
val contact = Contact(0, curPrefix, curFirstName, curMiddleName, curSurname, curSuffix, curPhotoUri, curPhoneNumbers, curEmails, curAddresses, curEvents, val contact = Contact(0, curPrefix, curFirstName, curMiddleName, curSurname, curSuffix, curPhotoUri, curPhoneNumbers, curEmails, curAddresses, curEvents,