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);
}
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());
}
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();
}
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;
}
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);
}
Aggregations