Amend EditSchema and VCard fields

* write PRODID with DAVdroid and ez-vcard version to VCards
* remove limit of 1 for contact Web sites in contact EditSchema
* add organization to contact EditSchema
* don't set null values in ORG/ROLE
pull/2/head
rfc2822 11 years ago
parent 15e8e20bad
commit 3af25754c4

@ -1,25 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<ContactsAccountType
xmlns:android="http://schemas.android.com/apk/res/android">
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android" >
<EditSchema>
<DataKind
kind="name"
maxOccurs="1"
supportsDisplayName="true"
supportsMiddleName="true"
supportsFamilyName="true"
supportsPhoneticFamilyName="true"
supportsPhoneticGivenName="true"
supportsPhoneticMiddleName="true"
supportsPrefix="true"
supportsSuffix="true" />
<DataKind
kind="photo"
maxOccurs="1" />
<DataKind kind="phone">
<DataKind
kind="name"
maxOccurs="1"
supportsDisplayName="true"
supportsFamilyName="true"
supportsMiddleName="true"
supportsPhoneticFamilyName="true"
supportsPhoneticGivenName="true"
supportsPhoneticMiddleName="true"
supportsPrefix="true"
supportsSuffix="true" />
<DataKind kind="phone" >
<Type type="mobile" />
<Type type="home" />
<Type type="work" />
@ -27,7 +22,7 @@
<Type type="fax_home" />
<Type type="pager" />
<Type type="other" />
<Type type="custom"/>
<Type type="custom" />
<Type type="callback" />
<Type type="car" />
<Type type="company_main" />
@ -37,41 +32,68 @@
<Type type="radio" />
<Type type="telex" />
<Type type="tty_tdd" />
<Type type="work_mobile"/>
<Type type="work_mobile" />
<Type type="work_pager" />
<Type type="assistant" />
<Type type="mms" />
</DataKind>
<DataKind kind="email">
<DataKind kind="email" >
<Type type="home" />
<Type type="work" />
<Type type="other" />
<Type type="mobile" />
<Type type="custom" />
</DataKind>
<DataKind kind="postal" needsStructured="true" >
</DataKind>
<DataKind
kind="photo"
maxOccurs="1" />
<DataKind
kind="organization"
maxOccurs="1" />
<DataKind kind="im" >
<Type type="aim" />
<Type type="msn" />
<Type type="yahoo" />
<Type type="skype" />
<Type type="qq" />
<Type type="google_talk" />
<Type type="icq" />
<Type type="jabber" />
<Type type="custom" />
</DataKind>
<DataKind
kind="nickname"
maxOccurs="1" />
<DataKind
kind="note"
maxOccurs="1" />
<DataKind
kind="postal"
needsStructured="true" >
<Type type="home" />
<Type type="work" />
<Type type="other" />
<Type type="custom" />
</DataKind>
<DataKind
kind="nickname"
maxOccurs="1" />
<DataKind kind="website" />
<DataKind
kind="note"
maxOccurs="1" />
<DataKind
dateWithTime="false"
kind="event">
<Type maxOccurs="1" type="birthday" yearOptional="false" />
<Type type="anniversary" />
</DataKind>
</EditSchema>
</ContactsAccountType>
<DataKind
dateWithTime="false"
kind="event" >
<Type
maxOccurs="1"
type="birthday"
yearOptional="false" />
<Type type="anniversary" />
</DataKind>
</EditSchema>
</ContactsAccountType>

@ -70,7 +70,7 @@ public class Contact extends Resource {
@Getter @Setter private String displayName, nickName;
@Getter @Setter private String prefix, givenName, middleName, familyName, suffix;
@Getter @Setter private String phoneticGivenName, phoneticMiddleName, phoneticFamilyName;
@Getter @Setter private String note, URL;
@Getter @Setter private String note;
@Getter @Setter private String organization, role;
@Getter @Setter private byte[] photo;
@ -78,10 +78,11 @@ public class Contact extends Resource {
@Getter @Setter private Anniversary anniversary;
@Getter @Setter private Birthday birthDay;
@Getter private List<Email> emails = new LinkedList<Email>();
@Getter private List<Telephone> phoneNumbers = new LinkedList<Telephone>();
@Getter private List<Address> addresses = new LinkedList<Address>();
@Getter private List<Email> emails = new LinkedList<Email>();
@Getter private List<Impp> impps = new LinkedList<Impp>();
@Getter private List<Address> addresses = new LinkedList<Address>();
@Getter private List<String> URLs = new LinkedList<String>();
/* instance methods */
@ -174,10 +175,8 @@ public class Contact extends Resource {
addresses = vcard.getAddresses();
for (Url url : vcard.getUrls()) {
URL = url.getValue();
break;
}
for (Url url : vcard.getUrls())
URLs.add(url.getValue());
birthDay = vcard.getBirthday();
anniversary = vcard.getAnniversary();
@ -187,6 +186,7 @@ public class Contact extends Resource {
@Override
public String toEntity() throws IOException {
VCard vcard = new VCard();
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION + " (ez-vcard/" + Ezvcard.VERSION + ")");
if (uid != null)
vcard.setUid(new Uid(uid));
@ -249,19 +249,19 @@ public class Contact extends Resource {
for (Address address : addresses)
vcard.addAddress(address);
if (URL != null && !URL.isEmpty())
vcard.addUrl(URL);
for (String url : URLs)
vcard.addUrl(url);
if (anniversary != null)
vcard.setAnniversary(anniversary);
if (birthDay != null)
vcard.setBirthday(birthDay);
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION);
vcard.setRevision(Revision.now());
return Ezvcard
.write(vcard)
.version(VCardVersion.V3_0)
.prodId(false) // we provide or own PRODID
.go();
}
}

@ -252,8 +252,12 @@ public class LocalAddressBook extends LocalCollection<Contact> {
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
if (cursor != null && cursor.moveToNext()) {
c.setOrganization(cursor.getString(0));
c.setRole(cursor.getString(1));
String org = cursor.getString(0),
role = cursor.getString(1);
if (org != null && !org.isEmpty())
c.setOrganization(org);
if (role != null && !role.isEmpty())
c.setRole(role);
}
// IMPPs
@ -365,7 +369,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
Website.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), Website.CONTENT_ITEM_TYPE }, null);
if (cursor != null && cursor.moveToNext())
c.setURL(cursor.getString(0));
c.getURLs().add(cursor.getString(0));
// events
cursor = providerClient.query(dataURI(), new String[] { CommonDataKinds.Event.TYPE, CommonDataKinds.Event.START_DATE },
@ -495,8 +499,8 @@ public class LocalAddressBook extends LocalCollection<Contact> {
// TODO group membership
if (contact.getURL() != null)
queueOperation(buildURL(newDataInsertBuilder(localID, backrefIdx), contact.getURL()));
for (String url : contact.getURLs())
queueOperation(buildURL(newDataInsertBuilder(localID, backrefIdx), url));
// events
if (contact.getAnniversary() != null)

Loading…
Cancel
Save