From a153427646552d7b99bc4c24d0b31694071f98ea Mon Sep 17 00:00:00 2001 From: Dirkster99 Date: Tue, 4 Sep 2018 17:33:43 +0200 Subject: [PATCH] Minor change Adjusted coding style and removed GROUP attribute as per comment from here: https://github.com/SimpleMobileTools/Simple-Contacts/issues/146 previous post, it should look like CATEGORIES:Testgroup,Testgroup1. Regarding the code, check the spacing, newlines, remove comments. --- .../contacts/helpers/VcfExporter.kt | 11 ++++------ .../contacts/helpers/VcfImporter.kt | 20 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) 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 399ab49b..e948258d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt @@ -123,16 +123,13 @@ class VcfExporter { card.addPhoto(photo) } - // Export a list of groups where this contact is a member of - if (contact.groups.size > 0){ - - // Copy groups into a categorized list and add this category into VCard + if (contact.groups.size > 0) { val groupList = Categories(); - contact.groups.forEach{ - groupList.addParameter("GROUP", it.title); + contact.groups.forEach { + groupList.getValues().add(it.title); } - card.addCategories(groupList); + card.setCategories(groupList); } cards.add(card) 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 ca81848c..d5ccc61b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt @@ -105,29 +105,23 @@ class VcfImporter(val activity: SimpleActivity) { val notes = ezContact.notes.firstOrNull()?.value ?: "" val groups = ArrayList() - if (ezContact.categories != null){ // Iterate through categories of this contact (if any) - - // Iterate through group names for this contact - // Check if group already exist and create it if not - // Associate group with this user - val groupNames = ezContact.categories.getParameters("GROUP"); - - if (groupNames != null){ // Resolve group references for this contact + if (ezContact.categories != null) { + val groupNames = ezContact.categories.getValues(); + if (groupNames != null) { val storedGroups = ContactsHelper(activity).getStoredGroups(); - groupNames.forEach { + groupNames.forEach { val groupName = it; val storedGroup = storedGroups.firstOrNull { it.title == groupName } - if (storedGroup != null){ - groups.add(storedGroup); // Group is already present on this device + if (storedGroup != null) { + groups.add(storedGroup); } else { - // Group is not present on this device, yet so we create a new one val newcontactGroup = activity.dbHelper.insertGroup(Group(0, groupName)); - if (newcontactGroup != null) // and associate it with this contact + if (newcontactGroup != null) groups.add(newcontactGroup); } }