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

Commit ab6167b9 authored by Sumit Pundir's avatar Sumit Pundir
Browse files

Merge remote-tracking branch 'bitfireAT/master' into sprint_freetown

parents 950239ee bf4ea05d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -11,10 +11,15 @@ It's a framework for
  from/into data classes that are compatible with the Android Contacts Provider, and
* accessing the Android Contacts Provider by a unified API.

It has been primarily developed for [DAVdroid](https://www.davdroid.com).
It has been primarily developed for [DAVx⁵](https://www.davx5.com).

_This software is not affiliated to, nor has it been authorized, sponsored or otherwise approved
by Google LLC. Android is a trademark of Google LLC._

Generated KDoc: https://bitfireAT.gitlab.io/vcard4android/dokka/vcard4android/

Discussion: https://forums.bitfire.at/category/18/libraries


## Contact

@@ -26,9 +31,6 @@ Florastraße 27

Email: [play@bitfire.at](mailto:play@bitfire.at) (do not use this)

For questions, suggestions etc. please use the DAVdroid forum:
https://www.davdroid.com/forums/


## License 

+27 −13
Original line number Diff line number Diff line

buildscript {
    ext.versions = [
        kotlin: '1.3.31',
        dokka: '0.9.17'
        kotlin: '1.3.61',
        dokka: '0.10.0'
    ]

    repositories {
@@ -11,9 +11,9 @@ buildscript {
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
    }
}

@@ -24,16 +24,22 @@ repositories {

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'
apply plugin: 'org.jetbrains.dokka'

android {
    compileSdkVersion 27
    buildToolsVersion '27.1.1'
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        minSdkVersion 24 
        targetSdkVersion 27
        targetSdkVersion 29
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        release {
            minifyEnabled false
@@ -53,12 +59,20 @@ android {
    defaultConfig {
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    dokka.configuration {
        sourceLink {
            url = "https://gitlab.com/bitfireAT/vcard4android/tree/master/"
            lineSuffix = "#L"
        }
        jdkVersion = 7
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"

    implementation 'org.apache.commons:commons-text:1.6'
    implementation 'org.apache.commons:commons-text:1.8'
    implementation 'commons-io:commons-io:2.6'

    // ez-vcard to parse/generate VCards
@@ -70,8 +84,8 @@ dependencies {
        exclude group: 'com.fasterxml.jackson.core'
    }

    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test:rules:1.2.0'

    testImplementation 'junit:junit:4.12'
}
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
+45 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import foundation.e.vcard4android.impl.TestAddressBook
import ezvcard.VCardVersion
import ezvcard.parameter.EmailType
import ezvcard.property.Address
import ezvcard.property.Birthday
import ezvcard.property.Email
@@ -202,6 +203,50 @@ class AndroidContactTest {
        }
    }

    @Test
    @SmallTest
    fun testEmailTypes() {
        val vCard = "BEGIN:VCARD\r\n" +
                "VERSION:4.0\r\n" +
                "FN:Test\r\n" +
                "EMAIL;TYPE=internet;TYPE=work:work@example.com\r\n" +
                "EMAIL;TYPE=home:home@example.com\r\n" +
                "EMAIL;TYPE=internet,pref:other1@example.com\r\n" +
                "EMAIL;TYPE=x400,other:other2@example.com\r\n" +
                "EMAIL;TYPE=x-mobile:mobile@example.com\r\n" +
                "END:VCARD\r\n"
        val contacts = Contact.fromReader(StringReader(vCard), null)

        val dbContact = AndroidContact(addressBook, contacts.first(), null, null)
        dbContact.add()

        val dbContact2 = addressBook.findContactByID(dbContact.id!!)
        try {
            val contact2 = dbContact2.contact!!
            assertEquals("work@example.com", contact2.emails[0].property.value)
            assertArrayEquals(arrayOf(EmailType.WORK), contact2.emails[0].property.types.toTypedArray())
            assertNull(contact2.emails[0].property.pref)

            assertEquals("home@example.com", contact2.emails[1].property.value)
            assertArrayEquals(arrayOf(EmailType.HOME), contact2.emails[1].property.types.toTypedArray())
            assertNull(contact2.emails[1].property.pref)

            assertEquals("other1@example.com", contact2.emails[2].property.value)
            assertTrue(contact2.emails[2].property.types.isEmpty())
            assertNotEquals(0, contact2.emails[2].property.pref)

            assertEquals("other2@example.com", contact2.emails[3].property.value)
            assertTrue(contact2.emails[3].property.types.isEmpty())
            assertNull(contact2.emails[3].property.pref)

            assertEquals("mobile@example.com", contact2.emails[4].property.value)
            assertArrayEquals(arrayOf(Contact.EMAIL_TYPE_MOBILE), contact2.emails[4].property.types.toTypedArray())
            assertNull(contact2.emails[4].property.pref)
        } finally {
            dbContact2.delete()
        }
    }


    @Test
    fun testLabelToXName() {
+1 −2
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />

    <application android:allowBackup="true"
                 android:label="@string/app_name"/>
    <application />

</manifest>
Loading