Compare commits

..
28 changed files with 682 additions and 498 deletions

No files matched your search

@@ -48,6 +48,8 @@ internal object SettingsBackupSchema {
SettingsKeys.autofocusEventTitle,
// Names its calendar by account and display name, so it finds it again on another device.
SettingsKeys.defaultNewEventCalendar,
// Names its members the same way (#166).
CalendarPrefKeys.calendarGroups,
SettingsKeys.defaultEventDurationMinutes,
SettingsKeys.remindersEnabled,
SettingsKeys.allowColorOnUnsupportedCalendars,
@@ -100,7 +102,6 @@ internal object SettingsBackupSchema {
// Usage history, not a setting.
SettingsKeys.recentTimeZones,
SettingsKeys.recentFixedTimeReminders,
SettingsKeys.recentCustomColors,
// A dismissed hint of this install.
SettingsKeys.notificationCategoryHintDismissed,
// This device's notification channels.
@@ -1,33 +1,35 @@
package de.jeanlucmakiola.calendula.data.calendar
import de.jeanlucmakiola.floret.components.PresetColors
/**
* The colours offered when creating or editing a calendar; ARGB ints for a raw
* `CALENDAR_COLOR` / `EVENT_COLOR`. The values are floret-kit's [PresetColors],
* shared with Agendula; distinctness after this app's tone pass is checked by
* `CalendarColorPaletteTest`.
* `CALENDAR_COLOR` / `EVENT_COLOR`.
*
* Hues rather than final fills: every surface that draws a calendar colour runs
* it through the app's own tone pass first, so these are chosen to stay
* distinguishable after it. Shared with Agendula, whose list palette these are —
* the two apps are the same family and a calendar and a task list picked from
* different-looking sets read as different products.
*
* The named entries exist for callers that need one specific hue (the managed
* special-dates calendars), so they can't drift from the swatches on offer.
*/
object CalendarColorPalette {
val Mauve = PresetColors.Mauve
val Red = PresetColors.Red
val Orange = PresetColors.Orange
val Amber = PresetColors.Amber
val Olive = PresetColors.Olive
val Green = PresetColors.Green
val Teal = PresetColors.Teal
val Cyan = PresetColors.Cyan
val Blue = PresetColors.Blue
val Indigo = PresetColors.Indigo
val Purple = PresetColors.Purple
val Pink = PresetColors.Pink
val Mauve = 0xFF7A5C6B.toInt()
val Red = 0xFFD7484A.toInt()
val Orange = 0xFFE8743B.toInt()
val Amber = 0xFFE0A32E.toInt()
val Olive = 0xFF7CA83E.toInt()
val Green = 0xFF35A06A.toInt()
val Teal = 0xFF19938C.toInt()
val Cyan = 0xFF2A9BC4.toInt()
val Blue = 0xFF3C74C8.toInt()
val Indigo = 0xFF6A5CC0.toInt()
val Purple = 0xFF9455B8.toInt()
val Pink = 0xFFC94F8E.toInt()
/** The full palette, in swatch-grid order. */
val all: List<Int> = PresetColors.all
/** The preset [argb] is, or null when it is a custom colour (never rewritten to match). */
fun presetOf(argb: Int?): Int? = PresetColors.presetOf(argb)
val all: List<Int> = listOf(
Mauve, Red, Orange, Amber, Olive, Green,
Teal, Cyan, Blue, Indigo, Purple, Pink,
)
}
@@ -9,6 +9,9 @@ import de.jeanlucmakiola.floret.prefs.nullableLongPref
import de.jeanlucmakiola.floret.prefs.nullableStringPref
import de.jeanlucmakiola.floret.prefs.stringSetPref
import de.jeanlucmakiola.calendula.data.calendar.SyncAccount
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.decodeCalendarGroups
import de.jeanlucmakiola.calendula.domain.encodeCalendarGroups
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import javax.inject.Singleton
@@ -79,6 +82,13 @@ class CalendarPrefs @Inject constructor(
suspend fun setLastUsedCalendarId(id: Long) = prefs.set(CalendarPrefKeys.lastUsedCalendarId, id)
/** The drawer's calendar groups (#166), in the order they were created. */
val calendarGroups: Flow<List<CalendarGroup>> = prefs.flow(CalendarPrefKeys.calendarGroups)
suspend fun updateCalendarGroups(transform: (List<CalendarGroup>) -> List<CalendarGroup>) {
prefs.update(CalendarPrefKeys.calendarGroups, transform)
}
/**
* Synced accounts the user chose never to be asked to grant sync-request
* access for (#240): no grant row, no "other accounts" receipt.
@@ -96,6 +106,8 @@ internal object CalendarPrefKeys {
val pendingDisabledCalendarIds: Pref<Set<Long>> = idSetPref("disabled_calendar_ids")
val visibilityNoticePending: Pref<Boolean?> = nullableBooleanPref("visibility_notice_pending")
val lastUsedCalendarId: Pref<Long?> = nullableLongPref("last_used_calendar_id")
val calendarGroups: Pref<List<CalendarGroup>> =
nullableStringPref("calendar_groups").map(::decodeCalendarGroups, ::encodeCalendarGroups)
val syncAccessDismissed: Pref<Set<SyncAccount>> = stringSetPref("sync_access_dismissed").map(
{ stored -> stored.mapNotNullTo(mutableSetOf()) { it.toSyncAccount() } },
{ accounts -> accounts.mapTo(mutableSetOf()) { "${it.type}$FIELD_SEPARATOR${it.name}" } },
@@ -44,8 +44,6 @@ import de.jeanlucmakiola.calendula.ui.onboarding.OnboardingStep
import de.jeanlucmakiola.calendula.ui.theme.FONT_SYSTEM_TOKEN
import de.jeanlucmakiola.calendula.widget.WidgetSize
import de.jeanlucmakiola.floret.android.stateWhileSubscribed
import de.jeanlucmakiola.floret.components.hexDigitsOf
import de.jeanlucmakiola.floret.components.parseHexColor
import de.jeanlucmakiola.floret.prefs.AppearancePrefs
import de.jeanlucmakiola.floret.prefs.Pref
import de.jeanlucmakiola.floret.prefs.PrefStore
@@ -189,7 +187,6 @@ class SettingsPrefs @Inject constructor(
val drawerViewOrder: Flow<List<CalendarView>> = prefs.flow(SettingsKeys.drawerViewOrder)
val defaultFormFields: Flow<Set<EventFormField>> = prefs.flow(SettingsKeys.defaultFormFields)
val recentTimeZones: Flow<List<String>> = prefs.flow(SettingsKeys.recentTimeZones)
val recentCustomColors: Flow<List<Int>> = prefs.flow(SettingsKeys.recentCustomColors)
val autofocusEventTitle: Flow<Boolean> = prefs.flow(SettingsKeys.autofocusEventTitle)
val defaultNewEventCalendar: Flow<DefaultCalendarRef?> = prefs.flow(SettingsKeys.defaultNewEventCalendar)
val defaultEventDurationMinutes: Flow<Int> = prefs.flow(SettingsKeys.defaultEventDurationMinutes)
@@ -314,11 +311,6 @@ class SettingsPrefs @Inject constructor(
prefs.update(SettingsKeys.recentTimeZones) { (listOf(zoneId) + it).distinct() }
}
/** Moves [argb] to the front of the custom-colour recents shared by the colour pickers. */
suspend fun addRecentCustomColor(argb: Int) {
prefs.update(SettingsKeys.recentCustomColors) { withRecentColor(it, argb) }
}
suspend fun setAutofocusEventTitle(enabled: Boolean) = prefs.set(SettingsKeys.autofocusEventTitle, enabled)
/** [calendar] null goes back to Automatic. */
@@ -655,8 +647,6 @@ class SettingsPrefs @Inject constructor(
setOf(EventFormField.Location, EventFormField.Description)
/** Enough to cover the zones a user actually recurs to, without a wall of rows. */
internal const val MAX_RECENT_TIME_ZONES = 5
/** One row of swatches in the colour pickers. */
internal const val MAX_RECENT_CUSTOM_COLORS = 8
/** Default automatic-backup interval: daily. */
const val DEFAULT_BACKUP_INTERVAL = 1_440L
/** Floor for the automatic-backup interval (also above WorkManager's 15-min limit). */
@@ -840,15 +830,6 @@ object SettingsKeys {
zones.take(SettingsPrefs.MAX_RECENT_TIME_ZONES).joinToString(",")
}
/**
* Custom colours the user picked recently, most recent first, as `RRGGBB`
* hex joined by commas; unreadable entries are dropped on read.
*/
val recentCustomColors: Pref<List<Int>> =
nullableStringPref("recent_custom_colors").map(::parseRecentColors) { colors ->
colors.take(SettingsPrefs.MAX_RECENT_CUSTOM_COLORS).joinToString(LIST_SEP, transform = ::hexDigitsOf)
}
/**
* Whether opening the new-event form focuses the title field and raises the
* keyboard straight away (issue #10). Only the create form auto-focuses.
@@ -1270,25 +1251,6 @@ private fun parseRecentTimeZones(stored: String?): List<String> =
.distinct()
.take(SettingsPrefs.MAX_RECENT_TIME_ZONES)
private fun parseRecentColors(stored: String?): List<Int> =
stored?.split(LIST_SEP).orEmpty()
.mapNotNull(::parseHexColor)
.distinct()
.take(SettingsPrefs.MAX_RECENT_CUSTOM_COLORS)
/**
* [recents] with [argb] (made opaque) moved to the front: an earlier copy is
* dropped rather than repeated, and the list stays at most
* [SettingsPrefs.MAX_RECENT_CUSTOM_COLORS] long.
*/
internal fun withRecentColor(recents: List<Int>, argb: Int): List<Int> {
val opaque = argb or OPAQUE_ALPHA
return (listOf(opaque) + recents.filter { (it or OPAQUE_ALPHA) != opaque })
.take(SettingsPrefs.MAX_RECENT_CUSTOM_COLORS)
}
private const val OPAQUE_ALPHA = 0xFF shl 24
private fun parseFormFields(stored: String?): Set<EventFormField> = when (stored) {
null -> SettingsPrefs.DEFAULT_FORM_FIELDS
else -> stored.split(',')
@@ -0,0 +1,92 @@
package de.jeanlucmakiola.calendula.domain
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.longOrNull
/**
* A user-named set of calendars shown or hidden together from the drawer
* (#166). Members may come from several accounts and groups may overlap; each
* member is named by account and display name ([DefaultCalendarRef]), so a
* group survives provider id changes and a restore on another device.
*/
data class CalendarGroup(
val id: String,
val name: String,
val members: List<DefaultCalendarRef>,
) {
/** The members that exist in [calendars], each once; missing ones are dropped. */
fun resolve(calendars: List<CalendarSource>): List<CalendarSource> =
members.mapNotNull { it.find(calendars) }.distinctBy { it.id }
}
/** [groups] as stored; null (no key) when there are none. */
fun encodeCalendarGroups(groups: List<CalendarGroup>): String? {
if (groups.isEmpty()) return null
return JsonArray(
groups.map { group ->
buildJsonObject {
put(KEY_ID, JsonPrimitive(group.id))
put(KEY_NAME, JsonPrimitive(group.name))
put(
KEY_MEMBERS,
JsonArray(
group.members.map { ref ->
buildJsonObject {
put(KEY_CALENDAR_ID, JsonPrimitive(ref.id))
put(KEY_ACCOUNT_TYPE, JsonPrimitive(ref.accountType))
put(KEY_ACCOUNT_NAME, JsonPrimitive(ref.accountName))
put(KEY_DISPLAY_NAME, JsonPrimitive(ref.displayName))
}
},
),
)
}
},
).toString()
}
/** The stored groups; an unreadable value reads as none, an unreadable entry or member is skipped. */
fun decodeCalendarGroups(stored: String?): List<CalendarGroup> {
if (stored.isNullOrBlank()) return emptyList()
val array = runCatching { Json.parseToJsonElement(stored) }.getOrNull() as? JsonArray ?: return emptyList()
return array.mapNotNull { element ->
val group = element as? JsonObject ?: return@mapNotNull null
val id = group.string(KEY_ID) ?: return@mapNotNull null
val name = group.string(KEY_NAME) ?: return@mapNotNull null
val members = (group[KEY_MEMBERS] as? JsonArray).orEmpty().mapNotNull { member ->
val ref = member as? JsonObject ?: return@mapNotNull null
DefaultCalendarRef(
id = (ref[KEY_CALENDAR_ID] as? JsonPrimitive)?.longOrNull ?: return@mapNotNull null,
accountType = ref.string(KEY_ACCOUNT_TYPE) ?: return@mapNotNull null,
accountName = ref.string(KEY_ACCOUNT_NAME) ?: return@mapNotNull null,
displayName = ref.string(KEY_DISPLAY_NAME) ?: return@mapNotNull null,
)
}
CalendarGroup(id, name, members)
}.distinctBy { it.id }
}
/**
* These groups with group [id] saved as [name] over [calendars], or appended
* when new. Members are rewritten from [calendars], which drops ones gone meanwhile.
*/
fun List<CalendarGroup>.withGroup(id: String, name: String, calendars: List<CalendarSource>): List<CalendarGroup> {
val group = CalendarGroup(id, name, calendars.distinctBy { it.id }.map(DefaultCalendarRef::of))
return if (any { it.id == id }) map { if (it.id == id) group else it } else this + group
}
private fun JsonObject.string(key: String): String? =
(this[key] as? JsonPrimitive)?.takeIf { it.isString }?.contentOrNull
private const val KEY_ID = "id"
private const val KEY_NAME = "name"
private const val KEY_MEMBERS = "members"
private const val KEY_CALENDAR_ID = "calendar_id"
private const val KEY_ACCOUNT_TYPE = "account_type"
private const val KEY_ACCOUNT_NAME = "account_name"
private const val KEY_DISPLAY_NAME = "display_name"
@@ -670,6 +670,10 @@ fun CalendarHost(
showViewCalendars = true
switchScope.launch { drawerState.close() }
},
onManageGroups = {
showCalendars = true
switchScope.launch { drawerState.close() }
},
)
},
) {
@@ -0,0 +1,180 @@
package de.jeanlucmakiola.calendula.ui.calendars
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Layers
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.CalendarSource
import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip
import de.jeanlucmakiola.calendula.ui.common.LeadingAvatar
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.components.FullScreenPicker
import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSectionHeader
import de.jeanlucmakiola.floret.components.GroupedSurface
import de.jeanlucmakiola.floret.components.InlineTextField
import de.jeanlucmakiola.floret.components.MultiOptionRows
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
/**
* The calendar groups (#166) in the manager: one row per group opening its
* editor, then "New group". Without groups only that row shows.
*/
@Composable
internal fun CalendarGroupsSection(
groups: List<CalendarGroup>,
calendars: List<CalendarSource>,
onEdit: (CalendarGroup) -> Unit,
onAdd: () -> Unit,
) {
if (groups.isNotEmpty()) GroupedSectionHeader(stringResource(R.string.calendar_groups_header))
val rows = groups.size + 1
groups.forEachIndexed { index, group ->
val count = group.resolve(calendars).size
GroupedRow(
title = group.name.orUnnamed(),
summary = if (count == 0) {
stringResource(R.string.calendar_groups_empty)
} else {
pluralStringResource(R.plurals.calendar_groups_count, count, count)
},
position = positionOf(index, rows),
leading = { LeadingAvatar(Icons.Default.Layers) },
onClick = { onEdit(group) },
)
}
GroupedRow(
title = stringResource(R.string.calendar_groups_new),
position = positionOf(groups.size, rows),
minHeight = 56.dp,
leading = { LeadingAvatar(Icons.Default.Add) },
onClick = onAdd,
)
}
/**
* 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
internal fun CalendarGroupEditor(
sessionKey: Int,
isNew: Boolean,
initialName: String,
initialMembers: Set<Long>,
calendars: List<CalendarSource>,
onSave: (name: String, members: List<CalendarSource>) -> Unit,
onDelete: () -> Unit,
onClose: () -> Unit,
) {
var name by rememberSaveable(sessionKey) { mutableStateOf(initialName) }
var members by rememberSaveable(sessionKey) { mutableStateOf(initialMembers.toList()) }
var confirmDelete by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() }
val valid = name.isNotBlank()
val commit = {
if (valid) onSave(name.trim(), calendars.filter { it.id in members })
}
FullScreenPicker(
title = stringResource(if (isNew) R.string.calendar_groups_new else R.string.calendar_groups_edit),
onDismiss = onClose,
predictiveBack = true,
actions = {
Button(
onClick = commit,
enabled = valid,
modifier = Modifier.padding(end = 12.dp),
) { Text(stringResource(R.string.event_edit_save)) }
},
) {
GroupedSurface(position = Position.Alone, modifier = Modifier.padding(horizontal = 16.dp)) {
Box(
modifier = Modifier.fillMaxWidth().heightIn(min = 72.dp).padding(horizontal = 20.dp),
contentAlignment = Alignment.CenterStart,
) {
InlineTextField(
value = name,
onValueChange = { name = it },
placeholder = stringResource(R.string.calendar_groups_name_hint),
capitalization = KeyboardCapitalization.Sentences,
imeAction = ImeAction.Done,
onImeAction = commit,
modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
)
}
}
LaunchedEffect(isNew) { if (isNew) focusRequester.requestFocus() }
calendars.groupByAccount().forEach { account ->
GroupedSectionHeader(accountGroupTitle(account))
MultiOptionRows(
options = account.calendars,
selected = account.calendars.filterTo(mutableSetOf()) { it.id in members },
label = { it.displayName.orUnnamed() },
onToggle = { calendar, checked ->
members = if (checked) members + calendar.id else members - calendar.id
},
leading = { CalendarColorChip(it.color) },
)
}
if (!isNew) {
Spacer(Modifier.height(24.dp))
DeleteCalendarRow(onClick = { confirmDelete = true })
}
Spacer(Modifier.height(24.dp))
}
if (confirmDelete) {
AlertDialog(
onDismissRequest = { confirmDelete = false },
title = { Text(stringResource(R.string.calendar_groups_delete_title)) },
text = { Text(stringResource(R.string.calendar_groups_delete_message, initialName)) },
confirmButton = {
TextButton(onClick = { confirmDelete = false; onDelete() }) {
Text(
stringResource(R.string.event_detail_delete),
color = MaterialTheme.colorScheme.error,
)
}
},
dismissButton = {
TextButton(onClick = { confirmDelete = false }) {
Text(stringResource(R.string.dialog_cancel))
}
},
)
}
}
@@ -66,6 +66,7 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.CalendarSource
import de.jeanlucmakiola.calendula.domain.CalendarStateLabel
import de.jeanlucmakiola.calendula.domain.hasVisibilitySwitch
@@ -73,10 +74,6 @@ import de.jeanlucmakiola.calendula.domain.isNotSynced
import de.jeanlucmakiola.calendula.domain.orderedForManager
import de.jeanlucmakiola.calendula.domain.stateLabels
import de.jeanlucmakiola.calendula.data.calendar.CalendarColorPalette
import de.jeanlucmakiola.floret.components.sameColor
import de.jeanlucmakiola.calendula.ui.common.CustomColorPicker
import de.jeanlucmakiola.calendula.ui.common.CustomColorRow
import de.jeanlucmakiola.calendula.ui.common.RecentColorsRow
import de.jeanlucmakiola.calendula.ui.common.AccountKey
import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip
import de.jeanlucmakiola.calendula.ui.common.CalendarView
@@ -129,6 +126,9 @@ import de.jeanlucmakiola.floret.components.GroupedSurface
/** Sentinel [editorId] meaning "the editor is composing a new calendar". */
private const val NEW_CALENDAR_ID = Long.MIN_VALUE
/** Sentinel group editor id meaning "the editor is composing a new group". */
private const val NEW_GROUP_ID = ""
/**
* Calendar manager (reached from Settings). Lists the app's own device-only
* calendars with create / rename / recolor / delete, and synced calendars
@@ -148,10 +148,12 @@ fun CalendarsScreen(
val deleteLockedIds by viewModel.deleteLockedCalendarIds.collectAsStateWithLifecycle()
val error by viewModel.error.collectAsStateWithLifecycle()
val syncAccessDismissed by viewModel.syncAccessDismissed.collectAsStateWithLifecycle()
val recentCustomColors by viewModel.recentCustomColors.collectAsStateWithLifecycle()
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) { viewModel.refreshAccess() }
val loadedHiddenViews by viewModel.hiddenViews.collectAsStateWithLifecycle()
val hiddenViews = loadedHiddenViews.orEmpty()
val calendarGroups by viewModel.calendarGroups.collectAsStateWithLifecycle()
// null = closed; NEW_GROUP_ID = create; any other id = edit that group (#166).
var groupEditorId by rememberSaveable { mutableStateOf<String?>(null) }
// null = list; NEW_CALENDAR_ID = create; any other id = edit that calendar.
// [editorSession] bumps on every open so the editor's field state resets for
@@ -173,8 +175,6 @@ fun CalendarsScreen(
showHiddenViews = true,
initialHiddenViews = editing?.let { hiddenViews[it.id] }.orEmpty(),
deleteLocked = editing != null && editing.id in deleteLockedIds,
recentColors = recentCustomColors,
onCustomColorUsed = viewModel::addRecentCustomColor,
onSave = { name, color, description, views ->
val id = editorId
if (id == null || id == NEW_CALENDAR_ID) {
@@ -207,7 +207,36 @@ fun CalendarsScreen(
onSetAccountVisible = viewModel::setAccountVisible,
syncAccessDismissed = syncAccessDismissed,
onAskSyncAccessAgain = viewModel::askSyncAccessAgain,
calendarGroups = calendarGroups.orEmpty(),
onEditGroup = { group -> editorSession++; groupEditorId = group.id },
onAddGroup = { editorSession++; groupEditorId = NEW_GROUP_ID },
)
groupEditorId?.let { id ->
val groups = calendarGroups
val editing = groups?.firstOrNull { it.id == id }
if (groups != null && id != NEW_GROUP_ID && editing == null) {
LaunchedEffect(id) { groupEditorId = null }
} else if (groups != null) {
CalendarGroupEditor(
sessionKey = editorSession,
isNew = editing == null,
initialName = editing?.name.orEmpty(),
initialMembers = editing?.resolve(calendars)?.mapTo(mutableSetOf()) { it.id }.orEmpty(),
// Switched-off calendars aren't offered, but stay members.
calendars = calendars.filter { it.isVisibleInSystem },
onSave = { name, members ->
val switchedOff = editing?.resolve(calendars).orEmpty().filterNot { it.isVisibleInSystem }
viewModel.saveGroup(editing?.id, name, members + switchedOff)
groupEditorId = null
},
onDelete = {
editing?.let { viewModel.deleteGroup(it.id) }
groupEditorId = null
},
onClose = { groupEditorId = null },
)
}
}
hidingId?.let { id ->
val calendar = calendars.firstOrNull { it.id == id }
// Gone while the picker was up; an empty list is one still loading, not a deletion.
@@ -244,6 +273,9 @@ private fun CalendarsList(
onSetAccountVisible: (Collection<Long>, Boolean) -> Unit,
syncAccessDismissed: List<SyncAccount>,
onAskSyncAccessAgain: (SyncAccount) -> Unit,
calendarGroups: List<CalendarGroup>,
onEditGroup: (CalendarGroup) -> Unit,
onAddGroup: () -> Unit,
) {
val context = LocalContext.current
val snackbarHostState = remember { SnackbarHostState() }
@@ -267,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)
@@ -415,15 +455,12 @@ internal fun CalendarEditor(
deleteLocked: Boolean = false,
showHiddenViews: Boolean = false,
initialHiddenViews: Set<CalendarView> = emptySet(),
recentColors: List<Int> = emptyList(),
onCustomColorUsed: (Int) -> Unit = {},
) {
var name by rememberSaveable(sessionKey) { mutableStateOf(initialName) }
val seededHiddenViews = rememberSaveable(sessionKey) { initialHiddenViews }
var hiddenViews by rememberSaveable(sessionKey) { mutableStateOf(initialHiddenViews) }
var pickHiddenViews by rememberSaveable(sessionKey) { mutableStateOf(false) }
var color by rememberSaveable(sessionKey) { mutableStateOf(initialColor) }
var pickCustomColor by rememberSaveable(sessionKey) { mutableStateOf(false) }
var description by rememberSaveable(sessionKey) { mutableStateOf(initialDescription) }
var confirmDelete by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() }
@@ -472,19 +509,7 @@ internal fun CalendarEditor(
Spacer(Modifier.height(20.dp))
EditorSectionLabel(stringResource(R.string.calendars_color_label))
// A stored colour that is no preset stays as it is and shows as custom.
val customColor = color.takeIf { CalendarColorPalette.presetOf(it) == null }
CalendarColorGrid(
selected = color,
recents = recentColors,
onSelect = { color = it },
onSelectRecent = {
color = it
onCustomColorUsed(it)
},
)
Spacer(Modifier.height(8.dp))
CustomColorRow(customColor = customColor, onClick = { pickCustomColor = true })
CalendarColorGrid(selected = color, onSelect = { color = it })
Spacer(Modifier.height(20.dp))
EditorSectionLabel(stringResource(R.string.calendars_description_label))
@@ -518,18 +543,6 @@ internal fun CalendarEditor(
Spacer(Modifier.height(24.dp))
}
if (pickCustomColor) {
CustomColorPicker(
initial = color,
onPick = {
color = it
onCustomColorUsed(it)
pickCustomColor = false
},
onDismiss = { pickCustomColor = false },
)
}
if (pickHiddenViews) {
HiddenViewsPicker(
calendarName = name.trim().orUnnamed(),
@@ -615,12 +628,7 @@ private fun CalendarNameField(
* colours" preference included.
*/
@Composable
private fun CalendarColorGrid(
selected: Int,
recents: List<Int>,
onSelect: (Int) -> Unit,
onSelectRecent: (Int) -> Unit,
) {
private fun CalendarColorGrid(selected: Int, onSelect: (Int) -> Unit) {
val dark = LocalFloretDarkTheme.current
val soften = LocalSoftenColors.current
GroupedSurface(position = Position.Alone, modifier = Modifier.padding(horizontal = 16.dp)) {
@@ -639,7 +647,7 @@ private fun CalendarColorGrid(
ColorSwatch(
fill = eventFill(swatch, dark, soften),
label = stringResource(swatchLabel(swatch)),
selected = sameColor(swatch, selected),
selected = swatch == selected,
onClick = { onSelect(swatch) },
modifier = Modifier.weight(1f),
)
@@ -649,12 +657,6 @@ private fun CalendarColorGrid(
repeat(SWATCHES_PER_ROW - row.size) { Spacer(Modifier.weight(1f)) }
}
}
RecentColorsRow(
recents = recents,
selected = selected.takeIf { CalendarColorPalette.presetOf(it) == null },
onSelect = onSelectRecent,
modifier = Modifier.padding(horizontal = 4.dp),
)
}
}
}
@@ -737,7 +739,7 @@ private fun ManagedNote() {
}
@Composable
private fun DeleteCalendarRow(onClick: () -> Unit) {
internal fun DeleteCalendarRow(onClick: () -> Unit) {
GroupedSurface(
position = Position.Alone,
modifier = Modifier.padding(horizontal = 16.dp),
@@ -13,7 +13,11 @@ import de.jeanlucmakiola.calendula.data.calendar.CalendarRepository
import de.jeanlucmakiola.calendula.data.calendar.SyncAccount
import de.jeanlucmakiola.calendula.data.ics.IcsExporter
import de.jeanlucmakiola.calendula.data.prefs.BackupStatus
import de.jeanlucmakiola.calendula.data.prefs.CalendarPrefs
import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.withGroup
import java.util.UUID
import de.jeanlucmakiola.calendula.domain.CalendarSource
import de.jeanlucmakiola.calendula.domain.FailureReason
import de.jeanlucmakiola.calendula.domain.backup.BackupSelection
@@ -52,6 +56,7 @@ class CalendarsViewModel @Inject constructor(
private val repository: CalendarRepository,
private val icsExporter: IcsExporter,
private val settingsPrefs: SettingsPrefs,
private val calendarPrefs: CalendarPrefs,
@IoDispatcher private val io: CoroutineDispatcher,
) : ViewModel() {
@@ -150,13 +155,20 @@ class CalendarsViewModel @Inject constructor(
settingsPrefs.setCalendarHiddenIn(id, view, hidden)
}
/** Recently used custom colours, shared with the event-colour picker. */
val recentCustomColors: StateFlow<List<Int>> =
settingsPrefs.recentCustomColors
/** The calendar groups (#166); null until first read. */
val calendarGroups: StateFlow<List<CalendarGroup>?> =
calendarPrefs.calendarGroups
.catch { emit(emptyList()) }
.stateWhileSubscribed(scope = viewModelScope, initialValue = emptyList())
.stateWhileSubscribed(scope = viewModelScope, initialValue = null)
fun addRecentCustomColor(argb: Int) = write { settingsPrefs.addRecentCustomColor(argb) }
/** Create (null [id]) or rewrite a calendar group with [members]. */
fun saveGroup(id: String?, name: String, members: List<CalendarSource>) = write {
calendarPrefs.updateCalendarGroups { it.withGroup(id ?: UUID.randomUUID().toString(), name, members) }
}
fun deleteGroup(id: String) = write {
calendarPrefs.updateCalendarGroups { groups -> groups.filterNot { it.id == id } }
}
private val _error = MutableStateFlow(false)
val error: StateFlow<Boolean> = _error.asStateFlow()
@@ -79,6 +79,7 @@ fun CalendarDrawer(
onJumpToDate: (LocalDate) -> Unit,
onSettings: () -> Unit,
onHideInView: () -> Unit,
onManageGroups: () -> Unit,
viewOrder: List<CalendarView> = IMPLEMENTED_VIEWS,
sync: DrawerSync? = null,
) {
@@ -123,7 +124,7 @@ fun CalendarDrawer(
Spacer(Modifier.height(16.dp))
DrawerSectionHeader(stringResource(R.string.filter_title))
CalendarFilterList(currentView = currentView, onHideInView = onHideInView)
CalendarFilterList(currentView = currentView, onHideInView = onHideInView, onManageGroups = onManageGroups)
Spacer(Modifier.height(16.dp))
GroupedRow(
@@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.ui.common
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ExperimentalLayoutApi
@@ -17,13 +18,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.selection.selectable
import de.jeanlucmakiola.floret.components.sameColor
import de.jeanlucmakiola.floret.components.formatHexColor
/**
* A wrapping row of round colour swatches; the one matching [selected] is
@@ -44,7 +39,7 @@ fun ColorSwatchRow(
val soften = LocalSoftenColors.current
FlowRow(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
colors.forEach { argb ->
val isSelected = sameColor(argb, selected)
val isSelected = argb == selected
val fill = eventFill(argb, dark, soften)
Box(
contentAlignment = Alignment.Center,
@@ -60,8 +55,7 @@ fun ColorSwatchRow(
Modifier
},
)
.selectable(selected = isSelected, role = Role.RadioButton) { onSelect(argb) }
.semantics { contentDescription = formatHexColor(argb) },
.clickable { onSelect(argb) },
) {
if (isSelected) {
Icon(
@@ -1,156 +0,0 @@
package de.jeanlucmakiola.calendula.ui.common
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Palette
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.floret.components.ColorPicker
import de.jeanlucmakiola.floret.components.FullScreenPicker
import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSurface
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.formatHexColor
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
/**
* The recently used custom colours under a "Recent" label; nothing when there
* are none. Shared by the calendar editor and the event-colour picker.
*/
@Composable
fun RecentColorsRow(
recents: List<Int>,
selected: Int?,
onSelect: (Int) -> Unit,
modifier: Modifier = Modifier,
) {
if (recents.isEmpty()) return
Column(modifier) {
Text(
text = stringResource(R.string.color_custom_recent),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Spacer(Modifier.height(4.dp))
ColorSwatchRow(
colors = recents,
selected = selected,
onSelect = onSelect,
dark = LocalFloretDarkTheme.current,
)
}
}
/**
* The entry that opens [CustomColorPicker]. When the current colour is a custom
* one ([customColor] non-null) the row is the selection: it carries that
* colour's swatch and hex code.
*/
@Composable
fun CustomColorRow(
customColor: Int?,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
GroupedRow(
title = stringResource(R.string.color_custom),
summary = customColor?.let(::formatHexColor),
position = Position.Alone,
selected = customColor != null,
modifier = modifier,
leading = {
if (customColor != null) {
Box(
Modifier
.size(32.dp)
.clip(CircleShape)
.background(
eventFill(customColor, LocalFloretDarkTheme.current, LocalSoftenColors.current),
),
)
} else {
Icon(Icons.Default.Palette, contentDescription = null)
}
},
onClick = onClick,
)
}
/**
* Full-screen custom-colour surface: a preview painted the way the app will
* paint the colour, over the hue/saturation/brightness picker and hex field.
* The colour is committed through Select in the title bar.
*/
@Composable
fun CustomColorPicker(
initial: Int,
onPick: (Int) -> Unit,
onDismiss: () -> Unit,
) {
var color by rememberSaveable { mutableIntStateOf(initial or (0xFF shl 24)) }
FullScreenPicker(
title = stringResource(R.string.color_custom),
onDismiss = onDismiss,
predictiveBack = true,
actions = {
Button(
onClick = { onPick(color) },
modifier = Modifier.padding(end = 12.dp),
) { Text(stringResource(R.string.color_custom_select)) }
},
) {
val fill = eventFill(color, LocalFloretDarkTheme.current, LocalSoftenColors.current)
Box(
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth()
.height(72.dp)
.clip(RoundedCornerShape(22.dp))
.background(fill)
.padding(horizontal = 20.dp),
contentAlignment = Alignment.CenterStart,
) {
Text(
text = stringResource(R.string.color_custom_preview),
style = MaterialTheme.typography.titleMedium,
color = eventInk(fill),
)
}
Spacer(Modifier.height(16.dp))
GroupedSurface(position = Position.Alone, modifier = Modifier.padding(horizontal = 16.dp)) {
ColorPicker(
color = color,
onColorChange = { color = it },
hueLabel = stringResource(R.string.color_custom_hue),
saturationLabel = stringResource(R.string.color_custom_saturation),
brightnessLabel = stringResource(R.string.color_custom_brightness),
hexLabel = stringResource(R.string.color_custom_hex),
hexError = stringResource(R.string.color_custom_hex_error),
modifier = Modifier.padding(20.dp),
)
}
Spacer(Modifier.height(24.dp))
}
}
@@ -151,9 +151,6 @@ import de.jeanlucmakiola.calendula.ui.common.RecurringScopeDialog
import de.jeanlucmakiola.calendula.ui.common.CalendarPickerGroups
import de.jeanlucmakiola.calendula.ui.common.CalendarDatePickerDialog
import de.jeanlucmakiola.calendula.ui.common.ColorSwatchRow
import de.jeanlucmakiola.calendula.ui.common.CustomColorPicker
import de.jeanlucmakiola.calendula.ui.common.CustomColorRow
import de.jeanlucmakiola.calendula.ui.common.RecentColorsRow
import de.jeanlucmakiola.calendula.ui.common.TimeZonePickerDialog
import de.jeanlucmakiola.calendula.ui.common.icuTimeZoneRegion
import de.jeanlucmakiola.calendula.ui.common.LocalSoftenColors
@@ -1560,7 +1557,6 @@ private fun EditSheetHost(
selected = form.color,
hasExplicitColor = form.color != null,
syncWarning = colorSyncRisk,
recents = state.recentCustomColors,
onPickKey = { key, argb ->
viewModel.setColorKey(key, argb)
onClose()
@@ -1569,10 +1565,6 @@ private fun EditSheetHost(
viewModel.setColorRaw(argb)
onClose()
},
onPickCustom = { argb ->
viewModel.setCustomColor(argb)
onClose()
},
onClear = {
viewModel.clearColor()
onClose()
@@ -2396,13 +2388,11 @@ private fun VisibilityPickerDialog(
}
/**
* Event-colour picker. A non-empty [palette] (the calendar account's published
* colours) picks by key so the colour round-trips through sync; such an account
* rejects any other colour, so there is no custom entry. Otherwise the app's
* own presets, the recent custom colours and a custom entry write a raw colour,
* with a [syncWarning] when that calendar may not keep it. A raw colour that is
* no preset shows as the custom selection. "Reset" (shown only once a colour is
* set) drops back to the calendar's own colour.
* Event-colour picker: just the swatches. A non-empty [palette] (the calendar
* account's published colours) picks by key so the colour round-trips through
* sync; otherwise the app's own palette writes a raw colour, with a
* [syncWarning] when that calendar may not keep it. The "Reset" button (shown
* only once a colour is set) drops back to the calendar's own colour.
*/
@Composable
private fun ColorPickerDialog(
@@ -2410,16 +2400,12 @@ private fun ColorPickerDialog(
selected: Int?,
hasExplicitColor: Boolean,
syncWarning: Boolean,
recents: List<Int>,
onPickKey: (String, Int) -> Unit,
onPickRaw: (Int) -> Unit,
onPickCustom: (Int) -> Unit,
onClear: () -> Unit,
onDismiss: () -> Unit,
) {
val dark = LocalFloretDarkTheme.current
var pickCustom by rememberSaveable { mutableStateOf(false) }
val customColor = selected?.takeIf { palette.isEmpty() && CalendarColorPalette.presetOf(it) == null }
FullScreenPicker(
title = stringResource(R.string.event_edit_color),
onDismiss = onDismiss,
@@ -2454,11 +2440,6 @@ private fun ColorPickerDialog(
},
dark = dark,
)
Text(
text = stringResource(R.string.color_custom_keyed_only),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
} else {
ColorSwatchRow(
colors = CalendarColorPalette.all,
@@ -2466,31 +2447,15 @@ private fun ColorPickerDialog(
onSelect = onPickRaw,
dark = dark,
)
RecentColorsRow(recents = recents, selected = customColor, onSelect = onPickCustom)
if (syncWarning) {
Text(
text = stringResource(R.string.event_edit_color_sync_warning),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
}
if (palette.isEmpty()) {
Spacer(Modifier.height(4.dp))
CustomColorRow(customColor = customColor, onClick = { pickCustom = true })
if (syncWarning) {
Text(
text = stringResource(R.string.event_edit_color_sync_warning),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp),
)
}
}
}
if (pickCustom) {
CustomColorPicker(
initial = selected ?: recents.firstOrNull() ?: CalendarColorPalette.Blue,
onPick = {
pickCustom = false
onPickCustom(it)
},
onDismiss = { pickCustom = false },
)
}
}
@@ -29,8 +29,6 @@ data class EventEditUiState(
val hiddenFields: List<EventFormField> = emptyList(),
/** Recently picked zones, most recent first — the zone picker's shortlist. */
val recentTimeZones: List<String> = emptyList(),
/** Recently used custom colours, most recent first; shared with the calendar editor. */
val recentCustomColors: List<Int> = emptyList(),
/** True while editing an existing event (the calendar is then fixed). */
val isEditing: Boolean = false,
/**
@@ -318,8 +318,8 @@ class EventEditViewModel @Inject constructor(
).flowOn(io),
colorPalette,
allCalendars,
combine(settingsPrefs.recentTimeZones, settingsPrefs.recentCustomColors, ::Pair).flowOn(io),
) { local, external, palette, allCalendars, (recentTimeZones, recentCustomColors) ->
settingsPrefs.recentTimeZones.flowOn(io),
) { local, external, palette, allCalendars, recentTimeZones ->
val form = local.form ?: return@combine null
val resolvedId = resolveEventCalendar(form.calendarId, external.hints, allCalendars)
// A colour is scoped to the calendar it came from, so one that came with
@@ -359,7 +359,6 @@ class EventEditViewModel @Inject constructor(
visibleFields = visibleFields,
hiddenFields = (offerableFields - visibleFields).sorted(),
recentTimeZones = recentTimeZones,
recentCustomColors = recentCustomColors,
isEditing = local.editTarget != null,
isManaged = isManaged,
autofocusTitle = external.autofocusTitle,
@@ -743,12 +742,6 @@ class EventEditViewModel @Inject constructor(
edit { it.copy(colorKey = null, color = argb) }
}
/** Pick a custom raw colour, which also goes to the front of the custom-colour recents. */
fun setCustomColor(argb: Int) {
setColorRaw(argb)
viewModelScope.launch { withContext(io) { settingsPrefs.addRecentCustomColor(argb) } }
}
/** Clear the colour so the event inherits its calendar's. */
fun clearColor() {
pinShownCalendar()
@@ -7,15 +7,20 @@ import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material.icons.filled.Layers
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.TriStateCheckbox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -27,6 +32,9 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@@ -57,6 +65,7 @@ import de.jeanlucmakiola.floret.components.positionOf
fun CalendarFilterList(
currentView: CalendarView,
onHideInView: () -> Unit,
onManageGroups: () -> Unit,
modifier: Modifier = Modifier,
viewModel: FilterViewModel = hiltViewModel(),
) {
@@ -68,6 +77,7 @@ fun CalendarFilterList(
val hiddenInView = remember(s, currentView) { s.hiddenOnlyIn(currentView) }
FilterList(
groups = s.groups,
calendarGroups = s.calendarGroups,
hidden = s.hidden,
hiddenInView = hiddenInView,
hiddenOnlyHere = hiddenInView.size,
@@ -75,6 +85,7 @@ fun CalendarFilterList(
onHideInView = onHideInView,
onToggleCalendar = viewModel::toggleCalendar,
onToggleGroup = viewModel::toggleGroup,
onManageGroups = onManageGroups,
modifier = modifier,
)
}
@@ -89,6 +100,7 @@ fun CalendarFilterList(
@Composable
private fun FilterList(
groups: List<CalendarAccountGroup>,
calendarGroups: List<DrawerCalendarGroup>,
hidden: Set<Long>,
hiddenInView: Set<Long>,
hiddenOnlyHere: Int,
@@ -96,10 +108,14 @@ private fun FilterList(
onHideInView: () -> Unit,
onToggleCalendar: (Long) -> Unit,
onToggleGroup: (List<Long>) -> Unit,
onManageGroups: () -> Unit,
modifier: Modifier = Modifier,
) {
val viewName = currentView.label()
Column(modifier = modifier.fillMaxWidth()) {
if (calendarGroups.isNotEmpty()) {
CalendarGroupRows(calendarGroups, hidden, onToggleGroup, onManageGroups)
}
groups.forEach { group ->
val ids = group.calendars.map { it.id }
GroupHeader(
@@ -149,6 +165,63 @@ private fun FilterList(
}
}
/**
* The user's calendar groups (#166), above the accounts: each row shows and
* hides its member calendars together, decided like an account header (#143).
* A group with no listed calendar is shown but inert.
*/
@Composable
private fun CalendarGroupRows(
calendarGroups: List<DrawerCalendarGroup>,
hidden: Set<Long>,
onToggleGroup: (List<Long>) -> Unit,
onManageGroups: () -> Unit,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = GroupedListInset, end = GroupedListInset / 2),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = stringResource(R.string.calendar_groups_title),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.weight(1f),
)
IconButton(onClick = onManageGroups) {
Icon(
Icons.Filled.Edit,
contentDescription = stringResource(R.string.calendar_groups_manage),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
calendarGroups.forEachIndexed { index, group ->
val empty = group.calendarIds.isEmpty()
val state = if (empty) ToggleableState.Off else groupVisibility(group.calendarIds, hidden)
GroupedRow(
title = group.name.orUnnamed(),
summary = if (empty) stringResource(R.string.calendar_groups_empty) else null,
position = positionOf(index, calendarGroups.size),
minHeight = 56.dp,
dimmed = empty,
leading = {
Box(Modifier.size(40.dp), contentAlignment = Alignment.Center) {
Icon(Icons.Filled.Layers, contentDescription = null)
}
},
trailing = { TriStateCheckbox(state = state, onClick = null, enabled = !empty) },
modifier = Modifier.semantics {
role = Role.Checkbox
toggleableState = state
},
onClick = if (empty) null else ({ onToggleGroup(group.calendarIds) }),
)
}
Spacer(Modifier.height(8.dp))
}
/**
* An account's header doubling as the group's parent checkbox (#143): checked
* when every calendar shows, indeterminate when some do. Tapping it shows all,
@@ -21,6 +21,7 @@ sealed interface FilterUiState {
val groups: List<CalendarAccountGroup>,
val hidden: Set<Long>,
val hiddenViews: Map<Long, Set<CalendarView>> = emptyMap(),
val calendarGroups: List<DrawerCalendarGroup> = emptyList(),
) : FilterUiState {
/**
* The listed calendars [view] hides on its own (#517); ones already
@@ -32,3 +33,6 @@ sealed interface FilterUiState {
}
}
}
/** A calendar group (#166) as the drawer toggles it: the listed calendars among its members. */
data class DrawerCalendarGroup(val id: String, val name: String, val calendarIds: List<Long>)
@@ -37,7 +37,8 @@ class FilterViewModel @Inject constructor(
prefs.hiddenCalendarIds,
// Only feeds a note on the rows; a failed read leaves it off rather than failing the list.
settingsPrefs.perCalendarHiddenViews.hidingNothingOnError(),
) { calendars, hidden, hiddenViews ->
prefs.calendarGroups,
) { calendars, hidden, hiddenViews, groups ->
// Calendars switched off device-wide don't belong in the drawer's
// hide/show list; they live only in Settings → Calendars.
val enabled = calendars.filter { it.isVisibleInSystem }
@@ -45,7 +46,13 @@ class FilterViewModel @Inject constructor(
if (failure != null) {
FilterUiState.Failure(failure)
} else {
FilterUiState.Success(enabled.groupByAccount(), hidden, hiddenViews)
val listed = enabled.mapTo(mutableSetOf()) { it.id }
FilterUiState.Success(
groups = enabled.groupByAccount(),
hidden = hidden,
hiddenViews = hiddenViews,
calendarGroups = drawerCalendarGroups(groups, calendars, listed),
)
}
}
.catch { emit(FilterUiState.Failure(FailureReason.ProviderUnavailable)) }
@@ -69,7 +76,8 @@ class FilterViewModel @Inject constructor(
}
/**
* Flip one calendar, or a whole group from its header (#143). Both decide
* Flip one calendar, or a whole account from its header (#143) or a
* calendar group (#166). All decide
* against the stored set rather than the last drawn state, so quick repeated
* taps still alternate.
*/
@@ -1,6 +1,8 @@
package de.jeanlucmakiola.calendula.ui.filter
import androidx.compose.ui.state.ToggleableState
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.CalendarSource
/** The drawer group header's checkbox state: on, off, or some of [calendarIds] shown. */
internal fun groupVisibility(calendarIds: Collection<Long>, hidden: Set<Long>): ToggleableState {
@@ -18,3 +20,15 @@ internal fun ToggleableState.nextGroupVisible(): Boolean = this != ToggleableSta
/** [hidden] after tapping the header of the group holding [calendarIds]. */
internal fun toggledGroup(hidden: Set<Long>, calendarIds: Collection<Long>): Set<Long> =
if (groupVisibility(calendarIds, hidden).nextGroupVisible()) hidden - calendarIds.toSet() else hidden + calendarIds
/**
* [groups] as the drawer lists them: members resolved against every calendar,
* so a switched-off one is not mistaken for another, then narrowed to [listed].
*/
internal fun drawerCalendarGroups(
groups: List<CalendarGroup>,
calendars: List<CalendarSource>,
listed: Set<Long>,
): List<DrawerCalendarGroup> = groups.map { group ->
DrawerCalendarGroup(group.id, group.name, group.resolve(calendars).map { it.id }.filter { it in listed })
}
+15 -10
View File
@@ -575,6 +575,21 @@
<string name="filter_group_show_all">Show all calendars in this group</string>
<string name="filter_group_hide_all">Hide all calendars in this group</string>
<!-- Calendar groups (#166): user-named sets of calendars shown or hidden together from the drawer -->
<string name="calendar_groups_title">Groups</string>
<string name="calendar_groups_header">Calendar groups</string>
<string name="calendar_groups_manage">Manage groups</string>
<string name="calendar_groups_empty">No calendars</string>
<string name="calendar_groups_new">New group</string>
<string name="calendar_groups_edit">Edit group</string>
<string name="calendar_groups_name_hint">Group name</string>
<string name="calendar_groups_delete_title">Delete group?</string>
<string name="calendar_groups_delete_message">\"%1$s\" is removed. Its calendars stay as they are.</string>
<plurals name="calendar_groups_count">
<item quantity="one">%d calendar</item>
<item quantity="other">%d calendars</item>
</plurals>
<!-- Settings (M4) -->
<string name="settings_title">Settings</string>
<string name="settings_back">Back</string>
@@ -994,16 +1009,6 @@
<string name="color_name_indigo">Indigo</string>
<string name="color_name_purple">Purple</string>
<string name="color_name_pink">Pink</string>
<string name="color_custom">Custom color</string>
<string name="color_custom_recent">Recent</string>
<string name="color_custom_hue">Hue</string>
<string name="color_custom_saturation">Saturation</string>
<string name="color_custom_brightness">Brightness</string>
<string name="color_custom_hex">Hex code</string>
<string name="color_custom_hex_error">Enter a 6-digit hex code</string>
<string name="color_custom_select">Select</string>
<string name="color_custom_preview">Preview</string>
<string name="color_custom_keyed_only">This calendar\'s account only allows its own colors.</string>
<string name="calendars_delete_confirm_title">Delete calendar?</string>
<string name="calendars_delete_confirm_message">\"%1$s\" and all of its events will be permanently removed from this device.</string>
<string name="calendars_write_error">Couldn\'t save the change.</string>
@@ -9,7 +9,9 @@ import de.jeanlucmakiola.calendula.data.prefs.CalendarPrefKeys
import de.jeanlucmakiola.calendula.data.prefs.FixedTimeOverride
import de.jeanlucmakiola.calendula.data.prefs.SettingsKeys
import de.jeanlucmakiola.calendula.data.prefs.fixedTimeOverrideFor
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.CalendarSource
import de.jeanlucmakiola.calendula.domain.withGroup
import de.jeanlucmakiola.calendula.domain.FontRole
import de.jeanlucmakiola.calendula.domain.contacts.SpecialDateType
import de.jeanlucmakiola.calendula.domain.reminders.FixedTimeReminder
@@ -126,6 +128,20 @@ class SettingsBackupTest {
assertThat(plan.calendars).hasSize(2)
}
@Test
fun `calendar groups travel and find their calendars by account and name`() {
val source = mutablePreferencesOf()
source[CalendarPrefKeys.calendarGroups] = emptyList<CalendarGroup>().withGroup("g", "Both", listOf(work, home))
val moved = listOf(calendar(12, "Home"), calendar(11, "Work"))
val target = mutablePreferencesOf()
import(roundTrip(source), target, environment(calendars = moved, managed = emptyList()))
val group = target[CalendarPrefKeys.calendarGroups].single()
assertThat(group.name).isEqualTo("Both")
assertThat(group.resolve(moved).map { it.id }).containsExactly(11L, 12L).inOrder()
}
@Test
fun `a calendar missing here is reported, and its old id is not reused`() {
val source = mutablePreferencesOf()
@@ -1,108 +0,0 @@
package de.jeanlucmakiola.calendula.data.calendar
import com.google.common.truth.Truth.assertWithMessage
import com.google.common.truth.Truth.assertThat
import de.jeanlucmakiola.calendula.domain.color.eventTone
import de.jeanlucmakiola.calendula.domain.color.oklchOf
import org.junit.jupiter.api.Test
import kotlin.math.pow
class CalendarColorPaletteTest {
private val palette = CalendarColorPalette.all
@Test
fun `painted swatches stay apart in both themes`() {
assertMinDistance("light fill", MIN_FILL_DISTANCE) { eventTone(it, dark = false, harmonise = true).container }
assertMinDistance("dark fill", MIN_FILL_DISTANCE) { eventTone(it, dark = true, harmonise = true).container }
}
@Test
fun `raw swatches stay apart with softening off`() {
assertMinDistance("raw", MIN_FILL_DISTANCE) { it }
}
@Test
fun `accents (dots, stripes) stay apart in both themes`() {
assertMinDistance("light accent", MIN_ACCENT_DISTANCE) { eventTone(it, dark = false, harmonise = true).accent }
assertMinDistance("dark accent", MIN_ACCENT_DISTANCE) { eventTone(it, dark = true, harmonise = true).accent }
}
@Test
fun `no two painted swatches merge under a colour-vision deficiency`() {
for ((name, matrix) in CVD) {
for (dark in listOf(false, true)) {
assertMinDistance("$name dark=$dark", MIN_CVD_DISTANCE) {
simulate(eventTone(it, dark, harmonise = true).container, matrix)
}
}
}
}
@Test
fun `a stored preset matches regardless of alpha`() {
assertThat(CalendarColorPalette.presetOf(CalendarColorPalette.Green)).isEqualTo(CalendarColorPalette.Green)
val translucentBlue = CalendarColorPalette.Blue and 0x00FFFFFF
assertThat(CalendarColorPalette.presetOf(translucentBlue)).isEqualTo(CalendarColorPalette.Blue)
}
@Test
fun `a colour from the old palette or anywhere else is custom`() {
val oldGreen = 0xFF35A06A.toInt()
assertThat(CalendarColorPalette.presetOf(oldGreen)).isNull()
assertThat(CalendarColorPalette.presetOf(0xFF123456.toInt())).isNull()
assertThat(CalendarColorPalette.presetOf(null)).isNull()
}
private fun assertMinDistance(label: String, min: Float, paint: (Int) -> Int) {
val painted = palette.map(paint).map(::oklchOf)
for (i in painted.indices) for (j in i + 1 until painted.size) {
assertWithMessage("$label: ${hex(palette[i])} vs ${hex(palette[j])}")
.that(painted[i].distanceTo(painted[j]))
.isAtLeast(min)
}
}
private fun hex(argb: Int) = "#%06X".format(argb and 0xFFFFFF)
/** [argb] as seen with a dichromacy, via a Machado et al. (2009) severity-1 matrix on linear RGB. */
private fun simulate(argb: Int, m: Array<DoubleArray>): Int {
val rgb = listOf(16, 8, 0).map { toLinear(((argb shr it) and 0xFF) / 255.0) }
val out = m.map { row -> row.indices.sumOf { row[it] * rgb[it] } }
.map { (toSrgb(it.coerceIn(0.0, 1.0)) * 255.0).toInt().coerceIn(0, 255) }
return (0xFF shl 24) or (out[0] shl 16) or (out[1] shl 8) or out[2]
}
private fun toLinear(c: Double) = if (c <= 0.04045) c / 12.92 else ((c + 0.055) / 1.055).pow(2.4)
private fun toSrgb(c: Double) = if (c <= 0.0031308) 12.92 * c else 1.055 * c.pow(1 / 2.4) - 0.055
private companion object {
/** Oklab distance; the palette before #198 had Olive/Green and Teal/Cyan at 0.056. */
const val MIN_FILL_DISTANCE = 0.075f
/** Accents share one lightness per theme, so only hue and chroma separate them. */
const val MIN_ACCENT_DISTANCE = 0.04f
/**
* Twelve hues at two lightness levels can't all stay far apart for a
* dichromat; this only rules out two swatches turning into one.
*/
const val MIN_CVD_DISTANCE = 0.01f
val CVD = mapOf(
"protanopia" to arrayOf(
doubleArrayOf(0.152286, 1.052583, -0.204868),
doubleArrayOf(0.114503, 0.786281, 0.099216),
doubleArrayOf(-0.003882, -0.048116, 1.051998),
),
"deuteranopia" to arrayOf(
doubleArrayOf(0.367322, 0.860646, -0.227968),
doubleArrayOf(0.280085, 0.672501, 0.047413),
doubleArrayOf(-0.011820, 0.042940, 0.968881),
),
"tritanopia" to arrayOf(
doubleArrayOf(1.255528, -0.076749, -0.178779),
doubleArrayOf(-0.078411, 0.930809, 0.147602),
doubleArrayOf(0.004733, 0.691367, 0.303900),
),
)
}
}
@@ -1022,39 +1022,5 @@ class SettingsPrefsTest {
canModifyContents = true,
isLocal = local,
)
@Test
fun `a recent colour goes to the front, once, made opaque`() {
val recents = listOf(0xFF111111.toInt(), 0xFF222222.toInt())
assertThat(withRecentColor(recents, 0x00222222))
.containsExactly(0xFF222222.toInt(), 0xFF111111.toInt()).inOrder()
}
@Test
fun `recent colours are capped, dropping the oldest`() {
val full = (1..SettingsPrefs.MAX_RECENT_CUSTOM_COLORS).map { (0xFF shl 24) or it }
val next = withRecentColor(full, 0xFFABCDEF.toInt())
assertThat(next).hasSize(SettingsPrefs.MAX_RECENT_CUSTOM_COLORS)
assertThat(next.first()).isEqualTo(0xFFABCDEF.toInt())
assertThat(next).doesNotContain(full.last())
}
@Test
fun `recent custom colours round-trip most recent first`(@TempDir tempDir: Path) = runTest {
val prefs = testSettings(tempDir)
assertThat(prefs.recentCustomColors.first()).isEmpty()
prefs.addRecentCustomColor(0xFF112233.toInt())
prefs.addRecentCustomColor(0xFFAABBCC.toInt())
prefs.addRecentCustomColor(0xFF112233.toInt())
assertThat(prefs.recentCustomColors.first())
.containsExactly(0xFF112233.toInt(), 0xFFAABBCC.toInt()).inOrder()
}
@Test
fun `unreadable stored recent colours are dropped`(@TempDir tempDir: Path) = runTest {
val store = testDataStore(tempDir, "test_settings")
store.updateData { it.toMutablePreferences().apply { this[stringPreferencesKey("recent_custom_colors")] = "112233,zz,ABC,445566" } }
assertThat(SettingsPrefs(store).recentCustomColors.first())
.containsExactly(0xFF112233.toInt(), 0xFFAABBCC.toInt(), 0xFF445566.toInt()).inOrder()
}
}
@@ -0,0 +1,78 @@
package de.jeanlucmakiola.calendula.domain
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
class CalendarGroupsTest {
private fun calendar(id: Long, name: String, account: String = "me@example.org", type: String = "com.google") =
CalendarSource(id = id, displayName = name, accountName = account, accountType = type, color = 0, isVisibleInSystem = true)
private val work = calendar(1, "Work")
private val team = calendar(2, "Team", account = "dav", type = "bitfire.at.davdroid")
private val sports = calendar(3, "Sports")
@Test
fun `groups survive storage, members included`() {
val groups = emptyList<CalendarGroup>()
.withGroup("a", "Meet-ups", listOf(work, team))
.withGroup("b", "Fun \"quoted\", odd\u001Fname", listOf(sports))
val decoded = decodeCalendarGroups(encodeCalendarGroups(groups))
assertThat(decoded).isEqualTo(groups)
assertThat(decoded[0].members.map { it.accountName }).containsExactly("me@example.org", "dav").inOrder()
}
@Test
fun `no groups store nothing`() {
assertThat(encodeCalendarGroups(emptyList())).isNull()
assertThat(decodeCalendarGroups(null)).isEmpty()
}
@Test
fun `an unreadable value reads as no groups, a broken entry is skipped`() {
assertThat(decodeCalendarGroups("not json")).isEmpty()
assertThat(decodeCalendarGroups("""{"id":"a"}""")).isEmpty()
val stored = """[{"id":"a","name":"A","members":[{"calendar_id":"x"},""" +
"""{"calendar_id":1,"account_type":"t","account_name":"n","display_name":"Work"}]},{"name":"no id"}]"""
val decoded = decodeCalendarGroups(stored)
assertThat(decoded).hasSize(1)
assertThat(decoded.single().members).containsExactly(DefaultCalendarRef(1, "t", "n", "Work"))
}
@Test
fun `saving replaces the group of that id and keeps the order`() {
val groups = emptyList<CalendarGroup>()
.withGroup("a", "A", listOf(work))
.withGroup("b", "B", listOf(team))
.withGroup("a", "Renamed", listOf(work, sports, sports))
assertThat(groups.map { it.name }).containsExactly("Renamed", "B").inOrder()
assertThat(groups[0].resolve(listOf(work, team, sports))).containsExactly(work, sports).inOrder()
}
@Test
fun `a missing calendar drops out, an empty group stays`() {
val groups = emptyList<CalendarGroup>()
.withGroup("a", "A", listOf(work, team))
.withGroup("b", "B", listOf(sports))
val now = listOf(work)
assertThat(groups[0].resolve(now)).containsExactly(work)
assertThat(groups[1].resolve(now)).isEmpty()
// Saving it again prunes the stored member too.
val saved = groups.withGroup("a", "A", groups[0].resolve(now))
assertThat(saved[0].members.map { it.id }).containsExactly(1L)
}
@Test
fun `members are found by account and name when the ids changed`() {
val group = emptyList<CalendarGroup>().withGroup("a", "A", listOf(work, team)).single()
val otherDevice = listOf(calendar(40, "Team", account = "dav", type = "bitfire.at.davdroid"), calendar(41, "Work"))
assertThat(group.resolve(otherDevice).map { it.id }).containsExactly(41L, 40L).inOrder()
}
}
@@ -0,0 +1,60 @@
package de.jeanlucmakiola.calendula.ui.filter
import androidx.compose.ui.state.ToggleableState
import com.google.common.truth.Truth.assertThat
import de.jeanlucmakiola.calendula.domain.CalendarGroup
import de.jeanlucmakiola.calendula.domain.CalendarSource
import de.jeanlucmakiola.calendula.domain.withGroup
import org.junit.jupiter.api.Test
/** Calendar groups (#166) toggle like the drawer's account headers (#143). */
class CalendarGroupToggleTest {
private fun calendar(id: Long, name: String, visible: Boolean = true) =
CalendarSource(id = id, displayName = name, accountName = "acc$id", accountType = "t", color = 0, isVisibleInSystem = visible)
private val one = calendar(1, "One")
private val two = calendar(2, "Two")
private val three = calendar(3, "Three")
private val all = listOf(one, two, three)
private val groups: List<CalendarGroup> = emptyList<CalendarGroup>()
.withGroup("a", "A", listOf(one, two))
.withGroup("b", "B", listOf(two, three))
private fun drawer(calendars: List<CalendarSource> = all) =
drawerCalendarGroups(groups, calendars, calendars.filter { it.isVisibleInSystem }.map { it.id }.toSet())
@Test
fun `a fully shown group hides its calendars only`() {
val a = drawer()[0]
assertThat(groupVisibility(a.calendarIds, emptySet())).isEqualTo(ToggleableState.On)
assertThat(toggledGroup(emptySet(), a.calendarIds)).containsExactly(1L, 2L)
}
@Test
fun `a partly or fully hidden group shows all of them`() {
val a = drawer()[0]
assertThat(groupVisibility(a.calendarIds, setOf(1L, 3L))).isEqualTo(ToggleableState.Indeterminate)
assertThat(toggledGroup(setOf(1L, 3L), a.calendarIds)).containsExactly(3L)
assertThat(toggledGroup(setOf(1L, 2L), a.calendarIds)).isEmpty()
}
@Test
fun `overlapping groups share the calendar they both hold`() {
val (a, b) = drawer()
val afterA = toggledGroup(emptySet(), a.calendarIds)
assertThat(groupVisibility(b.calendarIds, afterA)).isEqualTo(ToggleableState.Indeterminate)
assertThat(toggledGroup(afterA, b.calendarIds)).containsExactly(1L)
}
@Test
fun `a switched-off or missing calendar is not toggled, a group left with none is empty`() {
val listed = drawer(listOf(one, calendar(2, "Two", visible = false)))
assertThat(listed[0].calendarIds).containsExactly(1L)
assertThat(listed[1].calendarIds).isEmpty()
}
}
+5
View File
@@ -422,6 +422,11 @@ events through `instancesWithout(range, calendarsHiddenIn(view, …))`, which dr
the calendars hidden in that one view on top of the repository's filters; reminders, search and widgets read
the repository and never see it. The drawer's "Hide in “<view>” view" entry (#517, #143) edits the same
set for the view on show, and the drawer's per-row "Hidden in “<view>” view" notes read it.
Calendar groups (#166, `CalendarPrefs.calendarGroups`) are named member lists
over that same drawer filter: a group row toggles its members' entries in
`hiddenCalendarIds` exactly like an account header (#143). Members are stored
as `DefaultCalendarRef`s and resolved on read, so a missing calendar silently
drops out and a restore maps them by account and name.
**A channel per calendar (#145).** `ReminderChannels` keeps one notification
channel per calendar, grouped by account (one that syncs no events only gets
+4 -3
View File
@@ -57,7 +57,9 @@ The settings stored under their own on-disk key names, in their stored form,
e.g. `"theme_mode": "DARK"`, `"multi_day_count": 4`,
`"default_reminder_minutes": "10,60"`. Only keys that have been set are
written. `SettingsBackupSchema.plain` lists them: appearance, fonts,
views, the agenda screen, the event form and its default calendar, reminders
views, the agenda screen, the event form and its default calendar, the drawer's
calendar groups (`calendar_groups`, members named by account and display name
like the default calendar, so they resolve on another device), reminders
and the daily summary, automatic backup (switch, interval and whether it runs, layout, retention,
backup on change) and contact special dates (switch, types, title
templates, year).
@@ -125,8 +127,7 @@ bookkeeping, or meaningless on another device.
- Font stamps (`*_font_stamp`): cache keys for the local font file.
- `agenda_widget_range`, `widget_size`: legacy defaults for unconfigured
widgets. Widget configuration is not part of the backup at all.
- `recent_time_zones`, `recent_fixed_time_reminders`, `recent_custom_colors`: usage
history.
- `recent_time_zones`, `recent_fixed_time_reminders`: usage history.
- `notification_category_hint_dismissed`, `reminder_channel_versions`:
this install's notification hint and channels.
- `sync_access_dismissed`: sync-request grants of this device's accounts.