Version bump to 0.5

* don't download contact photos from URLs (we only want thumbs anyway)
* always use yyyy-MM-dd for birthdays/anniversaries
pull/2/head
rfc2822 11 years ago
parent 8c79c64d75
commit eaa080cfe8

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.davdroid"
android:versionCode="17"
android:versionName="0.4.4-alpha" >
android:versionCode="18"
android:versionName="0.5-alpha" >
<uses-sdk
android:minSdkVersion="14"

@ -9,7 +9,7 @@ package at.bitfire.davdroid;
public class Constants {
public static final String
APP_VERSION = "0.4.4-alpha",
APP_VERSION = "0.5-alpha",
ACCOUNT_TYPE = "bitfire.at.davdroid",

@ -9,12 +9,10 @@ package at.bitfire.davdroid.resource;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import lombok.Cleanup;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@ -40,6 +38,7 @@ import ezvcard.property.Nickname;
import ezvcard.property.Note;
import ezvcard.property.Organization;
import ezvcard.property.Photo;
import ezvcard.property.ProductId;
import ezvcard.property.RawProperty;
import ezvcard.property.Revision;
import ezvcard.property.Role;
@ -47,7 +46,6 @@ import ezvcard.property.StructuredName;
import ezvcard.property.Telephone;
import ezvcard.property.Uid;
import ezvcard.property.Url;
import ezvcard.util.IOUtils;
@ToString(callSuper = true)
public class Contact extends Resource {
@ -150,19 +148,9 @@ public class Contact extends Resource {
phoneNumbers = vcard.getTelephoneNumbers();
emails = vcard.getEmails();
List<Photo> photos = vcard.getPhotos();
if (!photos.isEmpty()) {
Photo photo = photos.get(0);
for (Photo photo : vcard.getPhotos()) {
this.photo = photo.getData();
if (this.photo == null) {
try {
URL url = new URL(photo.getUrl());
@Cleanup InputStream in = url.openStream();
this.photo = IOUtils.toByteArray(in);
} catch(IOException ex) {
Log.w(TAG, "Couldn't fetch photo from referenced URL", ex);
}
}
break;
}
if (vcard.getOrganization() != null) {
@ -170,9 +158,8 @@ public class Contact extends Resource {
if (!organizations.isEmpty())
organization = organizations.get(0);
}
List<Role> roles = vcard.getRoles();
if (!roles.isEmpty())
role = roles.get(0).getValue();
for (Role role : vcard.getRoles())
this.role = role.getValue();
impps = vcard.getImpps();
@ -270,8 +257,8 @@ public class Contact extends Resource {
vcard.setAnniversary(anniversary);
if (birthDay != null)
vcard.setBirthday(birthDay);
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION);
vcard.setProdId(new ProductId("DAVdroid/" + Constants.APP_VERSION));
vcard.setRevision(Revision.now());
return Ezvcard
.write(vcard)

@ -7,7 +7,9 @@
******************************************************************************/
package at.bitfire.davdroid.resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@ -39,6 +41,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;
import at.bitfire.davdroid.Constants;
import ezvcard.parameter.AddressType;
import ezvcard.parameter.EmailType;
@ -53,7 +56,7 @@ import ezvcard.property.Telephone;
public class LocalAddressBook extends LocalCollection<Contact> {
//private final static String TAG = "davdroid.LocalAddressBook";
private final static String TAG = "davdroid.LocalAddressBook";
protected AccountManager accountManager;
@ -364,19 +367,26 @@ public class LocalAddressBook extends LocalCollection<Contact> {
if (cursor != null && cursor.moveToNext())
c.setURL(cursor.getString(0));
// events (birthday)
// events
cursor = providerClient.query(dataURI(), new String[] { CommonDataKinds.Event.TYPE, CommonDataKinds.Event.START_DATE },
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
new String[] { String.valueOf(c.getLocalID()), CommonDataKinds.Event.CONTENT_ITEM_TYPE }, null);
while (cursor != null && cursor.moveToNext())
switch (cursor.getInt(0)) {
case CommonDataKinds.Event.TYPE_ANNIVERSARY:
c.setAnniversary(new Anniversary(cursor.getString(1)));
break;
case CommonDataKinds.Event.TYPE_BIRTHDAY:
c.setBirthDay(new Birthday(cursor.getString(1)));
break;
while (cursor != null && cursor.moveToNext()) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
try {
Date date = formatter.parse(cursor.getString(1));
switch (cursor.getInt(0)) {
case CommonDataKinds.Event.TYPE_ANNIVERSARY:
c.setAnniversary(new Anniversary(date));
break;
case CommonDataKinds.Event.TYPE_BIRTHDAY:
c.setBirthDay(new Birthday(date));
break;
}
} catch (ParseException e) {
Log.w(TAG, "Couldn't parse local birthday/anniversary date", e);
}
}
c.populated = true;
return;
@ -751,9 +761,12 @@ public class LocalAddressBook extends LocalCollection<Contact> {
protected Builder buildEvent(Builder builder, DateOrTimeProperty date, int type) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
return builder
.withValue(Data.MIMETYPE, CommonDataKinds.Event.CONTENT_ITEM_TYPE)
.withValue(CommonDataKinds.Event.TYPE, type)
.withValue(CommonDataKinds.Event.START_DATE, formatter.format(date.getDate()));
if (date.getDate() != null)
return builder
.withValue(Data.MIMETYPE, CommonDataKinds.Event.CONTENT_ITEM_TYPE)
.withValue(CommonDataKinds.Event.TYPE, type)
.withValue(CommonDataKinds.Event.START_DATE, formatter.format(date.getDate()));
else
return builder;
}
}

Loading…
Cancel
Save