mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
properly import event repeat exceptions from .ics files
This commit is contained in:
@@ -25,7 +25,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
private var curImportId = ""
|
private var curImportId = ""
|
||||||
private var curFlags = 0
|
private var curFlags = 0
|
||||||
private var curReminderMinutes = ArrayList<Int>()
|
private var curReminderMinutes = ArrayList<Int>()
|
||||||
private var curRepeatExceptions = ArrayList<Long>()
|
private var curRepeatExceptions = ArrayList<String>()
|
||||||
private var curRepeatInterval = 0
|
private var curRepeatInterval = 0
|
||||||
private var curRepeatLimit = 0L
|
private var curRepeatLimit = 0L
|
||||||
private var curRepeatRule = 0
|
private var curRepeatRule = 0
|
||||||
@@ -118,7 +118,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
value = value.substring(0, value.length - 1)
|
value = value.substring(0, value.length - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
curRepeatExceptions.add(getTimestamp(value))
|
curRepeatExceptions.add(Formatter.getDayCodeFromTS(getTimestamp(value)))
|
||||||
} else if (line.startsWith(LOCATION)) {
|
} else if (line.startsWith(LOCATION)) {
|
||||||
curLocation = getLocation(line.substring(LOCATION.length).replace("\\,", ","))
|
curLocation = getLocation(line.substring(LOCATION.length).replace("\\,", ","))
|
||||||
} else if (line == END_ALARM) {
|
} else if (line == END_ALARM) {
|
||||||
@@ -143,7 +143,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
val source = if (calDAVCalendarId == 0 || eventType?.isSyncedEventType() == false) SOURCE_IMPORTED_ICS else "$CALDAV-$calDAVCalendarId"
|
val source = if (calDAVCalendarId == 0 || eventType?.isSyncedEventType() == false) SOURCE_IMPORTED_ICS else "$CALDAV-$calDAVCalendarId"
|
||||||
val event = Event(null, curStart, curEnd, curTitle, curLocation, curDescription, curReminderMinutes.getOrElse(0) { -1 },
|
val event = Event(null, curStart, curEnd, curTitle, curLocation, curDescription, curReminderMinutes.getOrElse(0) { -1 },
|
||||||
curReminderMinutes.getOrElse(1) { -1 }, curReminderMinutes.getOrElse(2) { -1 }, curRepeatInterval, curRepeatRule,
|
curReminderMinutes.getOrElse(1) { -1 }, curReminderMinutes.getOrElse(2) { -1 }, curRepeatInterval, curRepeatRule,
|
||||||
curRepeatLimit, ArrayList(), curImportId, curFlags, curEventTypeId, 0, curLastModified, source)
|
curRepeatLimit, curRepeatExceptions, curImportId, curFlags, curEventTypeId, 0, curLastModified, source)
|
||||||
|
|
||||||
if (event.getIsAllDay() && curEnd > curStart) {
|
if (event.getIsAllDay() && curEnd > curStart) {
|
||||||
event.endTS -= DAY
|
event.endTS -= DAY
|
||||||
@@ -157,16 +157,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eventToUpdate == null) {
|
if (eventToUpdate == null) {
|
||||||
if (curRepeatExceptions.isEmpty()) {
|
|
||||||
eventsToInsert.add(event)
|
eventsToInsert.add(event)
|
||||||
} else {
|
|
||||||
eventsHelper.insertEvent(activity, event, true) {
|
|
||||||
for (exceptionTS in curRepeatExceptions) {
|
|
||||||
eventsHelper.addEventRepetitionException(it, exceptionTS, true)
|
|
||||||
}
|
|
||||||
existingEvents.add(event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
event.id = eventToUpdate.id
|
event.id = eventToUpdate.id
|
||||||
eventsHelper.updateEvent(null, event, true)
|
eventsHelper.updateEvent(null, event, true)
|
||||||
|
Reference in New Issue
Block a user