From 0b127489665a9cda452ed9483de74bc458d4d32f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 17 Jul 2017 22:29:16 +0200 Subject: [PATCH] add parsing Last-Modified field at importing .ics events --- .../com/simplemobiletools/calendar/helpers/Constants.kt | 1 + .../com/simplemobiletools/calendar/helpers/IcsImporter.kt | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index 9dc651c48..8940aca23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -76,6 +76,7 @@ val BEGIN_ALARM = "BEGIN:VALARM" val END_ALARM = "END:VALARM" val DTSTART = "DTSTART" val DTEND = "DTEND" +val LAST_MODIFIED = "LAST-MODIFIED" val DURATION = "DURATION:" val SUMMARY = "SUMMARY" val DESCRIPTION = "DESCRIPTION:" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index 61f5ed1d8..6571c221f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -25,6 +25,7 @@ class IcsImporter { var curRepeatLimit = 0 var curRepeatRule = 0 var curEventType = DBHelper.REGULAR_EVENT_TYPE_ID + var curLastModified = 0L var isNotificationDescription = false var lastReminderAction = "" @@ -84,6 +85,8 @@ class IcsImporter { } else if (line.startsWith(CATEGORIES)) { val categories = line.substring(CATEGORIES.length) tryAddCategories(categories, context) + } else if (line.startsWith(LAST_MODIFIED)) { + curLastModified = getTimestamp(line.substring(LAST_MODIFIED.length)) * 1000L } else if (line.startsWith(EXDATE)) { curRepeatExceptions.add(getTimestamp(line.substring(EXDATE.length))) } else if (line == END_EVENT) { @@ -95,7 +98,7 @@ class IcsImporter { val event = Event(0, curStart, curEnd, curTitle, curDescription, curReminderMinutes.getOrElse(0, { -1 }), curReminderMinutes.getOrElse(1, { -1 }), curReminderMinutes.getOrElse(2, { -1 }), curRepeatInterval, - curImportId, curFlags, curRepeatLimit, curRepeatRule, curEventType) + curImportId, curFlags, curRepeatLimit, curRepeatRule, curEventType, lastUpdated = curLastModified) if (event.isAllDay && curEnd > curStart) { event.endTS -= DAY @@ -197,6 +200,7 @@ class IcsImporter { curRepeatLimit = 0 curRepeatRule = 0 curEventType = DBHelper.REGULAR_EVENT_TYPE_ID + curLastModified = 0L isNotificationDescription = false lastReminderAction = "" }