Release v2.25.0 (#545)
Renovate / renovate (push) Successful in 1m13s
Release — F-Droid repo + Gitea/Codeberg release + Play / detect (push) Successful in 8s
Release — F-Droid repo + Gitea/Codeberg release + Play / release (push) Successful in 18m44s
Release — F-Droid repo + Gitea/Codeberg release + Play / play (push) Successful in 1m0s
Renovate / renovate (push) Successful in 1m13s
Release — F-Droid repo + Gitea/Codeberg release + Play / detect (push) Successful in 8s
Release — F-Droid repo + Gitea/Codeberg release + Play / release (push) Successful in 18m44s
Release — F-Droid repo + Gitea/Codeberg release + Play / play (push) Successful in 1m0s
This commit is contained in:
1 parent
a42b12d65d
commit
56a687169e
194 files changed
+15612
-2617
No files matched your search
+262
-11
@@ -10,6 +10,32 @@ the package list (recurring writes, save conflicts, reminder delivery).
|
||||
1. **`CalendarContract` is the single source of truth.** No app database,
|
||||
no caching layer, no sync code. Reads query the provider; writes go
|
||||
straight back to it. Sync is DAVx5's / Google's / the system's job.
|
||||
The app only *asks* for one through `ContentResolver.requestSync`: an
|
||||
expedited nudge for the account after each of its own writes to a synced
|
||||
calendar (#303, once per write, so a multi-row save or an import asks once
|
||||
per account, and never `MANUAL`, which would override master-sync-off), and
|
||||
a manual request from the drawer's "Sync now" (#240), which like the
|
||||
system's own "Sync now" also runs for accounts whose auto-sync is off. Both
|
||||
go through `SyncRequester` and only ask account types with a calendar sync
|
||||
adapter (visible to the app via a `<queries>` entry). From Android 13 a
|
||||
request naming an account the app can't see is silently dropped, and
|
||||
without `GET_ACCOUNTS` that is most of them. Such accounts are not asked at
|
||||
all (an account-less request would sync every account on the device); the
|
||||
drawer offers "Allow sync requests" instead, which opens the system account
|
||||
picker (`AccountManager.newChooseAccountIntent`) — the picked account
|
||||
becomes visible to the app. Access is re-read on every request and on
|
||||
every resume and drawer open, so a revoke simply puts the account back behind the
|
||||
grant row. Per account the user can choose "Don't ask" instead
|
||||
(`CalendarPrefs.syncAccessDismissed`); such accounts drop out of the grant
|
||||
row and the receipts, and the calendar manager lists them to ask again. Whether and when the adapter syncs stays its call.
|
||||
"Sync now" then follows what it asked for through the system's sync state
|
||||
(`READ_SYNC_STATS`: `isSyncPending` / `isSyncActive` plus a status-change
|
||||
listener, see `awaitSyncs`): it reports "Sync completed" once every reached
|
||||
account was seen pending or running and is idle again (or, never seen, is
|
||||
still idle after a short grace), and only "Sync requested" when that isn't
|
||||
seen within a minute or the state can't be read. The outcome shows in the
|
||||
drawer row while the drawer is open; one that lands with the drawer closed
|
||||
gets the chip.
|
||||
2. **Observer-driven UI.** A `ContentObserver` on the provider triggers
|
||||
re-queries; every screen recomposes from fresh provider state. After a
|
||||
write, nothing is patched by hand — the views refresh from the provider.
|
||||
@@ -62,7 +88,8 @@ flowchart TD
|
||||
of `data/calendar/` because the receiver needs neither the repository
|
||||
nor its flows.
|
||||
- **`data/prefs/`** — DataStore-backed settings (theme, week start, form
|
||||
field defaults, reminders toggle) and small state (last-used calendar).
|
||||
field defaults, default calendar, reminders toggle) and small state
|
||||
(last-used calendar).
|
||||
- **`ui/`** — one package per screen, each with Screen + ViewModel +
|
||||
UiState. Shared pieces in `ui/common/` (recurrence humanizer, FAB column,
|
||||
drawer, transitions). Selection pickers are full-screen and come from
|
||||
@@ -389,7 +416,113 @@ pre-permission launch); `CalendarVisibilityReconciler` drains it entry by entry,
|
||||
and until it does, the repository and `ReminderNotifier.post` honour it. That
|
||||
gate also covers a snooze re-shown from our own alarm after its calendar was
|
||||
switched off. The drawer's filter sheet (`CalendarPrefs.hiddenCalendarIds`) is a
|
||||
separate in-app declutter that never touches reminders.
|
||||
separate in-app declutter that never touches reminders. Narrower still is the per-view hide
|
||||
(`SettingsPrefs.perCalendarHiddenViews`, #270): each view model asks for its
|
||||
events through `instancesWithout(range, calendarsHiddenIn(view, …))`, which drops
|
||||
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.
|
||||
|
||||
**A channel per calendar (#145).** `ReminderChannels` keeps one notification
|
||||
channel per calendar, grouped by account (one that syncs no events only gets
|
||||
its channel once something posts on it), so a calendar can be
|
||||
muted or given its own sound in the system settings before it ever fires. Every
|
||||
scan with reminders on syncs them (skipped when nothing changed): missing
|
||||
channels are created, renamed ones updated, and channels of deleted calendars
|
||||
removed — but never on an empty snapshot, which is a provider hiccup more often
|
||||
than every calendar gone. Switched-off calendars keep theirs, so toggling one
|
||||
never cancels a showing reminder or loses its settings. `post` creates a missing
|
||||
channel itself, so a reminder never waits on a sync. A new channel copies the sound, vibration and
|
||||
importance of the pre-#145 single `reminders` channel, which is deleted once
|
||||
nothing showing still sits on it. Settings → Notifications deep-links into the
|
||||
system's channel screens for everything but the sound (#340). A sound picked in
|
||||
the app (#518) can't be set on an existing channel, so
|
||||
`ReminderChannels.setSound` recreates it under a new version
|
||||
(`reminders.calendar.<id>.v<n>`), copying everything else from the old one. The
|
||||
current version is simply the highest channel that exists, so the new one only
|
||||
takes over once written; `SettingsPrefs.reminderChannelVersions` is just a
|
||||
high-water mark that keeps ids from being reused (a re-used id would bring back
|
||||
the deleted channel's settings). `setSound` leaves the old version to the sync,
|
||||
which treats older versions as stale and keeps one while a notification still
|
||||
shows on it; `ReminderNotifier.post` resolves and posts under the channel lock
|
||||
(`withChannel`), so a pick never moves a channel mid-post.
|
||||
Separate from the channels, `SettingsPrefs.mutedReminderCalendarIds` is the in-app per-calendar
|
||||
off switch (#272): the scan plans nothing for those calendars (so they arm no
|
||||
wake-ups; toggling it re-scans), and `ReminderNotifier.post` checks it again
|
||||
for snoozes. The settings screen re-reads `ReminderChannels.status` on every
|
||||
resume and marks a calendar "Blocked in system settings" when the app, its
|
||||
channel or its account group is switched off there.
|
||||
|
||||
**Full-screen alerts (#171).** Settings → Notifications gives each calendar an
|
||||
alert style (`SettingsPrefs.reminderAlertStyles`): a plain notification, a
|
||||
full-screen alert that sounds once, or one that rings until handled. Only
|
||||
`ReminderNotifier.post` reads it, and `ReminderChannels.channelFor(id, style)`
|
||||
picks the channel. "Sound once" stays on the calendar's own channel, so its
|
||||
sound is still the one chosen in system settings, and adds a full-screen intent
|
||||
to `ReminderAlertActivity`. "Ring" starts `ReminderRingService`, which goes
|
||||
foreground on the shared silent `reminders_ring` channel and loops the alarm
|
||||
sound with vibration through floret-kit's `ring` module — the same player
|
||||
Clockula's alarms use. One reminder rings at a time; a newer one takes over and
|
||||
hands the older back to the shade quietly, as does a ring left unanswered for
|
||||
ten minutes, and switching the calendar away from ringing. Dismiss and Snooze,
|
||||
from the screen, the notification or a swipe, all go through
|
||||
`ReminderActionReceiver`, so the ring stops and the screen closes
|
||||
(`FullScreenAlerts`) however the reminder was handled. Starts and stops reach
|
||||
the service as commands, so a dismiss sent while a newer ring is on its way
|
||||
applies in order rather than killing it, and the service re-reads the settings
|
||||
once a ring arrives, so a style change or mute that raced a scan still wins. A
|
||||
blocked calendar, account group or ring channel never rings (Settings flags a
|
||||
blocked ring channel next to each ringing calendar, beside #145's blocked status), the tone pauses
|
||||
for a phone call, and a ring restarted after a process death only rings out
|
||||
what was left of its ten minutes. When Android 14+
|
||||
withholds `USE_FULL_SCREEN_INTENT`, the intent is left off and the alert is a
|
||||
heads-up; Settings shows a row leading to the system switch. When Android
|
||||
refuses the ring service, the reminder falls back to sounding once.
|
||||
|
||||
**Reminders at a set time (#459).** "1 day before at 20:00" on a timed event
|
||||
is an ordinary `Reminders` row whose offset is the distance from that wall-clock
|
||||
moment (device zone) to the start, so it syncs and fires everywhere — the scan
|
||||
plans it like any lead time. Only the editor knows it as a pattern
|
||||
(`EventForm.fixedReminders`), and it re-derives the offset from the start it
|
||||
saves with, so moving the event, in the form or by drag, keeps the wall clock.
|
||||
Reading a row back is a guess, made in one place (`classifyTimedReminder`): an
|
||||
offset is fixed-time only when it lands on a known pattern — a current or
|
||||
replaced default, or one saved by hand on this device
|
||||
(`recentFixedTimeReminders`, capped). Guessing from the offset's shape alone
|
||||
would turn ordinary leads ("12 hours before") into fixed ones. Limits: where a
|
||||
lead and a known pattern coincide ("1 day before" on an event at the default's
|
||||
own time) the pattern wins, and a pattern that falls out of the recents reads as
|
||||
a lead again — either way the alarm fires at the same moment until the start's
|
||||
time of day changes. A recurring series stores one offset for all occurrences,
|
||||
so it counts clock minutes rather than real ones (`wallClock`); the occurrence
|
||||
whose lead spans a DST change then fires an hour off, as in every other app
|
||||
reading that row. On another device or app the row is simply a lead time.
|
||||
New timed events get the default (`SettingsKeys.defaultFixedTimeReminder`, with
|
||||
a per-calendar inherit/off/value override) like the lead-time defaults.
|
||||
|
||||
**The daily summary (#459)** rides the same scan and watermark: its moment is
|
||||
due when it falls in `(lastScan, now]` (`scheduleDigest`), only the latest one
|
||||
counts after a long gap, and it is dropped once the day it lists has passed.
|
||||
It is independent of the event-reminder switch, posts on its own channel
|
||||
(`DailyDigestNotifier`), lists switched-on calendars minus its own exclusions,
|
||||
and replaces the previous summary — or withdraws it when the day is empty.
|
||||
Each day is listed once: the day is recorded as soon as it is posted
|
||||
(`ReminderStatePrefs.lastDigestDay`), so neither a pass failing later nor a later
|
||||
time picked the same evening lists it twice, and changing the switch, time or
|
||||
day stamps `dailyDigestArmedAt`, so a moment that passed before the change is
|
||||
not owed by it. A failing summary is logged and skipped; it never costs the
|
||||
event reminders of the same pass, and a failing reminder pass still arms a retry
|
||||
and the summary's next moment. Switching between "today's" and "tomorrow's"
|
||||
events clears the day last listed, so the first summary of the new mode comes.
|
||||
The notification names its date and times out when that day ends.
|
||||
Its channel's blocked state is read separately (`DailyDigestNotifier.isChannelOff`,
|
||||
with the app-wide block from `ReminderChannels.status`); while it is off the
|
||||
scan neither posts nor records the day, so allowing it brings the summary back.
|
||||
The channel is created when the summary is switched on, so a phone that starts
|
||||
new categories off shows it blocked in settings before the first summary.
|
||||
The per-calendar reminder mute does not apply: a calendar too noisy to ping per
|
||||
event can still belong in the overview, and the summary has its own
|
||||
per-calendar switch next to it.
|
||||
|
||||
Deliberately absent: a fallback to the provider's `EVENT_REMINDER` broadcast.
|
||||
Keeping both would double-post wherever the provider works, and Etar's way out —
|
||||
@@ -462,15 +595,122 @@ after the event — so `toIcsEvent` decodes it back through
|
||||
`fromProviderAllDayMinutes` first, and the importing device re-encodes it against
|
||||
its own setting.
|
||||
|
||||
**A backup carries the series' deleted occurrences.** `EXDATE` lives on the
|
||||
master row, so the export query's `ORIGINAL_ID IS NULL` filter — which does drop
|
||||
`RECURRENCE-ID` overrides — never hid it; it simply wasn't read. It is now part
|
||||
of `EventExportProjection`, and `IcsWriter` marks an all-day series' exclusions
|
||||
`VALUE=DATE`, because RFC 5545 ties `EXDATE`'s value type to `DTSTART`'s and a
|
||||
bare day code without it reads as a malformed DATE-TIME. Sync adapters disagree
|
||||
on whether an all-day exclusion is `yyyyMMdd` or a padded midnight stamp, so
|
||||
`exportExDates` drops the time part on the way out. Without this, an in-app
|
||||
backup→restore resurrected every occurrence the user had deleted.
|
||||
**Backups read any calendar; restores still write only into targets.**
|
||||
`CalendarDataSource.calendarEvents` reads the events of whatever calendar ids it
|
||||
is given — local, synced or read-only — and leaves the choice to its callers:
|
||||
export and the automatic backup offer every calendar but the managed mirrors
|
||||
(#147), defaulting to the writable local ones (`domain/backup/BackupPlan.kt`). A
|
||||
restore runs through the normal import, whose targets stay `isEventTarget`. The
|
||||
automatic backup writes one `<calendar name>_<date>_<time>.ics` series per
|
||||
calendar, or one `calendula-backup_…` series in combined mode (#411), and prunes
|
||||
each series to the retention count after its new file has landed. Pruning only
|
||||
deletes names recorded in a per-series ledger of files the backup wrote
|
||||
(`auto_backup_files`, keyed by calendar id, reset when the folder changes),
|
||||
never whatever happens to match a
|
||||
name, so renames, same-named calendars and the user's own files are safe.
|
||||
Each series also keeps a stable undated copy (`<calendar name>.ics`, or
|
||||
`calendula-backup.ics` combined) overwritten every run, so sync tools and
|
||||
subscriptions can follow one path. Retention never touches it, and it is only
|
||||
written over a file the series itself (or a series renaming away from that name
|
||||
in the same run) recorded. A renamed calendar's old copy is deleted once the new
|
||||
one has landed, and so is a copy the layout switch replaced (per-calendar ↔ combined); a calendar taken out
|
||||
of the backup keeps its last one. The pre-#411 fixed `calendula-backup.ics` is
|
||||
the combined series' stable copy for the install that wrote it, and an
|
||||
install that already had a folder stays on the combined layout.
|
||||
|
||||
**Backing up after a change (#516)** is opt-in. `BackupChangeJob` is a
|
||||
JobScheduler job with a content trigger on the provider's root URI (the provider
|
||||
notifies every change there, whoever made it: this app, a sync adapter or
|
||||
another app), a 2-minute settle delay capped at 15 minutes. A trigger fires
|
||||
once, so each firing queues a change run (a unique `BackupWorker`, battery not
|
||||
low, queued behind one already running) and schedules the next watch under the
|
||||
same id before it finishes, which carries over the changes seen meanwhile. Such
|
||||
a job can't be persisted; `BackupScheduler.reconcile` re-arms it on every
|
||||
process start (the boot receivers start one), without replacing a waiting watch.
|
||||
Runs share the scheduled backup's lock. A change run only rewrites the stable
|
||||
copies and never retries: the dated files and their retention stay on the
|
||||
interval, so a day of edits can't rotate the history out. Every run that writes
|
||||
something, or fails to, is recorded on the status line; the failure notification comes once
|
||||
per failure streak, as it reaches the threshold, and the next success of any run
|
||||
clears it. Since the trigger fires for any provider change (reminders, other
|
||||
calendars, sync bookkeeping), each series' file (events in a fixed order) is
|
||||
hashed without its `DTSTAMP`s (`auto_backup_fingerprints`, reset with the folder
|
||||
and kept only while the option is on) and a change run skips the series whose
|
||||
hash (bound to the copy's name) and stable copy are unchanged, without even
|
||||
listing the folder when no hash moved; the hash is dropped before a copy is
|
||||
rewritten. A copy that went missing is restored by the next run that lists the
|
||||
folder; one a still-loading listing doesn't show, or one edited in place outside
|
||||
the app, is left to the next scheduled run.
|
||||
|
||||
While the option is on, the interval itself can be switched off
|
||||
(`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as
|
||||
off without the option): the periodic work is cancelled and no run writes or
|
||||
prunes dated files. Run-now then rewrites every stable copy, change runs the
|
||||
changed ones and any missing from a complete listing (checked even when no hash
|
||||
moved, since no scheduled run would restore them), and a series whose stable
|
||||
name a file of the user's holds counts as failed (not retried), since nothing
|
||||
else backs it up. A change run fails on it again only once its content changed,
|
||||
and while it stays unchanged doesn't record the run as a success either. Turning the option on or off sets the interval back
|
||||
on, at the interval it had; any switch of the interval backs up right away.
|
||||
What the text above leaves to the next scheduled run then waits for the next
|
||||
run-now.
|
||||
|
||||
**A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on
|
||||
the master row and is part of `EventExportProjection`; `IcsWriter` marks an
|
||||
all-day series' exclusions `VALUE=DATE`, because RFC 5545 ties `EXDATE`'s value
|
||||
type to `DTSTART`'s and a bare day code without it reads as a malformed
|
||||
DATE-TIME. Sync adapters disagree on whether an all-day exclusion is `yyyyMMdd`
|
||||
or a padded midnight stamp, so `exportExDates` drops the time part on the way
|
||||
out.
|
||||
|
||||
A synced calendar records a deleted or moved occurrence as an *exception row*
|
||||
(`ORIGINAL_ID` / `ORIGINAL_SYNC_ID` = the series, `ORIGINAL_INSTANCE_TIME` = the
|
||||
occurrence) instead, and neither a backup file nor a copied calendar can hold
|
||||
one: an `.ics` restore skips `RECURRENCE-ID` overrides, and an inserted row has
|
||||
no `_sync_id` for an exception to attach through. `CalendarDataSource.calendarRows`
|
||||
therefore reads every row, exceptions included, and `flattenOverrides` — the one
|
||||
place this mapping lives, shared by the backup (`exportEvents`) and Copy events
|
||||
(#325, `planCalendarCopy`) — writes them the way Calendula writes "only this
|
||||
event" on an unsynced series: every exception adds its occurrence to the
|
||||
series' `EXDATE`, and a modified one becomes a standalone event at its own
|
||||
times. Its UID is derived from the series UID and the occurrence, so it is the
|
||||
same in every backup, and it carries the series UID as `X-CALENDULA-OVERRIDE-OF`.
|
||||
`importEvents` skips such an occurrence wherever its series already is — that
|
||||
series there has the override itself — so restoring into the calendar a backup
|
||||
came from adds nothing twice, while a restore into an empty one gets both. The
|
||||
standalone event also names its occurrence (`X-CALENDULA-OVERRIDE-AT`); if it
|
||||
fails to insert, the series is inserted without that exclusion, so the
|
||||
occurrence stays at its original time rather than vanishing for good. The
|
||||
import inserts every such event ahead of the series, whatever order the file
|
||||
lists them in.
|
||||
Exceptions whose series isn't among the rows are left out, a cancelled
|
||||
series' moved occurrences stay cancelled, and sync ids link only within their
|
||||
own calendar. Backups made before this carry no exceptions and restore exactly
|
||||
as before.
|
||||
|
||||
**`RDATE` travels like `EXDATE` (#515).** A series can repeat by listed dates
|
||||
alone. The provider stores `RDATE` in the same `<zone>;<stamps>` form as
|
||||
`EXDATE`, so `exportRecurrenceDates` resolves it the same way to UTC stamps (or
|
||||
bare days for an all-day series), line by line where several `RDATE`s were
|
||||
stored; a `PERIOD` entry keeps its start, and a bare day on a timed series
|
||||
becomes the occurrence at the series' time of day, so the copy (which never
|
||||
goes through the parser) and a file get the same stamps. `IcsWriter`
|
||||
writes it as `RDATE:` / `RDATE;VALUE=DATE:`, anchors such a series to its zone
|
||||
like an RRULE series, and writes its `EXDATE` too; `IcsParser` reads `RDATE`
|
||||
through the same normalisation as `EXDATE`, so a foreign `TZID` or floating
|
||||
value lands on the right instant. Older backups wrote such a series as a single
|
||||
event and still restore as one.
|
||||
|
||||
**Copying a calendar.** Backup & restore → Copy events (#325) runs the source's
|
||||
flattened rows straight into `importEvents`, so the UID dedup makes a re-run skip
|
||||
what landed before. It skips the `.ics` text: the writer pins a timed one-off to
|
||||
UTC and carries no colour or visibility; the direct mapping keeps them.
|
||||
Attendees and organizer are never read, and cancelled events and declined
|
||||
invitations are left out (an insert can't be cancelled; it would arrive live, and
|
||||
a declined occurrence counts as deleted, as does one of a declined series the
|
||||
user didn't accept on its own). A re-run is idempotent per
|
||||
snapshot: a series already in the target keeps its overrides, so an occurrence
|
||||
changed since keeps its earlier copy rather than gaining a second one.
|
||||
|
||||
That re-encode is sampled where the reminder will actually *fire*, not at
|
||||
`DTSTART` (`importedAllDayReminderDate`). An imported series' `DTSTART` is only an
|
||||
@@ -492,6 +732,17 @@ one the calendar accepts. The single-event review form deliberately keeps no col
|
||||
first question is which calendar to use, and answering it clears the colour
|
||||
anyway.
|
||||
|
||||
## Settings backup
|
||||
|
||||
Backup & restore also exports the app's settings as versioned JSON (#481),
|
||||
with the envelope and the generic preference section from floret-kit's
|
||||
`core-backup`. Every stored key is either carried or deliberately left out
|
||||
(`SettingsBackupSchema`, enforced by a test); per-calendar settings travel
|
||||
under the calendar's account and name, since provider ids are per device. An
|
||||
import replaces rather than merges, in one DataStore edit, then re-runs what
|
||||
reads settings outside DataStore. Format and per-key decisions:
|
||||
docs/SETTINGS_BACKUP.md.
|
||||
|
||||
## Testing
|
||||
|
||||
JUnit 5 + Truth + Turbine on the JVM. The seams that make it work:
|
||||
|
||||
Reference in new issue
Block a user