parse some more fields at caldav events

This commit is contained in:
tibbi 2017-08-14 21:22:23 +02:00
parent 484554d373
commit e71c8b699e
2 changed files with 10 additions and 2 deletions

View file

@ -292,13 +292,15 @@ fun Context.fetchCalDAVCalendarEvents(calendarID: Long, eventTypeId: Int) {
val endTS = (cursor.getLongValue(CalendarContract.Events.DTEND) / 1000).toInt()
val duration = cursor.getStringValue(CalendarContract.Events.DURATION)
val allDay = cursor.getIntValue(CalendarContract.Events.ALL_DAY)
val rrule = cursor.getStringValue(CalendarContract.Events.RRULE)
val rrule = cursor.getStringValue(CalendarContract.Events.RRULE) ?: ""
val reminders = getCalDAVEventReminders(id)
val importId = getCalDAVEventImportId(calendarID, id)
val repeatRule = Parser().parseRepeatInterval(rrule, startTS)
val event = Event(0, startTS, endTS, title, description, reminders.getOrElse(0, { -1 }),
reminders.getOrElse(1, { -1 }), reminders.getOrElse(2, { -1 }), repeatRule.repeatInterval,
"", 0 or allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, lastUpdated = System.currentTimeMillis())
importId, allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, lastUpdated = System.currentTimeMillis(),
source = "$CALDAV-$calendarID")
} while (cursor.moveToNext())
}
} finally {
@ -331,6 +333,8 @@ fun Context.getCalDAVEventReminders(eventId: Long): List<Int> {
return reminders
}
fun Context.getCalDAVEventImportId(calendarId: Long, eventId: Long) = "$CALDAV-$calendarId-$eventId"
fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDateTimeFromCode(dayCode).withTime(13, 0, 0, 0).seconds()
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())

View file

@ -15,6 +15,10 @@ class Parser {
var repeatInterval = 0
var repeatRule = 0
var repeatLimit = 0
if (fullString.isEmpty()) {
return RepeatRule(repeatInterval, repeatRule, repeatLimit)
}
for (part in parts) {
val keyValue = part.split("=")
val key = keyValue[0]