mirror of
https://github.com/etesync/android
synced 2025-04-26 20:19:07 +00:00
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
This commit is contained in:
parent
15e8e20bad
commit
3af25754c4
@ -1,24 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ContactsAccountType
|
<ContactsAccountType xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<EditSchema>
|
<EditSchema>
|
||||||
<DataKind
|
<DataKind
|
||||||
kind="name"
|
kind="name"
|
||||||
maxOccurs="1"
|
maxOccurs="1"
|
||||||
supportsDisplayName="true"
|
supportsDisplayName="true"
|
||||||
supportsMiddleName="true"
|
|
||||||
supportsFamilyName="true"
|
supportsFamilyName="true"
|
||||||
|
supportsMiddleName="true"
|
||||||
supportsPhoneticFamilyName="true"
|
supportsPhoneticFamilyName="true"
|
||||||
supportsPhoneticGivenName="true"
|
supportsPhoneticGivenName="true"
|
||||||
supportsPhoneticMiddleName="true"
|
supportsPhoneticMiddleName="true"
|
||||||
supportsPrefix="true"
|
supportsPrefix="true"
|
||||||
supportsSuffix="true" />
|
supportsSuffix="true" />
|
||||||
|
|
||||||
<DataKind
|
|
||||||
kind="photo"
|
|
||||||
maxOccurs="1" />
|
|
||||||
|
|
||||||
<DataKind kind="phone" >
|
<DataKind kind="phone" >
|
||||||
<Type type="mobile" />
|
<Type type="mobile" />
|
||||||
<Type type="home" />
|
<Type type="home" />
|
||||||
@ -51,10 +46,23 @@
|
|||||||
<Type type="custom" />
|
<Type type="custom" />
|
||||||
</DataKind>
|
</DataKind>
|
||||||
|
|
||||||
<DataKind kind="postal" needsStructured="true" >
|
<DataKind
|
||||||
<Type type="home" />
|
kind="photo"
|
||||||
<Type type="work" />
|
maxOccurs="1" />
|
||||||
<Type type="other" />
|
|
||||||
|
<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" />
|
<Type type="custom" />
|
||||||
</DataKind>
|
</DataKind>
|
||||||
|
|
||||||
@ -62,16 +70,30 @@
|
|||||||
kind="nickname"
|
kind="nickname"
|
||||||
maxOccurs="1" />
|
maxOccurs="1" />
|
||||||
|
|
||||||
<DataKind kind="website" />
|
|
||||||
<DataKind
|
<DataKind
|
||||||
kind="note"
|
kind="note"
|
||||||
maxOccurs="1" />
|
maxOccurs="1" />
|
||||||
|
|
||||||
|
<DataKind
|
||||||
|
kind="postal"
|
||||||
|
needsStructured="true" >
|
||||||
|
<Type type="home" />
|
||||||
|
<Type type="work" />
|
||||||
|
<Type type="other" />
|
||||||
|
<Type type="custom" />
|
||||||
|
</DataKind>
|
||||||
|
|
||||||
|
<DataKind kind="website" />
|
||||||
|
|
||||||
<DataKind
|
<DataKind
|
||||||
dateWithTime="false"
|
dateWithTime="false"
|
||||||
kind="event" >
|
kind="event" >
|
||||||
<Type maxOccurs="1" type="birthday" yearOptional="false" />
|
<Type
|
||||||
|
maxOccurs="1"
|
||||||
|
type="birthday"
|
||||||
|
yearOptional="false" />
|
||||||
<Type type="anniversary" />
|
<Type type="anniversary" />
|
||||||
</DataKind>
|
</DataKind>
|
||||||
</EditSchema>
|
</EditSchema>
|
||||||
|
|
||||||
</ContactsAccountType>
|
</ContactsAccountType>
|
@ -70,7 +70,7 @@ public class Contact extends Resource {
|
|||||||
@Getter @Setter private String displayName, nickName;
|
@Getter @Setter private String displayName, nickName;
|
||||||
@Getter @Setter private String prefix, givenName, middleName, familyName, suffix;
|
@Getter @Setter private String prefix, givenName, middleName, familyName, suffix;
|
||||||
@Getter @Setter private String phoneticGivenName, phoneticMiddleName, phoneticFamilyName;
|
@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 String organization, role;
|
||||||
|
|
||||||
@Getter @Setter private byte[] photo;
|
@Getter @Setter private byte[] photo;
|
||||||
@ -78,10 +78,11 @@ public class Contact extends Resource {
|
|||||||
@Getter @Setter private Anniversary anniversary;
|
@Getter @Setter private Anniversary anniversary;
|
||||||
@Getter @Setter private Birthday birthDay;
|
@Getter @Setter private Birthday birthDay;
|
||||||
|
|
||||||
@Getter private List<Email> emails = new LinkedList<Email>();
|
|
||||||
@Getter private List<Telephone> phoneNumbers = new LinkedList<Telephone>();
|
@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<Impp> impps = new LinkedList<Impp>();
|
||||||
|
@Getter private List<Address> addresses = new LinkedList<Address>();
|
||||||
|
@Getter private List<String> URLs = new LinkedList<String>();
|
||||||
|
|
||||||
|
|
||||||
/* instance methods */
|
/* instance methods */
|
||||||
@ -174,10 +175,8 @@ public class Contact extends Resource {
|
|||||||
|
|
||||||
addresses = vcard.getAddresses();
|
addresses = vcard.getAddresses();
|
||||||
|
|
||||||
for (Url url : vcard.getUrls()) {
|
for (Url url : vcard.getUrls())
|
||||||
URL = url.getValue();
|
URLs.add(url.getValue());
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
birthDay = vcard.getBirthday();
|
birthDay = vcard.getBirthday();
|
||||||
anniversary = vcard.getAnniversary();
|
anniversary = vcard.getAnniversary();
|
||||||
@ -187,6 +186,7 @@ public class Contact extends Resource {
|
|||||||
@Override
|
@Override
|
||||||
public String toEntity() throws IOException {
|
public String toEntity() throws IOException {
|
||||||
VCard vcard = new VCard();
|
VCard vcard = new VCard();
|
||||||
|
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION + " (ez-vcard/" + Ezvcard.VERSION + ")");
|
||||||
|
|
||||||
if (uid != null)
|
if (uid != null)
|
||||||
vcard.setUid(new Uid(uid));
|
vcard.setUid(new Uid(uid));
|
||||||
@ -249,19 +249,19 @@ public class Contact extends Resource {
|
|||||||
for (Address address : addresses)
|
for (Address address : addresses)
|
||||||
vcard.addAddress(address);
|
vcard.addAddress(address);
|
||||||
|
|
||||||
if (URL != null && !URL.isEmpty())
|
for (String url : URLs)
|
||||||
vcard.addUrl(URL);
|
vcard.addUrl(url);
|
||||||
|
|
||||||
if (anniversary != null)
|
if (anniversary != null)
|
||||||
vcard.setAnniversary(anniversary);
|
vcard.setAnniversary(anniversary);
|
||||||
if (birthDay != null)
|
if (birthDay != null)
|
||||||
vcard.setBirthday(birthDay);
|
vcard.setBirthday(birthDay);
|
||||||
|
|
||||||
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION);
|
|
||||||
vcard.setRevision(Revision.now());
|
vcard.setRevision(Revision.now());
|
||||||
return Ezvcard
|
return Ezvcard
|
||||||
.write(vcard)
|
.write(vcard)
|
||||||
.version(VCardVersion.V3_0)
|
.version(VCardVersion.V3_0)
|
||||||
|
.prodId(false) // we provide or own PRODID
|
||||||
.go();
|
.go();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,8 +252,12 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
|
||||||
if (cursor != null && cursor.moveToNext()) {
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
c.setOrganization(cursor.getString(0));
|
String org = cursor.getString(0),
|
||||||
c.setRole(cursor.getString(1));
|
role = cursor.getString(1);
|
||||||
|
if (org != null && !org.isEmpty())
|
||||||
|
c.setOrganization(org);
|
||||||
|
if (role != null && !role.isEmpty())
|
||||||
|
c.setRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPPs
|
// IMPPs
|
||||||
@ -365,7 +369,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
Website.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Website.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), Website.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), Website.CONTENT_ITEM_TYPE }, null);
|
||||||
if (cursor != null && cursor.moveToNext())
|
if (cursor != null && cursor.moveToNext())
|
||||||
c.setURL(cursor.getString(0));
|
c.getURLs().add(cursor.getString(0));
|
||||||
|
|
||||||
// events
|
// events
|
||||||
cursor = providerClient.query(dataURI(), new String[] { CommonDataKinds.Event.TYPE, CommonDataKinds.Event.START_DATE },
|
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
|
// TODO group membership
|
||||||
|
|
||||||
if (contact.getURL() != null)
|
for (String url : contact.getURLs())
|
||||||
queueOperation(buildURL(newDataInsertBuilder(localID, backrefIdx), contact.getURL()));
|
queueOperation(buildURL(newDataInsertBuilder(localID, backrefIdx), url));
|
||||||
|
|
||||||
// events
|
// events
|
||||||
if (contact.getAnniversary() != null)
|
if (contact.getAnniversary() != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user