mirror of
https://github.com/etesync/android
synced 2024-11-23 00:18:19 +00:00
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
This commit is contained in:
parent
8c79c64d75
commit
eaa080cfe8
@ -1,8 +1,8 @@
|
|||||||
<?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="17"
|
android:versionCode="18"
|
||||||
android:versionName="0.4.4-alpha" >
|
android:versionName="0.5-alpha" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
|
@ -9,7 +9,7 @@ package at.bitfire.davdroid;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
public static final String
|
public static final String
|
||||||
APP_VERSION = "0.4.4-alpha",
|
APP_VERSION = "0.5-alpha",
|
||||||
|
|
||||||
ACCOUNT_TYPE = "bitfire.at.davdroid",
|
ACCOUNT_TYPE = "bitfire.at.davdroid",
|
||||||
|
|
||||||
|
@ -9,12 +9,10 @@ package at.bitfire.davdroid.resource;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import lombok.Cleanup;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
@ -40,6 +38,7 @@ import ezvcard.property.Nickname;
|
|||||||
import ezvcard.property.Note;
|
import ezvcard.property.Note;
|
||||||
import ezvcard.property.Organization;
|
import ezvcard.property.Organization;
|
||||||
import ezvcard.property.Photo;
|
import ezvcard.property.Photo;
|
||||||
|
import ezvcard.property.ProductId;
|
||||||
import ezvcard.property.RawProperty;
|
import ezvcard.property.RawProperty;
|
||||||
import ezvcard.property.Revision;
|
import ezvcard.property.Revision;
|
||||||
import ezvcard.property.Role;
|
import ezvcard.property.Role;
|
||||||
@ -47,7 +46,6 @@ import ezvcard.property.StructuredName;
|
|||||||
import ezvcard.property.Telephone;
|
import ezvcard.property.Telephone;
|
||||||
import ezvcard.property.Uid;
|
import ezvcard.property.Uid;
|
||||||
import ezvcard.property.Url;
|
import ezvcard.property.Url;
|
||||||
import ezvcard.util.IOUtils;
|
|
||||||
|
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class Contact extends Resource {
|
public class Contact extends Resource {
|
||||||
@ -150,19 +148,9 @@ public class Contact extends Resource {
|
|||||||
phoneNumbers = vcard.getTelephoneNumbers();
|
phoneNumbers = vcard.getTelephoneNumbers();
|
||||||
emails = vcard.getEmails();
|
emails = vcard.getEmails();
|
||||||
|
|
||||||
List<Photo> photos = vcard.getPhotos();
|
for (Photo photo : vcard.getPhotos()) {
|
||||||
if (!photos.isEmpty()) {
|
|
||||||
Photo photo = photos.get(0);
|
|
||||||
this.photo = photo.getData();
|
this.photo = photo.getData();
|
||||||
if (this.photo == null) {
|
break;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcard.getOrganization() != null) {
|
if (vcard.getOrganization() != null) {
|
||||||
@ -170,9 +158,8 @@ public class Contact extends Resource {
|
|||||||
if (!organizations.isEmpty())
|
if (!organizations.isEmpty())
|
||||||
organization = organizations.get(0);
|
organization = organizations.get(0);
|
||||||
}
|
}
|
||||||
List<Role> roles = vcard.getRoles();
|
for (Role role : vcard.getRoles())
|
||||||
if (!roles.isEmpty())
|
this.role = role.getValue();
|
||||||
role = roles.get(0).getValue();
|
|
||||||
|
|
||||||
impps = vcard.getImpps();
|
impps = vcard.getImpps();
|
||||||
|
|
||||||
@ -271,7 +258,7 @@ public class Contact extends Resource {
|
|||||||
if (birthDay != null)
|
if (birthDay != null)
|
||||||
vcard.setBirthday(birthDay);
|
vcard.setBirthday(birthDay);
|
||||||
|
|
||||||
vcard.setProdId("DAVdroid/" + Constants.APP_VERSION);
|
vcard.setProdId(new ProductId("DAVdroid/" + Constants.APP_VERSION));
|
||||||
vcard.setRevision(Revision.now());
|
vcard.setRevision(Revision.now());
|
||||||
return Ezvcard
|
return Ezvcard
|
||||||
.write(vcard)
|
.write(vcard)
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package at.bitfire.davdroid.resource;
|
package at.bitfire.davdroid.resource;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -39,6 +41,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
|
|||||||
import android.provider.ContactsContract.CommonDataKinds.Website;
|
import android.provider.ContactsContract.CommonDataKinds.Website;
|
||||||
import android.provider.ContactsContract.Data;
|
import android.provider.ContactsContract.Data;
|
||||||
import android.provider.ContactsContract.RawContacts;
|
import android.provider.ContactsContract.RawContacts;
|
||||||
|
import android.util.Log;
|
||||||
import at.bitfire.davdroid.Constants;
|
import at.bitfire.davdroid.Constants;
|
||||||
import ezvcard.parameter.AddressType;
|
import ezvcard.parameter.AddressType;
|
||||||
import ezvcard.parameter.EmailType;
|
import ezvcard.parameter.EmailType;
|
||||||
@ -53,7 +56,7 @@ import ezvcard.property.Telephone;
|
|||||||
|
|
||||||
|
|
||||||
public class LocalAddressBook extends LocalCollection<Contact> {
|
public class LocalAddressBook extends LocalCollection<Contact> {
|
||||||
//private final static String TAG = "davdroid.LocalAddressBook";
|
private final static String TAG = "davdroid.LocalAddressBook";
|
||||||
|
|
||||||
protected AccountManager accountManager;
|
protected AccountManager accountManager;
|
||||||
|
|
||||||
@ -364,19 +367,26 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
if (cursor != null && cursor.moveToNext())
|
if (cursor != null && cursor.moveToNext())
|
||||||
c.setURL(cursor.getString(0));
|
c.setURL(cursor.getString(0));
|
||||||
|
|
||||||
// events (birthday)
|
// 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 },
|
||||||
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), CommonDataKinds.Event.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), CommonDataKinds.Event.CONTENT_ITEM_TYPE }, null);
|
||||||
while (cursor != null && cursor.moveToNext())
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
switch (cursor.getInt(0)) {
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
case CommonDataKinds.Event.TYPE_ANNIVERSARY:
|
try {
|
||||||
c.setAnniversary(new Anniversary(cursor.getString(1)));
|
Date date = formatter.parse(cursor.getString(1));
|
||||||
break;
|
switch (cursor.getInt(0)) {
|
||||||
case CommonDataKinds.Event.TYPE_BIRTHDAY:
|
case CommonDataKinds.Event.TYPE_ANNIVERSARY:
|
||||||
c.setBirthDay(new Birthday(cursor.getString(1)));
|
c.setAnniversary(new Anniversary(date));
|
||||||
break;
|
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;
|
c.populated = true;
|
||||||
return;
|
return;
|
||||||
@ -751,9 +761,12 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
|
|
||||||
protected Builder buildEvent(Builder builder, DateOrTimeProperty date, int type) {
|
protected Builder buildEvent(Builder builder, DateOrTimeProperty date, int type) {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
return builder
|
if (date.getDate() != null)
|
||||||
.withValue(Data.MIMETYPE, CommonDataKinds.Event.CONTENT_ITEM_TYPE)
|
return builder
|
||||||
.withValue(CommonDataKinds.Event.TYPE, type)
|
.withValue(Data.MIMETYPE, CommonDataKinds.Event.CONTENT_ITEM_TYPE)
|
||||||
.withValue(CommonDataKinds.Event.START_DATE, formatter.format(date.getDate()));
|
.withValue(CommonDataKinds.Event.TYPE, type)
|
||||||
|
.withValue(CommonDataKinds.Event.START_DATE, formatter.format(date.getDate()));
|
||||||
|
else
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user