Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/src/main/kotlin/at/bitfire/vcard4android/ContactReader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ class ContactReader internal constructor(val vCard: VCard, val downloader: Conta
c.jobDescription = prop.value?.trimToNull()

is Telephone ->
if (!prop.text.isNullOrBlank())
c.phoneNumbers += LabeledProperty(prop, findAndRemoveLabel(prop.group))
c.phoneNumbers += LabeledProperty(prop, findAndRemoveLabel(prop.group))
is Email ->
if (!prop.value.isNullOrBlank())
c.emails += LabeledProperty(prop, findAndRemoveLabel(prop.group))
c.emails += LabeledProperty(prop, findAndRemoveLabel(prop.group))
is Impp ->
c.impps += LabeledProperty(prop, findAndRemoveLabel(prop.group))
is XSip ->
Expand Down
47 changes: 43 additions & 4 deletions lib/src/test/kotlin/at/bitfire/vcard4android/ContactReaderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,50 @@

package at.bitfire.vcard4android

import at.bitfire.vcard4android.property.*
import at.bitfire.vcard4android.property.CustomType
import at.bitfire.vcard4android.property.XAbDate
import at.bitfire.vcard4android.property.XAbLabel
import at.bitfire.vcard4android.property.XAbRelatedNames
import at.bitfire.vcard4android.property.XAddressBookServerKind
import at.bitfire.vcard4android.property.XPhoneticFirstName
import at.bitfire.vcard4android.property.XPhoneticLastName
import at.bitfire.vcard4android.property.XPhoneticMiddleName
import at.bitfire.vcard4android.property.XSip
import ezvcard.VCard
import ezvcard.VCardVersion
import ezvcard.parameter.ImageType
import ezvcard.parameter.RelatedType
import ezvcard.parameter.SoundType
import ezvcard.property.*
import ezvcard.property.Address
import ezvcard.property.Anniversary
import ezvcard.property.Birthday
import ezvcard.property.Categories
import ezvcard.property.FormattedName
import ezvcard.property.Impp
import ezvcard.property.Kind
import ezvcard.property.Label
import ezvcard.property.Logo
import ezvcard.property.Member
import ezvcard.property.Nickname
import ezvcard.property.Organization
import ezvcard.property.Photo
import ezvcard.property.ProductId
import ezvcard.property.RawProperty
import ezvcard.property.Related
import ezvcard.property.Revision
import ezvcard.property.SortString
import ezvcard.property.Sound
import ezvcard.property.StructuredName
import ezvcard.property.Telephone
import ezvcard.property.Uid
import ezvcard.property.Url
import ezvcard.util.PartialDate
import org.junit.Assert.*
import ezvcard.util.TelUri
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import java.net.URI
import java.time.LocalDate
Expand Down Expand Up @@ -366,9 +401,13 @@ class ContactReaderTest {
@Test
fun testTelephone() {
val c = ContactReader.fromVCard(VCard().apply {
// number of type TEXT
addTelephoneNumber("+1 555 12345")
// number of type URI
addTelephoneNumber(Telephone(TelUri.parse("tel:123")))
})
assertEquals("+1 555 12345", c.phoneNumbers.first.property.text)
assertEquals("+1 555 12345", c.phoneNumbers[0].property.text)
assertEquals("123", c.phoneNumbers[1].property.uri.number)
}


Expand Down