A cross platform Audiobookshelf client for Android and iOS
Dart
Keep logs on by default in betas, say so once after the update and leave them off for anyone who turns them off
Barnabas2940f1f486a4
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex 7266d7b5..84504d88 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -38,6 +38,8 @@"settingsWhatsNew": "Show what's new after updates","settingsWhatsNewSubtitle": "After Absorb updates, a popup links to the release notes","gotIt": "Got it",+ "betaLoggingTitle": "Logs are on",+ "betaLoggingContent": "Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.","preview": "Preview","or": "or","file": "File",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex 7047f0a9..8f727157 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -316,6 +316,18 @@ abstract class AppLocalizations {/// **'Got it'**String get gotIt;+ /// No description provided for @betaLoggingTitle.+ ///+ /// In en, this message translates to:+ /// **'Logs are on'**+ String get betaLoggingTitle;++ /// No description provided for @betaLoggingContent.+ ///+ /// In en, this message translates to:+ /// **'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.'**+ String get betaLoggingContent;+/// No description provided for @preview.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex e16679e1..b8d2c1a9 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -115,6 +115,13 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get gotIt => 'Verstanden';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Vorschau';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex e2bd3ee6..6d809775 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -114,6 +114,13 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 9f9d60f1..600744fa 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -114,6 +114,13 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex b8e4c4ce..842d8c40 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -114,6 +114,13 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get gotIt => 'Entendido';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Vista previa';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex c435e182..fac3546b 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -115,6 +115,13 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get gotIt => 'Ok';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Aperçu';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex ce1b8a6c..51a24b58 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -114,6 +114,13 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 7585ac92..5d72f2e9 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -114,6 +114,13 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex 8242778f..a2ba99e4 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -114,6 +114,13 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex 65e8fa47..482264f9 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -114,6 +114,13 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex cf012b39..e28e7b97 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -114,6 +114,13 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex 4ac8f8c3..4dcb4472 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -109,6 +109,12 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get gotIt => 'Got it';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent => 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => 'Preview';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 48f3a0a0..5f9354a2 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -114,6 +114,13 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get gotIt => '知道了';+ @override+ String get betaLoggingTitle => 'Logs are on';++ @override+ String get betaLoggingContent =>+ 'Since this is a beta, Absorb now keeps logs to help track down problems. They stay on this device unless you share them.\n\nYou can send them or turn them off in Settings, under Issues & Support. If you turn them off, later betas leave them off.';+@overrideString get preview => '预览';diff --git a/lib/main.dart b/lib/main.dartindex 2d00dd80..054fa2d1 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -45,6 +45,7 @@ import 'services/wording.dart';import 'screens/login_screen.dart';import 'screens/app_shell.dart';import 'widgets/auth_loading_screen.dart';+import 'widgets/beta_logging_notice.dart';import 'widgets/setup_link_login.dart';/// Global notifier so any widget (e.g. settings) can change the theme instantly.@@ -695,6 +696,9 @@ class _AuthGateState extends State<AuthGate> {// Initialize log service early so all debugPrint calls are captured in the// log file. This is critical for diagnosing startup freezes in production.+ try {+ await BetaLoggingNotice.applyDefault(ApiService.appVersionFull);+ } catch (_) {}try {final loggingEnabled = await PlayerSettings.getLoggingEnabled();await LogService().init(loggingEnabled);diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex c547f5cd..7fd4920a 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -60,6 +60,7 @@ import 'stats_screen.dart';import 'settings_screen.dart';import 'app_shell_navigation_policy.dart';import '../widgets/library_picker_sheet.dart';+import '../widgets/beta_logging_notice.dart';import '../widgets/welcome_sheet.dart';import '../widgets/whats_new_prompt.dart';import '../services/review_service.dart';@@ -392,11 +393,19 @@ class _AppShellState extends State<AppShell>context.read<LibraryProvider>().addListener(_onLibraryChanged);_loadPodcastTabPrefs();PlayerSettings.settingsChanged.addListener(_loadPodcastTabPrefs);- WhatsNewPrompt.showIfUpdated(context);- WelcomeSheet.showIfNeeded(context);+ _showLaunchPrompts();_checkForUpdate();}+ /// One after another, so they never land on top of each other.+ Future<void> _showLaunchPrompts() async {+ await WhatsNewPrompt.showIfUpdated(context);+ if (!mounted) return;+ await WelcomeSheet.showIfNeeded(context);+ if (!mounted) return;+ await BetaLoggingNotice.showIfPending(context);+ }+Future<void> _loadPodcastTabPrefs() async {final enabled = await PlayerSettings.getPodcastTabEnabled();final libId = await PlayerSettings.getPodcastTabLibraryId();diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex bb1c6cdd..5d98715b 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -1092,6 +1092,9 @@ class PlayerSettings {final prefs = await SharedPreferences.getInstance();await prefs.setBool('loggingEnabled', value);}+ /// Whether the logging switch was ever set, by hand or from a backup.+ static Future<bool> loggingChosen() async =>+ (await SharedPreferences.getInstance()).containsKey('loggingEnabled');static Future<bool> getFullScreenPlayer() => _get('fullScreenPlayer', false);static Future<void> setFullScreenPlayer(bool value) => _set('fullScreenPlayer', value);diff --git a/lib/widgets/beta_logging_notice.dart b/lib/widgets/beta_logging_notice.dartnew file mode 100644index 00000000..dab90feb--- /dev/null+++ b/lib/widgets/beta_logging_notice.dart@@ -0,0 +1,55 @@+import 'package:flutter/foundation.dart';+import 'package:flutter/material.dart';+import 'package:shared_preferences/shared_preferences.dart';++import '../build_info.dart';+import '../l10n/app_localizations.dart';+import '../services/player_settings.dart';++/// Beta builds start with logging on, so testers have logs ready to send when+/// something goes wrong, and say so once after the update.+class BetaLoggingNotice {+ static const _appliedKey = 'beta_logging_default_applied';+ static const _pendingKey = 'beta_logging_notice_pending';++ /// Call before the log service starts. It only ever runs once, and never+ /// over a switch someone already flipped, so turning logging off sticks+ /// through later betas.+ static Future<void> applyDefault(String version) async {+ if (kIsWeb || betaNumberFor(version) == null) return;+ final prefs = await SharedPreferences.getInstance();+ if (prefs.getBool(_appliedKey) == true) return;+ await prefs.setBool(_appliedKey, true);+ if (await PlayerSettings.loggingChosen()) return;+ await PlayerSettings.setLoggingEnabled(true);+ await prefs.setBool(_pendingKey, true);+ }++ static Future<void> showIfPending(BuildContext context) async {+ final prefs = await SharedPreferences.getInstance();+ if (prefs.getBool(_pendingKey) != true) return;+ if (!await PlayerSettings.getLoggingEnabled()) {+ await prefs.remove(_pendingKey);+ return;+ }+ await Future.delayed(const Duration(milliseconds: 600));+ if (!context.mounted) return;+ await prefs.remove(_pendingKey);+ if (!context.mounted) return;+ final l = AppLocalizations.of(context)!;+ await showDialog<void>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.article_outlined),+ title: Text(l.betaLoggingTitle),+ content: Text(l.betaLoggingContent),+ actions: [+ FilledButton(+ onPressed: () => Navigator.pop(ctx),+ child: Text(l.gotIt),+ ),+ ],+ ),+ );+ }+}diff --git a/lib/widgets/welcome_sheet.dart b/lib/widgets/welcome_sheet.dartindex d16f7ec3..c217555a 100644--- a/lib/widgets/welcome_sheet.dart+++ b/lib/widgets/welcome_sheet.dart@@ -17,7 +17,7 @@ class WelcomeSheet {// Small delay so the app finishes its initial layout firstawait Future.delayed(const Duration(milliseconds: 800));if (!context.mounted) return;- showDialog<void>(+ await showDialog<void>(context: context,builder: (_) => const _WelcomeDialog(),);