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

Version bump to 0.7.6

* additional test
* minor code optimizations
This commit is contained in:
Ricki Hirner 2015-05-09 13:29:28 +02:00
parent 87df8f880d
commit a3ebd72321
4 changed files with 54 additions and 22 deletions

View File

@ -26,7 +26,18 @@ import android.provider.CalendarContract.Reminders;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import android.util.Log; import android.util.Log;
import net.fortuna.ical4j.model.DateList;
import net.fortuna.ical4j.model.TimeZone;
import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
import net.fortuna.ical4j.model.parameter.Value;
import net.fortuna.ical4j.model.property.RDate;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.SimpleTimeZone;
import lombok.Cleanup; import lombok.Cleanup;
@ -140,7 +151,7 @@ public class LocalCalendarTest extends InstrumentationTestCase {
assertTrue(testCalendar.findUpdated().length == 0); assertTrue(testCalendar.findUpdated().length == 0);
// insert a "new" event // insert a "new" event
long id = insertNewEvent(); final long id = insertNewEvent();
try { try {
// there must be one "new" event now // there must be one "new" event now
assertTrue(testCalendar.findNew().length == 1); assertTrue(testCalendar.findNew().length == 1);
@ -155,4 +166,23 @@ public class LocalCalendarTest extends InstrumentationTestCase {
} }
} }
public void testRecurrenceSetsToAndroidString() throws ParseException {
final String tzId = "Europe/Vienna";
// one entry without time zone
final List<RDate> list = new ArrayList<>(2);
list.add(new RDate(new DateList("20150101T103000,20150102T103000", Value.DATE_TIME)));
assertEquals("20150101T103000,20150102T103000", LocalCalendar.recurrenceSetsToAndroidString(list));
// two entries with time zone
list.add(new RDate(new DateList("20150103T103000,20150104T103000", Value.DATE_TIME)));
final TimeZoneRegistry tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry();
final TimeZone tz = tzRegistry.getTimeZone(tzId);
for (RDate rdate : list)
rdate.setTimeZone(tz);
assertEquals(tzId + ";20150101T103000,20150102T103000,20150103T103000,20150104T103000", LocalCalendar.recurrenceSetsToAndroidString(list));
}
} }

View File

@ -9,7 +9,7 @@
<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="61" android:versionName="0.7.5" android:versionCode="62" android:versionName="0.7.6"
android:installLocation="internalOnly"> android:installLocation="internalOnly">
<uses-sdk <uses-sdk

View File

@ -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.7.5", APP_VERSION = "0.7.6",
ACCOUNT_TYPE = "bitfire.at.davdroid", ACCOUNT_TYPE = "bitfire.at.davdroid",
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app", WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app",
WEB_URL_VIEW_LOGS = "https://github.com/bitfireAT/davdroid/wiki/How-to-view-the-logs"; WEB_URL_VIEW_LOGS = "https://github.com/bitfireAT/davdroid/wiki/How-to-view-the-logs";

View File

