From 59fa1cb06568a05d73a47977d667c7a7c1915ef7 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Aug 2026 21:59:59 +0000 Subject: [PATCH] Keep a category's custom colour when filing it into a group Filing a category used to default the "Use the group's colour" switch to on for everyone, which silently replaced a deliberately chosen custom colour with the group's role. Now: - The category's Add-to-group sheet starts the switch off when the category has a hex colour (fixed swatch or custom picker), with the subtitle explaining that turning it on replaces the custom colour. Categories on theme roles keep the previous on-by-default behaviour. - The group card's add-member sheet has one switch for many categories, so custom-coloured categories are protected per pick: they keep their colour even with the switch on (the subtitle says so). Adopting for such a category remains possible from its own Add-to-group sheet. - New helper isFixedColorToken covers both fixed swatches and custom picker colours (isCustomColorToken deliberately excludes swatches; a chosen swatch is just as much a deliberate colour). The length check alone is insufficient because "tertiary" is also 8 characters. CategoryEditScreen needed no change: editing derives the switch from the stored token and creation hides the picker while the switch is on. Verified: a11y_check.py, wcag_check.py, and the semantics-import sweep all clean; changelog fragment added (patch). Claude-Session: https://claude.ai/code/session_01PZJLynVBkgLtehJFXffnfg Co-authored-by: Claude --- .../categories/ManageCategoriesScreen.kt | 30 ++++++++++++++++--- .../keep-custom-colour-on-group-add.json | 6 ++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/keep-custom-colour-on-group-add.json diff --git a/app/src/main/java/com/mapgie/goflo/ui/screens/categories/ManageCategoriesScreen.kt b/app/src/main/java/com/mapgie/goflo/ui/screens/categories/ManageCategoriesScreen.kt index 9c75728..8760fa8 100644 --- a/app/src/main/java/com/mapgie/goflo/ui/screens/categories/ManageCategoriesScreen.kt +++ b/app/src/main/java/com/mapgie/goflo/ui/screens/categories/ManageCategoriesScreen.kt @@ -890,7 +890,10 @@ private fun AddToGroupSheet( onDismiss: () -> Unit, ) { val sheetState = rememberModalBottomSheetState() - var adoptColor by rememberSaveable { mutableStateOf(true) } + // A hex token (fixed swatch or custom picker) is a deliberate colour choice; + // filing must not silently replace it, so the adopt switch starts off. + val hasOwnFixedColor = isFixedColorToken(category.colorToken) + var adoptColor by rememberSaveable { mutableStateOf(!hasOwnFixedColor) } ModalBottomSheet(onDismissRequest = onDismiss, sheetState = sheetState) { Column( @@ -915,7 +918,11 @@ private fun AddToGroupSheet( ListCard { SwitchRow( title = "Use the group's colour", - subtitle = "The category follows its group's colour role from now on", + subtitle = if (hasOwnFixedColor) { + "This category has its own custom colour. Turning this on replaces it with the group's colour role." + } else { + "The category follows its group's colour role from now on" + }, checked = adoptColor, role = MaterialTheme.colorScheme.primary, onRole = MaterialTheme.colorScheme.onPrimary, @@ -1043,7 +1050,8 @@ private fun AddMemberSheet( ListCard { SwitchRow( title = "Use the group's colour", - subtitle = "Filed categories follow this group's colour role", + subtitle = "Filed categories follow this group's colour role. " + + "Categories with their own custom colour keep it.", checked = adoptColor, role = MaterialTheme.colorScheme.primary, onRole = MaterialTheme.colorScheme.onPrimary, @@ -1066,7 +1074,10 @@ private fun AddMemberSheet( key = category.name, value = currentGroup?.let { "In ${it.name}" } ?: "Ungrouped", valueColor = MaterialTheme.colorScheme.onSurfaceVariant, - onClick = { onPick(category, adoptColor) }, + // One switch covers every candidate, so a deliberately chosen + // hex colour is protected here per category; adopting for such + // a category stays available from its own Add-to-group sheet. + onClick = { onPick(category, adoptColor && !isFixedColorToken(category.colorToken)) }, ) } if (sorted.isNotEmpty()) HairlineDivider() @@ -1842,6 +1853,17 @@ private fun CategoryIconGrid(selectedKey: String, onSelect: (String) -> Unit) { } } +/** + * True when the token is a stored hex colour, i.e. any deliberately chosen + * non-theme colour: a fixed swatch or a custom picker colour. Unlike + * [isCustomColorToken] this includes the fixed swatches. The length check is + * not sufficient on its own because "tertiary" is also 8 characters. + */ +internal fun isFixedColorToken(token: String): Boolean { + if (token.length != 8) return false + return CategoryColor.entries.none { it.key == token } +} + internal fun isCustomColorToken(token: String): Boolean { if (token.length != 8) return false val categoryColorKeys = CategoryColor.entries.map { it.key }.toSet() diff --git a/changelog/unreleased/keep-custom-colour-on-group-add.json b/changelog/unreleased/keep-custom-colour-on-group-add.json new file mode 100644 index 0000000..a5529fa --- /dev/null +++ b/changelog/unreleased/keep-custom-colour-on-group-add.json @@ -0,0 +1,6 @@ +{ + "bump": "patch", + "changed": [ + "Adding a category to a group no longer replaces its custom colour by default: the colour switch starts off for custom-coloured categories, and bulk-adding from a group card always keeps them" + ] +}