use of ezvcard.property.Note in project android by nextcloud.
the class ContactOperations method convertNotes.
private void convertNotes(List<NonEmptyContentValues> contentValues, VCard vcard) {
for (Note note : vcard.getNotes()) {
String noteValue = note.getValue();
NonEmptyContentValues cv = new NonEmptyContentValues(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE);
cv.put(ContactsContract.CommonDataKinds.Note.NOTE, noteValue);
contentValues.add(cv);
}
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class VCardTest method setProperty.
@Test
public void setProperty() {
VCard vcard = new VCard();
Note property1 = new Note("value");
assertEquals(asList(), vcard.setProperty(property1));
assertEquals(asList(property1), vcard.getProperties(Note.class));
Note property2 = new Note("value2");
assertEquals(asList(property1), vcard.setProperty(property2));
assertEquals(asList(property2), vcard.getProperties(Note.class));
Note property3 = new Note("value3");
vcard.addProperty(property3);
assertEquals(asList(property2, property3), vcard.getProperties(Note.class));
Note property4 = new Note("value4");
assertEquals(asList(property2, property3), vcard.setProperty(property4));
assertEquals(asList(property4), vcard.getProperties(Note.class));
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class VCardTest method removeProperty.
@Test
public void removeProperty() {
VCard vcard = new VCard();
Note property1 = new Note("value");
assertFalse(vcard.removeProperty(property1));
vcard.addProperty(property1);
assertEquals(asList(property1), vcard.getProperties(Note.class));
assertTrue(vcard.removeProperty(property1));
assertEquals(asList(), vcard.getProperties(Note.class));
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class SampleVCardsTest method outlook2003VCard.
@Test
public void outlook2003VCard() throws Throwable {
VCardAsserter asserter = read("outlook-2003.vcf");
asserter.next(V2_1);
// @formatter:off
asserter.structuredName().family("Doe").given("John").prefixes("Mr.").suffixes("III").noMore();
asserter.simpleProperty(FormattedName.class).value("John Doe III").noMore();
asserter.listProperty(Nickname.class).values("Joey").noMore();
asserter.listProperty(Organization.class).values("Company, The", "TheDepartment").noMore();
asserter.simpleProperty(Title.class).value("The Job Title").noMore();
asserter.simpleProperty(Note.class).value("This is the note field!!\r\nSecond line\r\n\r\nThird line is empty\r\n").param("ENCODING", "QUOTED-PRINTABLE").noMore();
asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("BusinessPhone").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("HomePhone").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("MobilePhone").next().types(TelephoneType.WORK, TelephoneType.FAX).text("BusinessFaxPhone").noMore();
asserter.address().extendedAddress("TheOffice").streetAddress("123 Main St").locality("Austin").region("TX").postalCode("12345").country("United States of America").label("TheOffice\r\n123 Main St\r\nAustin, TX 12345\r\nUnited States of America").types(AddressType.WORK).noMore();
asserter.simpleProperty(Url.class).value("http://web-page-address.com").param("TYPE", "WORK").noMore();
asserter.simpleProperty(Role.class).value("TheProfession").noMore();
asserter.dateProperty(Birthday.class).date("1980-03-21").noMore();
asserter.binaryProperty(Key.class).param("ENCODING", "BASE64").param("TYPE", "X509").contentType(KeyType.X509).dataLength(805).noMore();
asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("jdoe@hotmail.com").noMore();
/*
* Outlook 2003 apparently doesn't output FBURL correctly:
* http://help.lockergnome.com/office/BUG-Outlook-2003-exports-FBURL-vCard-incorrectly--ftopict423660.html
*/
asserter.simpleProperty(FreeBusyUrl.class).value("????????????????s????????????" + (char) 12).param("ENCODING", "QUOTED-PRINTABLE").noMore();
asserter.simpleProperty(Revision.class).value(utc("2012-10-12 21:05:25")).noMore();
VCard vcard = asserter.getVCard();
asserter.validate().prop(vcard.getNickname(), // not supported in 2.1
2).prop(vcard.getFbUrls().get(0), // not supported in 2.1
2).run();
// @formatter:on
asserter.done();
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class XCardDocumentTest method add_group.
@Test
public void add_group() throws Throwable {
VCard vcard = new VCard();
vcard.setFormattedName("John Doe");
Note note = vcard.addNote("This is a\nnote.");
note.setGroup("group1");
note.setLanguage("en");
Photo photo = new Photo("http://example.com/image.jpg", ImageType.JPEG);
photo.setGroup("group1");
vcard.addPhoto(photo);
note = vcard.addNote("Bonjour.");
note.setGroup("group2");
XCardDocument xcard = new XCardDocument();
XCardDocumentStreamWriter writer = xcard.writer();
writer.setAddProdId(false);
writer.write(vcard);
Document actual = xcard.getDocument();
// @formatter:off
String xml = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<fn><text>John Doe</text></fn>" + "<group name=\"group1\">" + "<photo>" + "<parameters>" + "<mediatype><text>image/jpeg</text></mediatype>" + "</parameters>" + "<uri>http://example.com/image.jpg</uri>" + "</photo>" + "<note>" + "<parameters>" + "<language><language-tag>en</language-tag></language>" + "</parameters>" + "<text>This is a\nnote.</text>" + "</note>" + "</group>" + "<group name=\"group2\">" + "<note><text>Bonjour.</text></note>" + "</group>" + "</vcard>" + "</vcards>";
Document expected = XmlUtils.toDocument(xml);
// @formatter:on
assertXMLEqual(expected, actual);
}
Aggregations