A cross platform Audiobookshelf client for Android and iOS
Dart
Sync your settings between devices through your own WebDAV server
Barnabas6e03dd29a08d
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex 7823255d..ebde72d7 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -4590,6 +4590,61 @@"readerBookmarkDefault": "Bookmark","readerNoteTitle": "Note","readerNoteHint": "Add a note...",+ "backupAndSync": "Backup and sync",+ "backupAndSyncSubtitle": "Save a backup file, or keep settings in step across devices",+ "syncSettingsExperimental": "Experimental",+ "syncSettingsExperimentalBody": "Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.",+ "syncSettingsNeedServer": "Need a server?",+ "syncSettingsNeedServerSub": "Any WebDAV server works. Nextcloud is a free self-hosted one.",+ "syncSettingsConnection": "Connection",+ "syncSettingsConnectionNotSet": "Not set up yet",+ "syncSettingsBackupFile": "Backup file",+ "syncSettingsBackupFilePlain": "Save everything to a file you keep.",+ "syncSettingsBackupFileWithSync": "Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.",+ "syncSettingsStatusOff": "Not syncing",+ "syncSettingsStatusProblem": "Could not reach your server",+ "syncSettings": "Sync settings between devices",+ "syncSettingsExtras": "Also sync",+ "syncSettingsIncludeRmab": "ReadMeABook settings",+ "syncSettingsIncludeRmabSub": "Puts your ReadMeABook API token in the synced file",+ "syncSettingsSubtitle": "Keep your settings in step through your own WebDAV server",+ "syncSettingsEnable": "Sync settings",+ "syncSettingsServerUrl": "WebDAV folder URL",+ "syncSettingsServerUrlHint": "https://cloud.example.com/remote.php/dav/files/you/Absorb",+ "syncSettingsUsername": "Username",+ "syncSettingsPassword": "Password",+ "syncSettingsHeaders": "Custom headers (optional)",+ "syncSettingsHeadersHint": "One per line, like CF-Access-Client-Id: abc123",+ "syncSettingsTest": "Test connection",+ "syncSettingsHoldToUpload": "Hold to upload now",+ "syncSettingsUploadNow": "Upload now",+ "syncSettingsDownloadNow": "Download now",+ "syncSettingsOk": "Connected",+ "syncSettingsNoRemote": "Connected - nothing synced yet",+ "syncSettingsAuthFailed": "Wrong username or password",+ "syncSettingsNetworkError": "Could not reach that address",+ "syncSettingsNotConfigured": "Fill in the address, username and password first",+ "syncSettingsTooLarge": "Your settings are too big to sync",+ "syncSettingsUploaded": "Settings uploaded",+ "syncSettingsApplied": "Settings updated from your other device",+ "syncSettingsAppliedCount": "{count, plural, one{1 setting updated from your other device} other{{count} settings updated from your other device}}",+ "@syncSettingsAppliedCount": {+ "placeholders": {+ "count": {"type": "int"}+ }+ },+ "syncSettingsUpToDate": "Already up to date",+ "syncSettingsLastSynced": "Last synced {when}",+ "@syncSettingsLastSynced": {+ "placeholders": {+ "when": {"type": "String"}+ }+ },+ "syncSettingsNever": "Not synced yet",+ "syncSettingsWhatTravels": "Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.",+ "syncSettingsDownloadWarnTitle": "Replace this device's settings?",+ "syncSettingsDownloadWarnBody": "The synced copy will overwrite the settings on this device.",+ "syncSettingsDownloadWarnConfirm": "Replace","readerCopied": "Copied to clipboard","readerTooltipCopy": "Copy","readerTooltipSearch": "Search",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex 616f2d14..4edb32eb 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -13641,6 +13641,276 @@ abstract class AppLocalizations {/// **'Add a note...'**String get readerNoteHint;+ /// No description provided for @backupAndSync.+ ///+ /// In en, this message translates to:+ /// **'Backup and sync'**+ String get backupAndSync;++ /// No description provided for @backupAndSyncSubtitle.+ ///+ /// In en, this message translates to:+ /// **'Save a backup file, or keep settings in step across devices'**+ String get backupAndSyncSubtitle;++ /// No description provided for @syncSettingsExperimental.+ ///+ /// In en, this message translates to:+ /// **'Experimental'**+ String get syncSettingsExperimental;++ /// No description provided for @syncSettingsExperimentalBody.+ ///+ /// In en, this message translates to:+ /// **'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.'**+ String get syncSettingsExperimentalBody;++ /// No description provided for @syncSettingsNeedServer.+ ///+ /// In en, this message translates to:+ /// **'Need a server?'**+ String get syncSettingsNeedServer;++ /// No description provided for @syncSettingsNeedServerSub.+ ///+ /// In en, this message translates to:+ /// **'Any WebDAV server works. Nextcloud is a free self-hosted one.'**+ String get syncSettingsNeedServerSub;++ /// No description provided for @syncSettingsConnection.+ ///+ /// In en, this message translates to:+ /// **'Connection'**+ String get syncSettingsConnection;++ /// No description provided for @syncSettingsConnectionNotSet.+ ///+ /// In en, this message translates to:+ /// **'Not set up yet'**+ String get syncSettingsConnectionNotSet;++ /// No description provided for @syncSettingsBackupFile.+ ///+ /// In en, this message translates to:+ /// **'Backup file'**+ String get syncSettingsBackupFile;++ /// No description provided for @syncSettingsBackupFilePlain.+ ///+ /// In en, this message translates to:+ /// **'Save everything to a file you keep.'**+ String get syncSettingsBackupFilePlain;++ /// No description provided for @syncSettingsBackupFileWithSync.+ ///+ /// In en, this message translates to:+ /// **'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.'**+ String get syncSettingsBackupFileWithSync;++ /// No description provided for @syncSettingsStatusOff.+ ///+ /// In en, this message translates to:+ /// **'Not syncing'**+ String get syncSettingsStatusOff;++ /// No description provided for @syncSettingsStatusProblem.+ ///+ /// In en, this message translates to:+ /// **'Could not reach your server'**+ String get syncSettingsStatusProblem;++ /// No description provided for @syncSettings.+ ///+ /// In en, this message translates to:+ /// **'Sync settings between devices'**+ String get syncSettings;++ /// No description provided for @syncSettingsExtras.+ ///+ /// In en, this message translates to:+ /// **'Also sync'**+ String get syncSettingsExtras;++ /// No description provided for @syncSettingsIncludeRmab.+ ///+ /// In en, this message translates to:+ /// **'ReadMeABook settings'**+ String get syncSettingsIncludeRmab;++ /// No description provided for @syncSettingsIncludeRmabSub.+ ///+ /// In en, this message translates to:+ /// **'Puts your ReadMeABook API token in the synced file'**+ String get syncSettingsIncludeRmabSub;++ /// No description provided for @syncSettingsSubtitle.+ ///+ /// In en, this message translates to:+ /// **'Keep your settings in step through your own WebDAV server'**+ String get syncSettingsSubtitle;++ /// No description provided for @syncSettingsEnable.+ ///+ /// In en, this message translates to:+ /// **'Sync settings'**+ String get syncSettingsEnable;++ /// No description provided for @syncSettingsServerUrl.+ ///+ /// In en, this message translates to:+ /// **'WebDAV folder URL'**+ String get syncSettingsServerUrl;++ /// No description provided for @syncSettingsServerUrlHint.+ ///+ /// In en, this message translates to:+ /// **'https://cloud.example.com/remote.php/dav/files/you/Absorb'**+ String get syncSettingsServerUrlHint;++ /// No description provided for @syncSettingsUsername.+ ///+ /// In en, this message translates to:+ /// **'Username'**+ String get syncSettingsUsername;++ /// No description provided for @syncSettingsPassword.+ ///+ /// In en, this message translates to:+ /// **'Password'**+ String get syncSettingsPassword;++ /// No description provided for @syncSettingsHeaders.+ ///+ /// In en, this message translates to:+ /// **'Custom headers (optional)'**+ String get syncSettingsHeaders;++ /// No description provided for @syncSettingsHeadersHint.+ ///+ /// In en, this message translates to:+ /// **'One per line, like CF-Access-Client-Id: abc123'**+ String get syncSettingsHeadersHint;++ /// No description provided for @syncSettingsTest.+ ///+ /// In en, this message translates to:+ /// **'Test connection'**+ String get syncSettingsTest;++ /// No description provided for @syncSettingsHoldToUpload.+ ///+ /// In en, this message translates to:+ /// **'Hold to upload now'**+ String get syncSettingsHoldToUpload;++ /// No description provided for @syncSettingsUploadNow.+ ///+ /// In en, this message translates to:+ /// **'Upload now'**+ String get syncSettingsUploadNow;++ /// No description provided for @syncSettingsDownloadNow.+ ///+ /// In en, this message translates to:+ /// **'Download now'**+ String get syncSettingsDownloadNow;++ /// No description provided for @syncSettingsOk.+ ///+ /// In en, this message translates to:+ /// **'Connected'**+ String get syncSettingsOk;++ /// No description provided for @syncSettingsNoRemote.+ ///+ /// In en, this message translates to:+ /// **'Connected - nothing synced yet'**+ String get syncSettingsNoRemote;++ /// No description provided for @syncSettingsAuthFailed.+ ///+ /// In en, this message translates to:+ /// **'Wrong username or password'**+ String get syncSettingsAuthFailed;++ /// No description provided for @syncSettingsNetworkError.+ ///+ /// In en, this message translates to:+ /// **'Could not reach that address'**+ String get syncSettingsNetworkError;++ /// No description provided for @syncSettingsNotConfigured.+ ///+ /// In en, this message translates to:+ /// **'Fill in the address, username and password first'**+ String get syncSettingsNotConfigured;++ /// No description provided for @syncSettingsTooLarge.+ ///+ /// In en, this message translates to:+ /// **'Your settings are too big to sync'**+ String get syncSettingsTooLarge;++ /// No description provided for @syncSettingsUploaded.+ ///+ /// In en, this message translates to:+ /// **'Settings uploaded'**+ String get syncSettingsUploaded;++ /// No description provided for @syncSettingsApplied.+ ///+ /// In en, this message translates to:+ /// **'Settings updated from your other device'**+ String get syncSettingsApplied;++ /// No description provided for @syncSettingsAppliedCount.+ ///+ /// In en, this message translates to:+ /// **'{count, plural, one{1 setting updated from your other device} other{{count} settings updated from your other device}}'**+ String syncSettingsAppliedCount(int count);++ /// No description provided for @syncSettingsUpToDate.+ ///+ /// In en, this message translates to:+ /// **'Already up to date'**+ String get syncSettingsUpToDate;++ /// No description provided for @syncSettingsLastSynced.+ ///+ /// In en, this message translates to:+ /// **'Last synced {when}'**+ String syncSettingsLastSynced(String when);++ /// No description provided for @syncSettingsNever.+ ///+ /// In en, this message translates to:+ /// **'Not synced yet'**+ String get syncSettingsNever;++ /// No description provided for @syncSettingsWhatTravels.+ ///+ /// In en, this message translates to:+ /// **'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.'**+ String get syncSettingsWhatTravels;++ /// No description provided for @syncSettingsDownloadWarnTitle.+ ///+ /// In en, this message translates to:+ /// **'Replace this device\'s settings?'**+ String get syncSettingsDownloadWarnTitle;++ /// No description provided for @syncSettingsDownloadWarnBody.+ ///+ /// In en, this message translates to:+ /// **'The synced copy will overwrite the settings on this device.'**+ String get syncSettingsDownloadWarnBody;++ /// No description provided for @syncSettingsDownloadWarnConfirm.+ ///+ /// In en, this message translates to:+ /// **'Replace'**+ String get syncSettingsDownloadWarnConfirm;+/// No description provided for @readerCopied.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 3f500fb4..65eb215d 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -8011,6 +8011,164 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get readerNoteHint => 'Notiz hinzufügen...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'In Zwischenablage kopiert';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex ff75e1af..ad84d8d6 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 4b09bc1e..c4808fb8 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex 98fb7a33..e0b88284 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -7902,6 +7902,164 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex a54bd721..105ab0e5 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -7948,6 +7948,164 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get readerNoteHint => 'Ajouter une note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex 5b7261e6..b03ec9f2 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 113968ed..9fc7b7da 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex e094639b..11c58182 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex 8d02b054..65ca61a4 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 5dbeb642..55e347d8 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -7900,6 +7900,164 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex 86c807bb..37c55008 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -7905,6 +7905,164 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 3479d628..57d85d29 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -7808,6 +7808,164 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get readerNoteHint => 'Add a note...';+ @override+ String get backupAndSync => 'Backup and sync';++ @override+ String get backupAndSyncSubtitle =>+ 'Save a backup file, or keep settings in step across devices';++ @override+ String get syncSettingsExperimental => 'Experimental';++ @override+ String get syncSettingsExperimentalBody =>+ 'Sync is new and still being worked on. If two devices change things while they are apart, one side can lose its changes. Keep a backup file as your safe copy.';++ @override+ String get syncSettingsNeedServer => 'Need a server?';++ @override+ String get syncSettingsNeedServerSub =>+ 'Any WebDAV server works. Nextcloud is a free self-hosted one.';++ @override+ String get syncSettingsConnection => 'Connection';++ @override+ String get syncSettingsConnectionNotSet => 'Not set up yet';++ @override+ String get syncSettingsBackupFile => 'Backup file';++ @override+ String get syncSettingsBackupFilePlain =>+ 'Save everything to a file you keep.';++ @override+ String get syncSettingsBackupFileWithSync =>+ 'Save everything to a file you keep. Include login info and restoring it on another phone turns sync on there too.';++ @override+ String get syncSettingsStatusOff => 'Not syncing';++ @override+ String get syncSettingsStatusProblem => 'Could not reach your server';++ @override+ String get syncSettings => 'Sync settings between devices';++ @override+ String get syncSettingsExtras => 'Also sync';++ @override+ String get syncSettingsIncludeRmab => 'ReadMeABook settings';++ @override+ String get syncSettingsIncludeRmabSub =>+ 'Puts your ReadMeABook API token in the synced file';++ @override+ String get syncSettingsSubtitle =>+ 'Keep your settings in step through your own WebDAV server';++ @override+ String get syncSettingsEnable => 'Sync settings';++ @override+ String get syncSettingsServerUrl => 'WebDAV folder URL';++ @override+ String get syncSettingsServerUrlHint =>+ 'https://cloud.example.com/remote.php/dav/files/you/Absorb';++ @override+ String get syncSettingsUsername => 'Username';++ @override+ String get syncSettingsPassword => 'Password';++ @override+ String get syncSettingsHeaders => 'Custom headers (optional)';++ @override+ String get syncSettingsHeadersHint =>+ 'One per line, like CF-Access-Client-Id: abc123';++ @override+ String get syncSettingsTest => 'Test connection';++ @override+ String get syncSettingsHoldToUpload => 'Hold to upload now';++ @override+ String get syncSettingsUploadNow => 'Upload now';++ @override+ String get syncSettingsDownloadNow => 'Download now';++ @override+ String get syncSettingsOk => 'Connected';++ @override+ String get syncSettingsNoRemote => 'Connected - nothing synced yet';++ @override+ String get syncSettingsAuthFailed => 'Wrong username or password';++ @override+ String get syncSettingsNetworkError => 'Could not reach that address';++ @override+ String get syncSettingsNotConfigured =>+ 'Fill in the address, username and password first';++ @override+ String get syncSettingsTooLarge => 'Your settings are too big to sync';++ @override+ String get syncSettingsUploaded => 'Settings uploaded';++ @override+ String get syncSettingsApplied => 'Settings updated from your other device';++ @override+ String syncSettingsAppliedCount(int count) {+ String _temp0 = intl.Intl.pluralLogic(+ count,+ locale: localeName,+ other: '$count settings updated from your other device',+ one: '1 setting updated from your other device',+ );+ return '$_temp0';+ }++ @override+ String get syncSettingsUpToDate => 'Already up to date';++ @override+ String syncSettingsLastSynced(String when) {+ return 'Last synced $when';+ }++ @override+ String get syncSettingsNever => 'Not synced yet';++ @override+ String get syncSettingsWhatTravels =>+ 'Your preferences, per-book speeds, home layout, notes and ebook highlights travel. Logins, download folders and anything not yet sent to your server stay on this device.';++ @override+ String get syncSettingsDownloadWarnTitle =>+ 'Replace this device\'s settings?';++ @override+ String get syncSettingsDownloadWarnBody =>+ 'The synced copy will overwrite the settings on this device.';++ @override+ String get syncSettingsDownloadWarnConfirm => 'Replace';+@overrideString get readerCopied => 'Copied to clipboard';diff --git a/lib/main.dart b/lib/main.dartindex 9aad6e21..618b07e4 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -26,6 +26,7 @@ import 'services/progress_sync_service.dart';import 'services/local_session_service.dart';import 'services/equalizer_service.dart';import 'services/sleep_timer_service.dart';+import 'services/settings_sync_service.dart';import 'services/scoped_prefs.dart';import 'services/user_account_service.dart';import 'services/android_auto_service.dart';@@ -143,6 +144,21 @@ void applyManualSeed(int argb) => manualSeedNotifier.value = Color(argb);void applyGradientIntensity(double value) => gradientIntensityNotifier.value = value;void applyUseColorEverywhere(bool value) => useColorEverywhereNotifier.value = value;+/// Push every appearance setting from storage into the notifiers that drive+/// the theme. The individual appliers above are called by the settings screen+/// as the user changes each one; this is for when the whole store is replaced+/// underneath a running app - a settings-sync pull or a restore - where+/// nothing has told the theme it moved.+Future<void> applyAppearanceFromPrefs() async {+ applyThemeMode(await PlayerSettings.getThemeMode());+ applyFlatBackground(await PlayerSettings.getFlatBackground());+ applyColorSource(await PlayerSettings.getColorSource());+ applyManualSeed(await PlayerSettings.getManualSeedColor());+ applyGradientIntensity(await PlayerSettings.getGradientIntensity());+ applyUseColorEverywhere(await PlayerSettings.getUseColorEverywhere());+ await applyOrientationLock();+}+/// Apply the saved rotation preference. When "lock portrait" is on the app is/// pinned to portrait; otherwise all orientations are allowed (the default)./// Safe to call any time the setting changes.@@ -703,6 +719,9 @@ class _AuthGateState extends State<AuthGate> {await LocalSessionService().init();await EqualizerService().init();await SleepTimerService().loadAutoSleepSettings();+ // Watch for settings changes and pull the synced copy on the way in.+ await SettingsSyncService().startIfEnabled();+ unawaited(SettingsSyncService().onAppForegrounded());if (Platform.isAndroid) {// Pre-populate Android Auto browse tree in background.Future.microtask(() => AndroidAutoService().refresh());diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex df9e1de5..51af331a 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -30,6 +30,7 @@ import 'app_shell_navigation_policy.dart';import '../widgets/library_picker_sheet.dart';import '../widgets/welcome_sheet.dart';import '../services/review_service.dart';+import '../services/settings_sync_service.dart';import '../services/update_checker_service.dart';import '../widgets/update_dialog.dart';import '../widgets/overlay_toast.dart';@@ -649,6 +650,7 @@ class _AppShellState extends State<AppShell>AudioPlayerService.onAppForegrounded();HomeWidgetService().onAppForegrounded();ReviewService.onAppForegrounded();+ unawaited(SettingsSyncService().onAppForegrounded());_refreshDataForTab(_currentIndex);// Check auto sleep in case we resumed into the windowSleepTimerService().checkAutoSleep();@@ -662,6 +664,7 @@ class _AppShellState extends State<AppShell>SleepTimerService().onAppBackgrounded();AudioPlayerService.onAppBackgrounded();HomeWidgetService().onAppBackgrounded();+ unawaited(SettingsSyncService().onAppBackgrounded());}@overridediff --git a/lib/screens/backup_sync_screen.dart b/lib/screens/backup_sync_screen.dartnew file mode 100644index 00000000..99eedbd9--- /dev/null+++ b/lib/screens/backup_sync_screen.dart@@ -0,0 +1,617 @@+import 'dart:convert';+import 'dart:io';+import 'dart:typed_data';++import 'package:file_picker/file_picker.dart';+import 'package:flutter/material.dart';+import 'package:provider/provider.dart';++import '../l10n/app_localizations.dart';+import '../main.dart';+import '../providers/library_provider.dart';+import '../services/backup_service.dart';+import '../services/settings_sync_service.dart';+import '../widgets/overlay_toast.dart';+import 'sync_connection_screen.dart';++/// Backup and sync in one place. They were separate screens, but a backup taken+/// with login info is what sets sync up on a second phone - a relationship+/// neither screen could explain while they sat apart.+class BackupSyncScreen extends StatefulWidget {+ const BackupSyncScreen({super.key});++ @override+ State<BackupSyncScreen> createState() => _BackupSyncScreenState();+}++class _BackupSyncScreenState extends State<BackupSyncScreen> {+ final _sync = SettingsSyncService();++ bool _enabled = false;+ bool _loading = true;+ bool _busy = false;+ bool _syncRmab = false;+ DateTime? _lastSynced;+ String _connectionSummary = '';++ /// Set when the last sync attempt from this screen failed, so the status+ /// banner can say so instead of showing a stale success time.+ String? _lastProblem;++ @override+ void initState() {+ super.initState();+ _load();+ }++ Future<void> _load() async {+ final enabled = await _sync.getEnabled();+ final url = await _sync.getUrl();+ final user = await _sync.getUsername();+ final rmab = await _sync.getSyncRmab();+ final last = await _sync.getLastSyncTime();+ if (!mounted) return;+ setState(() {+ _enabled = enabled;+ _syncRmab = rmab;+ _lastSynced = last;+ _connectionSummary = _summarise(url, user);+ _loading = false;+ });+ }++ static String _summarise(String? url, String? user) {+ if (url == null || url.trim().isEmpty) return '';+ final host = Uri.tryParse(url.trim())?.host ?? url.trim();+ return (user == null || user.isEmpty) ? host : '$host · $user';+ }++ String _timeAgo(AppLocalizations l, DateTime dt) {+ final d = DateTime.now().difference(dt);+ if (d.inSeconds < 60) return l.justNow.toLowerCase();+ if (d.inMinutes < 60) return l.minutesAgo(d.inMinutes);+ if (d.inHours < 24) return l.hoursAgo(d.inHours);+ return l.daysAgo(d.inDays);+ }++ String _describe(AppLocalizations l, SyncResult r) {+ switch (r.status) {+ case SyncStatus.ok:+ return r.message == 'applied'+ ? l.syncSettingsApplied+ : r.message == 'up to date'+ ? l.syncSettingsUpToDate+ : l.syncSettingsOk;+ case SyncStatus.noRemote:+ return l.syncSettingsNoRemote;+ case SyncStatus.authFailed:+ return l.syncSettingsAuthFailed;+ case SyncStatus.notConfigured:+ return l.syncSettingsNotConfigured;+ case SyncStatus.tooLarge:+ return l.syncSettingsTooLarge;+ case SyncStatus.network:+ return l.syncSettingsNetworkError;+ }+ }++ Future<void> _run(Future<SyncResult> Function() action) async {+ final l = AppLocalizations.of(context)!;+ setState(() => _busy = true);+ final result = await action();+ final last = await _sync.getLastSyncTime();+ if (!mounted) return;+ final good = result.ok || result.status == SyncStatus.noRemote;+ setState(() {+ _busy = false;+ _lastSynced = last;+ _lastProblem = good ? null : _describe(l, result);+ });+ // A failure with diagnostics gets a dialog rather than a toast: the useful+ // part is the status line and the exception, which a toast truncates and+ // nobody can copy out of.+ if (!good && result.detail != null) {+ await showDialog<void>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.error_outline_rounded),+ title: Text(_describe(l, result)),+ content: SingleChildScrollView(+ child: SelectableText(+ result.detail!,+ style: Theme.of(ctx)+ .textTheme+ .bodySmall+ ?.copyWith(fontFamily: 'monospace'),+ ),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx),+ child: Text(l.ok),+ ),+ ],+ ),+ );+ return;+ }+ showOverlayToast(+ context,+ _describe(l, result),+ icon: good+ ? Icons.check_circle_outline_rounded+ : Icons.error_outline_rounded,+ );+ }++ Future<void> _downloadNow() async {+ final l = AppLocalizations.of(context)!;+ final confirmed = await showDialog<bool>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.download_rounded),+ title: Text(l.syncSettingsDownloadWarnTitle),+ content: Text(l.syncSettingsDownloadWarnBody),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx, false),+ child: Text(l.cancel),+ ),+ FilledButton(+ onPressed: () => Navigator.pop(ctx, true),+ child: Text(l.syncSettingsDownloadWarnConfirm),+ ),+ ],+ ),+ );+ if (confirmed != true) return;+ await _run(() => _sync.pull(force: true));+ }++ void _backupSettings(BuildContext context) {+ final l = AppLocalizations.of(context)!;+ showDialog(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.shield_rounded),+ title: Text(l.includeLoginInfoTitle),+ content: Text(l.includeLoginInfoContent),+ actions: [+ TextButton(+ onPressed: () {+ Navigator.pop(ctx);+ _performBackup(context, includeAccounts: false);+ },+ child: Text(l.noSettingsOnly),+ ),+ FilledButton(+ onPressed: () {+ Navigator.pop(ctx);+ _performBackup(context, includeAccounts: true);+ },+ child: Text(l.yesIncludeAccounts),+ ),+ ],+ ),+ );+ }++ Future<void> _performBackup(BuildContext context, {required bool includeAccounts}) async {+ final l = AppLocalizations.of(context)!;+ try {+ final data = await BackupService.exportSettings(includeAccounts: includeAccounts);+ final jsonStr = const JsonEncoder.withIndent(' ').convert(data);+ final now = DateTime.now();+ final datePart = '${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')}';+ final fileName = 'absorb_backup_$datePart.absorb';++ final bytes = Uint8List.fromList(utf8.encode(jsonStr));++ final result = await FilePicker.platform.saveFile(+ dialogTitle: l.saveAbsorbBackup,+ fileName: fileName,+ type: FileType.any,+ bytes: bytes,+ );++ if (result != null) {+ // Desktop platforms need manual file write; mobile writes via bytes param+ if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {+ await File(result).writeAsString(jsonStr);+ }+ if (mounted) {+ showOverlayToast(+ context,+ includeAccounts+ ? l.backupSavedWithAccounts+ : l.backupSavedSettingsOnly,+ icon: Icons.check_circle_outline_rounded,+ );+ }+ }+ } catch (e) {+ if (mounted) {+ showOverlayToast(context, l.backupFailed(e.toString()),+ icon: Icons.error_outline_rounded);+ }+ }+ }++ Future<void> _restoreSettings(BuildContext context) async {+ final l = AppLocalizations.of(context)!;+ try {+ final result = await FilePicker.platform.pickFiles(type: FileType.any);+ if (result == null || result.files.single.path == null) return;++ final file = File(result.files.single.path!);+ final jsonStr = await file.readAsString();+ final data = jsonDecode(jsonStr) as Map<String, dynamic>;++ if (data['version'] == null) {+ if (mounted) {+ showOverlayToast(context, l.invalidBackupFile,+ icon: Icons.error_outline_rounded);+ }+ return;+ }++ if (!mounted) return;++ final accounts = data['accounts'] as List<dynamic>?;+ final hasAccounts = accounts != null && accounts.isNotEmpty;+ final hasCustomHeaders = data['customHeaders'] != null;+ final createdAt = data['createdAt'] as String?;+ final appVersion = data['appVersion'] as String?;++ String details = '';+ if (appVersion != null) details += l.fromAbsorbVersion(appVersion);+ if (createdAt != null) {+ final dt = DateTime.tryParse(createdAt);+ if (dt != null) {+ details += details.isEmpty ? '' : l.backupDetailsSeparator;+ details += l.backupDateFormat(dt.month, dt.day, dt.year);+ }+ }++ final cs = Theme.of(context).colorScheme;+ final confirmed = await showDialog<bool>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.restore_rounded),+ title: Text(l.restoreBackupTitle),+ content: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(l.restoreBackupContent),+ if (details.isNotEmpty) ...[+ const SizedBox(height: 12),+ Text(details, style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),+ ],+ if (hasAccounts || hasCustomHeaders) ...[+ const SizedBox(height: 12),+ Wrap(+ spacing: 8,+ runSpacing: 8,+ children: [+ if (hasAccounts)+ _restoreChip(Icons.people_rounded, l.restoreAccountsChip(accounts.length), cs),+ if (hasCustomHeaders)+ _restoreChip(Icons.vpn_key_rounded, l.restoreCustomHeadersChip, cs),+ ],+ ),+ ],+ ],+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx, false),+ child: Text(l.cancel),+ ),+ FilledButton(+ onPressed: () => Navigator.pop(ctx, true),+ child: Text(l.restore),+ ),+ ],+ ),+ );++ if (confirmed != true || !mounted) return;++ await BackupService.importSettings(data);++ // Apply theme immediately+ final settings = data['settings'] as Map<String, dynamic>?;+ final theme = settings?['themeMode'] as String?;+ if (theme != null) {+ applyThemeMode(theme);+ }+ if (settings?['flatBackground'] is bool) applyFlatBackground(settings!['flatBackground'] as bool);+ if (settings?['colorSource'] is String) applyColorSource(settings!['colorSource'] as String);+ if (settings?['manualSeedColor'] is int) applyManualSeed(settings!['manualSeedColor'] as int);+ if (settings?['gradientIntensity'] is num) applyGradientIntensity((settings!['gradientIntensity'] as num).toDouble());+ if (settings?['useColorEverywhere'] is bool) applyUseColorEverywhere(settings!['useColorEverywhere'] as bool);+ await applyOrientationLock();++ // The provider caches these lists in memory at account load, so without+ // a reload it keeps serving the pre-restore copy - and the next absorbing+ // change writes that stale copy back over what was just restored.+ if (mounted) {+ await context.read<LibraryProvider>().reloadPrefsBackedState();+ }++ // Refresh UI+ await _load();++ if (mounted) {+ showOverlayToast(context, l.settingsRestoredSuccessfully,+ icon: Icons.check_circle_outline_rounded);+ }+ } catch (e) {+ if (mounted) {+ showOverlayToast(context, l.restoreFailed(e.toString()),+ icon: Icons.error_outline_rounded);+ }+ }+ }++ Widget _restoreChip(IconData icon, String label, ColorScheme cs) {+ return Container(+ padding: const EdgeInsets.all(10),+ decoration: BoxDecoration(+ color: cs.primaryContainer.withValues(alpha: 0.15),+ borderRadius: BorderRadius.circular(8),+ ),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ Icon(icon, size: 16, color: cs.primary),+ const SizedBox(width: 8),+ Text(label, style: TextStyle(fontSize: 12, color: cs.primary)),+ ]),+ );+ }++ Widget _statusBanner(AppLocalizations l, ColorScheme cs, TextTheme tt) {+ final problem = _lastProblem;+ final Color bg;+ final Color fg;+ final IconData icon;+ final String title;+ String? detail;++ if (!_enabled) {+ bg = cs.surfaceContainerHighest;+ fg = cs.onSurfaceVariant;+ icon = Icons.cloud_off_rounded;+ title = l.syncSettingsStatusOff;+ } else if (problem != null) {+ bg = cs.errorContainer;+ fg = cs.onErrorContainer;+ icon = Icons.cloud_off_rounded;+ title = l.syncSettingsStatusProblem;+ detail = problem;+ } else {+ bg = cs.secondaryContainer;+ fg = cs.onSecondaryContainer;+ icon = Icons.cloud_done_rounded;+ final at = _lastSynced;+ title = at == null+ ? l.syncSettingsNever+ : l.syncSettingsLastSynced(_timeAgo(l, at));+ detail = _connectionSummary.isEmpty ? null : _connectionSummary;+ }++ return Container(+ width: double.infinity,+ padding: const EdgeInsets.all(14),+ decoration: BoxDecoration(+ color: bg,+ borderRadius: BorderRadius.circular(14),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(children: [+ Icon(icon, size: 20, color: fg),+ const SizedBox(width: 10),+ Expanded(+ child: Text(+ title,+ style: tt.bodyMedium+ ?.copyWith(color: fg, fontWeight: FontWeight.w600),+ ),+ ),+ ]),+ if (detail != null) ...[+ const SizedBox(height: 4),+ Padding(+ padding: const EdgeInsets.only(left: 30),+ child: Text(+ detail,+ style: tt.bodySmall?.copyWith(color: fg.withValues(alpha: 0.8)),+ ),+ ),+ ],+ ],+ ),+ );+ }++ @override+ Widget build(BuildContext context) {+ final l = AppLocalizations.of(context)!;+ final cs = Theme.of(context).colorScheme;+ final tt = Theme.of(context).textTheme;++ return Scaffold(+ appBar: AppBar(title: Text(l.backupAndSync)),+ body: _loading+ ? const Center(child: CircularProgressIndicator())+ : ListView(+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 32),+ children: [+ _statusBanner(l, cs, tt),+ const SizedBox(height: 22),++ Text(l.syncSettingsBackupFile,+ style: tt.titleSmall+ ?.copyWith(fontWeight: FontWeight.w600)),+ const SizedBox(height: 4),+ Text(+ // The "sets sync up on the other phone" half is only true+ // when sync is actually on, and reads as a puzzle otherwise.+ _enabled+ ? l.syncSettingsBackupFileWithSync+ : l.syncSettingsBackupFilePlain,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ const SizedBox(height: 12),+ Row(children: [+ Expanded(+ child: FilledButton.tonalIcon(+ icon: const Icon(Icons.upload_rounded, size: 18),+ label: Text(l.backUp),+ onPressed: () => _backupSettings(context),+ ),+ ),+ const SizedBox(width: 10),+ Expanded(+ child: OutlinedButton.icon(+ icon: const Icon(Icons.download_rounded, size: 18),+ label: Text(l.restore),+ onPressed: () => _restoreSettings(context),+ ),+ ),+ ]),++ const SizedBox(height: 26),+ SwitchListTile(+ contentPadding: EdgeInsets.zero,+ title: Text(l.syncSettings,+ style: tt.titleSmall+ ?.copyWith(fontWeight: FontWeight.w600)),+ subtitle: Text(+ l.syncSettingsSubtitle,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ value: _enabled,+ onChanged: _busy+ ? null+ : (v) async {+ await _sync.setEnabled(v);+ if (!mounted) return;+ setState(() => _enabled = v);+ },+ ),++ // Shown whether sync is on or off: someone deciding whether to+ // turn it on is exactly who needs to read it.+ Container(+ width: double.infinity,+ padding: const EdgeInsets.all(12),+ decoration: BoxDecoration(+ border: Border.all(color: cs.outlineVariant),+ borderRadius: BorderRadius.circular(12),+ ),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Icon(Icons.science_outlined,+ size: 18, color: cs.onSurfaceVariant),+ const SizedBox(width: 10),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(l.syncSettingsExperimental,+ style: tt.bodySmall?.copyWith(+ fontWeight: FontWeight.w600)),+ const SizedBox(height: 2),+ Text(+ l.syncSettingsExperimentalBody,+ style: tt.bodySmall+ ?.copyWith(color: cs.onSurfaceVariant),+ ),+ ],+ ),+ ),+ ],+ ),+ ),++ if (_enabled) ...[+ const SizedBox(height: 12),+ Card(+ elevation: 0,+ color: cs.surfaceContainerHigh,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(14)),+ child: ListTile(+ leading: Icon(Icons.dns_rounded, color: cs.primary),+ title: Text(l.syncSettingsConnection),+ subtitle: Text(+ _connectionSummary.isEmpty+ ? l.syncSettingsConnectionNotSet+ : _connectionSummary,+ style:+ tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ trailing: Icon(Icons.chevron_right_rounded,+ color: cs.onSurfaceVariant),+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(14)),+ onTap: () async {+ await Navigator.push(+ context,+ MaterialPageRoute(+ builder: (_) => const SyncConnectionScreen()),+ );+ await _load();+ },+ ),+ ),+ SwitchListTile(+ contentPadding: EdgeInsets.zero,+ title: Text(l.syncSettingsIncludeRmab),+ subtitle: Text(+ l.syncSettingsIncludeRmabSub,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ value: _syncRmab,+ onChanged: _busy+ ? null+ : (v) async {+ await _sync.setSyncRmab(v);+ if (!mounted) return;+ setState(() => _syncRmab = v);+ },+ ),+ const SizedBox(height: 8),+ Row(children: [+ Expanded(+ child: FilledButton.tonalIcon(+ icon: const Icon(Icons.cloud_upload_rounded, size: 18),+ label: Text(l.syncSettingsUploadNow),+ onPressed: _busy ? null : () => _run(_sync.push),+ ),+ ),+ const SizedBox(width: 10),+ Expanded(+ child: OutlinedButton.icon(+ icon:+ const Icon(Icons.cloud_download_rounded, size: 18),+ label: Text(l.syncSettingsDownloadNow),+ onPressed: _busy ? null : _downloadNow,+ ),+ ),+ ]),+ const SizedBox(height: 20),+ Text(+ l.syncSettingsWhatTravels,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ ],+ ],+ ),+ );+ }+}diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex a8cb9fe1..9994dc77 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -1,11 +1,9 @@import 'dart:async';-import 'dart:convert';import 'dart:io';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:provider/provider.dart';import 'package:permission_handler/permission_handler.dart';-import 'package:file_picker/file_picker.dart';import 'package:background_downloader/background_downloader.dart';import 'package:url_launcher/url_launcher.dart';import 'package:just_audio/just_audio.dart' show AudioPlayer;@@ -16,7 +14,6 @@ import '../services/download_service.dart';import '../services/episode_notification_service.dart';import '../services/sleep_timer_service.dart';import '../services/user_account_service.dart';-import '../services/backup_service.dart';import '../services/log_service.dart';import '../services/scoped_prefs.dart';import '../services/socket_service.dart';@@ -29,6 +26,8 @@ import '../widgets/update_dialog.dart';import '../screens/admin_screen.dart';import '../screens/downloads_screen.dart';import '../screens/bookmarks_screen.dart';+import '../screens/backup_sync_screen.dart';+import '../services/settings_sync_service.dart';import '../screens/change_password_screen.dart';import '../screens/auth_sessions_screen.dart';import '../main.dart' show applyThemeMode, applyTrustAllCerts, applyFlatBackground, applyColorSource, applyManualSeed, applyGradientIntensity, applyUseColorEverywhere, applyOrientationLock, localeNotifier, flatNotifier, gradientIntensityNotifier, snappyTransitionsNotifier;@@ -227,6 +226,7 @@ class _SettingsScreenState extends State<SettingsScreen> {_localServerController = TextEditingController();_loadSettings();_loadAdminIssueCount();+ _refreshSyncStatus();SocketService().addItemsChangedListener(_onServerItemsChanged);PlayerSettings.settingsChanged.addListener(_onExternalSettingsChange);}@@ -3880,42 +3880,30 @@ class _SettingsScreenState extends State<SettingsScreen> {const SizedBox(height: 16),- // ── Backup & Restore ──+ // ── Backup and sync ──Padding(padding: const EdgeInsets.symmetric(horizontal: 16),child: Card(elevation: 0,color: cs.surfaceContainerHigh,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),- child: Padding(- padding: const EdgeInsets.all(16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(children: [- Icon(Icons.settings_backup_restore_rounded, color: cs.primary, size: 22),- const SizedBox(width: 10),- Text(l.backupAndRestore, style: tt.titleSmall?.copyWith(fontWeight: FontWeight.w600)),- ]),- const SizedBox(height: 4),- Text(l.backupAndRestoreSubtitle,- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),- const SizedBox(height: 14),- Row(children: [- Expanded(child: FilledButton.tonalIcon(- icon: const Icon(Icons.upload_rounded, size: 18),- label: Text(l.backUp),- onPressed: () => _backupSettings(context, cs, tt),- )),- const SizedBox(width: 10),- Expanded(child: OutlinedButton.icon(- icon: const Icon(Icons.download_rounded, size: 18),- label: Text(l.restore),- onPressed: () => _restoreSettings(context, cs, tt),- )),- ]),- ],- ),+ child: ListTile(+ leading: Icon(Icons.cloud_sync_rounded, color: cs.primary),+ title: Text(l.backupAndSync),+ subtitle: Text(_backupSyncStatus(l),+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ trailing: Icon(Icons.chevron_right_rounded, color: cs.onSurfaceVariant),+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),+ onTap: () async {+ await Navigator.push(context,+ MaterialPageRoute(builder: (_) => const BackupSyncScreen()));+ if (mounted) await _refreshSyncStatus();+ },+ // Shortcut for the impatient: push straight from here+ // rather than opening the screen for one button. Only+ // offered while sync is on, since there is nowhere to+ // send it otherwise.+ onLongPress: _syncOn ? () => _uploadSyncNow(l) : null,),),),@@ -4286,198 +4274,68 @@ class _SettingsScreenState extends State<SettingsScreen> {);}- void _backupSettings(BuildContext context, ColorScheme cs, TextTheme tt) {- final l = AppLocalizations.of(context)!;- showDialog(- context: context,- builder: (ctx) => AlertDialog(- icon: const Icon(Icons.shield_rounded),- title: Text(l.includeLoginInfoTitle),- content: Text(l.includeLoginInfoContent),- actions: [- TextButton(- onPressed: () {- Navigator.pop(ctx);- _performBackup(context, includeAccounts: false);- },- child: Text(l.noSettingsOnly),- ),- FilledButton(- onPressed: () {- Navigator.pop(ctx);- _performBackup(context, includeAccounts: true);- },- child: Text(l.yesIncludeAccounts),- ),- ],- ),- );- }+ bool _syncUploading = false;- Future<void> _performBackup(BuildContext context, {required bool includeAccounts}) async {- final l = AppLocalizations.of(context)!;+ /// Long-press upload from the settings row. Goes through the content check+ /// rather than forcing a push: an upload that changes nothing still bumps the+ /// file's timestamp, which wakes the other device to apply an identical copy.+ Future<void> _uploadSyncNow(AppLocalizations l) async {+ if (_syncUploading) return;+ _syncUploading = true;+ HapticFeedback.mediumImpact();try {- final data = await BackupService.exportSettings(includeAccounts: includeAccounts);- final jsonStr = const JsonEncoder.withIndent(' ').convert(data);- final now = DateTime.now();- final datePart = '${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')}';- final fileName = 'absorb_backup_$datePart.absorb';-- final bytes = Uint8List.fromList(utf8.encode(jsonStr));-- final result = await FilePicker.platform.saveFile(- dialogTitle: l.saveAbsorbBackup,- fileName: fileName,- type: FileType.any,- bytes: bytes,+ final result = await SettingsSyncService().pushIfChanged();+ if (!mounted) return;+ await _refreshSyncStatus();+ if (!mounted) return;+ final message = result.ok+ ? (result.message == 'unchanged'+ ? l.syncSettingsUpToDate+ : l.syncSettingsUploaded)+ : l.syncSettingsNetworkError;+ showOverlayToast(+ context,+ message,+ icon: result.ok+ ? Icons.check_circle_outline_rounded+ : Icons.error_outline_rounded,);-- if (result != null) {- // Desktop platforms need manual file write; mobile writes via bytes param- if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {- await File(result).writeAsString(jsonStr);- }- if (mounted) {- showOverlayToast(- context,- includeAccounts- ? l.backupSavedWithAccounts- : l.backupSavedSettingsOnly,- icon: Icons.check_circle_outline_rounded,- );- }- }- } catch (e) {- if (mounted) {- showOverlayToast(context, l.backupFailed(e.toString()),- icon: Icons.error_outline_rounded);- }+ } finally {+ _syncUploading = false;}}- void _restoreSettings(BuildContext context, ColorScheme cs, TextTheme tt) async {- final l = AppLocalizations.of(context)!;- try {- final result = await FilePicker.platform.pickFiles(type: FileType.any);- if (result == null || result.files.single.path == null) return;-- final file = File(result.files.single.path!);- final jsonStr = await file.readAsString();- final data = jsonDecode(jsonStr) as Map<String, dynamic>;-- if (data['version'] == null) {- if (mounted) {- showOverlayToast(context, l.invalidBackupFile,- icon: Icons.error_outline_rounded);- }- return;- }-- if (!mounted) return;-- final accounts = data['accounts'] as List<dynamic>?;- final hasAccounts = accounts != null && accounts.isNotEmpty;- final hasCustomHeaders = data['customHeaders'] != null;- final createdAt = data['createdAt'] as String?;- final appVersion = data['appVersion'] as String?;-- String details = '';- if (appVersion != null) details += l.fromAbsorbVersion(appVersion);- if (createdAt != null) {- final dt = DateTime.tryParse(createdAt);- if (dt != null) {- details += details.isEmpty ? '' : l.backupDetailsSeparator;- details += l.backupDateFormat(dt.month, dt.day, dt.year);- }- }-- final confirmed = await showDialog<bool>(- context: context,- builder: (ctx) => AlertDialog(- icon: const Icon(Icons.restore_rounded),- title: Text(l.restoreBackupTitle),- content: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(l.restoreBackupContent),- if (details.isNotEmpty) ...[- const SizedBox(height: 12),- Text(details, style: TextStyle(color: cs.onSurfaceVariant, fontSize: 12)),- ],- if (hasAccounts || hasCustomHeaders) ...[- const SizedBox(height: 12),- Wrap(- spacing: 8,- runSpacing: 8,- children: [- if (hasAccounts)- _restoreChip(Icons.people_rounded, l.restoreAccountsChip(accounts.length), cs),- if (hasCustomHeaders)- _restoreChip(Icons.vpn_key_rounded, l.restoreCustomHeadersChip, cs),- ],- ),- ],- ],- ),- actions: [- TextButton(- onPressed: () => Navigator.pop(ctx, false),- child: Text(l.cancel),- ),- FilledButton(- onPressed: () => Navigator.pop(ctx, true),- child: Text(l.restore),- ),- ],- ),- );-- if (confirmed != true || !mounted) return;-- await BackupService.importSettings(data);-- // Apply theme immediately- final settings = data['settings'] as Map<String, dynamic>?;- final theme = settings?['themeMode'] as String?;- if (theme != null) {- applyThemeMode(theme);- }- if (settings?['flatBackground'] is bool) applyFlatBackground(settings!['flatBackground'] as bool);- if (settings?['colorSource'] is String) applyColorSource(settings!['colorSource'] as String);- if (settings?['manualSeedColor'] is int) applyManualSeed(settings!['manualSeedColor'] as int);- if (settings?['gradientIntensity'] is num) applyGradientIntensity((settings!['gradientIntensity'] as num).toDouble());- if (settings?['useColorEverywhere'] is bool) applyUseColorEverywhere(settings!['useColorEverywhere'] as bool);- await applyOrientationLock();-- // Refresh UI- await _loadSettings();+ DateTime? _syncLastAt;+ bool _syncOn = false;++ /// Live status for the settings row, so the common question - is it syncing,+ /// and when did it last manage it - is answered without opening the screen.+ String _backupSyncStatus(AppLocalizations l) {+ if (!_syncOn) return l.backupAndSyncSubtitle;+ final at = _syncLastAt;+ final status =+ at == null ? l.syncSettingsNever : l.syncSettingsLastSynced(_syncTimeAgo(l, at));+ // A long-press nobody is told about is a long-press nobody uses, and this+ // row is the only place it could be discovered.+ return '$status · ${l.syncSettingsHoldToUpload}';+ }- if (mounted) {- showOverlayToast(context, l.settingsRestoredSuccessfully,- icon: Icons.check_circle_outline_rounded);- }- } catch (e) {- if (mounted) {- showOverlayToast(context, l.restoreFailed(e.toString()),- icon: Icons.error_outline_rounded);- }- }+ static String _syncTimeAgo(AppLocalizations l, DateTime dt) {+ final d = DateTime.now().difference(dt);+ if (d.inSeconds < 60) return l.justNow.toLowerCase();+ if (d.inMinutes < 60) return l.minutesAgo(d.inMinutes);+ if (d.inHours < 24) return l.hoursAgo(d.inHours);+ return l.daysAgo(d.inDays);}- Widget _restoreChip(IconData icon, String label, ColorScheme cs) {- return Container(- padding: const EdgeInsets.all(10),- decoration: BoxDecoration(- color: cs.primaryContainer.withValues(alpha: 0.15),- borderRadius: BorderRadius.circular(8),- ),- child: Row(mainAxisSize: MainAxisSize.min, children: [- Icon(icon, size: 16, color: cs.primary),- const SizedBox(width: 8),- Text(label, style: TextStyle(fontSize: 12, color: cs.primary)),- ]),- );+ Future<void> _refreshSyncStatus() async {+ final on = await SettingsSyncService().getEnabled();+ final at = await SettingsSyncService().getLastSyncTime();+ if (!mounted) return;+ setState(() {+ _syncOn = on;+ _syncLastAt = at;+ });}void _showAccountSheet(BuildContext context) {diff --git a/lib/screens/sync_connection_screen.dart b/lib/screens/sync_connection_screen.dartnew file mode 100644index 00000000..8d31a670--- /dev/null+++ b/lib/screens/sync_connection_screen.dart@@ -0,0 +1,240 @@+import 'package:flutter/material.dart';+import 'package:url_launcher/url_launcher.dart';++import '../l10n/app_localizations.dart';+import '../services/settings_sync_service.dart';+import '../widgets/overlay_toast.dart';++/// Where the WebDAV folder lives and how to sign in. Split off the main backup+/// and sync screen because these four fields are filled in once and then never+/// touched, so they do not deserve permanent space above the controls people+/// actually use.+class SyncConnectionScreen extends StatefulWidget {+ const SyncConnectionScreen({super.key});++ @override+ State<SyncConnectionScreen> createState() => _SyncConnectionScreenState();+}++class _SyncConnectionScreenState extends State<SyncConnectionScreen> {+ final _sync = SettingsSyncService();+ final _urlCtrl = TextEditingController();+ final _userCtrl = TextEditingController();+ final _passCtrl = TextEditingController();+ final _headersCtrl = TextEditingController();++ bool _loading = true;+ bool _busy = false;+ bool _obscurePass = true;++ @override+ void initState() {+ super.initState();+ _load();+ }++ @override+ void dispose() {+ _urlCtrl.dispose();+ _userCtrl.dispose();+ _passCtrl.dispose();+ _headersCtrl.dispose();+ super.dispose();+ }++ Future<void> _load() async {+ final url = await _sync.getUrl();+ final user = await _sync.getUsername();+ final pass = await _sync.getPassword();+ final headers = await _sync.getCustomHeaders();+ if (!mounted) return;+ setState(() {+ _urlCtrl.text = url ?? '';+ _userCtrl.text = user ?? '';+ _passCtrl.text = pass ?? '';+ _headersCtrl.text = SettingsSyncService.headerLines(headers);+ _loading = false;+ });+ }++ Future<void> _persist() async {+ await _sync.setUrl(_urlCtrl.text);+ await _sync.setUsername(_userCtrl.text);+ await _sync.setPassword(_passCtrl.text);+ await _sync.setCustomHeaders(+ SettingsSyncService.parseHeaderLines(_headersCtrl.text),+ );+ }++ String _describe(AppLocalizations l, SyncResult r) {+ switch (r.status) {+ case SyncStatus.ok:+ return l.syncSettingsOk;+ case SyncStatus.noRemote:+ return l.syncSettingsNoRemote;+ case SyncStatus.authFailed:+ return l.syncSettingsAuthFailed;+ case SyncStatus.notConfigured:+ return l.syncSettingsNotConfigured;+ case SyncStatus.tooLarge:+ return l.syncSettingsTooLarge;+ case SyncStatus.network:+ return l.syncSettingsNetworkError;+ }+ }++ Future<void> _test() async {+ final l = AppLocalizations.of(context)!;+ setState(() => _busy = true);+ await _persist();+ final result = await _sync.testConnection();+ if (!mounted) return;+ setState(() => _busy = false);+ final good = result.ok || result.status == SyncStatus.noRemote;+ if (!good && result.detail != null) {+ await showDialog<void>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.error_outline_rounded),+ title: Text(_describe(l, result)),+ content: SingleChildScrollView(+ child: SelectableText(+ result.detail!,+ style: Theme.of(ctx)+ .textTheme+ .bodySmall+ ?.copyWith(fontFamily: 'monospace'),+ ),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx),+ child: Text(l.ok),+ ),+ ],+ ),+ );+ return;+ }+ showOverlayToast(+ context,+ _describe(l, result),+ icon: good+ ? Icons.check_circle_outline_rounded+ : Icons.error_outline_rounded,+ );+ }++ @override+ Widget build(BuildContext context) {+ final l = AppLocalizations.of(context)!;++ return Scaffold(+ appBar: AppBar(title: Text(l.syncSettingsConnection)),+ // Save on the way out so a filled-in field is never lost to a back tap.+ body: PopScope(+ canPop: true,+ onPopInvokedWithResult: (didPop, _) {+ if (didPop) _persist();+ },+ child: _loading+ ? const Center(child: CircularProgressIndicator())+ : ListView(+ padding: const EdgeInsets.fromLTRB(16, 16, 16, 32),+ children: [+ TextField(+ controller: _urlCtrl,+ keyboardType: TextInputType.url,+ autocorrect: false,+ decoration: InputDecoration(+ labelText: l.syncSettingsServerUrl,+ hintText: l.syncSettingsServerUrlHint,+ hintMaxLines: 2,+ border: const OutlineInputBorder(),+ ),+ ),+ const SizedBox(height: 12),+ TextField(+ controller: _userCtrl,+ autocorrect: false,+ decoration: InputDecoration(+ labelText: l.syncSettingsUsername,+ border: const OutlineInputBorder(),+ ),+ ),+ const SizedBox(height: 12),+ TextField(+ controller: _passCtrl,+ obscureText: _obscurePass,+ autocorrect: false,+ decoration: InputDecoration(+ labelText: l.syncSettingsPassword,+ border: const OutlineInputBorder(),+ suffixIcon: IconButton(+ icon: Icon(_obscurePass+ ? Icons.visibility_rounded+ : Icons.visibility_off_rounded),+ onPressed: () =>+ setState(() => _obscurePass = !_obscurePass),+ ),+ ),+ ),+ const SizedBox(height: 12),+ TextField(+ controller: _headersCtrl,+ autocorrect: false,+ minLines: 1,+ maxLines: 4,+ decoration: InputDecoration(+ labelText: l.syncSettingsHeaders,+ hintText: l.syncSettingsHeadersHint,+ hintMaxLines: 2,+ border: const OutlineInputBorder(),+ ),+ ),+ const SizedBox(height: 20),+ OutlinedButton.icon(+ icon: const Icon(Icons.wifi_tethering_rounded, size: 18),+ label: Text(l.syncSettingsTest),+ onPressed: _busy ? null : _test,+ ),+ const SizedBox(height: 24),+ // Named as an example, not a requirement - this is plain+ // WebDAV and works against anything that speaks it.+ Card(+ elevation: 0,+ color: Theme.of(context).colorScheme.surfaceContainerHigh,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(14)),+ child: ListTile(+ leading: Icon(Icons.cloud_queue_rounded,+ color: Theme.of(context).colorScheme.primary),+ title: Text(l.syncSettingsNeedServer),+ subtitle: Text(+ l.syncSettingsNeedServerSub,+ style: Theme.of(context)+ .textTheme+ .bodySmall+ ?.copyWith(+ color: Theme.of(context)+ .colorScheme+ .onSurfaceVariant),+ ),+ trailing: Icon(Icons.open_in_new_rounded,+ size: 18,+ color: Theme.of(context)+ .colorScheme+ .onSurfaceVariant),+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(14)),+ onTap: () => launchUrl(+ Uri.parse('https://nextcloud.com/install/'),+ mode: LaunchMode.externalApplication),+ ),+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dartindex 3083becd..454d6af8 100644--- a/lib/services/backup_service.dart+++ b/lib/services/backup_service.dart@@ -195,8 +195,12 @@ class BackupService {// Saved ebooks (scoped)final savedEbooks = await ScopedPrefs.getStringList('saved_ebooks');- // Rolling download series (scoped)+ // Rolling download series (scoped). The id set carries no type, so the+ // companion name map has to come along or the auto-download list restores+ // as a column of unnamed ids until the caches happen to repopulate.final rollingDownloadSeries = await ScopedPrefs.getStringList('rolling_download_series');+ final rollingDownloadSourceNames =+ await ScopedPrefs.getString('rolling_download_source_names');// Upcoming-scan per-series overrides + removed-books list (scoped)final upcomingAlwaysScan = await ScopedPrefs.getStringList('upcoming_always_scan_series');@@ -324,6 +328,24 @@ class BackupService {// Custom download path (GLOBAL)final customDownloadPath = prefs.getString('custom_download_path');+ // Settings-sync setup (scoped). This lives in the backup file but never in+ // the synced payload itself - a sync config that synced itself would be+ // circular, and the point of putting it here is that restoring a backup on+ // a second phone leaves the two already keeping each other in step.+ //+ // The WebDAV password rides with `includeAccounts` for the same reason the+ // server tokens do: a settings-only backup is a file people hand around,+ // and it should not carry the key to their Nextcloud.+ final settingsSync = <String, dynamic>{+ 'url': await ScopedPrefs.getString('settingsSyncUrl'),+ 'username': await ScopedPrefs.getString('settingsSyncUser'),+ 'headers': await ScopedPrefs.getString('settingsSyncHeaders'),+ 'enabled': await ScopedPrefs.getBool('settingsSyncEnabled'),+ 'includeRmab': await ScopedPrefs.getBool('settingsSyncIncludeRmab'),+ if (includeAccounts)+ 'password': await ScopedPrefs.getString('settingsSyncPass'),+ }..removeWhere((_, v) => v == null);+// Accounts & custom headers (optional - contain auth data)List<Map<String, dynamic>>? accounts;Map<String, String>? customHeaders;@@ -353,6 +375,9 @@ class BackupService {'notes': notes,'savedEbooks': savedEbooks,'rollingDownloadSeries': rollingDownloadSeries,+ if (rollingDownloadSourceNames != null &&+ rollingDownloadSourceNames.isNotEmpty)+ 'rollingDownloadSourceNames': rollingDownloadSourceNames,'upcomingAlwaysScan': upcomingAlwaysScan,'upcomingNeverScan': upcomingNeverScan,if (upcomingIgnoredBooks != null && upcomingIgnoredBooks.isNotEmpty)@@ -376,6 +401,7 @@ class BackupService {'ereader': ereader,'podcastPrefs': podcastPrefs,'customDownloadPath': customDownloadPath,+ if (settingsSync.isNotEmpty) 'settingsSync': settingsSync,'accounts': accounts,'customHeaders': customHeaders,};@@ -676,6 +702,53 @@ class BackupService {rollingDownloadSeries.cast<String>(),);}+ final rollingDownloadSourceNames =+ data['rollingDownloadSourceNames'] as String?;+ if (rollingDownloadSourceNames != null &&+ rollingDownloadSourceNames.isNotEmpty) {+ await ScopedPrefs.setString(+ 'rolling_download_source_names',+ rollingDownloadSourceNames,+ );+ }++ // Settings-sync setup. Restoring it is what makes a backup taken on one+ // phone leave the second one already syncing. A backup saved without login+ // info carries no password, so sync stays switched off until one is typed+ // rather than silently failing to authenticate on every foreground.+ final settingsSync = data['settingsSync'] as Map<String, dynamic>?;+ if (settingsSync != null) {+ final url = settingsSync['url'] as String?;+ final username = settingsSync['username'] as String?;+ final headers = settingsSync['headers'] as String?;+ final password = settingsSync['password'] as String?;+ if (url != null) await ScopedPrefs.setString('settingsSyncUrl', url);+ if (username != null) {+ await ScopedPrefs.setString('settingsSyncUser', username);+ }+ if (headers != null) {+ await ScopedPrefs.setString('settingsSyncHeaders', headers);+ }+ if (password != null) {+ await ScopedPrefs.setString('settingsSyncPass', password);+ }+ if (settingsSync['includeRmab'] is bool) {+ await ScopedPrefs.setBool(+ 'settingsSyncIncludeRmab',+ settingsSync['includeRmab'] as bool,+ );+ }+ final wantEnabled = settingsSync['enabled'] == true;+ await ScopedPrefs.setBool(+ 'settingsSyncEnabled',+ wantEnabled && password != null && password.isNotEmpty,+ );+ // This device has just taken on another's settings wholesale, so clear+ // the sync bookkeeping: leaving the donor's "last seen" timestamp behind+ // would make the next pull think it had already caught up.+ await ScopedPrefs.remove('settingsSyncLastSeen');+ await ScopedPrefs.remove('settingsSyncLastHash');+ }// Upcoming-scan per-series overrides (scoped)final upcomingAlwaysScan = data['upcomingAlwaysScan'] as List<dynamic>?;diff --git a/lib/services/ebook_annotation_service.dart b/lib/services/ebook_annotation_service.dartindex b0a3b5ad..4e7a61bd 100644--- a/lib/services/ebook_annotation_service.dart+++ b/lib/services/ebook_annotation_service.dart@@ -1,6 +1,7 @@import 'dart:convert';import 'package:flutter/foundation.dart';import 'scoped_prefs.dart';+import 'settings_sync_service.dart';/// Types of ebook annotations.enum AnnotationType { highlight, bookmark }@@ -103,6 +104,11 @@ class EbookAnnotationService {Future<void> _save(String itemId, List<EbookAnnotation> annotations) async {final json = jsonEncode(annotations.map((a) => a.toJson()).toList());await ScopedPrefs.setString(_key(itemId), json);+ // Highlights and bookmarks live only on the device, so settings sync is+ // their only way to another one. Writing straight to prefs like this is+ // invisible to the settings-changed notifier, so tell sync directly rather+ // than leaving it to the periodic sweep.+ SettingsSyncService().noteLocalChange();}/// Add a highlight.diff --git a/lib/services/settings_sync_service.dart b/lib/services/settings_sync_service.dartnew file mode 100644index 00000000..5f38c377--- /dev/null+++ b/lib/services/settings_sync_service.dart@@ -0,0 +1,788 @@+import 'dart:async';+import 'dart:convert';++import 'package:crypto/crypto.dart';+import 'package:flutter/material.dart';+import 'package:http/http.dart' as http;++import 'package:provider/provider.dart';++import '../l10n/app_localizations.dart';+import '../main.dart' show rootNavigatorKey, applyAppearanceFromPrefs;+import '../providers/library_provider.dart';+import '../widgets/overlay_toast.dart';+import 'backup_service.dart';+import 'player_settings.dart';+import 'scoped_prefs.dart';+import 'user_account_service.dart';++enum SyncStatus {+ ok,+ notConfigured,+ noRemote,+ authFailed,+ network,+ tooLarge,+}++class SyncResult {+ final SyncStatus status;+ final String? message;++ /// The real reason, kept verbatim for the settings screen to show: the HTTP+ /// status, or the exception type and text, plus the URL that was actually+ /// requested. A generic "could not reach that address" hides whether the+ /// server said no, the name did not resolve, or a redirect landed on a+ /// certificate the app will not trust.+ final String? detail;++ const SyncResult(this.status, [this.message, this.detail]);++ bool get ok => status == SyncStatus.ok;+}++/// Keeps app settings in step across a user's devices by parking one JSON file+/// on their own WebDAV server (Nextcloud and friends). It reuses the backup+/// payload rather than inventing a second serializer, but only an explicit+/// subset of it travels - see [_syncedKeys].+///+/// WebDAV rather than Drive: it works on the GMS-free F-Droid build, most+/// self-hosters already have one, and a push is a single authenticated PUT+/// with no OAuth dance.+class SettingsSyncService {+ static final SettingsSyncService _instance = SettingsSyncService._();+ factory SettingsSyncService() => _instance;+ SettingsSyncService._();++ /// Swapped out in tests so the WebDAV round trip can be exercised without a+ /// server. Null in the app, which falls through to the package-level helpers.+ @visibleForTesting+ static http.Client? testClient;++ Future<http.Response> _put(Uri url, Map<String, String> headers, String body) {+ final c = testClient;+ return c != null+ ? c.put(url, headers: headers, body: body)+ : http.put(url, headers: headers, body: body);+ }++ Future<http.Response> _getUrl(Uri url, Map<String, String> headers) {+ final c = testClient;+ return c != null ? c.get(url, headers: headers) : http.get(url, headers: headers);+ }++ /// The ONLY top-level backup keys that ever leave the device. This is an+ /// allowlist and not a denylist on purpose: a key added to the backup later+ /// must not start syncing just because someone forgot this file exists.+ ///+ /// Deliberately absent, and why:+ /// - pendingSyncs / pendingOfflineListening / offlineListening /+ /// bookmarksPending* / pendingEbookProgress: this device's unsent listening+ /// ledger. Copy it to a second device and both flush the same entries,+ /// which is what produced the 28h phantom session.+ /// - accounts / customHeaders: real server tokens. Also, ABS rotates refresh+ /// tokens, so a stale one arriving from the file could overwrite a freshly+ /// rotated one and strand the session.+ /// - rmab: carries an API token, so it is opt-in rather than absent - see+ /// [getSyncRmab].+ /// - customDownloadPath: a path that is only true on one phone.+ /// - offlineMode: a per-device switch.+ static const _syncedKeys = <String>{+ 'settings',+ 'autoRewind',+ 'autoSleep',+ 'equalizer',+ 'bookSpeeds',+ 'notes',+ 'savedEbooks',+ 'rollingDownloadSeries',+ 'upcomingAlwaysScan',+ 'upcomingNeverScan',+ 'upcomingIgnoredBooks',+ 'subscribedPodcasts',+ 'absorbingManualAdds',+ 'absorbingFinishedManualAdds',+ 'absorbingManualRemoves',+ 'yearHiddenIds',+ 'homeLayouts',+ 'librarySettings',+ 'metadataOverrides',+ 'ebookAnnotations',+ 'ereader',+ 'podcastPrefs',+ };++ /// Entries inside the settings bucket that never travel, even though+ /// `settings` itself does. Stripped in BOTH directions.+ ///+ /// `trustAllCerts` is the one that matters: it feeds the global+ /// badCertificateCallback, so accepting it from the remote file would let+ /// anyone who can write to that file turn off certificate checking on every+ /// device that pulls. A sync file is not allowed to weaken transport+ /// security, so this stays a decision made on the device it applies to.+ ///+ /// `loggingEnabled` is here for a duller reason - you turn debug logging on+ /// for the device you are debugging, not for all of them.+ ///+ /// The local server address deliberately is NOT here: it travels with+ /// everything else, on the basis that a user's devices are usually on the+ /// same network as their server.+ static const _deviceLocalSettings = <String>{+ 'loggingEnabled',+ 'trustAllCerts',+ };++ /// Refuse to push anything bigger than this. Ebook annotations and per-item+ /// metadata overrides are unbounded, and silently shipping a huge blob to+ /// someone's Nextcloud every time a setting changes is not a kindness.+ static const _maxPayloadBytes = 2 * 1024 * 1024;++ static const _pushDebounce = Duration(seconds: 20);++ Timer? _debounce;++ /// Most settings never fire the change notifier - theme and default speed go+ /// through the plain setter, and the absorbing lists write prefs directly -+ /// so the debounce above misses nearly everything a user actually changes.+ /// Backgrounding is too late to rely on: the push is fire-and-forget and+ /// Android can freeze the process before the request lands. So while the app+ /// is open, check periodically whether the payload has moved. The check is a+ /// local hash and costs nothing when nothing changed.+ Timer? _changeCheck;+ static const _changeCheckInterval = Duration(seconds: 45);++ bool _started = false;+ bool _busy = false;+ DateTime? _lastPullAt;++ /// Applying a remote payload writes every setting locally, which fires the+ /// same change notification a user edit does. Left alone that pushes the+ /// settings straight back up with a fresh timestamp, the other device pulls+ /// them, applies, pushes again, and the two ping-pong forever. Ignore+ /// changes for a moment after an import - long enough to cover the import's+ /// un-awaited setters settling, short enough that a real edit right after+ /// still gets picked up by the next one.+ DateTime? _suppressPushUntil;+ static const _suppressAfterImport = Duration(seconds: 10);++ // Config, scoped per account.++ Future<bool> getEnabled() async =>+ await ScopedPrefs.getBool('settingsSyncEnabled') ?? false;++ Future<void> setEnabled(bool v) async {+ await ScopedPrefs.setBool('settingsSyncEnabled', v);+ if (v) {+ start();+ } else {+ stop();+ }+ }++ Future<String?> getUrl() => ScopedPrefs.getString('settingsSyncUrl');+ Future<void> setUrl(String v) =>+ ScopedPrefs.setString('settingsSyncUrl', v.trim());++ Future<String?> getUsername() => ScopedPrefs.getString('settingsSyncUser');+ Future<void> setUsername(String v) =>+ ScopedPrefs.setString('settingsSyncUser', v.trim());++ Future<String?> getPassword() => ScopedPrefs.getString('settingsSyncPass');+ Future<void> setPassword(String v) =>+ ScopedPrefs.setString('settingsSyncPass', v);++ /// Extra headers sent with every WebDAV request, for folders that sit behind+ /// a proxy wanting its own header (Cloudflare Access and friends). Not an+ /// alternative to the username and password - it rides alongside them.+ Future<Map<String, String>> getCustomHeaders() async {+ final raw = await ScopedPrefs.getString('settingsSyncHeaders');+ if (raw == null || raw.trim().isEmpty) return const {};+ try {+ final decoded = jsonDecode(raw);+ if (decoded is Map) {+ return decoded.map((k, v) => MapEntry('$k', '$v'));+ }+ } catch (_) {}+ return const {};+ }++ Future<void> setCustomHeaders(Map<String, String> headers) =>+ ScopedPrefs.setString(+ 'settingsSyncHeaders',+ headers.isEmpty ? '' : jsonEncode(headers),+ );++ /// Parse the settings screen's one-per-line `Name: value` text. Lines+ /// without a colon are skipped rather than silently mangled.+ static Map<String, String> parseHeaderLines(String text) {+ final out = <String, String>{};+ for (final line in text.split('\n')) {+ final trimmed = line.trim();+ if (trimmed.isEmpty) continue;+ final idx = trimmed.indexOf(':');+ if (idx <= 0) continue;+ final name = trimmed.substring(0, idx).trim();+ final value = trimmed.substring(idx + 1).trim();+ if (name.isEmpty) continue;+ out[name] = value;+ }+ return out;+ }++ static String headerLines(Map<String, String> headers) =>+ headers.entries.map((e) => '${e.key}: ${e.value}').join('\n');++ /// Opt-in because the ReadMeABook config carries an API token, and that is+ /// the user's decision to make about their own storage rather than a default+ /// worth choosing for them.+ Future<bool> getSyncRmab() async =>+ await ScopedPrefs.getBool('settingsSyncIncludeRmab') ?? false;+ Future<void> setSyncRmab(bool v) =>+ ScopedPrefs.setBool('settingsSyncIncludeRmab', v);++ /// Top-level keys allowed right now, base set plus whatever the user opted+ /// into. Resolved fresh on both push and pull, and it is deliberately THIS+ /// device's choice that decides on the way in - a remote file cannot opt a+ /// device into receiving something it has turned off.+ ///+ /// Server logins are not on offer here at any setting. Beyond the tokens+ /// themselves, ABS rotates refresh tokens, so a stale one arriving from the+ /// file could overwrite a freshly rotated one and strand the session.+ Future<Set<String>> _activeKeys() async => {+ ..._syncedKeys,+ if (await getSyncRmab()) 'rmab',+ };+++ /// Epoch ms of the newest payload this device has either written or applied.+ /// Both directions compare against it, so a device never re-imports its own+ /// push and never quietly loses a newer copy it has not seen.+ Future<int> _lastSeen() async =>+ await ScopedPrefs.getInt('settingsSyncLastSeen') ?? 0;++ Future<void> _setLastSeen(int v) =>+ ScopedPrefs.setInt('settingsSyncLastSeen', v);++ /// Fingerprint of the last payload actually written, ignoring its timestamp.+ Future<String?> _lastHash() => ScopedPrefs.getString('settingsSyncLastHash');+ Future<void> _setLastHash(String v) =>+ ScopedPrefs.setString('settingsSyncLastHash', v);++ /// Encode with every map's keys sorted, at every depth.+ ///+ /// Several payload buckets - book speeds, home layouts, per-library+ /// settings, ebook annotations, podcast prefs - are built by walking+ /// `prefs.getKeys()`, which has no defined order. Plain `jsonEncode` then+ /// gives two devices different text for identical content, which made every+ /// pull report a handful of phantom changes and could push when nothing had+ /// actually moved.+ static String _canonical(Object? value) {+ if (value is Map) {+ final keys = value.keys.map((k) => '$k').toList()..sort();+ return '{${keys.map((k) => '${jsonEncode(k)}:${_canonical(value[k])}').join(',')}}';+ }+ if (value is List) {+ return '[${value.map(_canonical).join(',')}]';+ }+ return jsonEncode(value);+ }++ static String _hash(Map<String, dynamic> payload) {+ final copy = Map<String, dynamic>.from(payload)..remove('syncedAt');+ return sha256.convert(utf8.encode(_canonical(copy))).toString();+ }++ Future<DateTime?> getLastSyncTime() async {+ final ms = await _lastSeen();+ return ms > 0 ? DateTime.fromMillisecondsSinceEpoch(ms) : null;+ }++ // Lifecycle.++ /// Begin watching for settings changes when the user has this turned on.+ /// Safe to call repeatedly.+ Future<void> startIfEnabled() async {+ if (await getEnabled()) start();+ }++ void start() {+ if (_started) return;+ _started = true;+ PlayerSettings.settingsChanged.addListener(_onSettingsChanged);+ _changeCheck?.cancel();+ _changeCheck = Timer.periodic(+ _changeCheckInterval,+ (_) => unawaited(pushIfChanged()),+ );+ debugPrint(+ '[SettingsSync] started - change check every '+ '${_changeCheckInterval.inSeconds}s',+ );+ }++ void stop() {+ if (!_started) return;+ _started = false;+ _debounce?.cancel();+ _debounce = null;+ _changeCheck?.cancel();+ _changeCheck = null;+ PlayerSettings.settingsChanged.removeListener(_onSettingsChanged);+ debugPrint('[SettingsSync] stopped');+ }++ void _onSettingsChanged() {+ final until = _suppressPushUntil;+ if (until != null && DateTime.now().isBefore(until)) return;+ _debounce?.cancel();+ // Through the content check, not straight to push. The notifier fires for+ // plenty of things that never reach the payload (and fires repeatedly for+ // one user action), and every redundant upload bumps syncedAt, which makes+ // the other device wake up and "apply" a file identical to what it has.+ _debounce = Timer(_pushDebounce, () => unawaited(pushIfChanged()));+ }++ /// Nothing pulls while the app sits open, so this is the only chance to+ /// notice another device's changes. The guard is only here to collapse the+ /// double call at startup (main() and the first foreground) and any lifecycle+ /// flapping - it is deliberately short, because a long one would skip the+ /// pull for a quick app switch and then leave the settings stale for as long+ /// as the app stayed open, which is the very thing this is meant to fix.+ static const _foregroundPullGuard = Duration(seconds: 10);++ Future<void> onAppForegrounded() async {+ if (!await getEnabled()) return;+ final now = DateTime.now();+ if (_lastPullAt != null &&+ now.difference(_lastPullAt!) < _foregroundPullGuard) {+ return;+ }+ _lastPullAt = now;+ // Send anything this device is still holding BEFORE taking the remote copy.+ // A change made just before the app was swiped away never got its push -+ // the process was gone - so it is sitting here unsent. Pulling first would+ // overwrite it with the other device's older copy and then upload that,+ // losing the change silently. Pushing first stamps our copy as the newest,+ // and the pull below then sees its own timestamp and skips.+ if (await _hasUnsentChanges()) {+ debugPrint('[SettingsSync] unsent local changes - pushing before pulling');+ await pushIfChanged();+ }+ final result = await pull();+ // Settings quietly rearranging themselves is unnerving, so say so - but+ // only when something actually landed. A pull that found nothing new, or+ // could not reach the server, is not worth interrupting anyone for.+ if (result.ok && result.message == 'applied') {+ _toastApplied(_lastApplyCount);+ }+ // Catch anything that changed while the app was away without going through+ // the settings notifier - see [pushIfChanged].+ await pushIfChanged();+ }++ /// How many entries the last applied pull actually moved. A count rather+ /// than a list of names: naming them would need a translated label for every+ /// setting, and the first pull on a new device changes everything at once,+ /// which no toast can hold. The number answers the question someone actually+ /// has when settings shift under them - was that a tweak or a wholesale+ /// replace.+ int _lastApplyCount = 0;++ @visibleForTesting+ int get debugLastApplyCount => _lastApplyCount;++ /// Entries the incoming payload would actually move. Settings are counted+ /// one by one; every other bucket counts as a single thing, since "your home+ /// screen layout changed" is one fact to a reader, not fourteen.+ ///+ /// Only keys PRESENT in [after] are considered, because that is exactly what+ /// importSettings applies - a key the remote file omits leaves the local+ /// value alone, so counting it as a change would report a wholesale replace+ /// every time an older or partial payload arrived.+ static int _countChanges(+ Map<String, dynamic> before,+ Map<String, dynamic> after,+ ) {+ const ignored = {'syncedAt', 'version', 'appVersion'};+ var changed = 0;+ for (final key in after.keys) {+ if (ignored.contains(key)) continue;+ if (key == 'settings') {+ final b = before['settings'] as Map? ?? const {};+ final a = after['settings'] as Map? ?? const {};+ for (final sk in a.keys) {+ if (_canonical(b[sk]) != _canonical(a[sk])) changed++;+ }+ } else if (_canonical(before[key]) != _canonical(after[key])) {+ changed++;+ }+ }+ return changed;+ }++ /// Importing only rewrites SharedPreferences. Anything already holding those+ /// values in memory keeps serving the old ones, and the absorbing lists go+ /// further and write their stale copy back over what just arrived. So after+ /// an import, tell the live app to re-read.+ Future<void> _applyToRunningApp() async {+ try {+ await applyAppearanceFromPrefs();+ } catch (e) {+ debugPrint('[SettingsSync] appearance refresh failed: $e');+ }+ try {+ final navigator = rootNavigatorKey.currentState;+ final context = navigator?.context;+ if (context != null && context.mounted) {+ await Provider.of<LibraryProvider>(+ context,+ listen: false,+ ).reloadPrefsBackedState();+ }+ } catch (e) {+ debugPrint('[SettingsSync] library reload failed: $e');+ }+ // Skip amounts, notification labels and the rest of the player's cached+ // settings come back through the normal settings-changed path.+ PlayerSettings.notifySettingsChanged();+ }++ void _toastApplied(int count) {+ final navigator = rootNavigatorKey.currentState;+ if (navigator == null) return;+ final l = AppLocalizations.of(navigator.context);+ showNavigatorOverlayToast(+ navigator,+ l?.syncSettingsAppliedCount(count) ??+ '$count settings updated from your other device',+ icon: Icons.cloud_done_rounded,+ );+ }++ /// Whether this device is holding changes it has not managed to upload.+ Future<bool> _hasUnsentChanges() async {+ try {+ return _hash(await buildPayload()) != await _lastHash();+ } catch (_) {+ return false;+ }+ }++ /// Nudge from code that writes synced data straight to prefs without going+ /// through PlayerSettings - ebook highlights and bookmarks, mainly. Without+ /// it those wait for the periodic check, which is up to 45 seconds and does+ /// not run at all once the app is backgrounded.+ void noteLocalChange() {+ if (!_started) return;+ final until = _suppressPushUntil;+ if (until != null && DateTime.now().isBefore(until)) return;+ _debounce?.cancel();+ _debounce = Timer(_pushDebounce, () => unawaited(pushIfChanged()));+ }++ /// Push when the payload's content has actually moved, regardless of whether+ /// anything fired the settings notifier.+ ///+ /// Most of what syncs is written straight through ScopedPrefs and never+ /// notifies: ebook highlights, home layouts, per-book speeds, subscribed+ /// podcasts, the absorbing lists, per-library skip overrides. Hanging uploads+ /// solely off PlayerSettings.settingsChanged would leave all of that sitting+ /// on the device until some unrelated toggle happened to move. Comparing a+ /// hash of the payload catches it without making dozens of setters notify+ /// and rebuild the UI for no reason.+ Future<SyncResult> pushIfChanged() async {+ if (!await getEnabled()) return const SyncResult(SyncStatus.notConfigured);+ try {+ final hash = _hash(await buildPayload());+ if (hash == await _lastHash()) {+ return const SyncResult(SyncStatus.ok, 'unchanged');+ }+ debugPrint('[SettingsSync] settings moved since last upload - pushing');+ } catch (e) {+ debugPrint('[SettingsSync] change check failed: $e');+ }+ return push();+ }++ /// Called when the app goes to the background, so a session's worth of+ /// highlights and layout changes ships without waiting for the next launch.+ Future<void> onAppBackgrounded() async {+ _debounce?.cancel();+ _debounce = null;+ await pushIfChanged();+ }++ /// The backup payload, reduced to what may travel.+ Future<Map<String, dynamic>> buildPayload() async {+ final full = await BackupService.exportSettings(includeAccounts: false);+ final allowed = await _activeKeys();+ final out = <String, dynamic>{+ 'version': full['version'],+ 'appVersion': full['appVersion'],+ };+ for (final key in allowed) {+ if (full.containsKey(key) && full[key] != null) out[key] = full[key];+ }+ out['settings'] = _stripSettings(out['settings']);+ return out;+ }++ static Map<String, dynamic> _stripSettings(Object? settings) {+ if (settings is! Map) return <String, dynamic>{};+ final copy = Map<String, dynamic>.from(settings);+ copy.removeWhere((k, _) => _deviceLocalSettings.contains(k));+ return copy;+ }++ // Transport.++ Uri? _remoteUri(String base) {+ final trimmed = base.trim().replaceAll(RegExp(r'/+$'), '');+ if (trimmed.isEmpty) return null;+ final uri = Uri.tryParse('$trimmed/${_fileName()}');+ if (uri == null || !uri.hasScheme || uri.host.isEmpty) return null;+ return uri;+ }++ /// One file per account, named from a hash of the account scope so two+ /// accounts pointed at the same folder cannot stomp each other, and so the+ /// filename does not leak a server address into the user's file listing.+ String _fileName() {+ final scope = UserAccountService().activeScopeKey;+ final digest = sha256.convert(utf8.encode(scope)).toString();+ return 'absorb-settings-${digest.substring(0, 16)}.json';+ }++ /// Diagnostics for a response the app did not like. `location` matters: a+ /// server that redirects plain HTTP to HTTPS is a common reason a URL that+ /// works in a browser fails here.+ static String _http(http.Response resp, Uri uri, String method) {+ final buf = StringBuffer('$method $uri\nHTTP ${resp.statusCode}');+ final location = resp.headers['location'];+ if (location != null) buf.write('\nredirected to: $location');+ final body = resp.body.trim();+ if (body.isNotEmpty) {+ buf.write('\n${body.substring(0, body.length.clamp(0, 300))}');+ }+ return buf.toString();+ }++ /// Diagnostics for a request that never produced a response at all. The+ /// exception type is the useful half - a name that does not resolve, a+ /// refused connection and a rejected certificate all read the same once+ /// they have been flattened to a sentence.+ static String _err(Object e, Uri uri, String method) =>+ '$method $uri\n${e.runtimeType}: $e';++ Future<Map<String, String>?> _authHeaders() async {+ final user = await getUsername();+ final pass = await getPassword();+ if (user == null || user.isEmpty || pass == null || pass.isEmpty) {+ return null;+ }+ final basic = base64Encode(utf8.encode('$user:$pass'));+ // Custom headers first so a stray `Authorization` entry can't displace the+ // credentials the user actually filled in.+ return {...await getCustomHeaders(), 'authorization': 'Basic $basic'};+ }++ /// Push local settings up. No-op while another sync is mid-flight.+ Future<SyncResult> push() async {+ if (_busy) {+ debugPrint('[SettingsSync] push skipped - another sync in flight');+ return const SyncResult(SyncStatus.ok, 'busy');+ }+ if (!await getEnabled()) {+ debugPrint('[SettingsSync] push skipped - sync is off');+ return const SyncResult(SyncStatus.notConfigured);+ }+ final base = await getUrl();+ if (base == null || base.isEmpty) {+ debugPrint('[SettingsSync] push skipped - no folder address set');+ return const SyncResult(SyncStatus.notConfigured);+ }+ final uri = _remoteUri(base);+ final headers = await _authHeaders();+ if (uri == null || headers == null) {+ debugPrint('[SettingsSync] push skipped - address or sign-in incomplete');+ return const SyncResult(SyncStatus.notConfigured);+ }++ _busy = true;+ try {+ final payload = await buildPayload();+ final stamp = DateTime.now().millisecondsSinceEpoch;+ payload['syncedAt'] = stamp;+ final body = jsonEncode(payload);+ if (body.length > _maxPayloadBytes) {+ debugPrint(+ '[SettingsSync] payload ${body.length}b over cap - not pushing',+ );+ return const SyncResult(SyncStatus.tooLarge);+ }+ final resp = await _put(+ uri,+ {...headers, 'content-type': 'application/json'},+ body,+ ).timeout(const Duration(seconds: 20));+ if (resp.statusCode == 401 || resp.statusCode == 403) {+ return SyncResult(SyncStatus.authFailed, null, _http(resp, uri, 'PUT'));+ }+ if (resp.statusCode >= 200 && resp.statusCode < 300) {+ await _setLastSeen(stamp);+ await _setLastHash(_hash(payload));+ debugPrint(+ '[SettingsSync] pushed ${body.length}b (HTTP ${resp.statusCode})',+ );+ return const SyncResult(SyncStatus.ok);+ }+ debugPrint('[SettingsSync] push rejected - HTTP ${resp.statusCode}');+ return SyncResult(SyncStatus.network, null, _http(resp, uri, 'PUT'));+ } catch (e) {+ debugPrint('[SettingsSync] push failed: ${e.runtimeType} - $e');+ return SyncResult(SyncStatus.network, null, _err(e, uri, 'PUT'));+ } finally {+ _busy = false;+ }+ }++ /// Fetch the remote copy and apply it when it is newer than anything this+ /// device has seen. Returns [SyncStatus.noRemote] before any device has+ /// pushed for the first time.+ Future<SyncResult> pull({bool force = false}) async {+ if (_busy) {+ debugPrint('[SettingsSync] pull skipped - another sync in flight');+ return const SyncResult(SyncStatus.ok, 'busy');+ }+ if (!await getEnabled()) {+ debugPrint('[SettingsSync] pull skipped - sync is off');+ return const SyncResult(SyncStatus.notConfigured);+ }+ final base = await getUrl();+ if (base == null || base.isEmpty) {+ return const SyncResult(SyncStatus.notConfigured);+ }+ final uri = _remoteUri(base);+ final headers = await _authHeaders();+ if (uri == null || headers == null) {+ return const SyncResult(SyncStatus.notConfigured);+ }++ _busy = true;+ try {+ final resp =+ await _getUrl(uri, headers).timeout(const Duration(seconds: 20));+ if (resp.statusCode == 401 || resp.statusCode == 403) {+ return SyncResult(SyncStatus.authFailed, null, _http(resp, uri, 'GET'));+ }+ if (resp.statusCode == 404) {+ debugPrint('[SettingsSync] nothing on the server yet (404)');+ return SyncResult(SyncStatus.noRemote, null, _http(resp, uri, 'GET'));+ }+ if (resp.statusCode < 200 || resp.statusCode >= 300) {+ debugPrint('[SettingsSync] pull rejected - HTTP ${resp.statusCode}');+ return SyncResult(SyncStatus.network, null, _http(resp, uri, 'GET'));+ }++ final decoded = jsonDecode(utf8.decode(resp.bodyBytes));+ if (decoded is! Map<String, dynamic>) {+ return SyncResult(+ SyncStatus.network,+ 'unexpected file contents',+ 'GET $uri returned ${resp.statusCode} but the body was not a JSON '+ 'object. First 200 chars:\n'+ '${resp.body.substring(0, resp.body.length.clamp(0, 200))}',+ );+ }+ final remoteAt = (decoded['syncedAt'] as num?)?.toInt() ?? 0;+ if (!force && remoteAt <= await _lastSeen()) {+ debugPrint('[SettingsSync] remote not newer - nothing to apply');+ return const SyncResult(SyncStatus.ok, 'up to date');+ }++ // Filter on the way in as well as out. The file sits on a server the app+ // does not control, so a payload written by a future (or tampered)+ // client cannot smuggle in accounts or a pending listening ledger.+ final allowed = await _activeKeys();+ final safe = <String, dynamic>{'version': decoded['version'] ?? 3};+ for (final key in allowed) {+ if (decoded.containsKey(key) && decoded[key] != null) {+ safe[key] = decoded[key];+ }+ }+ safe['settings'] = _stripSettings(safe['settings']);++ // Measure against what this device holds right now, before the import+ // overwrites it.+ try {+ _lastApplyCount = _countChanges(await buildPayload(), safe);+ } catch (_) {+ _lastApplyCount = 0;+ }+ _suppressPushUntil = DateTime.now().add(_suppressAfterImport);+ await BackupService.importSettings(safe);+ await _applyToRunningApp();+ await _setLastSeen(remoteAt);+ // Fingerprint what we just adopted, so the change check does not read the+ // freshly-applied remote state as a local edit and bounce it straight+ // back up.+ try {+ await _setLastHash(_hash(await buildPayload()));+ } catch (_) {}+ // Anything queued while the import was writing is the import's own echo,+ // not a user edit.+ _debounce?.cancel();+ _debounce = null;+ if (_lastApplyCount == 0) {+ // The remote file was newer but identical - nothing actually moved, so+ // there is nothing to tell the user about.+ debugPrint(+ '[SettingsSync] remote stamped $remoteAt was newer but identical',+ );+ return const SyncResult(SyncStatus.ok, 'up to date');+ }+ debugPrint(+ '[SettingsSync] applied $_lastApplyCount change(s) from remote '+ 'stamped $remoteAt',+ );+ return const SyncResult(SyncStatus.ok, 'applied');+ } catch (e) {+ debugPrint('[SettingsSync] pull failed: ${e.runtimeType} - $e');+ return SyncResult(SyncStatus.network, null, _err(e, uri, 'GET'));+ } finally {+ _busy = false;+ }+ }++ /// One-shot check so the settings screen can tell the user whether the+ /// address and credentials work, without touching local settings.+ Future<SyncResult> testConnection() async {+ final base = await getUrl();+ if (base == null || base.isEmpty) {+ return const SyncResult(SyncStatus.notConfigured);+ }+ final uri = _remoteUri(base);+ final headers = await _authHeaders();+ if (uri == null || headers == null) {+ return const SyncResult(SyncStatus.notConfigured);+ }+ try {+ final resp =+ await _getUrl(uri, headers).timeout(const Duration(seconds: 15));+ if (resp.statusCode == 401 || resp.statusCode == 403) {+ return SyncResult(SyncStatus.authFailed, null, _http(resp, uri, 'GET'));+ }+ // A 404 only means nothing has been pushed yet, which is a fine outcome+ // for first-time setup - the address and credentials still checked out.+ if (resp.statusCode == 404) {+ return SyncResult(SyncStatus.noRemote, null, _http(resp, uri, 'GET'));+ }+ if (resp.statusCode >= 200 && resp.statusCode < 300) {+ return SyncResult(SyncStatus.ok, null, _http(resp, uri, 'GET'));+ }+ return SyncResult(SyncStatus.network, null, _http(resp, uri, 'GET'));+ } catch (e) {+ return SyncResult(SyncStatus.network, null, _err(e, uri, 'GET'));+ }+ }+}