A cross platform Audiobookshelf client for Android and iOS
Dart
Show in the More menu when keep screen on is active, and let the button switch it off for this run when Settings has it on
Barnabasa962bed4a1b2
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex c787fbb8..01411500 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -5089,9 +5089,10 @@"catchUpPageAhead": "This page is ahead of the audiobook. Tap to move the audiobook here.","readerShortcutButton": "Shortcut button","keepScreenOn": "Keep screen on",+ "keepScreenOnActive": "Screen stays on","keepScreenOnUntilClosed": "Screen stays on until you close the app","keepScreenOnOff": "Screen can turn off again",- "keepScreenOnAlwaysHint": "Already on in Settings",+ "keepScreenOnOffUntilRestart": "Off until the app restarts. The Settings switch stays on","keepScreenOnPlayer": "Keep the screen on in the player","keepScreenOnPlayerSubtitle": "The screen stays on while the player is open","keepScreenOnCarMode": "Keep the screen on in car mode",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex c0f83f24..680d4aae 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -15687,6 +15687,12 @@ abstract class AppLocalizations {/// **'Keep screen on'**String get keepScreenOn;+ /// No description provided for @keepScreenOnActive.+ ///+ /// In en, this message translates to:+ /// **'Screen stays on'**+ String get keepScreenOnActive;+/// No description provided for @keepScreenOnUntilClosed.////// In en, this message translates to:@@ -15699,11 +15705,11 @@ abstract class AppLocalizations {/// **'Screen can turn off again'**String get keepScreenOnOff;- /// No description provided for @keepScreenOnAlwaysHint.+ /// No description provided for @keepScreenOnOffUntilRestart.////// In en, this message translates to:- /// **'Already on in Settings'**- String get keepScreenOnAlwaysHint;+ /// **'Off until the app restarts. The Settings switch stays on'**+ String get keepScreenOnOffUntilRestart;/// No description provided for @keepScreenOnPlayer.///diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 5e373bd6..2fb6fba8 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -9230,6 +9230,9 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9238,7 +9241,8 @@ class AppLocalizationsDe extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex d9277246..17ac9006 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsEl extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 2b4295c0..24500953 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsEn extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex 1117c097..7a5dc472 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -9111,6 +9111,9 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9119,7 +9122,8 @@ class AppLocalizationsEs extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex 0db62eee..6b45f15f 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -9162,6 +9162,9 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9170,7 +9173,8 @@ class AppLocalizationsFr extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex e49213b1..c0850a2b 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsIt extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 0ee9ef5b..86e59883 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsJa extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex ede91273..709ae59b 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsNo extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex 418abd4c..e6152c78 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsPt extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 4ea3f4db..d61d5ae8 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -9109,6 +9109,9 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9117,7 +9120,8 @@ class AppLocalizationsRo extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex a0868a0f..a20865a0 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -9114,6 +9114,9 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9122,7 +9125,8 @@ class AppLocalizationsRu extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 2b1a6b8a..bba9cc8c 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -9017,6 +9017,9 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get keepScreenOn => 'Keep screen on';+ @override+ String get keepScreenOnActive => 'Screen stays on';+@overrideString get keepScreenOnUntilClosed =>'Screen stays on until you close the app';@@ -9025,7 +9028,8 @@ class AppLocalizationsZh extends AppLocalizations {String get keepScreenOnOff => 'Screen can turn off again';@override- String get keepScreenOnAlwaysHint => 'Already on in Settings';+ String get keepScreenOnOffUntilRestart =>+ 'Off until the app restarts. The Settings switch stays on';@overrideString get keepScreenOnPlayer => 'Keep the screen on in the player';diff --git a/lib/services/screen_wake.dart b/lib/services/screen_wake.dartindex 993f033c..a028b6b5 100644--- a/lib/services/screen_wake.dart+++ b/lib/services/screen_wake.dart@@ -39,6 +39,9 @@ class PlayerScreenWake {static final covered = ValueNotifier<bool>(false);/// What the card's button shows: the switch or the session toggle.static final wanted = ValueNotifier<bool>(false);+ // The card button switching the Settings choice off for this run only;+ // the next launch follows Settings again.+ static final sessionOff = ValueNotifier<bool>(false);static bool _always = false;static bool _started = false;@@ -48,6 +51,7 @@ class PlayerScreenWake {if (_started) return;_started = true;sessionOn.addListener(_sync);+ sessionOff.addListener(_sync);onScreen.addListener(_sync);covered.addListener(_sync);PlayerSettings.settingsChanged.addListener(_reload);@@ -55,12 +59,16 @@ class PlayerScreenWake {}static Future<void> _reload() async {- _always = await PlayerSettings.getKeepScreenOnInPlayer();+ final always = await PlayerSettings.getKeepScreenOnInPlayer();+ // Flipping the switch in Settings is a fresh decision, so a card-button+ // override from before it no longer applies.+ if (always != _always) sessionOff.value = false;+ _always = always;_sync();}static void _sync() {- wanted.value = _always || sessionOn.value;+ wanted.value = (_always && !sessionOff.value) || sessionOn.value;ScreenWake.hold('player', wanted.value && onScreen.value && !covered.value);}}diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex 4df1961d..caed0a5f 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -97,14 +97,17 @@ class _PressableState extends State<Pressable> {}/// Show a toast when the user taps a button that requires active playback.-/// The card's Keep screen on button: holds the screen while the player is up-/// and playing, until the app is closed. With the Settings switch on it only-/// says so.+/// The card's Keep screen on button: holds the screen while the player is up,+/// until the app is closed. With the Settings switch on, the button switches+/// it off for this run only; the next launch follows Settings again.void toggleKeepScreenOn(BuildContext context) {final l = AppLocalizations.of(context)!;if (PlayerScreenWake.always) {- showOverlayToast(context, l.keepScreenOnAlwaysHint,- icon: Icons.lightbulb_rounded);+ final off = !PlayerScreenWake.sessionOff.value;+ PlayerScreenWake.sessionOff.value = off;+ showOverlayToast(context,+ off ? l.keepScreenOnOffUntilRestart : l.keepScreenOnUntilClosed,+ icon: off ? Icons.lightbulb_outline_rounded : Icons.lightbulb_rounded);return;}final on = !PlayerScreenWake.sessionOn.value;@@ -198,6 +201,9 @@ class MoreMenuItem extends StatelessWidget {final String label;final Color accent;final bool enabled;+ // A toggle that is currently on: the pill lights up in the accent so the+ // state shows before you press it.+ final bool active;final VoidCallback onTap;const MoreMenuItem({@@ -205,10 +211,12 @@ class MoreMenuItem extends StatelessWidget {required this.icon, required this.label,required this.accent, required this.onTap,this.enabled = true,+ this.active = false,});@override Widget build(BuildContext context) {final cs = Theme.of(context).colorScheme;+ final ink = _inkAccent(accent);// Grid pill: centered icon over a short label, fills its (fixed-height)// grid cell. Matches the book menu's quick-actions pills. The loose// Flexible lets a long label ellipsise inside the cell at big font scales.@@ -217,21 +225,28 @@ class MoreMenuItem extends StatelessWidget {child: Container(padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 10),decoration: BoxDecoration(- color: cs.surfaceContainerHigh,+ color: active ? ink.withValues(alpha: _inkAlpha(0.18, 0.0)) : cs.surfaceContainerHigh,borderRadius: BorderRadius.circular(16),- border: Border.all(color: cs.onSurface.withValues(alpha: _inkAlpha(0.08, 0.55))),+ border: Border.all(+ color: active+ ? ink.withValues(alpha: _inkAlpha(0.6, 1.0))+ : cs.onSurface.withValues(alpha: _inkAlpha(0.08, 0.55)),+ width: active ? 1.5 : 1,+ ),),child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [Icon(icon, size: 22, color: enabled- ? _inkAccent(accent).withValues(alpha: _inkAlpha(0.85, 1.0))+ ? ink.withValues(alpha: _inkAlpha(active ? 1.0 : 0.85, 1.0)): cs.onSurface.withValues(alpha: _inkAlpha(0.24, 0.85))),const SizedBox(height: 7),Flexible(child: Text(label, textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis,style: TextStyle(- color: enabled- ? cs.onSurface.withValues(alpha: _inkAlpha(0.85, 1.0))- : cs.onSurface.withValues(alpha: _inkAlpha(0.24, 0.85)),- fontSize: 11, fontWeight: FontWeight.w500, height: 1.15))),+ color: !enabled+ ? cs.onSurface.withValues(alpha: _inkAlpha(0.24, 0.85))+ : active+ ? ink+ : cs.onSurface.withValues(alpha: _inkAlpha(0.85, 1.0)),+ fontSize: 11, fontWeight: active ? FontWeight.w700 : FontWeight.w500, height: 1.15))),]),),);@@ -2056,11 +2071,12 @@ class CardActionDelegate {onTap: () { Navigator.pop(ctx); openCarMode(context); },);case 'wake':+ final wakeOn = PlayerScreenWake.wanted.value;return MoreMenuItem(- icon: PlayerScreenWake.wanted.value- ? Icons.lightbulb_rounded- : Icons.lightbulb_outline_rounded,- label: l.keepScreenOn, accent: accent,+ icon: wakeOn ? Icons.lightbulb_rounded : Icons.lightbulb_outline_rounded,+ label: wakeOn ? l.keepScreenOnActive : l.keepScreenOn,+ accent: accent,+ active: wakeOn,onTap: () { Navigator.pop(ctx); toggleKeepScreenOn(context); },);case 'notes':