Search in sources :

Example 26 with VCard

use of ezvcard.VCard in project ring-client-android by savoirfairelinux.

the class ConversationPresenter method sendTrustRequest.

public void sendTrustRequest() {
    VCard vCard = mVCardService.loadSmallVCard(mAccountId);
    mAccountService.sendTrustRequest(mAccountId, mContactRingId.getRawRingId(), Blob.fromString(VCardUtils.vcardToString(vCard)));
    CallContact contact = mContactService.findContact(mContactRingId);
    if (contact == null) {
        Log.e(TAG, "sendTrustRequest: not able to find contact");
        return;
    }
    contact.setStatus(CallContact.Status.REQUEST_SENT);
}
Also used : VCard(ezvcard.VCard) CallContact(cx.ring.model.CallContact)

Example 27 with VCard

use of ezvcard.VCard in project ring-client-android by savoirfairelinux.

the class RingNavigationPresenter method getAlias.

public String getAlias(Account account) {
    if (account == null) {
        Log.e(TAG, "Not able to get alias");
        return null;
    }
    VCard vcard = VCardUtils.loadLocalProfileFromDisk(mDeviceRuntimeService.provideFilesDir(), account.getAccountID());
    FormattedName name = vcard.getFormattedName();
    if (name != null) {
        String name_value = name.getValue();
        if (name_value != null && !name_value.isEmpty()) {
            return name_value;
        }
    }
    return null;
}
Also used : FormattedName(ezvcard.property.FormattedName) VCard(ezvcard.VCard)

Example 28 with VCard

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

the class JCardReaderTest method readExtendedType_override_standard_type_classes.

@Test
public void readExtendedType_override_standard_type_classes() throws Throwable {
    // @formatter:off
    String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"fn\", {}, \"text\", \"John Doe\"]" + "]" + "]";
    // @formatter:on
    JCardReader reader = new JCardReader(json);
    reader.registerScribe(new MyFormattedNameScribe());
    VCard vcard = reader.readNext();
    assertPropertyCount(1, vcard);
    assertVersion(V4_0, vcard);
    MyFormattedNameProperty prop = vcard.getProperty(MyFormattedNameProperty.class);
    assertEquals("JOHN DOE", prop.value);
    assertParseWarnings(reader);
    assertNoMoreVCards(reader);
}
Also used : MyFormattedNameScribe(ezvcard.io.MyFormattedNameProperty.MyFormattedNameScribe) MyFormattedNameProperty(ezvcard.io.MyFormattedNameProperty) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 29 with VCard

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

the class JCardReaderTest method registerExtendedType.

@Test
public void registerExtendedType() throws Throwable {
    // @formatter:off
    String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"x-type\", {}, \"text\", \"value\"]" + "]" + "]";
    // @formatter:on
    JCardReader reader = new JCardReader(json);
    reader.registerScribe(new TypeForTestingScribe());
    VCard vcard = reader.readNext();
    assertVersion(V4_0, vcard);
    assertPropertyCount(1, vcard);
    TypeForTesting prop = vcard.getProperty(TypeForTesting.class);
    assertEquals("value", prop.value.asSingle());
    assertParseWarnings(reader);
    assertNoMoreVCards(reader);
}
Also used : VCard(ezvcard.VCard) Test(org.junit.Test)

Example 30 with VCard

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

the class JCardSerializerTest method container.

@Test
public void container() throws Exception {
    VCard vcard = new VCard();
    vcard.setFormattedName("John Doe");
    vcard.setMailer("mailer");
    Container container = new Container(vcard);
    StringWriter result = new StringWriter();
    mapper.writeValue(result, container);
    String actual = result.toString();
    // @formatter:off
    String expected = "{" + "\"contact\":[\"vcard\"," + "[" + "[\"version\",{},\"text\",\"4.0\"]," + "[\"prodid\",{},\"text\",\"ez-vcard " + Ezvcard.VERSION + "\"]," + "[\"fn\",{},\"text\",\"John Doe\"]" + "]" + "]" + "}";
    // @formatter:on
    assertEquals(expected, actual);
}
Also used : StringWriter(java.io.StringWriter) VCard(ezvcard.VCard) Test(org.junit.Test)

Aggregations

VCard (ezvcard.VCard)189 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