From f14f6f32f4a29c8270bb40725dbd439072f5b878 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:04:13 +0100 Subject: [PATCH 1/5] fix(#459): point the set-time reminder picker to the daily summary --- .../ui/common/FixedTimeReminderUi.kt | 23 ++++++++++++++++++- .../ui/settings/NotificationSettings.kt | 18 ++++++++++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt index 111dad8f..f78fe9e9 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt @@ -9,7 +9,10 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.FilledTonalButton +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -131,7 +134,8 @@ fun FixedTimeReminderEditor( * Picker for a fixed-time default (#459), full-screen: off, or a reminder at a * set time edited in place — and, on a per-calendar picker ([inheritedLabel] * non-null), deferring to the global default, [inherited], which also seeds the - * editor. Applies live; the user leaves via back. + * editor. Applies live; the user leaves via back. A non-null [onOpenDailySummary] + * adds a row leading to the daily summary, for a list of the day's events instead. */ @Composable fun FixedTimeReminderPicker( @@ -141,6 +145,7 @@ fun FixedTimeReminderPicker( onDismiss: () -> Unit, inheritedLabel: String? = null, inherited: FixedTimeReminder? = null, + onOpenDailySummary: (() -> Unit)? = null, ) { var current by rememberSaveable(stateSaver = FixedTimeOverrideSaver) { mutableStateOf(selected) } var editing by rememberSaveable { mutableStateOf(false) } @@ -192,6 +197,22 @@ fun FixedTimeReminderPicker( }, ) } + if (onOpenDailySummary != null) { + Spacer(Modifier.height(24.dp)) + GroupedRow( + title = stringResource(R.string.settings_digest), + summary = stringResource(R.string.settings_fixed_reminder_digest_link), + position = Position.Alone, + trailing = { + Icon( + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) + }, + onClick = onOpenDailySummary, + ) + } } } 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 ac60a9b1..6079e765 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 @@ -15,6 +15,8 @@ import android.widget.Toast import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.relocation.BringIntoViewRequester +import androidx.compose.foundation.relocation.bringIntoViewRequester import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -108,6 +110,14 @@ internal fun NotificationsScreen( var showFixedDefault by remember { mutableStateOf(false) } var showDigestDay by remember { mutableStateOf(false) } var showDigestTime by remember { mutableStateOf(false) } + var revealDigest by remember { mutableStateOf(false) } + val digestRequester = remember { BringIntoViewRequester() } + LaunchedEffect(revealDigest) { + if (revealDigest) { + digestRequester.bringIntoView() + revealDigest = false + } + } val scope = rememberCoroutineScope() val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle() val digestBlocked by viewModel.digestBlocked.collectAsStateWithLifecycle() @@ -193,6 +203,7 @@ internal fun NotificationsScreen( Spacer(Modifier.height(24.dp)) DailyDigestRows( + modifier = Modifier.bringIntoViewRequester(digestRequester), digest = state.dailyDigest, blocked = channelStatus.appBlocked || digestBlocked, onEnable = toggleDigest, @@ -257,6 +268,10 @@ internal fun NotificationsScreen( selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off, onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) }, onDismiss = { showFixedDefault = false }, + onOpenDailySummary = { + showFixedDefault = false + revealDigest = true + }, ) } if (showDigestDay) { @@ -338,7 +353,8 @@ private fun DailyDigestRows( onPickDay: () -> Unit, onPickTime: () -> Unit, onOpenSound: () -> Unit, -) { + modifier: Modifier = Modifier, +) = Column(modifier) { GroupedSwitchRow( title = stringResource(R.string.settings_digest), checked = digest.enabled, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11c2e328..3ae3eb25 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -809,6 +809,7 @@ Daily summary One notification listing a day\'s events + Want one list of tomorrow\'s events instead? %1$s at %2$s Lists From 770a4756a4768ff1c43943ff8985d148722ce25d Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:07:51 +0100 Subject: [PATCH 2/5] fix(#459): move the summary pointer into a picker footer, hide it once on --- .../ui/common/FixedTimeReminderUi.kt | 26 +++------------ .../ui/settings/CalendarReminderSettings.kt | 2 +- .../ui/settings/NotificationSettings.kt | 32 +++++++++++-------- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt index f78fe9e9..4a5265d3 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt @@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.ui.common import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -9,10 +10,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.FilledTonalButton -import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -134,8 +132,7 @@ fun FixedTimeReminderEditor( * Picker for a fixed-time default (#459), full-screen: off, or a reminder at a * set time edited in place — and, on a per-calendar picker ([inheritedLabel] * non-null), deferring to the global default, [inherited], which also seeds the - * editor. Applies live; the user leaves via back. A non-null [onOpenDailySummary] - * adds a row leading to the daily summary, for a list of the day's events instead. + * editor. Applies live; the user leaves via back. [footer] follows the options. */ @Composable fun FixedTimeReminderPicker( @@ -145,7 +142,7 @@ fun FixedTimeReminderPicker( onDismiss: () -> Unit, inheritedLabel: String? = null, inherited: FixedTimeReminder? = null, - onOpenDailySummary: (() -> Unit)? = null, + footer: @Composable ColumnScope.() -> Unit = {}, ) { var current by rememberSaveable(stateSaver = FixedTimeOverrideSaver) { mutableStateOf(selected) } var editing by rememberSaveable { mutableStateOf(false) } @@ -197,22 +194,7 @@ fun FixedTimeReminderPicker( }, ) } - if (onOpenDailySummary != null) { - Spacer(Modifier.height(24.dp)) - GroupedRow( - title = stringResource(R.string.settings_digest), - summary = stringResource(R.string.settings_fixed_reminder_digest_link), - position = Position.Alone, - trailing = { - Icon( - imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, - contentDescription = null, - tint = MaterialTheme.colorScheme.onSurfaceVariant, - ) - }, - onClick = onOpenDailySummary, - ) - } + footer() } } 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 bec548ff..d5e4d2d8 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 @@ -429,7 +429,7 @@ private fun OverrideRow( } @Composable -private fun ChevronIcon() { +internal fun ChevronIcon() { Icon( imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, contentDescription = null, 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 6079e765..8e1cccf8 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 @@ -15,12 +15,12 @@ import android.widget.Toast import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.relocation.BringIntoViewRequester -import androidx.compose.foundation.relocation.bringIntoViewRequester 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.relocation.BringIntoViewRequester +import androidx.compose.foundation.relocation.bringIntoViewRequester import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.automirrored.filled.OpenInNew @@ -110,14 +110,7 @@ internal fun NotificationsScreen( var showFixedDefault by remember { mutableStateOf(false) } var showDigestDay by remember { mutableStateOf(false) } var showDigestTime by remember { mutableStateOf(false) } - var revealDigest by remember { mutableStateOf(false) } val digestRequester = remember { BringIntoViewRequester() } - LaunchedEffect(revealDigest) { - if (revealDigest) { - digestRequester.bringIntoView() - revealDigest = false - } - } val scope = rememberCoroutineScope() val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle() val digestBlocked by viewModel.digestBlocked.collectAsStateWithLifecycle() @@ -268,11 +261,22 @@ internal fun NotificationsScreen( selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off, onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) }, onDismiss = { showFixedDefault = false }, - onOpenDailySummary = { - showFixedDefault = false - revealDigest = true - }, - ) + ) { + // A pointer for those after one list of the day's events (#459). + if (!state.dailyDigest.enabled) { + Spacer(Modifier.height(24.dp)) + GroupedRow( + title = stringResource(R.string.settings_digest), + summary = stringResource(R.string.settings_fixed_reminder_digest_link), + position = Position.Alone, + trailing = { ChevronIcon() }, + onClick = { + showFixedDefault = false + scope.launch { digestRequester.bringIntoView() } + }, + ) + } + } } if (showDigestDay) { OptionPicker( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ae3eb25..89691ad6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -809,7 +809,7 @@ Daily summary One notification listing a day\'s events - Want one list of tomorrow\'s events instead? + Want one list of the day\'s events instead? %1$s at %2$s Lists From c4926145f3811ba738b3362872972f06eb637584 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 12:13:15 +0100 Subject: [PATCH 3/5] fix(#459): reuse the summary's hint, pass the pointer as footer --- .../ui/settings/CalendarReminderSettings.kt | 2 +- .../ui/settings/NotificationSettings.kt | 32 +++++++++---------- app/src/main/res/values/strings.xml | 1 - 3 files changed, 17 insertions(+), 18 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 d5e4d2d8..bec548ff 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 @@ -429,7 +429,7 @@ private fun OverrideRow( } @Composable -internal fun ChevronIcon() { +private fun ChevronIcon() { Icon( imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, contentDescription = null, 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 8e1cccf8..d0125329 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 @@ -261,22 +261,22 @@ internal fun NotificationsScreen( selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off, onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) }, onDismiss = { showFixedDefault = false }, - ) { - // A pointer for those after one list of the day's events (#459). - if (!state.dailyDigest.enabled) { - Spacer(Modifier.height(24.dp)) - GroupedRow( - title = stringResource(R.string.settings_digest), - summary = stringResource(R.string.settings_fixed_reminder_digest_link), - position = Position.Alone, - trailing = { ChevronIcon() }, - onClick = { - showFixedDefault = false - scope.launch { digestRequester.bringIntoView() } - }, - ) - } - } + footer = { + // A pointer for those after one list of the day's events (#459). + if (!state.dailyDigest.enabled) { + Spacer(Modifier.height(24.dp)) + GroupedRow( + title = stringResource(R.string.settings_digest), + summary = stringResource(R.string.settings_digest_hint), + position = Position.Alone, + onClick = { + showFixedDefault = false + scope.launch { digestRequester.bringIntoView() } + }, + ) + } + }, + ) } if (showDigestDay) { OptionPicker( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 89691ad6..11c2e328 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -809,7 +809,6 @@ Daily summary One notification listing a day\'s events - Want one list of the day\'s events instead? %1$s at %2$s Lists From 47e737f8ecfaf0a87501dbc8c1cf186b5c1ea5b6 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 15:23:01 +0100 Subject: [PATCH 4/5] fix(#459): review round 3 - the pointer turns the summary on and closes through onDismiss --- .../calendula/ui/common/FixedTimeReminderUi.kt | 7 ++++--- .../ui/settings/NotificationSettings.kt | 16 +++++++++------- app/src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt index 4a5265d3..9e6c4462 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt @@ -132,7 +132,8 @@ fun FixedTimeReminderEditor( * Picker for a fixed-time default (#459), full-screen: off, or a reminder at a * set time edited in place — and, on a per-calendar picker ([inheritedLabel] * non-null), deferring to the global default, [inherited], which also seeds the - * editor. Applies live; the user leaves via back. [footer] follows the options. + * editor. Applies live; the user leaves via back. [footer] follows the options + * and gets [onDismiss] to close the picker. */ @Composable fun FixedTimeReminderPicker( @@ -142,7 +143,7 @@ fun FixedTimeReminderPicker( onDismiss: () -> Unit, inheritedLabel: String? = null, inherited: FixedTimeReminder? = null, - footer: @Composable ColumnScope.() -> Unit = {}, + footer: @Composable ColumnScope.(dismiss: () -> Unit) -> Unit = {}, ) { var current by rememberSaveable(stateSaver = FixedTimeOverrideSaver) { mutableStateOf(selected) } var editing by rememberSaveable { mutableStateOf(false) } @@ -194,7 +195,7 @@ fun FixedTimeReminderPicker( }, ) } - footer() + footer(onDismiss) } } 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 d0125329..23986e83 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 @@ -196,7 +196,7 @@ internal fun NotificationsScreen( Spacer(Modifier.height(24.dp)) DailyDigestRows( - modifier = Modifier.bringIntoViewRequester(digestRequester), + switchRequester = digestRequester, digest = state.dailyDigest, blocked = channelStatus.appBlocked || digestBlocked, onEnable = toggleDigest, @@ -261,16 +261,17 @@ internal fun NotificationsScreen( selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off, onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) }, onDismiss = { showFixedDefault = false }, - footer = { - // A pointer for those after one list of the day's events (#459). + footer = { dismiss -> + // For those after one list of the day's events (#459). if (!state.dailyDigest.enabled) { Spacer(Modifier.height(24.dp)) GroupedRow( - title = stringResource(R.string.settings_digest), + title = stringResource(R.string.settings_digest_turn_on), summary = stringResource(R.string.settings_digest_hint), position = Position.Alone, onClick = { - showFixedDefault = false + toggleDigest(true) + dismiss() scope.launch { digestRequester.bringIntoView() } }, ) @@ -357,10 +358,11 @@ private fun DailyDigestRows( onPickDay: () -> Unit, onPickTime: () -> Unit, onOpenSound: () -> Unit, - modifier: Modifier = Modifier, -) = Column(modifier) { + switchRequester: BringIntoViewRequester, +) { GroupedSwitchRow( title = stringResource(R.string.settings_digest), + modifier = Modifier.bringIntoViewRequester(switchRequester), checked = digest.enabled, onCheckedChange = onEnable, summary = if (digest.enabled) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11c2e328..b4cc6991 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -808,6 +808,7 @@ Added to new timed events, e.g. the evening before. It follows the event when you move it to another time. Daily summary + Turn on daily summary One notification listing a day\'s events %1$s at %2$s From c14775d4e51d56ac24ca391057a70b407a8dd406 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 25 Nov 2026 15:49:39 +0100 Subject: [PATCH 5/5] fix(#459): review round 4 - reveal the whole summary block once it has expanded, mark the pointer row with an icon --- .gitignore | 1 + .../ui/common/FixedTimeReminderUi.kt | 4 +- .../ui/settings/NotificationSettings.kt | 118 +++++++++++------- 3 files changed, 74 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 06a7a2d0..c25ec7d9 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ Gemfile.lock # Claude Code /CLAUDE.md +.kotlin/ diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt index 9e6c4462..13ffcadb 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/FixedTimeReminderUi.kt @@ -132,8 +132,8 @@ fun FixedTimeReminderEditor( * Picker for a fixed-time default (#459), full-screen: off, or a reminder at a * set time edited in place — and, on a per-calendar picker ([inheritedLabel] * non-null), deferring to the global default, [inherited], which also seeds the - * editor. Applies live; the user leaves via back. [footer] follows the options - * and gets [onDismiss] to close the picker. + * editor. Applies live; the user leaves via back, or through [footer], which + * follows the options and gets [onDismiss]. */ @Composable fun FixedTimeReminderPicker( 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 23986e83..80f841ed 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 @@ -4,6 +4,7 @@ import de.jeanlucmakiola.floret.identity.collapseExit import de.jeanlucmakiola.floret.identity.expandEnter import androidx.compose.foundation.layout.Column import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.EnterExitState import android.Manifest import android.content.Context import android.content.Intent @@ -25,6 +26,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.automirrored.filled.OpenInNew import androidx.compose.material.icons.outlined.Info +import androidx.compose.material.icons.outlined.NotificationsActive import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -110,7 +112,7 @@ internal fun NotificationsScreen( var showFixedDefault by remember { mutableStateOf(false) } var showDigestDay by remember { mutableStateOf(false) } var showDigestTime by remember { mutableStateOf(false) } - val digestRequester = remember { BringIntoViewRequester() } + var revealDigest by rememberSaveable { mutableStateOf(false) } val scope = rememberCoroutineScope() val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle() val digestBlocked by viewModel.digestBlocked.collectAsStateWithLifecycle() @@ -196,10 +198,14 @@ internal fun NotificationsScreen( Spacer(Modifier.height(24.dp)) DailyDigestRows( - switchRequester = digestRequester, + reveal = revealDigest, + onRevealed = { revealDigest = false }, digest = state.dailyDigest, blocked = channelStatus.appBlocked || digestBlocked, - onEnable = toggleDigest, + onEnable = { + revealDigest = false + toggleDigest(it) + }, onPickDay = { showDigestDay = true }, onPickTime = { showDigestTime = true }, onOpenSound = { @@ -269,10 +275,17 @@ internal fun NotificationsScreen( title = stringResource(R.string.settings_digest_turn_on), summary = stringResource(R.string.settings_digest_hint), position = Position.Alone, + leading = { + Icon( + imageVector = Icons.Outlined.NotificationsActive, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + ) + }, onClick = { + revealDigest = true toggleDigest(true) dismiss() - scope.launch { digestRequester.bringIntoView() } }, ) } @@ -348,7 +361,8 @@ internal fun NotificationsScreen( /** * The daily summary (#459): its switch, and once on, which day it lists, when, - * and its channel's system settings. + * and its channel's system settings. With [reveal], the block scrolls into view + * once those rows have expanded, then reports [onRevealed]. */ @Composable private fun DailyDigestRows( @@ -358,49 +372,59 @@ private fun DailyDigestRows( onPickDay: () -> Unit, onPickTime: () -> Unit, onOpenSound: () -> Unit, - switchRequester: BringIntoViewRequester, + reveal: Boolean, + onRevealed: () -> Unit, ) { - GroupedSwitchRow( - title = stringResource(R.string.settings_digest), - modifier = Modifier.bringIntoViewRequester(switchRequester), - checked = digest.enabled, - onCheckedChange = onEnable, - summary = if (digest.enabled) { - stringResource( - R.string.settings_digest_summary, - stringResource(digestDayLabel(digest.day)), - settingsTimeOfDay(digest.timeMinutes), - ) - } else { - stringResource(R.string.settings_digest_hint) - }, - position = if (digest.enabled) Position.Top else Position.Alone, - ) - AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) { - Column { - GroupedRow( - title = stringResource(R.string.settings_digest_day), - summary = stringResource(digestDayLabel(digest.day)), - position = Position.Middle, - onClick = onPickDay, - ) - GroupedRow( - title = stringResource(R.string.settings_digest_time), - summary = settingsTimeOfDay(digest.timeMinutes), - position = Position.Middle, - onClick = onPickTime, - ) - GroupedRow( - title = stringResource(R.string.settings_notification_sound), - summary = if (blocked) { - stringResource(R.string.settings_notifications_blocked_hint) - } else { - stringResource(R.string.settings_digest_sound_hint) - }, - position = Position.Bottom, - trailing = { ExternalLinkIcon() }, - onClick = onOpenSound, - ) + val requester = remember { BringIntoViewRequester() } + Column(Modifier.bringIntoViewRequester(requester)) { + GroupedSwitchRow( + title = stringResource(R.string.settings_digest), + checked = digest.enabled, + onCheckedChange = onEnable, + summary = if (digest.enabled) { + stringResource( + R.string.settings_digest_summary, + stringResource(digestDayLabel(digest.day)), + settingsTimeOfDay(digest.timeMinutes), + ) + } else { + stringResource(R.string.settings_digest_hint) + }, + position = if (digest.enabled) Position.Top else Position.Alone, + ) + AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) { + val settled = !transition.isRunning && transition.currentState == EnterExitState.Visible + LaunchedEffect(settled, reveal) { + if (settled && reveal) { + requester.bringIntoView() + onRevealed() + } + } + Column { + GroupedRow( + title = stringResource(R.string.settings_digest_day), + summary = stringResource(digestDayLabel(digest.day)), + position = Position.Middle, + onClick = onPickDay, + ) + GroupedRow( + title = stringResource(R.string.settings_digest_time), + summary = settingsTimeOfDay(digest.timeMinutes), + position = Position.Middle, + onClick = onPickTime, + ) + GroupedRow( + title = stringResource(R.string.settings_notification_sound), + summary = if (blocked) { + stringResource(R.string.settings_notifications_blocked_hint) + } else { + stringResource(R.string.settings_digest_sound_hint) + }, + position = Position.Bottom, + trailing = { ExternalLinkIcon() }, + onClick = onOpenSound, + ) + } } } }