diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index b21cacd7..34cf1ca8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -65,6 +65,11 @@ const val HOME_FAX = "HOME;FAX" const val PAGER = "PAGER" const val MOBILE = "MOBILE" +// IMs not supported by Ez-vcard +const val HANGOUTS = "Hangouts" +const val QQ = "QQ" +const val JABBER = "Jabber" + const val ON_CLICK_CALL_CONTACT = 1 const val ON_CLICK_VIEW_CONTACT = 2 const val ON_CLICK_EDIT_CONTACT = 3 diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt index b4651fb5..a5dd3e06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt @@ -102,6 +102,22 @@ class VcfExporter { card.addAddress(address) } + contact.IMs.forEach { + val impp = when (it.type) { + CommonDataKinds.Im.PROTOCOL_AIM -> Impp.aim(it.value) + CommonDataKinds.Im.PROTOCOL_YAHOO -> Impp.yahoo(it.value) + CommonDataKinds.Im.PROTOCOL_MSN -> Impp.msn(it.value) + CommonDataKinds.Im.PROTOCOL_ICQ -> Impp.icq(it.value) + CommonDataKinds.Im.PROTOCOL_SKYPE -> Impp.skype(it.value) + CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value) + CommonDataKinds.Im.PROTOCOL_QQ -> Impp(QQ, it.value) + CommonDataKinds.Im.PROTOCOL_JABBER -> Impp(JABBER, it.value) + else -> Impp(it.label, it.value) + } + + card.addImpp(impp) + } + if (contact.notes.isNotEmpty()) { card.addNote(contact.notes) } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt index 81f46041..14eed066 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt @@ -15,6 +15,7 @@ import org.joda.time.DateTime import org.joda.time.format.DateTimeFormat import java.io.File import java.io.FileOutputStream +import java.net.URLDecoder import java.util.* class VcfImporter(val activity: SimpleActivity) { @@ -111,7 +112,27 @@ class VcfImporter(val activity: SimpleActivity) { val photo = null val thumbnailUri = savePhoto(photoData) val cleanPhoneNumbers = ArrayList() + val IMs = ArrayList() + ezContact.impps.forEach { + val typeString = it.uri.scheme + val value = URLDecoder.decode(it.uri.toString().substring(it.uri.scheme.length + 1), "UTF-8") + val type = when { + it.isAim -> CommonDataKinds.Im.PROTOCOL_AIM + it.isYahoo -> CommonDataKinds.Im.PROTOCOL_YAHOO + it.isMsn -> CommonDataKinds.Im.PROTOCOL_MSN + it.isIcq -> CommonDataKinds.Im.PROTOCOL_ICQ + it.isSkype -> CommonDataKinds.Im.PROTOCOL_SKYPE + typeString == HANGOUTS -> CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK + typeString == QQ -> CommonDataKinds.Im.PROTOCOL_QQ + typeString == JABBER -> CommonDataKinds.Im.PROTOCOL_JABBER + else -> CommonDataKinds.Im.PROTOCOL_CUSTOM + } + + val label = if (type == CommonDataKinds.Im.PROTOCOL_CUSTOM) URLDecoder.decode(typeString, "UTF-8") else "" + val IM = IM(value, type, label) + IMs.add(IM) + } val contact = Contact(0, prefix, firstName, middleName, surname, suffix, nickname, photoUri, phoneNumbers, emails, addresses, events, targetContactSource, starred, contactId, thumbnailUri, photo, notes, groups, organization, websites, cleanPhoneNumbers, IMs)