feat(backup): JSON export/import through SAF, whole-state replace

clockula-backup-v1.json, schema documented in docs/BACKUP.md per
PLAN.md §7: alarms, timers and world clocks as configuration only —
ring state and a timer's running anchors never leave the device, since
neither means anything on another one. Unknown fields are ignored at
any level; a malformed known field rejects the whole file rather than
importing it half-way.

Import is whole-state replacement, not a merge, and the backup screen
says so before the user confirms. Before replacing: a ringing alarm is
dismissed and every running timer is deleted, so the import can never
strand a live ring session; after it, AlarmEngine and TimerEngine are
told to re-resolve so the imported state is live immediately.

BackupDao adds delete-all/insert-many queries under one transaction —
no schema or version change, queries only.
This commit is contained in:
makiolaj committed 2026-10-01 22:06:44 +02:00
1 parent 7253445c4e
commit 616bf7f67f
22 files changed
+1657 -5

No files matched your search

+14
View File
@@ -280,4 +280,18 @@
<string name="settings_version">Version</string>
<string name="settings_version_value" translatable="false">%1$s</string>
<string name="settings_ringtone_custom">Custom sound</string>
<!-- M10: backup -->
<string name="settings_backup_section">Back up &amp; restore</string>
<string name="settings_backup_export">Export backup</string>
<string name="settings_backup_export_summary">Choose a folder to save clockula-backup-v1.json in</string>
<string name="settings_backup_import">Import backup</string>
<string name="settings_backup_import_summary">Replaces all your alarms, timers and world clocks</string>
<string name="settings_backup_export_succeeded">Backup saved</string>
<string name="settings_backup_export_failed">Couldn\'t save the backup</string>
<string name="settings_backup_import_succeeded">Backup restored</string>
<string name="settings_backup_import_failed">Couldn\'t restore the backup</string>
<string name="settings_backup_import_confirm_title">Replace everything?</string>
<string name="settings_backup_import_confirm_message">This replaces all your current alarms, timers, world clocks and settings with what\'s in the backup file. This can\'t be undone.</string>
<string name="settings_backup_import_confirm_action">Replace</string>
</resources>