diff --git a/app/build.gradle b/app/build.gradle index 1a900b11a777a22ae344e2c2b1f650205091ed9e..487e0432c176fc8467cb40827fd8b3d7a09a99bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -186,7 +186,7 @@ dependencies { // own libraries implementation "com.github.bitfireAT:cert4android:${versions.cert4android}" implementation files('../libs/ical4android.aar') - implementation "com.github.bitfireAT:vcard4android:${versions.vcard4android}" + implementation "foundation.e.lib:vcard4android:${versions.vcard4android}" // third-party libs implementation 'org.mnode.ical4j:ical4j:3.2.11' @@ -222,6 +222,10 @@ dependencies { exclude group: 'com.squareup.okhttp3' } + // ez-vcard to parse/generate vCards + api("com.googlecode.ez-vcard:ez-vcard:0.12.0") + + // for tests androidTestImplementation "com.google.dagger:hilt-android-testing:${versions.hilt}" kaptAndroidTest "com.google.dagger:hilt-android-compiler:${versions.hilt}" diff --git a/app/src/androidTestOse/java/at/bitfire/davdroid/syncadapter/TestSyncManager.kt b/app/src/androidTestOse/java/at/bitfire/davdroid/syncadapter/TestSyncManager.kt index 85b04d82d1f0e750da011bb7ec5bf8c3119c55cf..905e42744dabdc93dead79f743f7f1e48f1acd4b 100644 --- a/app/src/androidTestOse/java/at/bitfire/davdroid/syncadapter/TestSyncManager.kt +++ b/app/src/androidTestOse/java/at/bitfire/davdroid/syncadapter/TestSyncManager.kt @@ -35,7 +35,7 @@ class TestSyncManager( override fun prepare(): Boolean { collectionURL = mockWebServer.url("/") - davCollection = DavCollection(httpClient.okHttpClient, collectionURL, null) + davCollection = DavCollection(httpClient.okHttpClient, collectionURL) return true } diff --git a/app/src/main/java/at/bitfire/davdroid/resource/contactrow/GroupMembershipBuilder.kt b/app/src/main/java/at/bitfire/davdroid/resource/contactrow/GroupMembershipBuilder.kt index 84426a0c0ce6d7c9f2bc95efde01eb1b5e359a4d..c87cdc4ea3bfa7018f0fe440dddf1e0210737eb6 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/contactrow/GroupMembershipBuilder.kt +++ b/app/src/main/java/at/bitfire/davdroid/resource/contactrow/GroupMembershipBuilder.kt @@ -7,6 +7,7 @@ package at.bitfire.davdroid.resource.contactrow import android.net.Uri import android.provider.ContactsContract.CommonDataKinds.GroupMembership import at.bitfire.davdroid.resource.LocalAddressBook +import at.bitfire.davdroid.syncadapter.ContactsSyncManager.Companion.LABEL_STARRED import at.bitfire.vcard4android.BatchOperation import at.bitfire.vcard4android.Contact import at.bitfire.vcard4android.GroupMethod @@ -20,8 +21,14 @@ class GroupMembershipBuilder(dataRowUri: Uri, rawContactId: Long?, contact: Cont val result = LinkedList() if (addressBook.groupMethod == GroupMethod.CATEGORIES) - for (category in contact.categories) + for (category in contact.categories) { + + if (category == LABEL_STARRED) { + continue + } + result += newDataRow().withValue(GroupMembership.GROUP_ROW_ID, addressBook.findOrCreateGroup(category)) + } else { // GroupMethod.GROUP_VCARDS -> memberships are handled by LocalGroups (and not by the members = LocalContacts, which we are processing here) // TODO: CATEGORIES <-> unknown properties diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt b/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt index e32d4708c5051b3f89d29b1e60ca6dd0378e3a79..2f96ff59ac6b8ef4d550334329c80e53d75913a6 100644 --- a/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt +++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt @@ -91,6 +91,7 @@ class ContactsSyncManager( companion object { infix fun Set.disjunct(other: Set) = (this - other) union (other - this) + const val LABEL_STARRED = "starred" } private val readOnly = localAddressBook.readOnly @@ -230,6 +231,12 @@ class ContactsSyncManager( else -> throw IllegalArgumentException("resource must be LocalContact or LocalGroup") } + if (contact.starred && !contact.categories.contains(LABEL_STARRED)) { + contact.categories.add(LABEL_STARRED) + } else { + contact.categories.remove(LABEL_STARRED) + } + Logger.log.log(Level.FINE, "Preparing upload of vCard ${resource.fileName}", contact) val os = ByteArrayOutputStream() diff --git a/build.gradle b/build.gradle index 610b83ab56f33cd96b7239c6ca9557b1dd53ee1a..d0efb0c1f6f35366e2a5b881cbd1e46729ffe71e 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { cert4android: 'f167e84', dav4jvm: 'da94a8b', ical4android: 'a78e72f', - vcard4android: 'bd08206' + vcard4android: '1.1.1' ] repositories {