From b7c90f9cfb791a8ace9af286d5e384aedda99ca5 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Thu, 20 Apr 2023 02:58:40 -0400 Subject: [PATCH] Resolves (or at least improves): - #1538 - https://github.com/bitfireAT/davx5-ose/discussions/66 - https://github.com/Kozea/Radicale/issues/1264 - May also resolve some of the issues described in #1983. The "EXDATE" property is only meant to be set on events with the "RRULE" property. See discussion in #1538, especially the response from DAVx5 support listed in the first comment. I tried also setting STATUS_CANCELED on these recurrence exception events, but DAVx5 would sometimes no longer recognize them as belonging to the parent event and would give the child events different UIDs, which is undesirable. It seems like it works great to just leave out the EXDATE. I have not tested this patch with other CalDAV setups, but it solves the problem for me on DAVx5+Radicale. --- .../calendar/pro/activities/EventActivity.kt | 7 +++---- .../calendar/pro/activities/TaskActivity.kt | 6 +++--- .../calendar/pro/dialogs/EditRepeatingEventDialog.kt | 9 ++++++--- .../calendar/pro/helpers/CalDAVHelper.kt | 1 - .../simplemobiletools/calendar/pro/helpers/Constants.kt | 4 ++++ 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index e067183de..07b8246f8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -1310,7 +1310,7 @@ class EventActivity : SimpleActivity() { EditRepeatingEventDialog(this) { hideKeyboard() when (it) { - 0 -> { + EDIT_SELECTED_OCCURRENCE -> { ensureBackgroundThread { eventsHelper.addEventRepetitionException(mEvent.id!!, mEventOccurrenceTS, true) mEvent.apply { @@ -1326,7 +1326,7 @@ class EventActivity : SimpleActivity() { } } } - 1 -> { + EDIT_FUTURE_OCCURRENCES -> { ensureBackgroundThread { eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS) mEvent.apply { @@ -1338,8 +1338,7 @@ class EventActivity : SimpleActivity() { } } } - - 2 -> { + EDIT_ALL_OCCURRENCES -> { ensureBackgroundThread { eventsHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS) eventsHelper.updateEvent(mEvent, updateAtCalDAV = true, showToasts = true) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt index 473903d2f..d90a1bf4b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt @@ -464,7 +464,7 @@ class TaskActivity : SimpleActivity() { EditRepeatingEventDialog(this, isTask = true) { hideKeyboard() when (it) { - 0 -> { + EDIT_SELECTED_OCCURRENCE -> { ensureBackgroundThread { eventsHelper.addEventRepetitionException(mTask.id!!, mTaskOccurrenceTS, addToCalDAV = false) mTask.apply { @@ -480,7 +480,7 @@ class TaskActivity : SimpleActivity() { } } } - 1 -> { + EDIT_FUTURE_OCCURRENCES -> { ensureBackgroundThread { eventsHelper.addEventRepeatLimit(mTask.id!!, mTaskOccurrenceTS) mTask.apply { @@ -492,7 +492,7 @@ class TaskActivity : SimpleActivity() { } } } - 2 -> { + EDIT_ALL_OCCURRENCES -> { ensureBackgroundThread { eventsHelper.addEventRepeatLimit(mTask.id!!, mTaskOccurrenceTS) eventsHelper.updateEvent(mTask, updateAtCalDAV = false, showToasts = true) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt index 974859cff..5627e539e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt @@ -4,6 +4,9 @@ import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.activities.SimpleActivity +import com.simplemobiletools.calendar.pro.helpers.EDIT_ALL_OCCURRENCES +import com.simplemobiletools.calendar.pro.helpers.EDIT_FUTURE_OCCURRENCES +import com.simplemobiletools.calendar.pro.helpers.EDIT_SELECTED_OCCURRENCE import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.setupDialogStuff @@ -14,9 +17,9 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean init { val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_repeating_event, null) as ViewGroup).apply { - edit_repeating_event_one_only.setOnClickListener { sendResult(0) } - edit_repeating_event_this_and_future_occurences.setOnClickListener { sendResult(1) } - edit_repeating_event_all_occurrences.setOnClickListener { sendResult(2) } + edit_repeating_event_one_only.setOnClickListener { sendResult(EDIT_SELECTED_OCCURRENCE) } + edit_repeating_event_this_and_future_occurences.setOnClickListener { sendResult(EDIT_FUTURE_OCCURRENCES) } + edit_repeating_event_all_occurrences.setOnClickListener { sendResult(EDIT_ALL_OCCURRENCES) } if (isTask) { edit_repeating_event_title.setText(R.string.task_is_repeatable) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index bba9a7c61..c0ea15719 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -502,7 +502,6 @@ class CalDAVHelper(val context: Context) { put(Events.ORIGINAL_ID, event.getCalDAVEventId()) put(Events.EVENT_TIMEZONE, TimeZone.getDefault().id.toString()) put(Events.ORIGINAL_INSTANCE_TIME, occurrenceTS * 1000L) - put(Events.EXDATE, Formatter.getDayCodeFromTS(occurrenceTS)) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index b3581a4c0..255a2f165 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -232,6 +232,10 @@ const val DELETE_SELECTED_OCCURRENCE = 0 const val DELETE_FUTURE_OCCURRENCES = 1 const val DELETE_ALL_OCCURRENCES = 2 +const val EDIT_SELECTED_OCCURRENCE = 0 +const val EDIT_FUTURE_OCCURRENCES = 1 +const val EDIT_ALL_OCCURRENCES = 2 + const val REMINDER_NOTIFICATION = 0 const val REMINDER_EMAIL = 1