diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index de757cc5a..0617727e6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -466,7 +466,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { private fun storeEvent(wasRepeatable: Boolean) { if (mEvent.id == 0) { - dbHelper.insert(mEvent) { + dbHelper.insert(mEvent, true) { if (DateTime.now().isAfter(mEventStartDateTime.millis)) { toast(R.string.past_event_added) } else { @@ -486,7 +486,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS) mEvent.parentId = mEvent.id mEvent.id = 0 - dbHelper.insert(mEvent) { + dbHelper.insert(mEvent, true) { toast(R.string.event_updated) finish() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index 756ff666b..0a0967f67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -326,7 +326,7 @@ fun Context.fetchCalDAVCalendarEvents(calendarId: Long, eventTypeId: Int) { } } } else { - dbHelper.insert(event) { + dbHelper.insert(event, false) { importIdsMap.put(event.importId, event) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index de77a8a2c..8a702dd37 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -175,7 +175,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont addEventType(eventType, db) } - fun insert(event: Event, callback: (id: Int) -> Unit) { + fun insert(event: Event, addToCalDAV: Boolean, callback: (id: Int) -> Unit) { if (event.startTS > event.endTS || event.title.trim().isEmpty()) { callback(0) return @@ -192,6 +192,11 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont context.updateWidgets() context.scheduleReminder(event, this) + + if (addToCalDAV) { + + } + callback(event.id) } @@ -283,7 +288,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont endTS = 0 } - insert(childEvent) { + insert(childEvent, false) { callback(ContentValues().apply { put(COL_PARENT_EVENT_ID, parentEventId) put(COL_OCCURRENCE_DAYCODE, Formatter.getDayCodeFromTS(occurrenceTS)) 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 09f86006f..bcf56ab54 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -105,7 +105,7 @@ class IcsImporter { event.endTS -= DAY } - context.dbHelper.insert(event) { + context.dbHelper.insert(event, true) { for (exceptionTS in curRepeatExceptions) { context.dbHelper.addEventRepeatException(it, exceptionTS) }