mirror of
https://github.com/etesync/android
synced 2024-11-14 03:39:52 +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:
parent
fee6431981
commit
ea06c4a7a1
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="at.bitfire.davdroid"
|
||||
android:versionCode="25"
|
||||
android:versionCode="26"
|
||||
android:versionName="0.5.7-alpha" android:installLocation="internalOnly">
|
||||
|
||||
<uses-sdk
|
||||
|
Binary file not shown.
BIN
libs/ez-vcard-0.9.1.jar
Normal file
BIN
libs/ez-vcard-0.9.1.jar
Normal file
Binary file not shown.
@ -74,7 +74,8 @@ public class Contact extends Resource {
|
||||
@Getter @Setter private String prefix, givenName, middleName, familyName, suffix;
|
||||
@Getter @Setter private String phoneticGivenName, phoneticMiddleName, phoneticFamilyName;
|
||||
@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;
|
||||
|
||||
@ -159,18 +160,14 @@ public class Contact extends Resource {
|
||||
this.photo = photo.getData();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vcard.getOrganization() != null) {
|
||||
List<String> organizations = vcard.getOrganization().getValues();
|
||||
if (!organizations.isEmpty())
|
||||
organization = organizations.get(0);
|
||||
}
|
||||
|
||||
organization = vcard.getOrganization();
|
||||
for (Title title : vcard.getTitles()) {
|
||||
jobTitle = title.getValue();
|
||||
break;
|
||||
}
|
||||
for (Role role : vcard.getRoles()) {
|
||||
this.department = role.getValue();
|
||||
this.jobDescription = role.getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -243,15 +240,12 @@ public class Contact extends Resource {
|
||||
for (Email email : emails)
|
||||
vcard.addEmail(email);
|
||||
|
||||
if (organization != null) {
|
||||
Organization org = new Organization();
|
||||
org.addValue(organization);
|
||||
vcard.addOrganization(org);
|
||||
}
|
||||
if (organization != null)
|
||||
vcard.addOrganization(organization);
|
||||
if (jobTitle != null)
|
||||
vcard.addTitle(jobTitle);
|
||||
if (department != null)
|
||||
vcard.addRole(department);
|
||||
if (jobDescription != null)
|
||||
vcard.addRole(jobDescription);
|
||||
|
||||
for (Impp impp : impps)
|
||||
vcard.addImpp(impp);
|
||||
|
@ -12,6 +12,7 @@ import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -313,19 +314,26 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
||||
|
||||
protected void populateOrganization(Contact c) throws RemoteException {
|
||||
@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 + "=?",
|
||||
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
|
||||
if (cursor != null && cursor.moveToNext()) {
|
||||
String org = cursor.getString(0),
|
||||
title = cursor.getString(1),
|
||||
department = cursor.getString(2);
|
||||
if (!StringUtils.isEmpty(org))
|
||||
String company = cursor.getString(0),
|
||||
department = cursor.getString(1),
|
||||
title = cursor.getString(2),
|
||||
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);
|
||||
}
|
||||
if (!StringUtils.isEmpty(title))
|
||||
c.setJobTitle(title);
|
||||
if (!StringUtils.isEmpty(department))
|
||||
c.setDepartment(department);
|
||||
if (!StringUtils.isEmpty(role))
|
||||
c.setJobDescription(role);
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,9 +532,9 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
||||
if (contact.getPhoto() != null)
|
||||
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),
|
||||
contact.getOrganization(), contact.getJobTitle(), contact.getDepartment()));
|
||||
contact.getOrganization(), contact.getJobTitle(), contact.getJobDescription()));
|
||||
|
||||
for (Impp impp : contact.getImpps())
|
||||
queueOperation(buildIMPP(newDataInsertBuilder(localID, backrefIdx), impp));
|
||||
@ -688,12 +696,21 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
||||
.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
|
||||
.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.DEPARTMENT, department);
|
||||
.withValue(Organization.JOB_DESCRIPTION, jobDescription);
|
||||
}
|
||||
|
||||
protected Builder buildIMPP(Builder builder, Impp impp) {
|
||||
|
Loading…
Reference in New Issue
Block a user