Reminders: global repeat toggle + per-dose "Ikke forstyrr"

Two ways to stop the every-10-min nag, per feature request:

- A global "Gjenta påminnelser" switch in Settings. Off → a due dose
  alerts once and goes quiet; only the automatic re-nag chain is gated,
  so an explicit "Utsett 15 min" still gives one more reminder. The gate
  sits at the three automatic arm points (fireOccurrence, escalate
  re-arm, armAll resume-after-reboot), never on Snooze.

- An "Ikke forstyrr" action that appears from the second reminder on
  (nagCount >= 1). It stops nagging this one dose but leaves it PENDING
  so it can still be taken later — distinct from Skip. Implemented by
  jumping to the existing terminal state (nagCount = NAG_CAP) rather than
  a new column, so it needs no migration and survives reboot for free
  (armAll re-arms only nagCount < cap).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-06-29 14:16:16 +02:00
commit 778a6aec27
7 changed files with 82 additions and 3 deletions

View file

@ -85,7 +85,11 @@ class DoseAlarmReceiver : BroadcastReceiver() {
Notifications.doseNotificationId(log.id),
Notifications.buildDoseNotification(context, med, log),
)
if (log.nagCount < AlarmScheduler.NAG_CAP) scheduler.armEscalation(log.id)
// Start the automatic re-nag chain only if the user wants repeats; an
// explicit Snooze still re-arms regardless (DoseActions.snooze).
if (repeatReminders(context) && log.nagCount < AlarmScheduler.NAG_CAP) {
scheduler.armEscalation(log.id)
}
}
private suspend fun escalate(context: Context, logId: Long) {
@ -107,6 +111,14 @@ class DoseAlarmReceiver : BroadcastReceiver() {
Notifications.doseNotificationId(logId),
Notifications.buildDoseNotification(context, med, nagged),
)
if (nagged.nagCount < AlarmScheduler.NAG_CAP) AlarmScheduler(context).armEscalation(logId)
// Re-arm the next automatic nag only while repeats are enabled. A nag
// already in flight from a Snooze still fires once (this post), then
// stops here — Snooze stays a single deferral, not an endless chain.
if (repeatReminders(context) && nagged.nagCount < AlarmScheduler.NAG_CAP) {
AlarmScheduler(context).armEscalation(logId)
}
}
private fun repeatReminders(context: Context): Boolean =
no.naiv.meddetsamme.settings.SettingsStore(context).repeatReminders
}