A cross platform Audiobookshelf client for Android and iOS
Dart
Remove audio output, keep screen awake, and disable audio focus features; fix series scroll perf; bump 1.8.62
Nathan Poulsond53d384dc81b
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.ktindex ddecb548..0abd5460 100644--- a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt+++ b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt@@ -16,7 +16,6 @@ import android.os.StatFsimport android.util.Logimport com.ryanheise.audioservice.AudioServiceActivityimport com.ryanheise.just_audio.MonoController-import com.ryanheise.just_audio.OutputDeviceControllerimport io.flutter.embedding.engine.FlutterEngineimport io.flutter.plugin.common.MethodChannel@@ -29,7 +28,6 @@ class MainActivity : AudioServiceActivity() {private var virtualizer: Virtualizer? = nullprivate var loudnessEnhancer: LoudnessEnhancer? = nullprivate var currentSessionId: Int = 0- private var selectedOutputDeviceId: Int? = null // user's manual overrideprivate var eqLoudnessGainMb: Int = 0 // extra gain from EQ loudness slidercompanion object {@@ -87,23 +85,6 @@ class MainActivity : AudioServiceActivity() {}Log.d(TAG, "EQ method channel registered")- MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.absorb.audio_output")- .setMethodCallHandler { call, result ->- when (call.method) {- "getAudioOutputDevices" -> {- result.success(getAudioOutputDevices())- }- "setAudioOutputDevice" -> {- val id = call.argument<Int>("id") ?: 0- result.success(setAudioOutputDevice(id))- }- "resetAudioOutput" -> {- result.success(resetAudioOutput())- }- else -> result.notImplemented()- }- }-MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.absorb.storage").setMethodCallHandler { call, result ->when (call.method) {@@ -239,100 +220,6 @@ class MainActivity : AudioServiceActivity() {}}- private fun getAudioOutputDevices(): List<Map<String, Any>> {- val am = getSystemService(Context.AUDIO_SERVICE) as AudioManager- val devices = am.getDevices(AudioManager.GET_DEVICES_OUTPUTS)- .filter { isMediaOutputDevice(it.type) }-- // If user has manually selected a device, use that; otherwise fall back to priority- val manualId = selectedOutputDeviceId- val hasManualSelection = manualId != null && devices.any { it.id == manualId }-- // Determine active output by priority: wired > BT A2DP > USB > speaker- val activeTypes: Set<Int> = when {- devices.any { it.type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES || it.type == AudioDeviceInfo.TYPE_WIRED_HEADSET } ->- setOf(AudioDeviceInfo.TYPE_WIRED_HEADPHONES, AudioDeviceInfo.TYPE_WIRED_HEADSET)- devices.any { it.type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP } ->- setOf(AudioDeviceInfo.TYPE_BLUETOOTH_A2DP)- devices.any { it.type == AudioDeviceInfo.TYPE_USB_DEVICE || it.type == AudioDeviceInfo.TYPE_USB_HEADSET } ->- setOf(AudioDeviceInfo.TYPE_USB_DEVICE, AudioDeviceInfo.TYPE_USB_HEADSET)- else -> setOf(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER)- }-- // Deduplicate: prefer A2DP over SCO for same product name- val seen = mutableSetOf<String>()- return devices- .sortedBy { if (it.type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP) 0 else 1 }- .filter { device ->- val key = device.productName?.toString()?.takeIf { it.isNotBlank() } ?: device.id.toString()- seen.add(key)- }- .map { device ->- val typeName = getOutputTypeName(device.type)- val name = device.productName?.toString()?.takeIf { it.isNotBlank() }- ?: getOutputTypeLabel(device.type)- val isActive = if (hasManualSelection) device.id == manualId- else device.type in activeTypes- mapOf(- "id" to device.id,- "name" to name,- "typeName" to typeName,- "isActive" to isActive- )- }- }-- private fun isMediaOutputDevice(type: Int): Boolean {- return type in listOf(- AudioDeviceInfo.TYPE_BUILTIN_SPEAKER,- AudioDeviceInfo.TYPE_WIRED_HEADPHONES,- AudioDeviceInfo.TYPE_WIRED_HEADSET,- AudioDeviceInfo.TYPE_BLUETOOTH_A2DP,- AudioDeviceInfo.TYPE_USB_DEVICE,- AudioDeviceInfo.TYPE_USB_HEADSET,- )- }-- private fun getOutputTypeName(type: Int): String {- return when (type) {- AudioDeviceInfo.TYPE_BUILTIN_SPEAKER -> "speaker"- AudioDeviceInfo.TYPE_WIRED_HEADPHONES, AudioDeviceInfo.TYPE_WIRED_HEADSET -> "wired"- AudioDeviceInfo.TYPE_BLUETOOTH_A2DP -> "bluetooth"- AudioDeviceInfo.TYPE_USB_DEVICE, AudioDeviceInfo.TYPE_USB_HEADSET -> "usb"- else -> "unknown"- }- }-- private fun getOutputTypeLabel(type: Int): String {- return when (type) {- AudioDeviceInfo.TYPE_BUILTIN_SPEAKER -> "This Phone"- AudioDeviceInfo.TYPE_WIRED_HEADPHONES -> "Wired Headphones"- AudioDeviceInfo.TYPE_WIRED_HEADSET -> "Wired Headset"- AudioDeviceInfo.TYPE_BLUETOOTH_A2DP -> "Bluetooth"- AudioDeviceInfo.TYPE_USB_DEVICE -> "USB Audio"- AudioDeviceInfo.TYPE_USB_HEADSET -> "USB Headset"- else -> "Audio Device"- }- }-- private fun setAudioOutputDevice(deviceId: Int): Boolean {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {- val am = getSystemService(Context.AUDIO_SERVICE) as AudioManager- val devices = am.getDevices(AudioManager.GET_DEVICES_OUTPUTS)- val target = devices.firstOrNull { it.id == deviceId }- OutputDeviceController.setPreferredOutputDevice(target)- selectedOutputDeviceId = deviceId- return true- }- return false- }-- private fun resetAudioOutput(): Boolean {- OutputDeviceController.setPreferredOutputDevice(null)- selectedOutputDeviceId = null- return true- }-private fun releaseEffects() {try { equalizer?.release() } catch (_: Exception) {}try { bassBoost?.release() } catch (_: Exception) {}diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swiftindex 53b0b47f..42771fac 100644--- a/ios/Runner/AppDelegate.swift+++ b/ios/Runner/AppDelegate.swift@@ -31,24 +31,6 @@ import AVFoundationGeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)guard let controller = window?.rootViewController as? FlutterViewController else { return }- let channel = FlutterMethodChannel(name: "com.absorb.audio_output",- binaryMessenger: controller.binaryMessenger)- channel.setMethodCallHandler { [weak self] (call, result) in- switch call.method {- case "getAudioOutputDevices":- result(self?.getAudioOutputDevices() ?? [])- case "setAudioOutputDevice":- if let args = call.arguments as? [String: Any], let id = args["id"] as? Int {- result(self?.setAudioOutputDevice(portIndex: id) ?? false)- } else {- result(false)- }- case "resetAudioOutput":- result(self?.resetAudioOutput() ?? false)- default:- result(FlutterMethodNotImplemented)- }- }let storageChannel = FlutterMethodChannel(name: "com.absorb.storage",binaryMessenger: controller.binaryMessenger)@@ -88,83 +70,4 @@ import AVFoundation}}- private func getAudioOutputDevices() -> [[String: Any]] {- let session = AVAudioSession.sharedInstance()- let currentOutputs = session.currentRoute.outputs- let currentPortUIDs = Set(currentOutputs.map { $0.uid })-- var devices: [[String: Any]] = []- var seenTypes = Set<String>()-- // Add current outputs first- for port in currentOutputs {- let typeName = portTypeName(port.portType)- seenTypes.insert(typeName)- devices.append([- "id": port.uid.hashValue,- "name": port.portName,- "typeName": typeName,- "isActive": true,- "uid": port.uid,- ])- }-- // Add available outputs that aren't current- for output in session.availableInputs ?? [] {- // availableInputs on iOS - for Bluetooth HFP, the input port maps to output too- }-- // Always add speaker if not already current- if !seenTypes.contains("speaker") {- devices.append([- "id": "speaker".hashValue,- "name": "This iPhone",- "typeName": "speaker",- "isActive": false,- "uid": "speaker",- ])- }-- return devices- }-- private func portTypeName(_ portType: AVAudioSession.Port) -> String {- switch portType {- case .bluetoothA2DP, .bluetoothHFP, .bluetoothLE:- return "bluetooth"- case .headphones:- return "wired"- case .builtInSpeaker:- return "speaker"- case .builtInReceiver:- return "earpiece"- case .usbAudio:- return "usb"- default:- return "unknown"- }- }-- private func setAudioOutputDevice(portIndex: Int) -> Bool {- let session = AVAudioSession.sharedInstance()- // If requesting speaker, override to speaker- if portIndex == "speaker".hashValue {- do {- try session.overrideOutputAudioPort(.speaker)- return true- } catch { return false }- }- // Otherwise, clear override to let system route to connected device- do {- try session.overrideOutputAudioPort(.none)- return true- } catch { return false }- }-- private func resetAudioOutput() -> Bool {- do {- try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)- return true- } catch { return false }- }}diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex b43ed3d2..35d43b52 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -82,8 +82,6 @@ class _SettingsScreenState extends State<SettingsScreen> {bool _localServerEnabled = false;String _localServerUrl = '';late final TextEditingController _localServerController;- bool _keepScreenAwake = false;- bool _disableAudioFocus = false;bool _trustAllCerts = false;bool _includePreReleases = false;bool _loaded = false;@@ -180,8 +178,7 @@ class _SettingsScreenState extends State<SettingsScreen> {PlayerSettings.getStreamingCacheSizeMb(), // 30PlayerSettings.getLocalServerEnabled(), // 31PlayerSettings.getLocalServerUrl(), // 32- PlayerSettings.getDisableAudioFocus(), // 33- PlayerSettings.getAutoDownloadOnStream(), // 34+ PlayerSettings.getAutoDownloadOnStream(), // 33PlayerSettings.getStartScreen(), // 36PlayerSettings.getPodcastQueueMode(), // 37PlayerSettings.getCardButtonLayout(), // 38@@ -224,17 +221,16 @@ class _SettingsScreenState extends State<SettingsScreen> {final cacheSizeMb = results[29] as int;final localEnabled = results[30] as bool;final localUrl = results[31] as String;- final audioFocusOff = results[32] as bool;- final autoDlStream = results[33] as bool;- final startScreen = results[34] as int;- final podcastQueueMode = results[35] as String;- final cardBtnLayout = results[36] as String;- final rectCovers = results[37] as bool;- final trustCerts = results[38] as bool;- final coverPlay = results[39] as bool;- final skipBarrier = results[40] as bool;- final showExplicit = results[41] as bool;- final preReleases = results[42] as bool;+ final autoDlStream = results[32] as bool;+ final startScreen = results[33] as int;+ final podcastQueueMode = results[34] as String;+ final cardBtnLayout = results[35] as String;+ final rectCovers = results[36] as bool;+ final trustCerts = results[37] as bool;+ final coverPlay = results[38] as bool;+ final skipBarrier = results[39] as bool;+ final showExplicit = results[40] as bool;+ final preReleases = results[41] as bool;if (mounted) setState(() {_rewindSettings = s;_defaultSpeed = speed;@@ -274,7 +270,6 @@ class _SettingsScreenState extends State<SettingsScreen> {_localServerEnabled = localEnabled;_localServerUrl = localUrl;_localServerController.text = localUrl;- _disableAudioFocus = audioFocusOff;_startScreen = startScreen;_cardButtonLayout = cardBtnLayout;_rectangleCovers = rectCovers;@@ -956,18 +951,6 @@ class _SettingsScreenState extends State<SettingsScreen> {} : null,),const Divider(height: 1, indent: 16, endIndent: 16),- SwitchListTile(- title: const Text('Keep screen awake'),- subtitle: Text(- _keepScreenAwake ? 'On - screen stays on during playback' : 'Off',- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),- value: _keepScreenAwake,- onChanged: _loaded ? (v) {- setState(() => _keepScreenAwake = v);- PlayerSettings.keepScreenAwake = v;- } : null,- ),- const Divider(height: 1, indent: 16, endIndent: 16),// ── Auto-Rewind ──SwitchListTile(title: const Text('Auto-rewind on resume'),@@ -1786,43 +1769,6 @@ class _SettingsScreenState extends State<SettingsScreen> {],],const Divider(height: 1, indent: 16, endIndent: 16),- if (!Platform.isIOS) ...[- SwitchListTile(- title: Row(children: [- const Flexible(child: Text('Disable audio focus')),- _infoIcon('Audio Focus', 'By default, Android gives audio "focus" to one app at a time - when Absorb plays, other audio (music, videos) will pause. Disabling audio focus lets Absorb play alongside other apps. Phone calls will still pause playback regardless of this setting.'),- ]),- subtitle: Text(- _disableAudioFocus- ? 'On - plays alongside other audio (still pauses for calls)'- : 'Off - other audio pauses when Absorb plays',- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),- value: _disableAudioFocus,- onChanged: _loaded ? (v) async {- setState(() => _disableAudioFocus = v);- await PlayerSettings.setDisableAudioFocus(v);- if (!context.mounted) return;- final restart = await showDialog<bool>(- context: context,- builder: (ctx) => AlertDialog(- title: const Text('Restart Required'),- content: Text(- 'Audio focus change requires a full restart to take effect. '- 'Close the app now?',- ),- actions: [- TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Later')),- FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Close App')),- ],- ),- );- if (restart == true) {- SystemChannels.platform.invokeMethod('SystemNavigator.pop', true);- }- } : null,- ),- const Divider(height: 1, indent: 16, endIndent: 16),- ],SwitchListTile(title: Row(children: [const Flexible(child: Text('Trust all certificates')),diff --git a/lib/services/audio_output_service.dart b/lib/services/audio_output_service.dartdeleted file mode 100644index 9fae5fe4..00000000--- a/lib/services/audio_output_service.dart+++ /dev/null@@ -1,68 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';--class AudioOutputDevice {- final int id;- final String name;- final String typeName;- final bool isActive;-- const AudioOutputDevice({- required this.id,- required this.name,- required this.typeName,- this.isActive = false,- });-- IconData get icon {- switch (typeName) {- case 'bluetooth':- return Icons.bluetooth_rounded;- case 'wired':- return Icons.headphones_rounded;- case 'speaker':- return Icons.phone_android_rounded;- case 'earpiece':- return Icons.hearing_rounded;- case 'usb':- return Icons.usb_rounded;- default:- return Icons.volume_up_rounded;- }- }-}--class AudioOutputService {- static const _channel = MethodChannel('com.absorb.audio_output');-- static Future<List<AudioOutputDevice>> getOutputDevices() async {- try {- final result = await _channel.invokeMethod('getAudioOutputDevices');- final list = (result as List).cast<Map>();- return list.map((m) => AudioOutputDevice(- id: m['id'] as int? ?? 0,- name: m['name'] as String? ?? 'Unknown',- typeName: m['typeName'] as String? ?? 'unknown',- isActive: m['isActive'] as bool? ?? false,- )).toList();- } catch (_) {- return [];- }- }-- static Future<bool> setOutputDevice(int deviceId) async {- try {- return await _channel.invokeMethod('setAudioOutputDevice', {'id': deviceId}) == true;- } catch (_) {- return false;- }- }-- static Future<bool> resetToDefault() async {- try {- return await _channel.invokeMethod('resetAudioOutput') == true;- } catch (_) {- return false;- }- }-}diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dartindex ee9726f1..34373100 100644--- a/lib/services/audio_player_service.dart+++ b/lib/services/audio_player_service.dart@@ -7,7 +7,6 @@ import 'package:just_audio/just_audio.dart';import 'package:audio_service/audio_service.dart';import 'package:audio_session/audio_session.dart';import 'package:shared_preferences/shared_preferences.dart';-import 'package:wakelock_plus/wakelock_plus.dart';import 'api_service.dart';import 'download_service.dart';import 'playback_history_service.dart' hide PlaybackEvent;@@ -999,53 +998,9 @@ class AudioPlayerService extends ChangeNotifier {/// starting new playback to avoid blasting audio on the phone speaker.static bool get wasNoisyPause => _noisyPause;- static bool _audioFocusDisabled = false;-static Future<void> _configureAudioSession() async {- _audioFocusDisabled = await PlayerSettings.getDisableAudioFocus();final session = await AudioSession.instance;- if (_audioFocusDisabled) {- // Allow mixing with other audio - don't request exclusive focus- await session.configure(const AudioSessionConfiguration(- avAudioSessionCategory: AVAudioSessionCategory.playback,- avAudioSessionMode: AVAudioSessionMode.defaultMode,- avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.mixWithOthers,- androidAudioAttributes: AndroidAudioAttributes(- contentType: AndroidAudioContentType.music,- usage: AndroidAudioUsage.media,- ),- androidAudioFocusGainType: AndroidAudioFocusGainType.gainTransientMayDuck,- ));- debugPrint('[AudioSession] Audio focus disabled - mixing with other apps');-- // Ignore all interruption events - can't distinguish Spotify from- // phone calls, so disable everything when user opts out of audio focus- _interruptSub?.cancel();- _interruptSub = null;-- // Still pause when headphones/BT disconnect- _noisySub?.cancel();- _noisySub = session.becomingNoisyEventStream.listen((_) async {- try {- final service = _instance;- debugPrint('[AudioSession] Becoming noisy - pausing');- _noisyPause = true;- service._wasPlayingBeforeInterrupt = false;- _handler?.cancelPendingClick();- if (service.isPlaying) {- await service.pause();- }- } catch (e) {- debugPrint('[AudioSession] Noisy handler error: $e');- }- }, onError: (e) {- debugPrint('[AudioSession] Noisy stream error - re-subscribing: $e');- _configureAudioSession();- });- return;- }-await session.configure(AudioSessionConfiguration(// iOS: playback category — no duckOthers so iOS properly recognises this// app as the Now Playing app and shows lock screen / Control Center controls.@@ -1158,9 +1113,7 @@ class AudioPlayerService extends ChangeNotifier {if (!service.hasBook) return;debugPrint('[MediaSession] Foregrounded - refreshing (playing=${service.isPlaying}, session=${service._playbackSessionId != null}, item=${service._currentItemId})');// Re-activate audio session to get a fresh system token- if (!_audioFocusDisabled) {- try { (await AudioSession.instance).setActive(true); } catch (_) {}- }+ try { (await AudioSession.instance).setActive(true); } catch (_) {}// Re-push playback state so the system re-registers the MediaSession_handler?.refreshPlaybackState();// Re-push media item so notification metadata is fresh@@ -1529,9 +1482,7 @@ class AudioPlayerService extends ChangeNotifier {// reaches the audio_service iOS plugin with an active session.// Without this, iOS ignores the MPNowPlayingInfoCenter update and// lock screen / Control Center / AirPod controls never appear.- if (!_audioFocusDisabled) {- try { (await AudioSession.instance).setActive(true); } catch (_) {}- }+ try { (await AudioSession.instance).setActive(true); } catch (_) {}_player!.play();notifyListeners();_setupSync();@@ -1683,9 +1634,7 @@ class AudioPlayerService extends ChangeNotifier {await _player!.setSpeed(speed);debugPrint('[Player] Starting stream playback at ${speed}x');// Re-activate audio session before play (see local playback comment above)- if (!_audioFocusDisabled) {- try { (await AudioSession.instance).setActive(true); } catch (_) {}- }+ try { (await AudioSession.instance).setActive(true); } catch (_) {}_player!.play();notifyListeners();_setupSync();@@ -1756,9 +1705,7 @@ class AudioPlayerService extends ChangeNotifier {final speed = bookSpeed ?? await PlayerSettings.getDefaultSpeed();await _player!.setSpeed(speed);debugPrint('[Player] Transcoded playback starting at ${speed}x');- if (!_audioFocusDisabled) {- try { (await AudioSession.instance).setActive(true); } catch (_) {}- }+ try { (await AudioSession.instance).setActive(true); } catch (_) {}_player!.play();notifyListeners();_setupSync();@@ -1847,14 +1794,6 @@ class AudioPlayerService extends ChangeNotifier {));}- void _updateWakeLock(bool playing) {- if (PlayerSettings.keepScreenAwake && playing) {- debugPrint('[Battery] WakeLock ENABLED');- WakelockPlus.enable();- } else {- WakelockPlus.disable();- }- }void _clearState() {_currentItemId = null;@@ -2524,13 +2463,11 @@ class AudioPlayerService extends ChangeNotifier {}}// Re-activate audio session (needed after stop() releases it)- if (!_audioFocusDisabled) {- try { (await AudioSession.instance).setActive(true); } catch (_) {}- }+ try { (await AudioSession.instance).setActive(true); } catch (_) {}_player?.play();_logEvent(PlaybackEventType.play);_onPlaybackStateChangedCallback?.call(true);- _updateWakeLock(true);+// Restart safety-net save timer (stopped on pause to avoid background wakes)if (_bgSaveTimer == null || !_bgSaveTimer!.isActive) {_bgSaveTimer?.cancel();@@ -2571,7 +2508,7 @@ class AudioPlayerService extends ChangeNotifier {await _player?.pause();_logEvent(PlaybackEventType.pause);_onPlaybackStateChangedCallback?.call(false);- _updateWakeLock(false);+notifyListeners();final pos = position;debugPrint('[Player] Saving on pause: ${(pos.inMilliseconds / 1000.0).toStringAsFixed(1)}s');@@ -2607,10 +2544,8 @@ class AudioPlayerService extends ChangeNotifier {_playbackSessionId = null;}// Release audio focus so other apps can use it- if (!_audioFocusDisabled) {- debugPrint('[Battery] AudioSession DEACTIVATED (pause timeout)');- try { (await AudioSession.instance).setActive(false); } catch (_) {}- }+ debugPrint('[Battery] AudioSession DEACTIVATED (pause timeout)');+ try { (await AudioSession.instance).setActive(false); } catch (_) {}// Cancel sleep timerif (SleepTimerService().isActive) {SleepTimerService().cancel();@@ -2787,7 +2722,7 @@ class AudioPlayerService extends ChangeNotifier {await _player?.stop();_onPlaybackStateChangedCallback?.call(false);- _updateWakeLock(false);+_clearState();_chapters = [];_handler?.updateChaptersQueue(const []);@@ -2797,7 +2732,7 @@ class AudioPlayerService extends ChangeNotifier {}// Release audio focus so other apps can use it - but not during casting,// because deactivating the session can interfere with cast playback.- if (!_audioFocusDisabled && !ChromecastService().isCasting) {+ if (!ChromecastService().isCasting) {debugPrint('[Battery] AudioSession DEACTIVATED (stop)');try { (await AudioSession.instance).setActive(false); } catch (_) {}}diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dartindex 0f24ee31..46d8f42b 100644--- a/lib/services/backup_service.dart+++ b/lib/services/backup_service.dart@@ -61,7 +61,6 @@ class BackupService {'seriesSortAsc': await PlayerSettings.getSeriesSortAsc(),'authorSort': await PlayerSettings.getAuthorSort(),'authorSortAsc': await PlayerSettings.getAuthorSortAsc(),- 'disableAudioFocus': await PlayerSettings.getDisableAudioFocus(),'trustAllCerts': await PlayerSettings.getTrustAllCerts(),'localServerEnabled': await PlayerSettings.getLocalServerEnabled(),'localServerUrl': await PlayerSettings.getLocalServerUrl(),@@ -266,7 +265,6 @@ class BackupService {if (s['seriesSortAsc'] != null) PlayerSettings.setSeriesSortAsc(s['seriesSortAsc'] as bool);if (s['authorSort'] != null) PlayerSettings.setAuthorSort(s['authorSort'] as String);if (s['authorSortAsc'] != null) PlayerSettings.setAuthorSortAsc(s['authorSortAsc'] as bool);- if (s['disableAudioFocus'] != null) PlayerSettings.setDisableAudioFocus(s['disableAudioFocus'] as bool);if (s['trustAllCerts'] != null) PlayerSettings.setTrustAllCerts(s['trustAllCerts'] as bool);if (s['localServerEnabled'] != null) PlayerSettings.setLocalServerEnabled(s['localServerEnabled'] as bool);if (s['localServerUrl'] != null) PlayerSettings.setLocalServerUrl(s['localServerUrl'] as String);diff --git a/lib/services/chromecast_service.dart b/lib/services/chromecast_service.dartindex 1185f318..14d6827d 100644--- a/lib/services/chromecast_service.dart+++ b/lib/services/chromecast_service.dart@@ -3,7 +3,6 @@ import 'dart:io';import 'package:flutter/material.dart';import 'package:flutter_chrome_cast/flutter_chrome_cast.dart';-import 'package:wakelock_plus/wakelock_plus.dart';import 'api_service.dart';import 'audio_player_service.dart';import 'progress_sync_service.dart';@@ -181,7 +180,7 @@ class ChromecastService extends ChangeNotifier {_syncTimer?.cancel();_idleDebounceTimer?.cancel();_disconnectDebounceTimer?.cancel();- _updateWakeLock(false);+_onPlaybackStateChangedCallback?.call(false);notifyListeners();@@ -277,7 +276,7 @@ class ChromecastService extends ChangeNotifier {_idleDebounceTimer = Timer(_idleGrace, () {debugPrint('[Cast] Idle grace expired - applying idle state');_playbackState = CastPlaybackState.idle;- _updateWakeLock(false);+_onPlaybackStateChangedCallback?.call(false);notifyListeners();});@@ -297,7 +296,6 @@ class ChromecastService extends ChangeNotifier {final nowPlaying = _playbackState == CastPlaybackState.playing || _playbackState == CastPlaybackState.buffering;if (wasPlaying != nowPlaying) {_onPlaybackStateChangedCallback?.call(nowPlaying);- _updateWakeLock(nowPlaying);}// Detect playback completion: was playing/buffering → now idle@@ -777,7 +775,7 @@ class ChromecastService extends ChangeNotifier {_castingDuration = 0; _castingChapters = [];_fallbackTracks = null; _fallbackOffsets = null; _fallbackTrackIdx = -1;_idleDebounceTimer?.cancel();- _updateWakeLock(false);+_onPlaybackStateChangedCallback?.call(false);notifyListeners();}@@ -916,15 +914,6 @@ class ChromecastService extends ChangeNotifier {// ── Wake Lock ──- void _updateWakeLock(bool active) {- if (active) {- WakelockPlus.enable();- debugPrint('[Cast] Wake lock enabled');- } else {- WakelockPlus.disable();- debugPrint('[Cast] Wake lock disabled');- }- }@overridevoid dispose() {diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex 87cd8c26..19ac660b 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -170,10 +170,6 @@ class PlayerSettings {static Future<bool> getSkipChapterBarrier() => _get('skipChapterBarrier', true);static Future<void> setSkipChapterBarrier(bool value) => _set('skipChapterBarrier', value);- /// Intentionally NOT persisted - resets to false on every app start so- /// users can't accidentally leave wake lock on after a listening session.- static bool keepScreenAwake = false;-/// Cached value for synchronous access in widget build methods.static bool showExplicitBadge = true;static Future<bool> getShowExplicitBadge() => _get('showExplicitBadge', true);@@ -304,11 +300,6 @@ class PlayerSettings {static Future<bool> getCoverPlayButton() => _get('coverPlayButton', false);static Future<void> setCoverPlayButton(bool value) => _set('coverPlayButton', value, notify: true);- // ── Audio focus ──-- static Future<bool> getDisableAudioFocus() => _get('disableAudioFocus', false);- static Future<void> setDisableAudioFocus(bool value) => _set('disableAudioFocus', value);-// ── Self-signed certificates (global, not per-user) ──static Future<bool> getTrustAllCerts() async {diff --git a/lib/widgets/audio_output_sheet.dart b/lib/widgets/audio_output_sheet.dartdeleted file mode 100644index 35f777a2..00000000--- a/lib/widgets/audio_output_sheet.dart+++ /dev/null@@ -1,106 +0,0 @@-import 'package:flutter/material.dart';-import '../services/audio_output_service.dart';--class AudioOutputSheet extends StatefulWidget {- final Color accent;- const AudioOutputSheet({super.key, required this.accent});-- @override- State<AudioOutputSheet> createState() => _AudioOutputSheetState();-}--class _AudioOutputSheetState extends State<AudioOutputSheet> {- List<AudioOutputDevice> _devices = [];- bool _loading = true;-- @override- void initState() {- super.initState();- _loadDevices();- }-- Future<void> _loadDevices() async {- final devices = await AudioOutputService.getOutputDevices();- if (mounted) setState(() { _devices = devices; _loading = false; });- }-- @override- Widget build(BuildContext context) {- final cs = Theme.of(context).colorScheme;- return SafeArea(- child: Padding(- padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Container(- width: 40, height: 4,- decoration: BoxDecoration(- color: cs.onSurface.withValues(alpha: 0.24),- borderRadius: BorderRadius.circular(2),- ),- ),- const SizedBox(height: 16),- Text('Audio Output', style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w600)),- const SizedBox(height: 16),- if (_loading)- const Padding(- padding: EdgeInsets.all(24),- child: CircularProgressIndicator(),- )- else if (_devices.isEmpty)- Padding(- padding: const EdgeInsets.all(24),- child: Text('No output devices found',- style: TextStyle(color: cs.onSurface.withValues(alpha: 0.5))),- )- else- ..._devices.map((device) => _buildDeviceTile(device, cs)),- ],- ),- ),- );- }-- Widget _buildDeviceTile(AudioOutputDevice device, ColorScheme cs) {- return Padding(- padding: const EdgeInsets.only(bottom: 6),- child: GestureDetector(- onTap: () async {- await AudioOutputService.setOutputDevice(device.id);- await _loadDevices();- },- child: Container(- padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),- decoration: BoxDecoration(- color: device.isActive- ? widget.accent.withValues(alpha: 0.12)- : cs.onSurface.withValues(alpha: 0.06),- borderRadius: BorderRadius.circular(14),- border: Border.all(- color: device.isActive- ? widget.accent.withValues(alpha: 0.3)- : cs.onSurface.withValues(alpha: 0.08),- ),- ),- child: Row(- children: [- Icon(device.icon, size: 22,- color: device.isActive ? widget.accent : cs.onSurface.withValues(alpha: 0.6)),- const SizedBox(width: 14),- Expanded(- child: Text(device.name,- style: TextStyle(- fontWeight: device.isActive ? FontWeight.w600 : FontWeight.w500,- color: device.isActive ? widget.accent : cs.onSurface,- )),- ),- if (device.isActive)- Icon(Icons.check_rounded, size: 20, color: widget.accent),- ],- ),- ),- ),- );- }-}diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dartindex 0647c5a3..8f69cb39 100644--- a/lib/widgets/book_detail_sheet.dart+++ b/lib/widgets/book_detail_sheet.dart@@ -479,7 +479,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {const SizedBox(width: 8),// More button - opens styled bottom sheet with secondary actionsGestureDetector(- onTap: () => _showMoreSheet(context, auth, lib, title, authorName, progress, isFinished, duration, ebookFile, isEbookOnly),+ onTap: () => _showMoreSheet(context, auth, lib, title, authorName, progress, isFinished, duration, ebookFile, isEbookOnly, serverPath),child: Container(height: 36, width: 44,decoration: BoxDecoration(@@ -571,38 +571,12 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {])),]));})]],- // ─── Server path (tap to copy) ────────────────────────- if (serverPath.isNotEmpty) ...[const SizedBox(height: 16),- GestureDetector(- onTap: () {- Clipboard.setData(ClipboardData(text: serverPath));- HapticFeedback.lightImpact();- showOverlayToast(context, 'Path copied', icon: Icons.copy_rounded);- },- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),- decoration: BoxDecoration(- color: cs.onSurface.withValues(alpha: 0.06),- borderRadius: BorderRadius.circular(20),- border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),- ),- child: Row(children: [- Icon(Icons.folder_outlined, size: 12, color: cs.onSurface.withValues(alpha: 0.3)),- const SizedBox(width: 6),- Expanded(child: Text(serverPath, overflow: TextOverflow.ellipsis, maxLines: 1,- style: TextStyle(color: cs.onSurfaceVariant, fontSize: 11))),- const SizedBox(width: 6),- Icon(Icons.copy_rounded, size: 11, color: cs.onSurface.withValues(alpha: 0.2)),- ]),- ),- ),- ],]);}void _showMoreSheet(BuildContext context, AuthProvider auth, LibraryProvider lib,String title, String authorName, double progress, bool isFinished,- double duration, Map<String, dynamic>? ebookFile, bool isEbookOnly) {+ double duration, Map<String, dynamic>? ebookFile, bool isEbookOnly, String serverPath) {final cs = Theme.of(context).colorScheme;showModalBottomSheet(context: context,@@ -679,6 +653,19 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {final meta = media['metadata'] as Map<String, dynamic>? ?? {};showEditMetadataSheet(context, itemId: widget.itemId, metadata: meta);}),+ if (auth.isAdmin && serverPath.isNotEmpty) ...[+ const SizedBox(height: 8),+ GestureDetector(+ onTap: () {+ Clipboard.setData(ClipboardData(text: serverPath));+ HapticFeedback.lightImpact();+ Navigator.pop(ctx);+ showOverlayToast(context, 'Path copied', icon: Icons.copy_rounded);+ },+ child: Text(serverPath, maxLines: 1, overflow: TextOverflow.ellipsis,+ style: TextStyle(color: cs.onSurface.withValues(alpha: 0.25), fontSize: 11)),+ ),+ ],]),),);diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex 4b8cd7e5..ad970f34 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -1,4 +1,3 @@-import 'dart:io';import 'package:flutter/material.dart';import 'package:provider/provider.dart';import '../providers/auth_provider.dart';@@ -12,7 +11,6 @@ import '../services/playback_history_service.dart';import '../services/sleep_timer_service.dart';import 'absorb_slider.dart';import 'absorbing_shared.dart';-import 'audio_output_sheet.dart';import 'book_detail_sheet.dart';import 'card_button_config.dart';import 'card_chapters_sheet.dart';@@ -832,17 +830,6 @@ class _MoreMenuSheetState extends State<MoreMenuSheet> {return _buildNormalMode(cs, tt);}- void _showAudioOutputPicker(BuildContext context) {- showModalBottomSheet(- context: context,- backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,- shape: const RoundedRectangleBorder(- borderRadius: BorderRadius.vertical(top: Radius.circular(24)),- ),- builder: (_) => AudioOutputSheet(accent: widget.accent),- );- }-Widget _buildNormalMode(ColorScheme cs, TextTheme tt) {return Container(decoration: BoxDecoration(@@ -856,22 +843,11 @@ class _MoreMenuSheetState extends State<MoreMenuSheet> {child: Column(mainAxisSize: MainAxisSize.min,children: [- // Drag handle + audio output button + edit button+ // Drag handle + edit buttonStack(alignment: Alignment.center,children: [Container(width: 40, height: 4, decoration: BoxDecoration(color: cs.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2))),- if (!Platform.isIOS)- Align(- alignment: Alignment.centerLeft,- child: GestureDetector(- onTap: () => _showAudioOutputPicker(context),- child: Padding(- padding: const EdgeInsets.all(8),- child: Icon(Icons.volume_up_rounded, size: 18, color: cs.onSurface.withValues(alpha: 0.5)),- ),- ),- ),Align(alignment: Alignment.centerRight,child: GestureDetector(diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dartindex 81307397..f13232cf 100644--- a/lib/widgets/library_grid_tiles.dart+++ b/lib/widgets/library_grid_tiles.dart@@ -232,18 +232,26 @@ class _GridBookTileState extends State<GridBookTile> {Widget _blurCover(String coverUrl, Map<String, String> headers, ColorScheme cs, double aspectRatio) {final isSquare = (aspectRatio - 1.0).abs() < 0.01;+ // Skip blur overhead for rectangular covers - they fill the space naturally+ if (!isSquare) {+ if (coverUrl.startsWith('/')) {+ return Image.file(File(coverUrl), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder(cs));+ }+ return CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,+ httpHeaders: headers, placeholder: (_, __) => _placeholder(cs),+ errorWidget: (_, __, ___) => _placeholder(cs));+ }if (coverUrl.startsWith('/')) {return BlurPaddedCover(- enabled: isSquare,- child: Image.file(File(coverUrl), fit: isSquare ? BoxFit.contain : BoxFit.cover,+ child: Image.file(File(coverUrl), fit: BoxFit.contain,errorBuilder: (_, __, ___) => _placeholder(cs)),blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ errorBuilder: (_, __ ,___) => const SizedBox.shrink()),);}return BlurPaddedCover(- enabled: isSquare,- child: CachedNetworkImage(imageUrl: coverUrl, fit: isSquare ? BoxFit.contain : BoxFit.cover,+ child: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.contain,httpHeaders: headers, placeholder: (_, __) => _placeholder(cs),errorWidget: (_, __, ___) => _placeholder(cs)),blurChild: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,@@ -425,24 +433,14 @@ class _StackedCovers extends StatelessWidget {Widget _coverImage(String? url) {if (url == null) return _placeholder();- final isSquare = (coverAspectRatio - 1.0).abs() < 0.01;+ // Series stacked covers are always cropped to fit - no blur padding neededif (url.startsWith('/')) {- return BlurPaddedCover(- enabled: isSquare,- child: Image.file(File(url), fit: isSquare ? BoxFit.contain : BoxFit.cover,- errorBuilder: (_, __, ___) => _placeholder()),- blurChild: Image.file(File(url), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => const SizedBox.shrink()),- );+ return Image.file(File(url), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder());}- return BlurPaddedCover(- enabled: isSquare,- child: CachedNetworkImage(imageUrl: url, fit: isSquare ? BoxFit.contain : BoxFit.cover,- httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),- errorWidget: (_, __, ___) => _placeholder()),- blurChild: CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,- httpHeaders: mediaHeaders, errorWidget: (_, __, ___) => const SizedBox.shrink()),- );+ return CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,+ httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder());}Widget _placeholder() {diff --git a/lib/widgets/series_card.dart b/lib/widgets/series_card.dartindex d15e3549..6787799a 100644--- a/lib/widgets/series_card.dart+++ b/lib/widgets/series_card.dart@@ -4,7 +4,6 @@ import 'package:provider/provider.dart';import 'package:cached_network_image/cached_network_image.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';-import 'absorbing_shared.dart';import 'series_books_sheet.dart';class SeriesCard extends StatelessWidget {@@ -254,24 +253,14 @@ class _StackedCovers extends StatelessWidget {Widget _coverImage(String? url) {if (url == null) return _placeholder();- final isSquare = (coverAspectRatio - 1.0).abs() < 0.01;+ // Series stacked covers are always cropped to fit - no blur padding neededif (url.startsWith('/')) {- return BlurPaddedCover(- enabled: isSquare,- child: Image.file(File(url), fit: isSquare ? BoxFit.contain : BoxFit.cover,- errorBuilder: (_, __, ___) => _placeholder()),- blurChild: Image.file(File(url), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => const SizedBox.shrink()),- );+ return Image.file(File(url), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder());}- return BlurPaddedCover(- enabled: isSquare,- child: CachedNetworkImage(imageUrl: url, fit: isSquare ? BoxFit.contain : BoxFit.cover,- httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),- errorWidget: (_, __, ___) => _placeholder()),- blurChild: CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,- httpHeaders: mediaHeaders, errorWidget: (_, __, ___) => const SizedBox.shrink()),- );+ return CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,+ httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder());}Widget _placeholder() {diff --git a/pubspec.lock b/pubspec.lockindex 39c7cc7a..5d7eb60a 100644--- a/pubspec.lock+++ b/pubspec.lock@@ -1121,22 +1121,6 @@ packages:url: "https://pub.dev"source: hostedversion: "15.0.0"- wakelock_plus:- dependency: "direct main"- description:- name: wakelock_plus- sha256: "61713aa82b7f85c21c9f4cd0a148abd75f38a74ec645fcb1e446f882c82fd09b"- url: "https://pub.dev"- source: hosted- version: "1.3.3"- wakelock_plus_platform_interface:- dependency: transitive- description:- name: wakelock_plus_platform_interface- sha256: "036deb14cd62f558ca3b73006d52ce049fabcdcb2eddfe0bf0fe4e8a943b5cf2"- url: "https://pub.dev"- source: hosted- version: "1.3.0"web:dependency: transitivedescription:diff --git a/pubspec.yaml b/pubspec.yamlindex 8d83e75a..9651dd8a 100644--- a/pubspec.yaml+++ b/pubspec.yaml@@ -1,7 +1,7 @@name: absorbdescription: An Audiobookshelf Clientpublish_to: 'none'-version: 1.8.61+79+version: 1.8.62+80# v1.8.41: JWT auth (accessToken + refreshToken), MANAGE_EXTERNAL_STORAGE removed from playstore flavor# Build scripts (run from Git Bash):# . ./build_bundle.sh - Play Store AAB (no MANAGE_EXTERNAL_STORAGE)@@ -85,7 +85,6 @@ dependencies:vibration: ^3.1.8webview_flutter: ^4.13.1flutter_markdown_plus: ^1.0.7- wakelock_plus: ^1.3.3palette_generator: ^0.3.3+7dev_dependencies: