1
0
mirror of https://github.com/etesync/android synced 2025-01-11 00:01:12 +00:00

Better organization, job title/description handling

* handle VCard structured organization (department), job title/description correctly
* there's still an EZVCard bug: https://code.google.com/p/ez-vcard/issues/detail?id=13
* bump version code
This commit is contained in:
rfc2822 2014-01-25 13:07:33 +01:00
parent fee6431981
commit ea06c4a7a1
5 changed files with 39 additions and 28 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.davdroid" package="at.bitfire.davdroid"
android:versionCode="25" android:versionCode="26"
android:versionName="0.5.7-alpha" android:installLocation="internalOnly"> android:versionName="0.5.7-alpha" android:installLocation="internalOnly">
<uses-sdk <uses-sdk

Binary file not shown.

BIN
libs/ez-vcard-0.9.1.jar Normal file

Binary file not shown.

View File

@ -74,7 +74,8 @@ public class Contact extends Resource {
@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; @Getter @Setter private String note;
@Getter @Setter private String organization, jobTitle, department; @Getter @Setter private Organization organization;
@Getter @Setter private String jobTitle, jobDescription;
@Getter @Setter private byte[] photo; @Getter @Setter private byte[] photo;
@ -159,18 +160,14 @@ public class Contact extends Resource {
this.photo = photo.getData(); this.photo = photo.getData();
break; break;
} }
if (vcard.getOrganization() != null) { organization = vcard.getOrganization();
List<String> organizations = vcard.getOrganization().getValues();
if (!organizations.isEmpty())
organization = organizations.get(0);
}
for (Title title : vcard.getTitles()) { for (Title title : vcard.getTitles()) {
jobTitle = title.getValue(); jobTitle = title.getValue();
break; break;
} }
for (Role role : vcard.getRoles()) { for (Role role : vcard.getRoles()) {
this.department = role.getValue(); this.jobDescription = role.getValue();
break; break;
} }
@ -243,15 +240,12 @@ public class Contact extends Resource {
for (Email email : emails) for (Email email : emails)
vcard.addEmail(email); vcard.addEmail(email);
if (organization != null) { if (organization != null)
Organization org = new Organization(); vcard.addOrganization(organization);
org.addValue(organization);
vcard.addOrganization(org);
}
if (jobTitle != null) if (jobTitle != null)
vcard.addTitle(jobTitle); vcard.addTitle(jobTitle);
if (department != null) if (jobDescription != null)
vcard.addRole(department); vcard.addRole(jobDescription);
for (Impp impp : impps) for (Impp impp : impps)
vcard.addImpp(impp); vcard.addImpp(impp);

View File

@ -12,6 +12,7 @@ import java.io.InputStream;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -313,19 +314,26 @@ public class LocalAddressBook extends LocalCollection<Contact> {
protected void populateOrganization(Contact c) throws RemoteException { protected void populateOrganization(Contact c) throws RemoteException {
@Cleanup Cursor cursor = providerClient.query(dataURI(), @Cleanup Cursor cursor = providerClient.query(dataURI(),
new String[] { Organization.COMPANY, Organization.TITLE, Organization.DEPARTMENT }, new String[] { Organization.COMPANY, Organization.DEPARTMENT, Organization.TITLE, Organization.JOB_DESCRIPTION },
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()) {
String org = cursor.getString(0), String company = cursor.getString(0),
title = cursor.getString(1), department = cursor.getString(1),
department = cursor.getString(2); title = cursor.getString(2),
if (!StringUtils.isEmpty(org)) role = cursor.getString(3);
if (!StringUtils.isEmpty(company) || !StringUtils.isEmpty(department)) {
ezvcard.property.Organization org = new ezvcard.property.Organization();
if (!StringUtils.isEmpty(company))
org.addValue(company);
if (!StringUtils.isEmpty(department))
org.addValue(department);
c.setOrganization(org); c.setOrganization(org);
}
if (!StringUtils.isEmpty(title)) if (!StringUtils.isEmpty(title))
c.setJobTitle(title); c.setJobTitle(title);
if (!StringUtils.isEmpty(department)) if (!StringUtils.isEmpty(role))
c.setDepartment(department); c.setJobDescription(role);
} }
} }
@ -524,9 +532,9 @@ public class LocalAddressBook extends LocalCollection<Contact> {
if (contact.getPhoto() != null) if (contact.getPhoto() != null)
queueOperation(buildPhoto(newDataInsertBuilder(localID, backrefIdx), contact.getPhoto())); queueOperation(buildPhoto(newDataInsertBuilder(localID, backrefIdx), contact.getPhoto()));
if (contact.getOrganization() != null || contact.getJobTitle() != null || contact.getDepartment() != null) if (contact.getOrganization() != null || contact.getJobTitle() != null || contact.getJobDescription() != null)
queueOperation(buildOrganization(newDataInsertBuilder(localID, backrefIdx), queueOperation(buildOrganization(newDataInsertBuilder(localID, backrefIdx),
contact.getOrganization(), contact.getJobTitle(), contact.getDepartment())); contact.getOrganization(), contact.getJobTitle(), contact.getJobDescription()));
for (Impp impp : contact.getImpps()) for (Impp impp : contact.getImpps())
queueOperation(buildIMPP(newDataInsertBuilder(localID, backrefIdx), impp)); queueOperation(buildIMPP(newDataInsertBuilder(localID, backrefIdx), impp));
@ -688,12 +696,21 @@ public class LocalAddressBook extends LocalCollection<Contact> {
.withValue(Photo.PHOTO, photo); .withValue(Photo.PHOTO, photo);
} }
protected Builder buildOrganization(Builder builder, String organization, String jobTitle, String department) { protected Builder buildOrganization(Builder builder, ezvcard.property.Organization organization, String jobTitle, String jobDescription) {
String company = null, department = null;
Iterator<String> org = organization.getValues().iterator();
if (org.hasNext())
company = org.next();
if (org.hasNext())
department = org.next();
return builder return builder
.withValue(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE) .withValue(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE)
.withValue(Organization.COMPANY, organization) .withValue(Organization.COMPANY, company)
.withValue(Organization.DEPARTMENT, department)
.withValue(Organization.TITLE, jobTitle) .withValue(Organization.TITLE, jobTitle)
.withValue(Organization.DEPARTMENT, department); .withValue(Organization.JOB_DESCRIPTION, jobDescription);
} }
protected Builder buildIMPP(Builder builder, Impp impp) { protected Builder buildIMPP(Builder builder, Impp impp) {