From f7329e45e3c353b7d4613ea1e732eab9a28ca337 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 30 Nov 2026 22:02:52 +0100 Subject: [PATCH] Calendar groups first in the manager, switched-off calendars kept but not offered (#166) --- .../ui/calendars/CalendarGroupsUi.kt | 2 +- .../calendula/ui/calendars/CalendarsScreen.kt | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarGroupsUi.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarGroupsUi.kt index ea297c3c..ca220599 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarGroupsUi.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarGroupsUi.kt @@ -84,7 +84,7 @@ internal fun CalendarGroupsSection( } /** - * Create or edit a calendar group: its name over every calendar by account, + * Create or edit a calendar group: its name over [calendars] by account, * checked ones being the members; the commit sits in the title bar. */ @Composable diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsScreen.kt index ac523488..028a2430 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/calendars/CalendarsScreen.kt @@ -222,9 +222,11 @@ fun CalendarsScreen( isNew = editing == null, initialName = editing?.name.orEmpty(), initialMembers = editing?.resolve(calendars)?.mapTo(mutableSetOf()) { it.id }.orEmpty(), - calendars = calendars, + // Switched-off calendars aren't offered, but stay members. + calendars = calendars.filter { it.isVisibleInSystem }, onSave = { name, members -> - viewModel.saveGroup(editing?.id, name, members) + val switchedOff = editing?.resolve(calendars).orEmpty().filterNot { it.isVisibleInSystem } + viewModel.saveGroup(editing?.id, name, members + switchedOff) groupEditorId = null }, onDelete = { @@ -297,6 +299,14 @@ private fun CalendarsList( predictiveBack = true, visible = visible, ) { + CalendarGroupsSection( + groups = calendarGroups, + calendars = local + synced, + onEdit = onEditGroup, + onAdd = onAddGroup, + ) + Spacer(Modifier.height(16.dp)) + // What the per-calendar / per-account switches below actually do. GroupedHint(stringResource(R.string.calendars_visibility_hint), style = MaterialTheme.typography.bodySmall) @@ -350,14 +360,6 @@ private fun CalendarsList( onClick = onOpenBackup, ) - Spacer(Modifier.height(16.dp)) - CalendarGroupsSection( - groups = calendarGroups, - calendars = local + synced, - onEdit = onEditGroup, - onAdd = onAddGroup, - ) - Spacer(Modifier.height(16.dp)) // Synced calendars — read-only, grouped by account. Each account is a