mirror of
https://github.com/etesync/android
synced 2025-05-09 18:38:51 +00:00
Improve event exception handling (always convert RECURRENCE-ID DATE-TIME to DATE when master event is all-day)
This commit is contained in:
parent
01d1b1a6c0
commit
6ad74c79f0
@ -57,7 +57,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -649,21 +651,15 @@ public class LocalCalendar extends LocalCollection<Event> {
|
|||||||
buildEntry(builder, exception, false);
|
buildEntry(builder, exception, false);
|
||||||
builder.withValue(Events.ORIGINAL_SYNC_ID, exception.getName());
|
builder.withValue(Events.ORIGINAL_SYNC_ID, exception.getName());
|
||||||
|
|
||||||
// Some servers (iCloud, for instance) return RECURRENCE-ID with DATE-TIME even if
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
final RecurrenceId recurrenceId = exception.getRecurrenceId();
|
final RecurrenceId recurrenceId = exception.getRecurrenceId();
|
||||||
final boolean originalAllDay = master.isAllDay();
|
final boolean originalAllDay = master.isAllDay();
|
||||||
|
|
||||||
Date date = recurrenceId.getDate();
|
Date date = recurrenceId.getDate();
|
||||||
if (originalAllDay && date instanceof DateTime) {
|
if (originalAllDay && date instanceof DateTime) { // correct VALUE=DATE-TIME RECURRENCE-IDs to VALUE=DATE
|
||||||
String value = recurrenceId.getValue();
|
final DateFormat dateFormatDate = new SimpleDateFormat("yyyyMMdd");
|
||||||
if (value.matches("^\\d{8}T\\d{6}$"))
|
final String dateString = dateFormatDate.format(recurrenceId.getDate());
|
||||||
try {
|
try {
|
||||||
// no "Z" at the end indicates "local" time
|
date = new Date(dateString);
|
||||||
// so this is a "local" time, but it should be a ical4j Date without time
|
|
||||||
date = new Date(value.substring(0, 8));
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Log.e(TAG, "Couldn't parse DATE part of DATE-TIME RECURRENCE-ID", e);
|
Log.e(TAG, "Couldn't parse DATE part of DATE-TIME RECURRENCE-ID", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user