Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion lib/app/layouts/settings/pages/misc/misc_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,36 @@ class _MiscPanelState extends OptimizedState<MiscPanel> {
),
)),
const SettingsDivider(),
if (Platform.isAndroid)
Obx(() => SettingsSwitch(
onChanged: (bool val) {
ss.settings.systemRotation.value = val;
saveSettings();
SystemChrome.setPreferredOrientations(val ? [] : [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
if (ss.settings.allowUpsideDownRotation.value) DeviceOrientation.portraitDown,
]);
},
initialVal: ss.settings.systemRotation.value,
title: "Follow System Rotation",
subtitle: "Recommended on foldables. Off restores the app's own orientation list.",
backgroundColor: tileColor,
leading: const SettingsLeadingIcon(
iosIcon: CupertinoIcons.device_phone_portrait,
materialIcon: Icons.screen_rotation_alt,
containerColor: Colors.teal
),
)),
if (Platform.isAndroid)
const SettingsDivider(),
if (Platform.isAndroid)
Obx(() => SettingsSwitch(
onChanged: (bool val) {
ss.settings.allowUpsideDownRotation.value = val;
saveSettings();
SystemChrome.setPreferredOrientations([
SystemChrome.setPreferredOrientations(ss.settings.systemRotation.value ? [] : [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
Expand Down
4 changes: 4 additions & 0 deletions lib/database/global/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Settings {
final RxBool statusIndicatorsOnChats = false.obs;
final RxInt apiTimeout = 30000.obs;
final RxBool allowUpsideDownRotation = false.obs;
final RxBool systemRotation = true.obs; // Fold fix: let Android decide rotation (no requested orientation)
final RxBool cancelQueuedMessages = false.obs;
final RxBool repliesToPrevious = false.obs;
final RxnString localhostPort = RxnString(null);
Expand Down Expand Up @@ -361,6 +362,7 @@ class Settings {
'indicatorsOnPinnedChats': statusIndicatorsOnChats.value,
'apiTimeout': apiTimeout.value,
'allowUpsideDownRotation': allowUpsideDownRotation.value,
'systemRotation': systemRotation.value,
'cancelQueuedMessages': cancelQueuedMessages.value,
'repliesToPrevious': repliesToPrevious.value,
'useLocalhost': localhostPort.value,
Expand Down Expand Up @@ -525,6 +527,7 @@ class Settings {
ss.settings.statusIndicatorsOnChats.value = map['indicatorsOnPinnedChats'] ?? false;
ss.settings.apiTimeout.value = map['apiTimeout'] ?? 15000;
ss.settings.allowUpsideDownRotation.value = map['allowUpsideDownRotation'] ?? false;
ss.settings.systemRotation.value = map['systemRotation'] ?? true;
ss.settings.cancelQueuedMessages.value = map['cancelQueuedMessages'] ?? false;
ss.settings.repliesToPrevious.value = map['repliesToPrevious'] ?? false;
ss.settings.localhostPort.value = map['useLocalhost'];
Expand Down Expand Up @@ -699,6 +702,7 @@ class Settings {
s.statusIndicatorsOnChats.value = map['indicatorsOnPinnedChats'] ?? false;
s.apiTimeout.value = map['apiTimeout'] ?? 15000;
s.allowUpsideDownRotation.value = map['allowUpsideDownRotation'] ?? false;
s.systemRotation.value = map['systemRotation'] ?? true;
s.cancelQueuedMessages.value = map['cancelQueuedMessages'] ?? false;
s.repliesToPrevious.value = map['repliesToPrevious'] ?? false;
s.localhostPort.value = map['useLocalhost'];
Expand Down
6 changes: 5 additions & 1 deletion lib/services/backend/settings/settings_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class SettingsService extends GetxService {
if (settings.immersiveMode.value) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
}
SystemChrome.setPreferredOrientations([
// Foldables (Galaxy Z Fold inner screen): the explicit three-orientation list maps to Android's
// SCREEN_ORIENTATION_USER, which pins the panel's natural orientation (landscape on the inner
// display) whenever rotation lock is on. An empty list is SCREEN_ORIENTATION_UNSPECIFIED, the
// same as every normal app, so the system's own foldable handling applies.
SystemChrome.setPreferredOrientations(settings.systemRotation.value ? [] : [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
Expand Down