diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncoding.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncoding.kt index 3e188040..1ed2f599 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncoding.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncoding.kt @@ -54,16 +54,6 @@ internal fun toProviderAllDayMinutes( return if (raw == MINUTES_DEFAULT) MINUTES_DEFAULT - 1 else raw } -/** - * Lead times rounded down to the whole days an all-day reminder can express, the - * same truncation [toProviderAllDayMinutes] applies, so the form shows what will - * be saved. [MINUTES_DEFAULT] passes through. - */ -internal fun wholeDayReminders(minutes: List): List = minutes - .map { if (it == MINUTES_DEFAULT) it else it / MINUTES_PER_DAY * MINUTES_PER_DAY } - .distinct() - .sorted() - /** * The next date on or after [today] carrying [month]/[day] — the date to sample * a yearly all-day reminder's UTC offset at. A managed birthday's DTSTART is an diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/Picker.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/Picker.kt index ec87b900..9b560995 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/Picker.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/Picker.kt @@ -97,7 +97,8 @@ fun ReminderDefaultPicker( var customExpanded by rememberSaveable { mutableStateOf(false) } var amountText by rememberSaveable { mutableStateOf("") } - var unit by rememberSaveable { mutableStateOf(units.first()) } + var pickedUnit by rememberSaveable { mutableStateOf(units.first()) } + val unit = pickedUnit.takeIf { it in units } ?: units.first() fun apply(override: ReminderOverride) { userEdited = true @@ -154,7 +155,7 @@ fun ReminderDefaultPicker( onAmountChange = { amountText = it }, units = units, unit = unit, - onUnitChange = { unit = it }, + onUnitChange = { pickedUnit = it }, onConfirm = { minutes -> emit(selectedMinutes + minutes) amountText = "" diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt index 7be100ed..cc4a63a6 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt @@ -1591,7 +1591,8 @@ private fun ReminderPickerDialog( var customMode by rememberSaveable { mutableStateOf(false) } var amountText by rememberSaveable { mutableStateOf("") } val units = customReminderUnits(isAllDay) - var unit by rememberSaveable { mutableStateOf(units.first()) } + var pickedUnit by rememberSaveable { mutableStateOf(units.first()) } + val unit = pickedUnit.takeIf { it in units } ?: units.first() val customMinutes = amountText.toIntOrNull() ?.takeIf { it in 1..999 } ?.let { it * unit.minutesFactor } @@ -1643,7 +1644,7 @@ private fun ReminderPickerDialog( DialogUnitDropdown( label = stringResource(reminderUnitLabel(unit)), entries = units.map { stringResource(reminderUnitLabel(it)) }, - onPick = { unit = units[it] }, + onPick = { pickedUnit = units[it] }, ) } } 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 882d37be..5235cb7b 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 @@ -7,7 +7,6 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import de.jeanlucmakiola.calendula.data.calendar.CalendarRepository import de.jeanlucmakiola.calendula.data.calendar.NoSuchEventException -import de.jeanlucmakiola.calendula.data.calendar.wholeDayReminders import de.jeanlucmakiola.calendula.data.ics.IcsExporter import de.jeanlucmakiola.calendula.data.prefs.CalendarPrefs import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs @@ -640,12 +639,7 @@ class EventEditViewModel @Inject constructor( // A kept pass of a repeated hour stays, so switching back out of all-day // lands where the event was — unless dropping the pin changed the zone. edit { - if (value) { - it.withTimezone(null, zoneSource.current()) - .copy(isAllDay = true, reminders = wholeDayReminders(it.reminders)) - } else { - it.copy(isAllDay = false) - } + if (value) it.withTimezone(null, zoneSource.current()).copy(isAllDay = true) else it.copy(isAllDay = false) } // The default reminder differs for all-day vs timed; re-apply the // type-appropriate default unless the user has hand-edited it (guarded). diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncodingTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncodingTest.kt index b6d678f8..123c5dc6 100644 --- a/app/src/test/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncodingTest.kt +++ b/app/src/test/java/de/jeanlucmakiola/calendula/data/calendar/AllDayReminderEncodingTest.kt @@ -48,12 +48,6 @@ class AllDayReminderEncodingTest { assertThat(actualFire(raw, summer)).isEqualTo(intendedFire(summer, 0, nineAm)) } - @Test - fun `whole-day rounding matches the encoder and keeps the default sentinel`() { - assertThat(wholeDayReminders(listOf(2_880, 10, 1_500, 0, MINUTES_DEFAULT))) - .containsExactly(MINUTES_DEFAULT, 0, 1_440, 2_880).inOrder() - } - @Test fun `three weeks before fires at 9am local across a DST change`() { val afterDst = LocalDate.of(2026, 4, 10) // CEST; three weeks earlier is CET