Search in sources :

Example 86 with VCard

use of ezvcard.VCard in project ez-vcard by mangstadt.

the class AgentTest method validate.

@Test
public void validate() {
    Agent property = new Agent();
    assertValidate(property).versions(VCardVersion.V2_1, VCardVersion.V3_0).run(8);
    assertValidate(property).versions(VCardVersion.V4_0).run(8, 2);
    VCard agentVCard = new VCard();
    property.setVCard(agentVCard);
    assertValidate(property).versions(VCardVersion.V2_1).run(10);
    assertValidate(property).versions(VCardVersion.V3_0).run(10, 10);
    assertValidate(property).versions(VCardVersion.V4_0).run(10, 2);
    property.setUrl("http://example.com");
    assertValidate(property).versions(VCardVersion.V2_1, VCardVersion.V3_0).run();
    assertValidate(property).versions(VCardVersion.V4_0).run(2);
}
Also used : VCard(ezvcard.VCard) Test(org.junit.Test)

Example 87 with VCard

use of ezvcard.VCard in project ez-vcard by mangstadt.

the class AgentTest method constructors.

@Test
public void constructors() {
    VCard vcard = new VCard();
    Agent agent = new Agent();
    assertNull(agent.getUrl());
    assertNull(agent.getVCard());
    agent = new Agent("one");
    assertEquals("one", agent.getUrl());
    assertNull(agent.getVCard());
    agent = new Agent(vcard);
    assertNull(agent.getUrl());
    assertEquals(vcard, agent.getVCard());
}
Also used : VCard(ezvcard.VCard) Test(org.junit.Test)

Example 88 with VCard

use of ezvcard.VCard in project ez-vcard by mangstadt.

the class EmailScribeTest method prepareParameters_pref_parameter.

@Test
public void prepareParameters_pref_parameter() {
    Email property = new Email("johndoe@example.com");
    property.setPref(1);
    VCard vcard = new VCard();
    vcard.addEmail(property);
    sensei.assertPrepareParams(property).versions(V2_1, V3_0).vcard(vcard).expected("TYPE", "pref").run();
    sensei.assertPrepareParams(property).versions(V4_0).vcard(vcard).expected("PREF", "1").run();
}
Also used : Email(ezvcard.property.Email) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 89 with VCard

use of ezvcard.VCard in project Signal-Android by WhisperSystems.

the class SharedContactRepository method getContactFromVcard.

@WorkerThread
@Nullable
private Contact getContactFromVcard(@NonNull Uri uri) {
    Contact contact = null;
    try (InputStream stream = PartAuthority.getAttachmentStream(context, uri)) {
        VCard vcard = Ezvcard.parse(stream).first();
        contact = VCardUtil.getContactFromVcard(vcard);
    } catch (IOException e) {
        Log.w(TAG, "Failed to parse the vcard.", e);
    }
    if (BlobProvider.AUTHORITY.equals(uri.getAuthority())) {
        BlobProvider.getInstance().delete(context, uri);
    }
    return contact;
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) VCard(ezvcard.VCard) WorkerThread(androidx.annotation.WorkerThread) Nullable(androidx.annotation.Nullable)

Example 90 with VCard

use of ezvcard.VCard in project qksms by moezbhatti.

the class MessageListAdapter method bindVcard.

private void bindVcard(MessageListViewHolder holder, MessageItem messageItem) {
    if (!ContentType.TEXT_VCARD.equals(messageItem.mTextContentType)) {
        return;
    }
    VCard vCard = Ezvcard.parse(messageItem.mBody).first();
    SpannableString name = new SpannableString(vCard.getFormattedName().getValue());
    name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
    holder.mBodyTextView.setText(name);
}
Also used : SpannableString(android.text.SpannableString) VCard(ezvcard.VCard) UnderlineSpan(android.text.style.UnderlineSpan)

Aggregations

VCard (ezvcard.VCard)191 Test (org.junit.Test)134 StringWriter (java.io.StringWriter)29 StructuredName (ezvcard.property.StructuredName)23 Person (com.google.api.services.people.v1.model.Person)22 Telephone (ezvcard.property.Telephone)21 Photo (ezvcard.property.Photo)17 Email (ezvcard.property.Email)16 List (java.util.List)16 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)15 Document (org.w3c.dom.Document)15 VCardVersion (ezvcard.VCardVersion)14 XCardDocumentStreamWriter (ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter)14 Address (ezvcard.property.Address)14 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)13 Collectors (java.util.stream.Collectors)12 Name (com.google.api.services.people.v1.model.Name)11 File (java.io.File)11 Truth.assertThat (com.google.common.truth.Truth.assertThat)10 Pair (com.google.gdata.util.common.base.Pair)10