add event to CalDAV if sync is on
This commit is contained in:
parent
d8ed0c49d4
commit
ab21bcd1a8
4 changed files with 8 additions and 5 deletions
|
@ -508,7 +508,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
offset = getCurrentOffset()
|
||||
isDstIncluded = TimeZone.getDefault().inDaylightTime(Date())
|
||||
lastUpdated = System.currentTimeMillis()
|
||||
source = SOURCE_SIMPLE_CALENDAR
|
||||
source = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0) SOURCE_SIMPLE_CALENDAR else "$CALDAV-${config.lastUsedCaldavCalendar}"
|
||||
}
|
||||
|
||||
storeEvent(wasRepeatable)
|
||||
|
|
|
@ -122,7 +122,8 @@ class CalDAVEventsHandler(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
fun addCalDAVEvent(event: Event, calendarId: Int) {
|
||||
fun addCalDAVEvent(event: Event) {
|
||||
val calendarId = event.getCalDAVCalendarId()
|
||||
val uri = CalendarContract.Events.CONTENT_URI
|
||||
val values = ContentValues().apply {
|
||||
put(CalendarContract.Events.CALENDAR_ID, calendarId)
|
||||
|
@ -167,7 +168,7 @@ class CalDAVEventsHandler(val context: Context) {
|
|||
|
||||
fun deleteCalDAVEvent(event: Event) {
|
||||
val uri = CalendarContract.Events.CONTENT_URI
|
||||
val contentUri = ContentUris.withAppendedId(uri, event.getCalDAVId())
|
||||
val contentUri = ContentUris.withAppendedId(uri, event.getCalDAVEventId())
|
||||
context.contentResolver.delete(contentUri, null, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
context.scheduleReminder(event, this)
|
||||
|
||||
if (addToCalDAV) {
|
||||
|
||||
CalDAVEventsHandler(context).addCalDAVEvent(event)
|
||||
}
|
||||
|
||||
callback(event.id)
|
||||
|
|
|
@ -105,5 +105,7 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var
|
|||
}
|
||||
}
|
||||
|
||||
fun getCalDAVId() = (importId.split("-").lastOrNull() ?: "0").toString().toLong()
|
||||
fun getCalDAVEventId() = (importId.split("-").lastOrNull() ?: "0").toString().toLong()
|
||||
|
||||
fun getCalDAVCalendarId() = (source.split("-").lastOrNull() ?: "0").toString().toInt()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue