Rx-expiry ongoing alert (7-day lead), configurable morning check, Felleskatalogen links

The daily digest splits in two: low stock stays an auto-cancel
notification re-posted each morning while below the per-item limit;
prescription renewal becomes a separate ONGOING notification starting
7 days before rx expiry — survives 'Clear all', swipe-dismissable on
Android 14+, returns each morning until the rx date is updated, and
cancels itself once renewed (post-or-cancel in SupplyCheckReceiver).
Check time is now configurable (Innstillinger → Varsler, M3 TimePicker,
default 10:00); same PendingIntent so re-arming replaces. 'Slå opp i
Felleskatalogen' buttons on the item editor and the med editor's
summary card open the browser — decision #8 clarified: the ban covers
Felleskatalogen as a data source, not human-facing links.

Emulator-verified: both notifications post with correct flags
(ONGOING_EVENT vs AUTO_CANCEL), auto-clear after renewal/restock,
alarm follows the configured time (10:00 → 07:30), FK button opens
Chrome.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-06-11 16:21:25 +02:00
commit 608d84236b
9 changed files with 142 additions and 15 deletions

View file

@ -27,6 +27,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import no.naiv.meddetsamme.R
@ -68,6 +70,15 @@ fun ItemEditScreen(nav: Nav, itemId: Long?) {
) {
InventoryItemForm(form)
if (form.name.isNotBlank()) {
TextButton(
onClick = { context.startActivity(felleskatalogenIntent(form.name)) },
modifier = Modifier
.fillMaxWidth()
.semantics { contentDescription = "Slå opp ${form.name} i Felleskatalogen. Åpner nettleseren." },
) { Text("Slå opp i Felleskatalogen ↗") }
}
Button(
onClick = {
val item = form.buildItem(itemId ?: 0) ?: return@Button