Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 161ac16d authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury Committed by Vincent Bourgmayer
Browse files

Issue 2427: sync starred contacts

parent c82130a0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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}"
+1 −1
Original line number Diff line number Diff line
@@ -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
    }

+8 −1
Original line number Diff line number Diff line
@@ -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<BatchOperation.CpoBuilder>()

        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
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ class ContactsSyncManager(

    companion object {
        infix fun <T> Set<T>.disjunct(other: Set<T>) = (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()
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ buildscript {
        cert4android: 'f167e84',
        dav4jvm: 'da94a8b',
        ical4android: 'a78e72f',
        vcard4android: 'bd08206'
        vcard4android: '1.1.1'
    ]

    repositories {