From 14f2dfe158ec1936354675a9d5f3268e61fef51c Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 16 Nov 2026 18:52:19 +0100 Subject: [PATCH 1/3] fix(#145): per-calendar reminders on their own grouped subpage --- .../ui/settings/CalendarReminderSettings.kt | 290 ++++++++++++++++++ .../ui/settings/NotificationSettings.kt | 197 +----------- .../calendula/ui/settings/SettingsScreen.kt | 20 +- app/src/main/res/values/strings.xml | 1 + floret-kit | 2 +- 5 files changed, 320 insertions(+), 190 deletions(-) create mode 100644 app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt new file mode 100644 index 00000000..206d2987 --- /dev/null +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt @@ -0,0 +1,290 @@ +package de.jeanlucmakiola.calendula.ui.settings + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.LifecycleResumeEffect +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import de.jeanlucmakiola.calendula.R +import de.jeanlucmakiola.calendula.domain.CalendarSource +import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip +import de.jeanlucmakiola.calendula.ui.common.REMINDER_PRESETS +import de.jeanlucmakiola.calendula.ui.common.ReminderDefaultPicker +import de.jeanlucmakiola.calendula.ui.common.accountGroupTitle +import de.jeanlucmakiola.calendula.ui.common.groupByAccount +import de.jeanlucmakiola.calendula.ui.common.orUnnamed +import de.jeanlucmakiola.floret.android.openNotificationSettings +import de.jeanlucmakiola.floret.components.CollapsingScaffold +import de.jeanlucmakiola.floret.components.ExpandIcon +import de.jeanlucmakiola.floret.components.GroupedHint +import de.jeanlucmakiola.floret.components.GroupedRow +import de.jeanlucmakiola.floret.components.GroupedSectionHeader +import de.jeanlucmakiola.floret.components.GroupedSwitchRow +import de.jeanlucmakiola.floret.components.Position +import de.jeanlucmakiola.floret.components.positionOf +import de.jeanlucmakiola.floret.identity.collapseExit +import de.jeanlucmakiola.floret.identity.expandEnter +import de.jeanlucmakiola.floret.reminders.ReminderOverride +import de.jeanlucmakiola.floret.reminders.reminderOverrideFor +import kotlinx.coroutines.launch + +/** + * Per-calendar notifications and reminder overrides (#145, #272), reached from + * Settings → Notifications. Calendars are listed by account as connected groups; + * a calendar unfolds its options in place, one tone darker, inside its group. + */ +@Composable +internal fun CalendarRemindersScreen( + state: SettingsUiState, + viewModel: SettingsViewModel, + onBack: () -> Unit, + onOpenSpecialDates: () -> Unit, + visible: Boolean = true, +) { + val context = LocalContext.current + val scope = rememberCoroutineScope() + var expandedCalendars by rememberSaveable { mutableStateOf(emptyList()) } + var overrideDialog by remember { mutableStateOf(null) } + val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle() + val calendarIds = state.reminderCalendars.map { it.id } + LifecycleResumeEffect(calendarIds) { + viewModel.refreshChannelStatus(calendarIds) + onPauseOrDispose { } + } + + CollapsingScaffold( + title = stringResource(R.string.settings_calendar_reminders_title), + onBack = onBack, + predictiveBack = true, + visible = visible, + ) { + GroupedHint(stringResource(R.string.settings_calendar_reminders_hint), style = MaterialTheme.typography.bodySmall) + state.reminderCalendars.groupByAccount().forEachIndexed { groupIndex, group -> + if (groupIndex > 0) Spacer(Modifier.height(8.dp)) + GroupedSectionHeader(accountGroupTitle(group)) + group.calendars.forEachIndexed { index, calendar -> + val expanded = calendar.id in expandedCalendars + val notifying = calendar.id !in state.mutedReminderCalendarIds + CalendarReminderEntry( + calendar = calendar, + state = state, + position = positionOf(index, group.calendars.size), + expanded = expanded, + notifying = notifying, + blocked = notifying && calendar.id in channelStatus.blockedCalendarIds, + onToggleExpand = { + expandedCalendars = if (expanded) { + expandedCalendars - calendar.id + } else { + expandedCalendars + calendar.id + } + }, + onSetNotifying = { viewModel.setCalendarRemindersEnabled(calendar.id, it) }, + onOpenSound = { + scope.launch { + context.openNotificationSettings(viewModel.soundSettingsChannel(calendar.id)) + } + }, + onOpenSpecialDates = onOpenSpecialDates, + onEditOverride = { overrideDialog = it }, + ) + } + } + } + + overrideDialog?.let { target -> + val map = if (target.isAllDay) { + state.perCalendarAllDayReminderOverride + } else { + state.perCalendarReminderOverride + } + ReminderDefaultPicker( + title = stringResource( + if (target.isAllDay) { + R.string.settings_default_reminder_allday + } else { + R.string.settings_default_reminder + }, + ), + presets = if (target.isAllDay) ALLDAY_REMINDER_PRESETS else REMINDER_PRESETS, + selected = map.reminderOverrideFor(target.calendarId), + allowInherit = true, + onSelect = { + if (target.isAllDay) { + viewModel.setCalendarAllDayReminderOverride(target.calendarId, it) + } else { + viewModel.setCalendarReminderOverride(target.calendarId, it) + } + }, + onDismiss = { overrideDialog = null }, + leadTimeSummary = if (target.isAllDay) { + allDayFiringTimeSummary(state.allDayReminderTimeMinutes) + } else { + null + }, + ) + } +} + +/** + * One calendar in its account group, with its options unfolding beneath it: + * the notification switch and channel deep-link for every calendar, then the + * default-reminder overrides where it takes them — or, for a special-dates + * calendar, a link to the section that owns them. + */ +@Composable +private fun CalendarReminderEntry( + calendar: CalendarSource, + state: SettingsUiState, + position: Position, + expanded: Boolean, + notifying: Boolean, + blocked: Boolean, + onToggleExpand: () -> Unit, + onSetNotifying: (Boolean) -> Unit, + onOpenSound: () -> Unit, + onOpenSpecialDates: () -> Unit, + onEditOverride: (OverrideTarget) -> Unit, +) { + val opensGroup = position == Position.Top || position == Position.Alone + val closesGroup = position == Position.Bottom || position == Position.Alone + GroupedRow( + title = calendar.displayName.orUnnamed(), + summary = when { + !notifying -> stringResource(R.string.settings_calendar_notifications_off) + blocked -> stringResource(R.string.settings_notifications_blocked) + else -> null + }, + position = when { + !expanded -> position + opensGroup -> Position.Top + else -> Position.Middle + }, + leading = { CalendarColorChip(calendar.color) }, + trailing = { ExpandIcon(expanded) }, + onClick = onToggleExpand, + ) + AnimatedVisibility( + visible = expanded, + enter = expandEnter(), + exit = collapseExit(), + ) { + val managed = calendar.id in state.managedCalendarIds + val takesOverrides = calendar.canModifyContents && !managed + val nested = MaterialTheme.colorScheme.surfaceContainerHighest + val last = if (closesGroup) Position.Bottom else Position.Middle + Column { + GroupedSwitchRow( + title = stringResource(R.string.settings_calendar_notifications), + checked = notifying, + onCheckedChange = onSetNotifying, + summary = stringResource(R.string.settings_calendar_notifications_hint), + position = Position.Middle, + container = nested, + ) + GroupedRow( + title = stringResource(R.string.settings_notification_sound), + summary = if (blocked) { + stringResource(R.string.settings_notifications_blocked_hint) + } else { + stringResource(R.string.settings_calendar_notification_sound_hint) + }, + position = if (managed || takesOverrides) Position.Middle else last, + container = nested, + trailing = { ExternalLinkIcon() }, + onClick = onOpenSound, + ) + if (managed) { + GroupedRow( + title = stringResource(R.string.settings_default_reminder_allday), + summary = stringResource(R.string.settings_calendar_reminders_managed_hint), + position = last, + container = nested, + trailing = { ChevronIcon() }, + onClick = onOpenSpecialDates, + ) + } else if (takesOverrides) { + OverrideRow( + calendarId = calendar.id, + isAllDay = false, + choice = state.perCalendarReminderOverride.reminderOverrideFor(calendar.id), + globalDefault = state.defaultReminderMinutes, + position = Position.Middle, + container = nested, + onEditOverride = onEditOverride, + ) + OverrideRow( + calendarId = calendar.id, + isAllDay = true, + choice = state.perCalendarAllDayReminderOverride.reminderOverrideFor(calendar.id), + globalDefault = state.defaultAllDayReminderMinutes, + position = last, + container = nested, + onEditOverride = onEditOverride, + ) + } + } + } +} + +@Composable +private fun OverrideRow( + calendarId: Long, + isAllDay: Boolean, + choice: ReminderOverride, + globalDefault: List, + position: Position, + container: Color, + onEditOverride: (OverrideTarget) -> Unit, +) { + GroupedRow( + title = stringResource( + if (isAllDay) R.string.settings_default_reminder_allday else R.string.settings_default_reminder, + ), + summary = calendarOverrideSummary(choice, globalDefault), + position = position, + container = container, + onClick = { onEditOverride(OverrideTarget(calendarId, isAllDay)) }, + ) +} + +@Composable +private fun ChevronIcon() { + Icon( + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) +} + +/** Which calendar + event kind a per-calendar reminder-override dialog targets. */ +private data class OverrideTarget(val calendarId: Long, val isAllDay: Boolean) + +/** Row summary for a calendar: its override, or the inherited global default. */ +@Composable +private fun calendarOverrideSummary( + choice: ReminderOverride, + globalDefault: List, +): String = when (choice) { + ReminderOverride.Inherit -> + stringResource(R.string.settings_calendar_reminder_inherits, reminderChoiceLabel(globalDefault)) + ReminderOverride.None -> stringResource(R.string.reminder_none) + is ReminderOverride.Minutes -> reminderChoiceLabel(choice.minutes) +} diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/NotificationSettings.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/NotificationSettings.kt index efa61104..b90b06c9 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/NotificationSettings.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/NotificationSettings.kt @@ -8,9 +8,7 @@ import android.os.PowerManager import android.provider.Settings import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -42,28 +40,21 @@ import androidx.lifecycle.compose.LifecycleResumeEffect import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle import de.jeanlucmakiola.calendula.R -import de.jeanlucmakiola.calendula.domain.CalendarSource -import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip import de.jeanlucmakiola.calendula.ui.common.DurationPicker import de.jeanlucmakiola.calendula.ui.common.REMINDER_PRESETS import de.jeanlucmakiola.calendula.ui.common.ReminderDefaultPicker import de.jeanlucmakiola.calendula.ui.common.TimePickerAlert import de.jeanlucmakiola.calendula.ui.common.durationLabel -import de.jeanlucmakiola.calendula.ui.common.orUnnamed import de.jeanlucmakiola.floret.android.hasPermission import de.jeanlucmakiola.floret.android.openNotificationSettings import de.jeanlucmakiola.floret.components.CollapsingScaffold -import de.jeanlucmakiola.floret.components.ExpandIcon import de.jeanlucmakiola.floret.components.GroupedRow import de.jeanlucmakiola.floret.components.GroupedSwitchRow import de.jeanlucmakiola.floret.components.IconInfoCard import de.jeanlucmakiola.floret.components.Position import de.jeanlucmakiola.floret.components.SelectedCheck -import de.jeanlucmakiola.floret.identity.collapseExit -import de.jeanlucmakiola.floret.identity.expandEnter import de.jeanlucmakiola.floret.reminders.ReminderOverride import de.jeanlucmakiola.floret.reminders.minutesOrEmpty -import de.jeanlucmakiola.floret.reminders.reminderOverrideFor import kotlinx.coroutines.launch import kotlinx.datetime.LocalTime @@ -77,7 +68,7 @@ internal fun NotificationsScreen( state: SettingsUiState, viewModel: SettingsViewModel, onBack: () -> Unit, - onOpenSpecialDates: () -> Unit, + onOpenCalendarReminders: () -> Unit, visible: Boolean = true, ) { val context = LocalContext.current @@ -98,9 +89,6 @@ internal fun NotificationsScreen( var showAllDayReminder by remember { mutableStateOf(false) } var showAllDayReminderTime by remember { mutableStateOf(false) } var showSnooze by remember { mutableStateOf(false) } - var overrideDialog by remember { mutableStateOf(null) } - var calendarSectionExpanded by remember { mutableStateOf(false) } - var expandedCalendars by remember { mutableStateOf(emptySet()) } val scope = rememberCoroutineScope() val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle() val calendarIds = state.reminderCalendars.map { it.id } @@ -108,9 +96,6 @@ internal fun NotificationsScreen( viewModel.refreshChannelStatus(calendarIds) onPauseOrDispose { } } - val openCalendarSound: (Long) -> Unit = { calendarId -> - scope.launch { context.openNotificationSettings(viewModel.soundSettingsChannel(calendarId)) } - } CollapsingScaffold( title = stringResource(R.string.settings_section_notifications), @@ -203,64 +188,21 @@ internal fun NotificationsScreen( onClick = { showSnooze = true }, ) - // Per-calendar notifications and reminder overrides (#145, #272). if (state.reminderCalendars.isNotEmpty()) { Spacer(Modifier.height(24.dp)) GroupedRow( title = stringResource(R.string.settings_calendar_reminders_title), - summary = stringResource(R.string.settings_calendar_reminders_hint), + summary = stringResource(R.string.settings_calendar_reminders_subtitle), position = Position.Alone, - trailing = { ExpandIcon(calendarSectionExpanded) }, - onClick = { calendarSectionExpanded = !calendarSectionExpanded }, + trailing = { + Icon( + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) + }, + onClick = onOpenCalendarReminders, ) - AnimatedVisibility( - visible = calendarSectionExpanded, - enter = expandEnter(), - exit = collapseExit(), - ) { - Column { - state.reminderCalendars.forEach { calendar -> - Spacer(Modifier.height(16.dp)) - val expanded = calendar.id in expandedCalendars - val notifying = calendar.id !in state.mutedReminderCalendarIds - val blocked = notifying && calendar.id in channelStatus.blockedCalendarIds - GroupedRow( - title = calendar.displayName.orUnnamed(), - summary = when { - !notifying -> stringResource(R.string.settings_calendar_notifications_off) - blocked -> stringResource(R.string.settings_notifications_blocked) - else -> null - }, - position = if (expanded) Position.Top else Position.Alone, - leading = { CalendarColorChip(calendar.color) }, - trailing = { ExpandIcon(expanded) }, - onClick = { - expandedCalendars = if (expanded) { - expandedCalendars - calendar.id - } else { - expandedCalendars + calendar.id - } - }, - ) - AnimatedVisibility( - visible = expanded, - enter = expandEnter(), - exit = collapseExit(), - ) { - CalendarNotificationRows( - calendar = calendar, - state = state, - notifying = notifying, - blocked = blocked, - onSetNotifying = { viewModel.setCalendarRemindersEnabled(calendar.id, it) }, - onOpenSound = { openCalendarSound(calendar.id) }, - onOpenSpecialDates = onOpenSpecialDates, - onEditOverride = { overrideDialog = it }, - ) - } - } - } - } } } @@ -309,108 +251,6 @@ internal fun NotificationsScreen( onDismiss = { showAllDayReminderTime = false }, ) } - overrideDialog?.let { target -> - val map = if (target.isAllDay) { - state.perCalendarAllDayReminderOverride - } else { - state.perCalendarReminderOverride - } - ReminderDefaultPicker( - title = stringResource( - if (target.isAllDay) { - R.string.settings_default_reminder_allday - } else { - R.string.settings_default_reminder - }, - ), - presets = if (target.isAllDay) ALLDAY_REMINDER_PRESETS else REMINDER_PRESETS, - selected = map.reminderOverrideFor(target.calendarId), - allowInherit = true, - onSelect = { - if (target.isAllDay) { - viewModel.setCalendarAllDayReminderOverride(target.calendarId, it) - } else { - viewModel.setCalendarReminderOverride(target.calendarId, it) - } - }, - onDismiss = { overrideDialog = null }, - leadTimeSummary = if (target.isAllDay) { - allDayFiringTimeSummary(state.allDayReminderTimeMinutes) - } else { - null - }, - ) - } -} - -/** - * One calendar's expanded rows: its notification switch and channel deep-link - * for every calendar, then the default-reminder overrides where it takes them — - * or, for a special-dates calendar, a link to the section that owns them. - */ -@Composable -private fun CalendarNotificationRows( - calendar: CalendarSource, - state: SettingsUiState, - notifying: Boolean, - blocked: Boolean, - onSetNotifying: (Boolean) -> Unit, - onOpenSound: () -> Unit, - onOpenSpecialDates: () -> Unit, - onEditOverride: (OverrideTarget) -> Unit, -) { - val managed = calendar.id in state.managedCalendarIds - val takesOverrides = calendar.canModifyContents && !managed - Column { - GroupedSwitchRow( - title = stringResource(R.string.settings_calendar_notifications), - checked = notifying, - onCheckedChange = onSetNotifying, - summary = stringResource(R.string.settings_calendar_notifications_hint), - position = Position.Middle, - ) - GroupedRow( - title = stringResource(R.string.settings_notification_sound), - summary = if (blocked) { - stringResource(R.string.settings_notifications_blocked_hint) - } else { - stringResource(R.string.settings_calendar_notification_sound_hint) - }, - position = if (managed || takesOverrides) Position.Middle else Position.Bottom, - trailing = { ExternalLinkIcon() }, - onClick = onOpenSound, - ) - if (managed) { - GroupedRow( - title = stringResource(R.string.settings_default_reminder_allday), - summary = stringResource(R.string.settings_calendar_reminders_managed_hint), - position = Position.Bottom, - trailing = { - Icon( - imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, - contentDescription = null, - tint = MaterialTheme.colorScheme.onSurfaceVariant, - ) - }, - onClick = onOpenSpecialDates, - ) - } else if (takesOverrides) { - val timed = state.perCalendarReminderOverride.reminderOverrideFor(calendar.id) - GroupedRow( - title = stringResource(R.string.settings_default_reminder), - summary = calendarOverrideSummary(timed, state.defaultReminderMinutes), - position = Position.Middle, - onClick = { onEditOverride(OverrideTarget(calendar.id, isAllDay = false)) }, - ) - val allDay = state.perCalendarAllDayReminderOverride.reminderOverrideFor(calendar.id) - GroupedRow( - title = stringResource(R.string.settings_default_reminder_allday), - summary = calendarOverrideSummary(allDay, state.defaultAllDayReminderMinutes), - position = Position.Bottom, - onClick = { onEditOverride(OverrideTarget(calendar.id, isAllDay = true)) }, - ) - } - } } /** Samsung's One UI can start a new notification category switched off (#145). */ @@ -436,7 +276,7 @@ private fun NotificationCategoryHint(onOpen: () -> Unit, onDismiss: () -> Unit) } @Composable -private fun ExternalLinkIcon() { +internal fun ExternalLinkIcon() { Icon( imageVector = Icons.AutoMirrored.Filled.OpenInNew, contentDescription = null, @@ -444,25 +284,10 @@ private fun ExternalLinkIcon() { ) } -/** Which calendar + event kind a per-calendar reminder-override dialog targets. */ -private data class OverrideTarget(val calendarId: Long, val isAllDay: Boolean) - /** A global default (empty = none) as a picker choice for selection highlighting. */ private fun List.toReminderChoice(): ReminderOverride = if (isEmpty()) ReminderOverride.None else ReminderOverride.Minutes(this) -/** Row summary for a calendar: its override, or the inherited global default. */ -@Composable -private fun calendarOverrideSummary( - choice: ReminderOverride, - globalDefault: List, -): String = when (choice) { - ReminderOverride.Inherit -> - stringResource(R.string.settings_calendar_reminder_inherits, reminderChoiceLabel(globalDefault)) - ReminderOverride.None -> stringResource(R.string.reminder_none) - is ReminderOverride.Minutes -> reminderChoiceLabel(choice.minutes) -} - /** Snooze delays offered for the notification "Snooze" action, in minutes. */ private val SNOOZE_PRESETS = listOf(5, 10, 15, 30, 60) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/SettingsScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/SettingsScreen.kt index 3bab7449..e3ba551c 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/SettingsScreen.kt @@ -73,7 +73,7 @@ import de.jeanlucmakiola.floret.identity.predictiveBackExit /** The settings sub-screens reached from the hub's category rows. */ private enum class SettingsSection { - Appearance, Views, EventForm, Notifications, SpecialDates, Widgets, Licences + Appearance, Views, EventForm, Notifications, CalendarReminders, SpecialDates, Widgets, Licences } /** @@ -131,8 +131,9 @@ fun SettingsScreen( ) { EventFormScreen(state = state, viewModel = viewModel, onBack = { section = null }, visible = section == SettingsSection.EventForm) } + // Stays up beneath its per-calendar subpage, so backing out reveals it. AnimatedVisibility( - visible = section == SettingsSection.Notifications, + visible = section == SettingsSection.Notifications || section == SettingsSection.CalendarReminders, enter = slideInHorizontally(slideSpec) { it } + fadeIn(), exit = overlayExit, ) { @@ -140,10 +141,23 @@ fun SettingsScreen( state = state, viewModel = viewModel, onBack = { section = null }, - onOpenSpecialDates = { section = SettingsSection.SpecialDates }, + onOpenCalendarReminders = { section = SettingsSection.CalendarReminders }, visible = section == SettingsSection.Notifications, ) } + AnimatedVisibility( + visible = section == SettingsSection.CalendarReminders, + enter = slideInHorizontally(slideSpec) { it } + fadeIn(), + exit = overlayExit, + ) { + CalendarRemindersScreen( + state = state, + viewModel = viewModel, + onBack = { section = SettingsSection.Notifications }, + onOpenSpecialDates = { section = SettingsSection.SpecialDates }, + visible = section == SettingsSection.CalendarReminders, + ) + } AnimatedVisibility( visible = section == SettingsSection.SpecialDates, enter = slideInHorizontally(slideSpec) { it } + fadeIn(), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3e7b8d77..8d182bf1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -731,6 +731,7 @@ Amount Set Per-calendar reminders + Notifications, sound and default reminders per calendar Turn notifications off or pick a sound per calendar, and override the default reminder for calendars you can edit. Notifications Notify at this calendar\'s reminder times diff --git a/floret-kit b/floret-kit index 20b136aa..a517ef6e 160000 --- a/floret-kit +++ b/floret-kit @@ -1 +1 @@ -Subproject commit 20b136aaf71277643267018ed1c57dae0b0c54ec +Subproject commit a517ef6e028b6e501d9397f5a74bad36c4188d09 From 10e18ef888ac813c9825600f7eead118c367e344 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 16 Nov 2026 19:09:00 +0100 Subject: [PATCH 2/3] fix(#145): an expanded calendar closes off its own rounded run --- .../ui/settings/CalendarReminderSettings.kt | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt index 206d2987..fa6e15b5 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt @@ -38,7 +38,6 @@ import de.jeanlucmakiola.floret.components.GroupedRow import de.jeanlucmakiola.floret.components.GroupedSectionHeader import de.jeanlucmakiola.floret.components.GroupedSwitchRow import de.jeanlucmakiola.floret.components.Position -import de.jeanlucmakiola.floret.components.positionOf import de.jeanlucmakiola.floret.identity.collapseExit import de.jeanlucmakiola.floret.identity.expandEnter import de.jeanlucmakiola.floret.reminders.ReminderOverride @@ -79,13 +78,18 @@ internal fun CalendarRemindersScreen( state.reminderCalendars.groupByAccount().forEachIndexed { groupIndex, group -> if (groupIndex > 0) Spacer(Modifier.height(8.dp)) GroupedSectionHeader(accountGroupTitle(group)) - group.calendars.forEachIndexed { index, calendar -> + val calendars = group.calendars + calendars.forEachIndexed { index, calendar -> val expanded = calendar.id in expandedCalendars + val isExpanded = { i: Int -> calendars[i].id in expandedCalendars } val notifying = calendar.id !in state.mutedReminderCalendarIds CalendarReminderEntry( calendar = calendar, state = state, - position = positionOf(index, group.calendars.size), + position = segmentPosition( + startsSegment = expanded || index == 0 || isExpanded(index - 1), + endsSegment = !expanded && (index == calendars.lastIndex || isExpanded(index + 1)), + ), expanded = expanded, notifying = notifying, blocked = notifying && calendar.id in channelStatus.blockedCalendarIds, @@ -163,8 +167,6 @@ private fun CalendarReminderEntry( onOpenSpecialDates: () -> Unit, onEditOverride: (OverrideTarget) -> Unit, ) { - val opensGroup = position == Position.Top || position == Position.Alone - val closesGroup = position == Position.Bottom || position == Position.Alone GroupedRow( title = calendar.displayName.orUnnamed(), summary = when { @@ -172,11 +174,7 @@ private fun CalendarReminderEntry( blocked -> stringResource(R.string.settings_notifications_blocked) else -> null }, - position = when { - !expanded -> position - opensGroup -> Position.Top - else -> Position.Middle - }, + position = position, leading = { CalendarColorChip(calendar.color) }, trailing = { ExpandIcon(expanded) }, onClick = onToggleExpand, @@ -189,7 +187,7 @@ private fun CalendarReminderEntry( val managed = calendar.id in state.managedCalendarIds val takesOverrides = calendar.canModifyContents && !managed val nested = MaterialTheme.colorScheme.surfaceContainerHighest - val last = if (closesGroup) Position.Bottom else Position.Middle + val last = Position.Bottom Column { GroupedSwitchRow( title = stringResource(R.string.settings_calendar_notifications), @@ -244,6 +242,17 @@ private fun CalendarReminderEntry( } } +/** + * A calendar row's place in its connected run: an expanded calendar opens its own + * run that its options close, so the rows around it round off against it. + */ +private fun segmentPosition(startsSegment: Boolean, endsSegment: Boolean): Position = when { + startsSegment && endsSegment -> Position.Alone + startsSegment -> Position.Top + endsSegment -> Position.Bottom + else -> Position.Middle +} + @Composable private fun OverrideRow( calendarId: Long, From efe454f200473f58b3f3b9192acc1bec7ef9a314 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 16 Nov 2026 19:18:47 +0100 Subject: [PATCH 3/3] fix(#145): an expanded calendar's options round off with a gap below --- .../ui/settings/CalendarReminderSettings.kt | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt index fa6e15b5..ef670cad 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/settings/CalendarReminderSettings.kt @@ -4,6 +4,7 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.Icon @@ -38,6 +39,7 @@ import de.jeanlucmakiola.floret.components.GroupedRow import de.jeanlucmakiola.floret.components.GroupedSectionHeader import de.jeanlucmakiola.floret.components.GroupedSwitchRow import de.jeanlucmakiola.floret.components.Position +import de.jeanlucmakiola.floret.components.positionOf import de.jeanlucmakiola.floret.identity.collapseExit import de.jeanlucmakiola.floret.identity.expandEnter import de.jeanlucmakiola.floret.reminders.ReminderOverride @@ -81,15 +83,11 @@ internal fun CalendarRemindersScreen( val calendars = group.calendars calendars.forEachIndexed { index, calendar -> val expanded = calendar.id in expandedCalendars - val isExpanded = { i: Int -> calendars[i].id in expandedCalendars } val notifying = calendar.id !in state.mutedReminderCalendarIds CalendarReminderEntry( calendar = calendar, state = state, - position = segmentPosition( - startsSegment = expanded || index == 0 || isExpanded(index - 1), - endsSegment = !expanded && (index == calendars.lastIndex || isExpanded(index + 1)), - ), + position = positionOf(index, calendars.size), expanded = expanded, notifying = notifying, blocked = notifying && calendar.id in channelStatus.blockedCalendarIds, @@ -167,6 +165,8 @@ private fun CalendarReminderEntry( onOpenSpecialDates: () -> Unit, onEditOverride: (OverrideTarget) -> Unit, ) { + val opensGroup = position == Position.Top || position == Position.Alone + val closesGroup = position == Position.Bottom || position == Position.Alone GroupedRow( title = calendar.displayName.orUnnamed(), summary = when { @@ -174,7 +174,11 @@ private fun CalendarReminderEntry( blocked -> stringResource(R.string.settings_notifications_blocked) else -> null }, - position = position, + position = when { + !expanded -> position + opensGroup -> Position.Top + else -> Position.Middle + }, leading = { CalendarColorChip(calendar.color) }, trailing = { ExpandIcon(expanded) }, onClick = onToggleExpand, @@ -187,8 +191,8 @@ private fun CalendarReminderEntry( val managed = calendar.id in state.managedCalendarIds val takesOverrides = calendar.canModifyContents && !managed val nested = MaterialTheme.colorScheme.surfaceContainerHighest - val last = Position.Bottom - Column { + // The options round off their calendar; mid-group they keep the row gap. + Column(if (closesGroup) Modifier else Modifier.padding(bottom = 2.dp)) { GroupedSwitchRow( title = stringResource(R.string.settings_calendar_notifications), checked = notifying, @@ -204,7 +208,7 @@ private fun CalendarReminderEntry( } else { stringResource(R.string.settings_calendar_notification_sound_hint) }, - position = if (managed || takesOverrides) Position.Middle else last, + position = if (managed || takesOverrides) Position.Middle else Position.Bottom, container = nested, trailing = { ExternalLinkIcon() }, onClick = onOpenSound, @@ -213,7 +217,7 @@ private fun CalendarReminderEntry( GroupedRow( title = stringResource(R.string.settings_default_reminder_allday), summary = stringResource(R.string.settings_calendar_reminders_managed_hint), - position = last, + position = Position.Bottom, container = nested, trailing = { ChevronIcon() }, onClick = onOpenSpecialDates, @@ -233,7 +237,7 @@ private fun CalendarReminderEntry( isAllDay = true, choice = state.perCalendarAllDayReminderOverride.reminderOverrideFor(calendar.id), globalDefault = state.defaultAllDayReminderMinutes, - position = last, + position = Position.Bottom, container = nested, onEditOverride = onEditOverride, ) @@ -242,17 +246,6 @@ private fun CalendarReminderEntry( } } -/** - * A calendar row's place in its connected run: an expanded calendar opens its own - * run that its options close, so the rows around it round off against it. - */ -private fun segmentPosition(startsSegment: Boolean, endsSegment: Boolean): Position = when { - startsSegment && endsSegment -> Position.Alone - startsSegment -> Position.Top - endsSegment -> Position.Bottom - else -> Position.Middle -} - @Composable private fun OverrideRow( calendarId: Long,