mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
properly handle moving an event from 1 caldav calendar to another one
This commit is contained in:
@@ -489,6 +489,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val wasRepeatable = mEvent.repeatInterval > 0
|
val wasRepeatable = mEvent.repeatInterval > 0
|
||||||
|
val oldSource = mEvent.source
|
||||||
val newImportId = if (mEvent.id != 0) mEvent.importId else UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
val newImportId = if (mEvent.id != 0) mEvent.importId else UUID.randomUUID().toString().replace("-", "") + System.currentTimeMillis().toString()
|
||||||
|
|
||||||
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0) mEventTypeId else dbHelper.getEventTypeIdWithCalDAVCalendarId(config.lastUsedCaldavCalendar)
|
val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendar == 0) mEventTypeId else dbHelper.getEventTypeIdWithCalDAVCalendarId(config.lastUsedCaldavCalendar)
|
||||||
@@ -516,6 +517,12 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||||||
source = newSource
|
source = newSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// recreate the event if it was moved in a different CalDAV calendar
|
||||||
|
if (mEvent.id != 0 && oldSource != newSource) {
|
||||||
|
dbHelper.deleteEvents(arrayOf(mEvent.id.toString()), true)
|
||||||
|
mEvent.id = 0
|
||||||
|
}
|
||||||
|
|
||||||
storeEvent(wasRepeatable)
|
storeEvent(wasRepeatable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -199,7 +199,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
context.updateWidgets()
|
context.updateWidgets()
|
||||||
context.scheduleReminder(event, this)
|
context.scheduleReminder(event, this)
|
||||||
|
|
||||||
if (addToCalDAV) {
|
if (addToCalDAV && event.source != SOURCE_SIMPLE_CALENDAR) {
|
||||||
CalDAVEventsHandler(context).insertCalDAVEvent(event)
|
CalDAVEventsHandler(context).insertCalDAVEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
|
|
||||||
context.updateWidgets()
|
context.updateWidgets()
|
||||||
context.scheduleReminder(event, this)
|
context.scheduleReminder(event, this)
|
||||||
if (updateAtCalDAV) {
|
if (updateAtCalDAV && event.source != SOURCE_SIMPLE_CALENDAR) {
|
||||||
CalDAVEventsHandler(context).updateCalDAVEvent(event)
|
CalDAVEventsHandler(context).updateCalDAVEvent(event)
|
||||||
}
|
}
|
||||||
callback()
|
callback()
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.simplemobiletools.calendar.models
|
package com.simplemobiletools.calendar.models
|
||||||
|
|
||||||
|
import com.simplemobiletools.calendar.extensions.parseCalendarIdFromSource
|
||||||
import com.simplemobiletools.calendar.extensions.seconds
|
import com.simplemobiletools.calendar.extensions.seconds
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.helpers.Formatter
|
import com.simplemobiletools.calendar.helpers.Formatter
|
||||||
@@ -88,8 +89,7 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var
|
|||||||
wantedDay = firstProperDay + ((daysCnt - firstProperDay) / 7) * 7
|
wantedDay = firstProperDay + ((daysCnt - firstProperDay) / 7) * 7
|
||||||
}
|
}
|
||||||
|
|
||||||
val addedProperOrder = properMonth.withDayOfMonth(wantedDay)
|
return properMonth.withDayOfMonth(wantedDay)
|
||||||
return addedProperOrder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIsAllDay() = flags and FLAG_ALL_DAY != 0
|
fun getIsAllDay() = flags and FLAG_ALL_DAY != 0
|
||||||
|
Reference in New Issue
Block a user