A cross platform Audiobookshelf client for Android and iOS
Dart
Add a keep screen on option for the player and car mode, and a rewind for when the car disconnects while the book is playing
Barnabasc506af85904e
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xmlindex b2f5c4ff..8856e392 100644--- a/android/app/src/main/AndroidManifest.xml+++ b/android/app/src/main/AndroidManifest.xml@@ -233,6 +233,7 @@</application><queries>+ <provider android:authorities="androidx.car.app.connection" /><intent><action android:name="android.intent.action.PROCESS_TEXT"/><data android:mimeType="text/plain"/>diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex 8473229c..5ce3b16e 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -5064,5 +5064,18 @@"findInAudiobookPlaying": "Playing this passage in the audiobook","catchUpAudioAhead": "The audiobook is further along. Tap to go there.","catchUpPageAhead": "This page is ahead of the audiobook. Tap to move the audiobook here.",- "readerShortcutButton": "Shortcut button"+ "readerShortcutButton": "Shortcut button",+ "keepScreenOn": "Keep screen on",+ "keepScreenOnUntilClosed": "Screen stays on until you close the app",+ "keepScreenOnOff": "Screen can turn off again",+ "keepScreenOnAlwaysHint": "Already on in Settings",+ "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",+ "keepScreenOnCarModeSubtitle": "The screen stays on while car mode is open",+ "carDisconnectRewind": "Rewind when the car disconnects",+ "carDisconnectRewindOff": "Off",+ "carDisconnectRewindValue": "{seconds} seconds",+ "@carDisconnectRewindValue": { "placeholders": { "seconds": { "type": "int" } } },+ "carDisconnectRewindInfo": "When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected."}diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex a362df71..0fe45e35 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -15566,6 +15566,78 @@ abstract class AppLocalizations {/// In en, this message translates to:/// **'Shortcut button'**String get readerShortcutButton;++ /// No description provided for @keepScreenOn.+ ///+ /// In en, this message translates to:+ /// **'Keep screen on'**+ String get keepScreenOn;++ /// No description provided for @keepScreenOnUntilClosed.+ ///+ /// In en, this message translates to:+ /// **'Screen stays on until you close the app'**+ String get keepScreenOnUntilClosed;++ /// No description provided for @keepScreenOnOff.+ ///+ /// In en, this message translates to:+ /// **'Screen can turn off again'**+ String get keepScreenOnOff;++ /// No description provided for @keepScreenOnAlwaysHint.+ ///+ /// In en, this message translates to:+ /// **'Already on in Settings'**+ String get keepScreenOnAlwaysHint;++ /// No description provided for @keepScreenOnPlayer.+ ///+ /// In en, this message translates to:+ /// **'Keep the screen on in the player'**+ String get keepScreenOnPlayer;++ /// No description provided for @keepScreenOnPlayerSubtitle.+ ///+ /// In en, this message translates to:+ /// **'The screen stays on while the player is open'**+ String get keepScreenOnPlayerSubtitle;++ /// No description provided for @keepScreenOnCarMode.+ ///+ /// In en, this message translates to:+ /// **'Keep the screen on in car mode'**+ String get keepScreenOnCarMode;++ /// No description provided for @keepScreenOnCarModeSubtitle.+ ///+ /// In en, this message translates to:+ /// **'The screen stays on while car mode is open'**+ String get keepScreenOnCarModeSubtitle;++ /// No description provided for @carDisconnectRewind.+ ///+ /// In en, this message translates to:+ /// **'Rewind when the car disconnects'**+ String get carDisconnectRewind;++ /// No description provided for @carDisconnectRewindOff.+ ///+ /// In en, this message translates to:+ /// **'Off'**+ String get carDisconnectRewindOff;++ /// No description provided for @carDisconnectRewindValue.+ ///+ /// In en, this message translates to:+ /// **'{seconds} seconds'**+ String carDisconnectRewindValue(int seconds);++ /// No description provided for @carDisconnectRewindInfo.+ ///+ /// In en, this message translates to:+ /// **'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.'**+ String get carDisconnectRewindInfo;}class _AppLocalizationsDelegatediff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 3a46446c..69bb53aa 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -9157,4 +9157,46 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex da79134b..f8fd4b5e 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex 11e33b71..4b2b1378 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex 0ffa7784..112cc44b 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -9038,4 +9038,46 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex 3d3222fb..3037cdc6 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -9089,4 +9089,46 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex 7ae0b9ea..7c26c95e 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 1bae5e5c..df187ac8 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex 0fa8cb44..9908a9d6 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex f5b44c5f..189f0575 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 2a204995..d7702aeb 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -9036,4 +9036,46 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex 018dfd66..28f5e970 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -9041,4 +9041,46 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 0b8274ab..7877e1b2 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -8944,4 +8944,46 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get readerShortcutButton => 'Shortcut button';++ @override+ String get keepScreenOn => 'Keep screen on';++ @override+ String get keepScreenOnUntilClosed =>+ 'Screen stays on until you close the app';++ @override+ String get keepScreenOnOff => 'Screen can turn off again';++ @override+ String get keepScreenOnAlwaysHint => 'Already on in Settings';++ @override+ String get keepScreenOnPlayer => 'Keep the screen on in the player';++ @override+ String get keepScreenOnPlayerSubtitle =>+ 'The screen stays on while the player is open';++ @override+ String get keepScreenOnCarMode => 'Keep the screen on in car mode';++ @override+ String get keepScreenOnCarModeSubtitle =>+ 'The screen stays on while car mode is open';++ @override+ String get carDisconnectRewind => 'Rewind when the car disconnects';++ @override+ String get carDisconnectRewindOff => 'Off';++ @override+ String carDisconnectRewindValue(int seconds) {+ return '$seconds seconds';+ }++ @override+ String get carDisconnectRewindInfo =>+ 'When the car is turned off without pausing first, the phone can take a few seconds to notice that Android Auto or CarPlay has disconnected, and playback continues until it does. This rewinds by the amount set here so nothing is missed. Time how long your car takes to pause after it is turned off and use that. Nothing happens if playback was already paused when the car disconnected.';}diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dartindex 2bca6700..15d8a866 100644--- a/lib/providers/_lp_core.dart+++ b/lib/providers/_lp_core.dart@@ -1395,6 +1395,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {void setReaderQuiet(bool quiet) {if (_readerQuiet == quiet) return;_readerQuiet = quiet;+ PlayerScreenWake.covered.value = quiet;if (quiet) {_readerQuietAt = DateTime.now();debugPrint('[Library] Reader open - quieting live work');diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dartindex cd134ddc..a30974b3 100644--- a/lib/providers/library_provider.dart+++ b/lib/providers/library_provider.dart@@ -27,6 +27,8 @@ import '../utils/absorbing_inclusion.dart';import '../l10n/app_localizations.dart';import '../main.dart' show rootNavigatorKey;import '../widgets/overlay_toast.dart';+import '../services/ebook_cache.dart';+import '../services/screen_wake.dart';part '_lp_state.dart';part '_lp_core.dart';diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex 6a7f52a2..24a73c63 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -7,6 +7,7 @@ import 'package:provider/provider.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';+import '../services/screen_wake.dart';import '../services/volume_key_service.dart';import '../services/chromecast_service.dart';import '../services/home_widget_service.dart';@@ -246,17 +247,23 @@ class _AppShellState extends State<AppShell>_syncNavBarListener(index);if (snappyTransitionsNotifier.value || einkModeNotifier.value) {setState(() => _currentIndex = index);+ _syncPlayerOnScreen();} else {_fadeController.reverse().then((_) {if (!mounted) return;setState(() {_currentIndex = index;});+ _syncPlayerOnScreen();_fadeController.forward();});}}+ void _syncPlayerOnScreen() {+ PlayerScreenWake.onScreen.value = _currentIndex == 2 || _expandedIsOpen;+ }+/// Subscribe to the active screen's barsRevealNotifier when on Home or/// Library tab, and ensure the nav bar is visible on all other tabs.void _syncNavBarListener(int index) {@@ -343,6 +350,7 @@ class _AppShellState extends State<AppShell>PlayerSettings.getStartScreen().then((idx) {if (mounted && idx != _currentIndex && idx >= 0 && idx <= 4) {setState(() => _currentIndex = idx);+ _syncPlayerOnScreen();_ensurePageBuilt(idx);_restoreBookLibraryForCurrentTab(restoreLibraryPage: true);}@@ -354,8 +362,10 @@ class _AppShellState extends State<AppShell>super.initState();_instance = this;EreaderVolumeNav.ensureHandler();+ PlayerScreenWake.start();if (!widget.startOnAbsorbing) _loadStartScreen();_ensurePageBuilt(_currentIndex);+ _syncPlayerOnScreen();_playerHadBook = _player.hasBook;_wasPlaying = _player.isPlaying;_lastItemId = _player.currentItemId;@@ -623,6 +633,7 @@ class _AppShellState extends State<AppShell>}_expandedIsOpen = true;+ _syncPlayerOnScreen();final nav = Navigator.of(context, rootNavigator: true);await nav.push(ExpandedCardRoute(@@ -631,6 +642,7 @@ class _AppShellState extends State<AppShell>);// Route was popped — expanded view closed_expandedIsOpen = false;+ _syncPlayerOnScreen();}@overridediff --git a/lib/screens/car_mode_screen.dart b/lib/screens/car_mode_screen.dartindex e336da9e..6f7d1cef 100644--- a/lib/screens/car_mode_screen.dart+++ b/lib/screens/car_mode_screen.dart@@ -11,6 +11,7 @@ import '../providers/library_provider.dart';import '../services/audio_player_service.dart';import '../services/bookmark_service.dart';import '../widgets/card_buttons.dart';+import '../services/screen_wake.dart';import '../widgets/overlay_toast.dart';import '../l10n/app_localizations.dart';@@ -92,6 +93,9 @@ class _CarModeScreenState extends State<CarModeScreen>PlayerSettings.getNotificationChapterProgress().then((v) {if (mounted && v != _preferChapterBar) setState(() => _preferChapterBar = v);});+ PlayerSettings.getKeepScreenOnInCarMode().then((v) {+ if (mounted) ScreenWake.hold('car', v);+ });}void _onPlayerChanged() {@@ -105,6 +109,7 @@ class _CarModeScreenState extends State<CarModeScreen>_displayTimer?.cancel();PlayerSettings.settingsChanged.removeListener(_loadSkipSettings);widget.player.removeListener(_onPlayerChanged);+ ScreenWake.hold('car', false);_playPauseController.dispose();// Back to the user's saved rotation preference - the old empty list// ("all allowed") silently dropped the portrait lock until a restart.diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex b96bdcec..8e44980a 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -95,6 +95,9 @@ class _SettingsScreenState extends State<SettingsScreen> {bool _notifSpeedBookmark = false;bool _duckBriefInterruptions = false;bool _autoplayOnCarConnect = false;+ bool _keepScreenOnPlayer = false;+ bool _keepScreenOnCarMode = false;+ int _carDisconnectRewind = 0;String _carBookSort = 'title';bool _carBookSortReverse = false;String _carPodcastSort = 'title';@@ -1078,6 +1081,9 @@ class _SettingsScreenState extends State<SettingsScreen> {final episodeNotifMinutes = await PlayerSettings.getEpisodeNotifIntervalMinutes();final duckBriefInterruptions = await PlayerSettings.getDuckBriefInterruptions();final autoplayOnCarConnect = await PlayerSettings.getAutoplayOnCarConnect();+ final keepScreenOnPlayer = await PlayerSettings.getKeepScreenOnInPlayer();+ final keepScreenOnCarMode = await PlayerSettings.getKeepScreenOnInCarMode();+ final carDisconnectRewind = await PlayerSettings.getCarDisconnectRewindSeconds();final carBookSort = await PlayerSettings.getCarBookSort();final carBookSortReverse = await PlayerSettings.getCarBookSortReverse();final carPodcastSort = await PlayerSettings.getCarPodcastSort();@@ -1102,6 +1108,9 @@ class _SettingsScreenState extends State<SettingsScreen> {_notifSpeedBookmark = notifSpeedBookmark;_duckBriefInterruptions = duckBriefInterruptions;_autoplayOnCarConnect = autoplayOnCarConnect;+ _keepScreenOnPlayer = keepScreenOnPlayer;+ _keepScreenOnCarMode = keepScreenOnCarMode;+ _carDisconnectRewind = carDisconnectRewind;_carBookSort = carBookSort;_carBookSortReverse = carBookSortReverse;_carPodcastSort = carPodcastSort;@@ -2437,6 +2446,17 @@ class _SettingsScreenState extends State<SettingsScreen> {} : null,),const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: Text(l.keepScreenOnPlayer),+ subtitle: Text(l.keepScreenOnPlayerSubtitle,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _keepScreenOnPlayer,+ onChanged: _loaded ? (v) {+ setState(() => _keepScreenOnPlayer = v);+ PlayerSettings.setKeepScreenOnInPlayer(v);+ } : null,+ ),+ const Divider(height: 1, indent: 16, endIndent: 16),ValueListenableBuilder<bool>(valueListenable: classicWordingNotifier,builder: (context, _, __) {@@ -3096,6 +3116,48 @@ class _SettingsScreenState extends State<SettingsScreen> {} : null,),const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: Text(l.keepScreenOnCarMode),+ subtitle: Text(l.keepScreenOnCarModeSubtitle,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _keepScreenOnCarMode,+ onChanged: _loaded ? (v) {+ setState(() => _keepScreenOnCarMode = v);+ PlayerSettings.setKeepScreenOnInCarMode(v);+ } : null,+ ),+ const Divider(height: 1, indent: 16, endIndent: 16),+ Padding(+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),+ child: Row(+ children: [+ Expanded(+ child: Row(children: [+ Flexible(child: Text(l.carDisconnectRewind, style: tt.bodyMedium)),+ _infoIcon(l.carDisconnectRewind, l.carDisconnectRewindInfo),+ ]),+ ),+ Text(+ _carDisconnectRewind == 0+ ? l.carDisconnectRewindOff+ : l.carDisconnectRewindValue(_carDisconnectRewind),+ style: tt.bodyMedium?.copyWith(+ fontWeight: FontWeight.w700, color: cs.primary)),+ ],+ ),+ ),+ Slider(+ value: _carDisconnectRewind.toDouble(),+ min: 0,+ max: 30,+ divisions: 30,+ onChanged: _loaded ? (v) {+ setState(() => _carDisconnectRewind = v.round());+ } : null,+ onChangeEnd: (v) =>+ PlayerSettings.setCarDisconnectRewindSeconds(v.round()),+ ),+ const Divider(height: 1, indent: 16, endIndent: 16),_carSortPicker(tt,l.carBookOrder,diff --git a/lib/screens/settings_search_index.dart b/lib/screens/settings_search_index.dartindex 3e6809a2..242f9825 100644--- a/lib/screens/settings_search_index.dart+++ b/lib/screens/settings_search_index.dart@@ -46,6 +46,7 @@ List<SettingSearchEntry> settingsSearchEntries(BuildContext context) {SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.cardBackground, [l.cardBackgroundBlurred, l.cardBackgroundGradient, l.off]),SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.cardScrubbers, [l.cardScrubbersBothSubtitle, l.cardScrubbersChapterSubtitle, l.cardScrubbersLockedSubtitle]),SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.speedAdjustedTime, [l.speedAdjustedTimeOnSubtitle, l.speedAdjustedTimeOffSubtitle]),+ SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.keepScreenOnPlayer, [l.keepScreenOnPlayerSubtitle]),SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, w.mergeLibraries, [w.mergeLibrariesOnSubtitle, w.mergeLibrariesOffSubtitle, l.settingsMergeImpliedByPodcastTab]),SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.queueMode, [l.queueModeMergedSubtitle, l.queueModeBooks, l.queueModePodcasts, l.queueModeOff, l.queueModeManual, l.queueModeAuto, l.queueModeSeriesLabel, l.queueModeShowLabel, l.queueModePlaylist]),SettingSearchEntry('Absorbing Cards', w.sectionAbsorbingCards, l.autoDownloadQueue, [l.autoDownloadQueueOffSubtitle]),@@ -78,6 +79,8 @@ List<SettingSearchEntry> settingsSearchEntries(BuildContext context) {SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar,Platform.isIOS ? l.carConnectAutoplayIos : l.carConnectAutoplay,[l.carConnectAutoplayOnSubtitle, l.carConnectAutoplayOffSubtitle]),+ SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.keepScreenOnCarMode, [l.keepScreenOnCarModeSubtitle]),+ SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carDisconnectRewind, [l.carDisconnectRewindInfo]),SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carBookOrder, [l.title, l.author, l.dateAdded]),SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carBookOrderReverse, [l.carBookOrderReverseSubtitle]),SettingSearchEntry('Car', Platform.isIOS ? l.sectionCarIos : l.sectionCar, l.carPodcastOrder, [l.title, l.dateAdded]),diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dartindex b43300bb..ac2f3977 100644--- a/lib/services/audio_player_service.dart+++ b/lib/services/audio_player_service.dart@@ -114,7 +114,9 @@ class AudioPlayerHandler extends BaseAudioHandler with SeekHandler {'keyCode=${snap['lastKeyCode']} keyAgeMs=${snap['lastKeyAgeMs']} ''lastPlayCaller=${snap['lastPlayCaller']} playAgeMs=${snap['lastPlayCallerAgeMs']} ''lastPauseCaller=${snap['lastPauseCaller']} pauseAgeMs=${snap['lastPauseCallerAgeMs']} '- 'carClientAgeMs=${snap['carClientAgeMs']} keyPkg=${snap['lastKeyPkg']}',+ 'carClientAgeMs=${snap['carClientAgeMs']} '+ 'carState=${snap['carConnectionState']} carGoneAgeMs=${snap['carGoneAgeMs']} '+ 'keyPkg=${snap['lastKeyPkg']}',);}@@ -3110,6 +3112,7 @@ class AudioPlayerService extends ChangeNotifier {debugPrint('[AudioSession] Permanent focus loss - not resuming on its own',);+ unawaited(service._rewindIfCarJustLeft());}// The notification reads the player directly, but the home// widget, cards and watch only refresh on notify - without this@@ -7361,6 +7364,7 @@ class AudioPlayerService extends ChangeNotifier {_stuckCheckTimer = null;}await _player?.pause();+ unawaited(_rewindIfCarJustLeft());_logEvent(PlaybackEventType.pause);_onPlaybackStateChangedCallback?.call(false);@@ -7476,6 +7480,62 @@ class AudioPlayerService extends ChangeNotifier {notifyListeners();}+ /// CarPlay reported the car gone. iOS pauses on the lost route on its own,+ /// so a pause in the last moments counts the same as still playing.+ Future<void> onCarDisconnected() async {+ final lastPause = _lastPauseTime;+ final pausedByRoute = !isPlaying &&+ _noisyPause &&+ lastPause != null &&+ DateTime.now().difference(lastPause) < const Duration(seconds: 20);+ if (!isPlaying && !pausedByRoute) return;+ if (isPlaying) await pause();+ await rewindForCarDisconnect();+ }++ DateTime? _lastCarRewindAt;++ /// Android: a pause that may be the system's late reaction to the car going+ /// away. The service stamps the moment Android Auto's projection ended; if+ /// that was just before this pause, or turns up within a few seconds after+ /// it, the stretch in between played to nobody.+ Future<void> _rewindIfCarJustLeft() async {+ if (!Platform.isAndroid) return;+ if (await PlayerSettings.getCarDisconnectRewindSeconds() <= 0) return;+ final last = _lastCarRewindAt;+ if (last != null && DateTime.now().difference(last) < const Duration(minutes: 1)) {+ return;+ }+ for (var attempt = 0; attempt < 3; attempt++) {+ final snap = await AudioPlayerHandler._absorbDiagSnapshot();+ final gone = snap?['carGoneAgeMs'];+ debugPrint('[CarRewind] check ${attempt + 1}: carState=${snap?['carConnectionState']} '+ 'carGoneAgeMs=$gone playing=$isPlaying');+ if (gone is int && gone >= 0 && gone < 30000) {+ _lastCarRewindAt = DateTime.now();+ await rewindForCarDisconnect();+ return;+ }+ if (isPlaying) return;+ await Future.delayed(const Duration(seconds: 4));+ }+ }++ /// Takes back the stretch that played after the car disconnected, in real+ /// seconds, so the setting matches a stopwatch at any playback speed.+ Future<void> rewindForCarDisconnect() async {+ final seconds = await PlayerSettings.getCarDisconnectRewindSeconds();+ if (seconds <= 0 || _player == null || !hasBook) return;+ var target = position - Duration(milliseconds: (seconds * 1000 * speed).round());+ if (target < Duration.zero) target = Duration.zero;+ debugPrint('[CarRewind] car disconnected while playing - rewinding ${seconds}s');+ await seekTo(+ target,+ logAs: PlaybackEventType.autoRewind,+ logDetail: '${seconds}s (car disconnected)',+ );+ }+/// Rewind triggered by the sleep timer firing. Same mechanics as a manual/// seek-back, but logged as an auto-rewind so the playback history reads/// "Auto-rewound 15m (sleep timer)" instead of a raw seek (GH #232).diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dartindex aaac1a2d..7f22e3cd 100644--- a/lib/services/backup_service.dart+++ b/lib/services/backup_service.dart@@ -30,6 +30,9 @@ class BackupService {'cardScrubberMode': (await PlayerSettings.getCardScrubberMode()).name,'showBookSlider': await PlayerSettings.getShowBookSlider(),'speedAdjustedTime': await PlayerSettings.getSpeedAdjustedTime(),+ 'keepScreenOnPlayer': await PlayerSettings.getKeepScreenOnInPlayer(),+ 'keepScreenOnCarMode': await PlayerSettings.getKeepScreenOnInCarMode(),+ 'carDisconnectRewind': await PlayerSettings.getCarDisconnectRewindSeconds(),'forwardSkip': await PlayerSettings.getForwardSkip(),'backSkip': await PlayerSettings.getBackSkip(),'longSkipButtons': await PlayerSettings.getLongSkipButtons(),@@ -535,6 +538,9 @@ class BackupService {await PlayerSettings.setShowBookSlider(s['showBookSlider'] as bool);}if (s['speedAdjustedTime'] != null) PlayerSettings.setSpeedAdjustedTime(s['speedAdjustedTime'] as bool);+ if (s['keepScreenOnPlayer'] != null) PlayerSettings.setKeepScreenOnInPlayer(s['keepScreenOnPlayer'] as bool);+ if (s['keepScreenOnCarMode'] != null) PlayerSettings.setKeepScreenOnInCarMode(s['keepScreenOnCarMode'] as bool);+ if (s['carDisconnectRewind'] != null) PlayerSettings.setCarDisconnectRewindSeconds(s['carDisconnectRewind'] as int);if (s['forwardSkip'] != null) PlayerSettings.setForwardSkip(s['forwardSkip'] as int);if (s['backSkip'] != null) PlayerSettings.setBackSkip(s['backSkip'] as int);if (s['shakeMode'] != null) PlayerSettings.setShakeMode(s['shakeMode'] as String);diff --git a/lib/services/carplay_service.dart b/lib/services/carplay_service.dartindex 1d863874..fe0093b5 100644--- a/lib/services/carplay_service.dart+++ b/lib/services/carplay_service.dart@@ -88,6 +88,7 @@ class CarPlayService {void _onConnectionChange(ConnectionStatusTypes status) {debugPrint('[CarPlay] Connection status: $status');if (status == ConnectionStatusTypes.disconnected) {+ if (_connected) unawaited(AudioPlayerService().onCarDisconnected());_connected = false;_rootTemplate = null;_lastRootBuilt = null;diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 044ab94f..1aa674a6 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -843,6 +843,15 @@ class PlayerSettings {// alive but paused) belongs to the car system's own resume behavior; this// covers the cold start where no session exists for it to resume.static Future<bool> getAutoplayOnCarConnect() => _get('autoplayOnCarConnect', false);+ static Future<bool> getKeepScreenOnInPlayer() => _get('keepScreenOnPlayer', false);+ static Future<void> setKeepScreenOnInPlayer(bool value) =>+ _set('keepScreenOnPlayer', value, notify: true);+ static Future<bool> getKeepScreenOnInCarMode() => _get('keepScreenOnCarMode', false);+ static Future<int> getCarDisconnectRewindSeconds() => _get('carDisconnectRewind', 0);+ static Future<void> setCarDisconnectRewindSeconds(int seconds) =>+ _set('carDisconnectRewind', seconds, notify: true);+ static Future<void> setKeepScreenOnInCarMode(bool value) =>+ _set('keepScreenOnCarMode', value, notify: true);// Android Auto / CarPlay library browsing. Book sort is 'title', 'author' or// 'added' (newest first); reverse flips whichever is picked. Podcast shows@@ -1203,7 +1212,7 @@ class PlayerSettings {// ── Card button order ──- static const defaultButtonOrder = ['chapters', 'speed', 'sleep', 'bookmarks', 'details', 'ebook', 'findinebook', 'lyrics', 'equalizer', 'cast', 'airplay', 'history', 'remove', 'car', 'notes', 'download'];+ static const defaultButtonOrder = ['chapters', 'speed', 'sleep', 'bookmarks', 'details', 'ebook', 'findinebook', 'lyrics', 'equalizer', 'cast', 'airplay', 'history', 'remove', 'car', 'notes', 'wake', 'download'];static Future<List<String>> getCardButtonOrder() async {final stored = await ScopedPrefs.getStringList('card_button_order');diff --git a/lib/services/screen_wake.dart b/lib/services/screen_wake.dartindex d0f4949c..993f033c 100644--- a/lib/services/screen_wake.dart+++ b/lib/services/screen_wake.dart@@ -1,17 +1,66 @@import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';+import 'player_settings.dart';+/// Keeps the screen from timing out while something hands-free is on screen,/// like the ebook reader's auto scroll. FLAG_KEEP_SCREEN_ON on Android, the-/// idle timer on iOS. Callers must release it: neither platform clears it.+/// idle timer on iOS. Each caller holds it under its own name and must let+/// go: neither platform clears it, and the screen stays on while anyone holds.class ScreenWake {static const _channel = MethodChannel('com.absorb.screen_wake');+ static final _holders = <String>{};+ static bool _on = false;- static Future<void> keepOn(bool on) async {+ static Future<void> hold(String owner, bool on) async {+ if (on) {+ _holders.add(owner);+ } else {+ _holders.remove(owner);+ }+ final want = _holders.isNotEmpty;+ if (want == _on) return;+ _on = want;try {- await _channel.invokeMethod('set', {'on': on});+ await _channel.invokeMethod('set', {'on': want});} catch (e) {- debugPrint('[ScreenWake] keepOn($on) failed: $e');+ debugPrint('[ScreenWake] keepOn($want) failed: $e');}}}++/// The player's hold: while the Absorbing tab or the full screen card is up,+/// playing or paused, when the Settings switch or the card's button asks. The+/// button lasts until the app is closed; the switch is for good.+class PlayerScreenWake {+ static final sessionOn = ValueNotifier<bool>(false);+ static final onScreen = ValueNotifier<bool>(false);+ // The ebook reader sits over the shell and holds the screen on its own terms.+ static final covered = ValueNotifier<bool>(false);+ /// What the card's button shows: the switch or the session toggle.+ static final wanted = ValueNotifier<bool>(false);+ static bool _always = false;+ static bool _started = false;++ static bool get always => _always;++ static void start() {+ if (_started) return;+ _started = true;+ sessionOn.addListener(_sync);+ onScreen.addListener(_sync);+ covered.addListener(_sync);+ PlayerSettings.settingsChanged.addListener(_reload);+ _reload();+ }++ static Future<void> _reload() async {+ _always = await PlayerSettings.getKeepScreenOnInPlayer();+ _sync();+ }++ static void _sync() {+ wanted.value = _always || sessionOn.value;+ ScreenWake.hold('player', wanted.value && onScreen.value && !covered.value);+ }+}diff --git a/lib/widgets/card_button_config.dart b/lib/widgets/card_button_config.dartindex 870131b3..a3aa5565 100644--- a/lib/widgets/card_button_config.dart+++ b/lib/widgets/card_button_config.dart@@ -39,6 +39,8 @@ String localizedCardButtonLabel(AppLocalizations l, CardButtonDef def) {return l.carModeTitle;case 'notes':return l.notes;+ case 'wake':+ return l.keepScreenOn;case 'download':return l.download;case 'ebook':@@ -75,6 +77,7 @@ const _allCardButtons = [CardButtonDef('remove', 'Remove from Absorbing', Icons.remove_circle_outline_rounded),CardButtonDef('car', 'Car Mode', Icons.directions_car_rounded),CardButtonDef('notes', 'Notes', Icons.note_rounded),+ CardButtonDef('wake', 'Keep screen on', Icons.lightbulb_outline_rounded),CardButtonDef('download', 'Download', Icons.download_outlined),CardButtonDef('ebook', 'Read', Icons.menu_book_rounded),CardButtonDef('findinebook', 'Find position in ebook', Icons.manage_search_rounded),diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex fdbe9e15..346c69f7 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -18,6 +18,7 @@ import '../services/transcription_service.dart';import '../services/equalizer_service.dart';import '../services/playback_history_service.dart';import '../services/scoped_prefs.dart';+import '../services/screen_wake.dart';import '../services/sleep_timer_service.dart';import '../utils/episode_key.dart';import 'absorb_slider.dart';@@ -81,6 +82,22 @@ 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.+void toggleKeepScreenOn(BuildContext context) {+ final l = AppLocalizations.of(context)!;+ if (PlayerScreenWake.always) {+ showOverlayToast(context, l.keepScreenOnAlwaysHint,+ icon: Icons.lightbulb_rounded);+ return;+ }+ final on = !PlayerScreenWake.sessionOn.value;+ PlayerScreenWake.sessionOn.value = on;+ showOverlayToast(context, on ? l.keepScreenOnUntilClosed : l.keepScreenOnOff,+ icon: on ? Icons.lightbulb_rounded : Icons.lightbulb_outline_rounded);+}+void showInactiveToast(BuildContext context) {final l = AppLocalizations.of(context)!;showOverlayToast(context, l.startPlayingSomethingFirst,@@ -1857,6 +1874,17 @@ class CardActionDelegate {accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact, iconsOnly: iconsOnly,onTap: () => openCarMode(context),);+ case 'wake':+ return ValueListenableBuilder<bool>(+ valueListenable: PlayerScreenWake.wanted,+ builder: (_, on, __) => CardWideButton(+ icon: on ? Icons.lightbulb_rounded : Icons.lightbulb_outline_rounded,+ label: l.keepScreenOn,+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact, iconsOnly: iconsOnly,+ highlighted: on,+ onTap: () => toggleKeepScreenOn(context),+ ),+ );case 'notes':return CardWideButton(icon: Icons.note_rounded, label: l.notes,@@ -2012,6 +2040,14 @@ class CardActionDelegate {icon: Icons.directions_car_rounded, label: l.carModeTitle, accent: accent,onTap: () { Navigator.pop(ctx); openCarMode(context); },);+ case 'wake':+ return MoreMenuItem(+ icon: PlayerScreenWake.wanted.value+ ? Icons.lightbulb_rounded+ : Icons.lightbulb_outline_rounded,+ label: l.keepScreenOn, accent: accent,+ onTap: () { Navigator.pop(ctx); toggleKeepScreenOn(context); },+ );case 'notes':return MoreMenuItem(icon: Icons.note_rounded, label: l.notes, accent: accent,diff --git a/lib/widgets/ebook_reader_view.dart b/lib/widgets/ebook_reader_view.dartindex 4a68e2a5..d35e368b 100644--- a/lib/widgets/ebook_reader_view.dart+++ b/lib/widgets/ebook_reader_view.dart@@ -638,10 +638,10 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs/// releases it outright since the platform never clears it on its own.void _syncScreenWake() {if (_screenWakeHeldOff) {- ScreenWake.keepOn(false);+ ScreenWake.hold('reader', false);return;}- ScreenWake.keepOn(_keepAwake || _autoScroll || _readAlongOn);+ ScreenWake.hold('reader', _keepAwake || _autoScroll || _readAlongOn);}/// The reader is being used again after the auto scroll sleep timer let@@ -685,7 +685,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs_speedToast?.dismiss();_autoScrollSleepTimer?.cancel();if (_autoScroll) _epubController?.autoScrollStop();- ScreenWake.keepOn(false);+ ScreenWake.hold('reader', false);_quietLib.setReaderQuiet(false);WidgetsBinding.instance.removeObserver(this);_volumeNav.detach();@@ -1944,7 +1944,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsawait _epubController?.autoScrollStart(speed: _autoScrollSpeed) ?? false;if (!mounted || !started) return;_screenWakeHeldOff = false;- ScreenWake.keepOn(true);+ ScreenWake.hold('reader', true);showOverlayToast(context, AppLocalizations.of(context)!.readerAutoScrollStarted,icon: Icons.swap_vert_rounded);setState(() {@@ -3950,7 +3950,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs_readAlongLastMatch = DateTime.now();_readAlongLost = false;_readAlongSeekAt = null;- ScreenWake.keepOn(true);+ ScreenWake.hold('reader', true);_readAlongTimer?.cancel();// 100ms so a word is never skipped at 2x: the sweep below moves at most// one word per tick, ten words a second.diff --git a/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java b/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.javaindex 7c0ffaaf..428ab40b 100644--- a/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java+++ b/packages/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java@@ -7,6 +7,8 @@ import android.app.PendingIntent;import android.content.ComponentName;import android.content.Context;import android.content.Intent;+import android.database.ContentObserver;+import android.database.Cursor;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.media.AudioManager;@@ -129,6 +131,54 @@ public class AudioService extends MediaBrowserServiceCompat {if (isCarPackage(pkg)) lastCarClientAt = SystemClock.elapsedRealtime();}+ // Android Auto's connection, from the car app connection provider:+ // 2 = projection (Android Auto), 1 = the car's own Android, 0 = no car.+ // The moment projection ends is stamped so Dart can tell the system's+ // late pause after the engine went off from an ordinary pause.+ private static final Uri CAR_CONNECTION_URI = Uri.parse("content://androidx.car.app.connection");+ private static volatile int carConnectionState = 0;+ private static volatile long carGoneAt = 0;+ private ContentObserver carConnectionObserver;++ private void readCarConnectionState() {+ int state = 0;+ try (Cursor c = getContentResolver().query(CAR_CONNECTION_URI,+ new String[]{"CarConnectionState"}, null, null, null)) {+ if (c != null && c.moveToFirst()) {+ int col = c.getColumnIndex("CarConnectionState");+ if (col >= 0) state = c.getInt(col);+ }+ } catch (Exception e) {+ // No Android Auto on this phone.+ }+ if (carConnectionState == 2 && state != 2) carGoneAt = SystemClock.elapsedRealtime();+ carConnectionState = state;+ }++ private void watchCarConnection() {+ try {+ carConnectionObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {+ @Override+ public void onChange(boolean selfChange) {+ readCarConnectionState();+ }+ };+ getContentResolver().registerContentObserver(CAR_CONNECTION_URI, false, carConnectionObserver);+ } catch (Exception e) {+ carConnectionObserver = null;+ }+ readCarConnectionState();+ }++ private void stopWatchingCarConnection() {+ if (carConnectionObserver == null) return;+ try {+ getContentResolver().unregisterContentObserver(carConnectionObserver);+ } catch (Exception ignored) {+ }+ carConnectionObserver = null;+ }+public static Map<String, Object> getDiagnosticSnapshot() {final long now = SystemClock.elapsedRealtime();final Map<String, Object> snapshot = new HashMap<>();@@ -139,6 +189,8 @@ public class AudioService extends MediaBrowserServiceCompat {snapshot.put("lastPauseCaller", "mediaSession");snapshot.put("lastPauseCallerAgeMs", lastPauseAt == 0 ? -1 : now - lastPauseAt);snapshot.put("carClientAgeMs", lastCarClientAt == 0 ? -1 : now - lastCarClientAt);+ snapshot.put("carConnectionState", carConnectionState);+ snapshot.put("carGoneAgeMs", carGoneAt == 0 ? -1 : now - carGoneAt);snapshot.put("lastKeyPkg", lastMediaKeyPkg);return snapshot;}@@ -378,6 +430,7 @@ public class AudioService extends MediaBrowserServiceCompat {playing = false;processingState = AudioProcessingState.idle;mediaSession = new MediaSessionCompat(this, "media-session");+ watchCarConnection();configure(new AudioServiceConfig(getApplicationContext()));@@ -434,6 +487,7 @@ public class AudioService extends MediaBrowserServiceCompat {@Overridepublic void onDestroy() {super.onDestroy();+ stopWatchingCarConnection();if (listener != null) {listener.onDestroy();listener = null;