From 4fec43786b64bda26da84db4b8ceea6b51a099f1 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 22 Aug 2023 18:47:07 +0530 Subject: [PATCH 1/8] use our fork of vcard4android --- app/build.gradle | 4 +++- build.gradle | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1a900b11a..3108c368f 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,8 @@ dependencies { exclude group: 'com.squareup.okhttp3' } + + // for tests androidTestImplementation "com.google.dagger:hilt-android-testing:${versions.hilt}" kaptAndroidTest "com.google.dagger:hilt-android-compiler:${versions.hilt}" diff --git a/build.gradle b/build.gradle index 610b83ab5..e7d2b9007 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { cert4android: 'f167e84', dav4jvm: 'da94a8b', ical4android: 'a78e72f', - vcard4android: 'bd08206' + vcard4android: '1.1.0-test' ] repositories { -- GitLab From af27b9e476d3856be28c3cb41c376e5b06fc7416 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 22 Aug 2023 18:47:53 +0530 Subject: [PATCH 2/8] prevent making "starred" category on device --- .../davdroid/resource/contactrow/GroupMembershipBuilder.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 84426a0c0..dc223625f 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 @@ -20,8 +20,10 @@ 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 == "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 -- GitLab From 66139064c28eda277ef70857a5718aab9a1816ee Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 22 Aug 2023 18:48:30 +0530 Subject: [PATCH 3/8] add starred category while uploading to cloud --- .../at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 e32d4708c..7e9e66a0e 100644 --- a/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt +++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt @@ -230,6 +230,12 @@ class ContactsSyncManager( else -> throw IllegalArgumentException("resource must be LocalContact or LocalGroup") } + if (contact.starred && !contact.categories.contains("starred")) { + contact.categories.add("starred") + } else { + contact.categories.remove("starred") + } + Logger.log.log(Level.FINE, "Preparing upload of vCard ${resource.fileName}", contact) val os = ByteArrayOutputStream() -- GitLab From 87620dd5049e77d68a7f64c28753a2df67057a91 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 22 Aug 2023 19:46:09 +0530 Subject: [PATCH 4/8] add ez-vcard --- app/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 3108c368f..487e0432c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -222,6 +222,8 @@ dependencies { exclude group: 'com.squareup.okhttp3' } + // ez-vcard to parse/generate vCards + api("com.googlecode.ez-vcard:ez-vcard:0.12.0") // for tests -- GitLab From 515698aa9a5f32f71cda285b787169585212cb05 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 22 Aug 2023 20:01:19 +0530 Subject: [PATCH 5/8] use const val for "starred" --- .../at/bitfire/davdroid/syncadapter/ContactsSyncManager.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 7e9e66a0e..2f96ff59a 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,10 +231,10 @@ class ContactsSyncManager( else -> throw IllegalArgumentException("resource must be LocalContact or LocalGroup") } - if (contact.starred && !contact.categories.contains("starred")) { - contact.categories.add("starred") + if (contact.starred && !contact.categories.contains(LABEL_STARRED)) { + contact.categories.add(LABEL_STARRED) } else { - contact.categories.remove("starred") + contact.categories.remove(LABEL_STARRED) } Logger.log.log(Level.FINE, "Preparing upload of vCard ${resource.fileName}", contact) -- GitLab From 616e06fdd7e5d8fbfed5306b18b7ebd06555dda8 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 23 Aug 2023 12:41:25 +0530 Subject: [PATCH 6/8] use LABEL_STARRED --- .../java/at/bitfire/davdroid/syncadapter/TestSyncManager.kt | 2 +- .../davdroid/resource/contactrow/GroupMembershipBuilder.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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 85b04d82d..905e42744 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 dc223625f..509e25a30 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 @@ -21,7 +22,7 @@ class GroupMembershipBuilder(dataRowUri: Uri, rawContactId: Long?, contact: Cont if (addressBook.groupMethod == GroupMethod.CATEGORIES) for (category in contact.categories) { - if (category == "starred") continue + if (category == LABEL_STARRED) continue result += newDataRow().withValue(GroupMembership.GROUP_ROW_ID, addressBook.findOrCreateGroup(category)) } else { -- GitLab From 758b368e022e957c8c83a5c61ad4cc7214ecdcbd Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 23 Aug 2023 09:15:31 +0000 Subject: [PATCH 7/8] Apply 1 suggestion(s) to 1 file(s) --- .../davdroid/resource/contactrow/GroupMembershipBuilder.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 509e25a30..c87cdc4ea 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 @@ -22,7 +22,11 @@ class GroupMembershipBuilder(dataRowUri: Uri, rawContactId: Long?, contact: Cont if (addressBook.groupMethod == GroupMethod.CATEGORIES) for (category in contact.categories) { - if (category == LABEL_STARRED) continue + + if (category == LABEL_STARRED) { + continue + } + result += newDataRow().withValue(GroupMembership.GROUP_ROW_ID, addressBook.findOrCreateGroup(category)) } else { -- GitLab From 93b6a3bebdd5c58a13167396898b993ca40c0017 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 23 Aug 2023 15:17:34 +0530 Subject: [PATCH 8/8] use vcard4android version 1.1.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e7d2b9007..d0efb0c1f 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { cert4android: 'f167e84', dav4jvm: 'da94a8b', ical4android: 'a78e72f', - vcard4android: '1.1.0-test' + vcard4android: '1.1.1' ] repositories { -- GitLab