From 4f263d00fe6616a9ebbc51ed532d437e42249498 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 12 Jul 2026 11:46:51 +0200 Subject: [PATCH] fix(edit): apply default reminder to ACTION_INSERT events (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit External ACTION_INSERT launches (e.g. Google Maps' "add to calendar", the Todo Agenda widget) share the single-event .ics prefill channel: CalendarHost routes requestedInsertForm as importForm, so EventEditScreen calls openImported(), which froze reminders as touched to respect a file's own VALARMs. But an insert intent carries no reminders, so the empty freeze just suppressed the configured settings default — the event opened (and saved) with no reminder. Make the freeze follow the source, not the path: a form that carries its own reminders (an .ics with VALARMs) still freezes them; a form with none (every insert intent, and an .ics without VALARMs) falls back to the settings default via applyDefaultReminder(), exactly like openNew(). An intent that did carry reminders still wins. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../calendula/ui/edit/EventEditViewModel.kt | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditViewModel.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditViewModel.kt index e2da425..fc7dc31 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditViewModel.kt @@ -241,18 +241,31 @@ class EventEditViewModel @Inject constructor( } /** - * Seed a fresh event from a parsed `.ics` file (the single-event "open into - * the create form" path). [form] already carries the file's fields; its - * [EventForm.calendarId] is null so the calendar still resolves to the - * last-used/first-writable one, and reminders are frozen as touched so the - * settings default never overwrites what the file specified. No-op when a - * form is already open, so the prefill survives configuration changes. + * Seed a fresh event from a prefilled [form] — a parsed single-event `.ics` + * file or an external `ACTION_INSERT` intent (another app/widget creating an + * event, e.g. Google Maps' "add to calendar"; #30, #49). [EventForm.calendarId] + * is null so the calendar still resolves to the last-used/first-writable one. + * + * Reminders follow the source rather than the path: a form that carries its + * own (an `.ics` with VALARMs) freezes them as touched, so the settings + * default never overwrites what it specified; a form with none — every + * insert intent, and an `.ics` without VALARMs — falls back to the settings + * default exactly like [openNew], instead of the empty freeze suppressing it. + * No-op when a form is already open, so the prefill survives configuration + * changes. */ fun openImported(form: EventForm) { if (_form.value != null || _editTarget.value != null) return - _remindersTouched.value = true _revealed.value = form.populatedFields() _form.value = form + if (form.reminders.isNotEmpty()) { + // Source specified its own reminders — freeze so the default can't + // clobber them (and a later calendar/all-day switch won't re-apply). + _remindersTouched.value = true + } else { + // Nothing carried: inherit the settings default like a new event. + applyDefaultReminder() + } } /**