@ -122,7 +122,7 @@ public class LocalCalendar extends LocalCollection<Event> {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
public static void create(Account account, ContentResolver resolver, ServerInfo.ResourceInfo info) throws LocalStorageException { public static void create(Account account, ContentResolver resolver, ServerInfo.ResourceInfo info) throws LocalStorageException {
ContentProviderClient client = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY); final ContentProviderClient client = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY);
if (client == null) if (client == null)
throw new LocalStorageException("No Calendar Provider found (Calendar app disabled?)"); throw new LocalStorageException("No Calendar Provider found (Calendar app disabled?)");
@ -342,12 +342,12 @@ public class LocalCalendar extends LocalCollection<Event> {
e.setLocation(values.getAsString(Events.EVENT_LOCATION)); e.setLocation(values.getAsString(Events.EVENT_LOCATION));
e.setDescription(values.getAsString(Events.DESCRIPTION)); e.setDescription(values.getAsString(Events.DESCRIPTION));
boolean allDay = values.getAsBoolean(Events.ALL_DAY); final boolean allDay = values.getAsBoolean(Events.ALL_DAY);
long tsStart = values.getAsLong(Events.DTSTART); final long tsStart = values.getAsLong(Events.DTSTART);
Long tsEnd = values.getAsLong(Events.DTEND); final String duration = values.getAsString(Events.DURATION);
String duration = values.getAsString(Events.DURATION);
String tzId = null; String tzId = null;
Long tsEnd = values.getAsLong(Events.DTEND);
if (allDay) { if (allDay) {
e.setDtStart(tsStart, null); e.setDtStart(tsStart, null);
if (tsEnd == null) { if (tsEnd == null) {
@ -529,7 +529,7 @@ public class LocalCalendar extends LocalCollection<Event> {
@Override @Override
protected Builder buildEntry(Builder builder, Resource resource) { protected Builder buildEntry(Builder builder, Resource resource) {
Event event = (Event)resource; final Event event = (Event)resource;
builder = builder builder = builder
.withValue(Events.CALENDAR_ID, id) .withValue(Events.CALENDAR_ID, id)
@ -542,7 +542,7 @@ public class LocalCalendar extends LocalCollection<Event> {
.withValue(Events.GUESTS_CAN_MODIFY, 1) .withValue(Events.GUESTS_CAN_MODIFY, 1)
.withValue(Events.GUESTS_CAN_SEE_GUESTS, 1); .withValue(Events.GUESTS_CAN_SEE_GUESTS, 1);
RecurrenceId recurrenceId = event.getRecurrenceId(); final RecurrenceId recurrenceId = event.getRecurrenceId();
if (recurrenceId == null) { if (recurrenceId == null) {
// this event is a "master event" (not an exception) // this event is a "master event" (not an exception)
builder = builder builder = builder
@ -596,7 +596,7 @@ public class LocalCalendar extends LocalCollection<Event> {
if (organizer.getScheme() != null && organizer.getScheme().equalsIgnoreCase("mailto")) if (organizer.getScheme() != null && organizer.getScheme().equalsIgnoreCase("mailto"))
builder = builder.withValue(Events.ORGANIZER, organizer.getSchemeSpecificPart()); builder = builder.withValue(Events.ORGANIZER, organizer.getSchemeSpecificPart());
} }
Status status = event.getStatus(); Status status = event.getStatus();
if (status != null) { if (status != null) {
int statusCode = Events.STATUS_TENTATIVE; int statusCode = Events.STATUS_TENTATIVE;
@ -618,7 +618,8 @@ public class LocalCalendar extends LocalCollection<Event> {
@Override @Override
protected void addDataRows(Resource resource, long localID, int backrefIdx) { protected void addDataRows(Resource resource, long localID, int backrefIdx) {
Event event = (Event)resource; final Event event = (Event)resource;
// add exceptions // add exceptions
for (Event exception : event.getExceptions()) for (Event exception : event.getExceptions())
pendingOperations.add(buildException(newDataInsertBuilder(Events.CONTENT_URI, Events.ORIGINAL_ID, localID, backrefIdx), event, exception).build()); pendingOperations.add(buildException(newDataInsertBuilder(Events.CONTENT_URI, Events.ORIGINAL_ID, localID, backrefIdx), event, exception).build());
@ -632,7 +633,8 @@ public class LocalCalendar extends LocalCollection<Event> {
@Override @Override
protected void removeDataRows(Resource resource) { protected void removeDataRows(Resource resource) {
Event event = (Event)resource; final Event event = (Event)resource;
// delete exceptions // delete exceptions
pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Events.CONTENT_URI)) pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Events.CONTENT_URI))
.withSelection(Events.ORIGINAL_ID + "=?", new String[] { String.valueOf(event.getLocalID())}).build()); .withSelection(Events.ORIGINAL_ID + "=?", new String[] { String.valueOf(event.getLocalID())}).build());
@ -653,10 +655,10 @@ public class LocalCalendar extends LocalCollection<Event> {
// the original event is an all-day event. Workaround: determine value of ORIGINAL_ALL_DAY // the original event is an all-day event. Workaround: determine value of ORIGINAL_ALL_DAY
// by original event type (all-day or not) and not by whether RECURRENCE-ID is DATE or DATE-TIME. // by original event type (all-day or not) and not by whether RECURRENCE-ID is DATE or DATE-TIME.
RecurrenceId recurrenceId = exception.getRecurrenceId(); final RecurrenceId recurrenceId = exception.getRecurrenceId();
Date date = recurrenceId.getDate(); final boolean originalAllDay = master.isAllDay();
boolean originalAllDay = master.isAllDay(); Date date = recurrenceId.getDate();
if (originalAllDay && date instanceof DateTime) { if (originalAllDay && date instanceof DateTime) {
String value = recurrenceId.getValue(); String value = recurrenceId.getValue();
if (value.matches("^\\d{8}T\\d{6}$")) if (value.matches("^\\d{8}T\\d{6}$"))
@ -676,13 +678,13 @@ public class LocalCalendar extends LocalCollection<Event> {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
protected Builder buildAttendee(Builder builder, Attendee attendee) { protected Builder buildAttendee(Builder builder, Attendee attendee) {
Uri member = Uri.parse(attendee.getValue()); final Uri member = Uri.parse(attendee.getValue());
String email = member.getSchemeSpecificPart(); final String email = member.getSchemeSpecificPart();
Cn cn = (Cn)attendee.getParameter(Parameter.CN); final Cn cn = (Cn)attendee.getParameter(Parameter.CN);
if (cn != null) if (cn != null)
builder = builder.withValue(Attendees.ATTENDEE_NAME, cn.getValue()); builder = builder.withValue(Attendees.ATTENDEE_NAME, cn.getValue());
int type = Attendees.TYPE_NONE; int type = Attendees.TYPE_NONE;
CuType cutype = (CuType)attendee.getParameter(Parameter.CUTYPE); CuType cutype = (CuType)attendee.getParameter(Parameter.CUTYPE);
@ -760,7 +762,7 @@ public class LocalCalendar extends LocalCollection<Event> {
* @param dates one more more lists of RDATE or EXDATE * @param dates one more more lists of RDATE or EXDATE
* @return formatted string for Android calendar provider * @return formatted string for Android calendar provider
*/ */
protected static String recurrenceSetsToAndroidString(List<? extends DateListProperty> dates) { static String recurrenceSetsToAndroidString(List<? extends DateListProperty> dates) {
String tzID = null; String tzID = null;
List<String> strDates = new LinkedList<String>(); List<String> strDates = new LinkedList<String>();