A cross platform Audiobookshelf client for Android and iOS
Dart
Keep the rotation lock applied after reopening the app and after leaving car mode
Barnabasb059d7f2c668
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex bbdad814..39a31dd3 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -14,7 +14,7 @@ import 'package:cached_network_image/cached_network_image.dart';import 'package:palette_generator/palette_generator.dart';import '../utils/cover_accent.dart';import '../main.dart'- show snappyTransitionsNotifier, coverSchemeNotifier, rootNavigatorKey;+ show snappyTransitionsNotifier, coverSchemeNotifier, rootNavigatorKey, applyOrientationLock;import '../l10n/app_localizations.dart';import '../services/wording.dart';import '../services/android_auto_service.dart';@@ -614,6 +614,11 @@ class _AppShellState extends State<AppShell>void _handleAppForegrounded() {if (!_lifecycleBackgrounded) return;_lifecycleBackgrounded = false;+ // The rotation lock lives on the Activity, and Android can recreate the+ // activity over the still-running cached engine (swipe away from recents+ // while playback keeps the service alive). main() doesn't re-run then, so+ // re-apply the saved lock on every return to the foreground.+ applyOrientationLock();// Belt-and-suspenders: never let the nav bar come back hidden after a// resume. The screens snap their own driver back to shown on next scroll// anyway, but mirror it here in case the user resumes onto a stale tab.diff --git a/lib/screens/car_mode_screen.dart b/lib/screens/car_mode_screen.dartindex 23353b9e..1914cf3c 100644--- a/lib/screens/car_mode_screen.dart+++ b/lib/screens/car_mode_screen.dart@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';import 'package:just_audio/just_audio.dart' hide PlaybackEvent;import 'package:provider/provider.dart';import 'package:cached_network_image/cached_network_image.dart';+import '../main.dart' show applyOrientationLock;import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';@@ -100,7 +101,9 @@ class _CarModeScreenState extends State<CarModeScreen>PlayerSettings.settingsChanged.removeListener(_loadSkipSettings);widget.player.removeListener(_onPlayerChanged);_playPauseController.dispose();- SystemChrome.setPreferredOrientations([]);+ // Back to the user's saved rotation preference - the old empty list+ // ("all allowed") silently dropped the portrait lock until a restart.+ applyOrientationLock();super.dispose();}