Skip to content

feat(settings): add screen rotation mode setting#40

Merged
Xitee1 merged 1 commit into
mainfrom
feat/rotation-mode-setting
Jul 6, 2026
Merged

feat(settings): add screen rotation mode setting#40
Xitee1 merged 1 commit into
mainfrom
feat/rotation-mode-setting

Conversation

@Xitee1

@Xitee1 Xitee1 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a rotation-mode setting so users can control screen orientation, which was previously hard-wired (Timer screen locked to portrait with in-Compose counter-rotation; other screens followed the device pose — ignoring the system-wide auto-rotate lock entirely).

A new Auto-rotate row in Settings → Appearance opens a dialog (same pattern as the existing screen-lock dialog) with three modes:

  • System setting (new default) — rotate only while the OS auto-rotate flag is on, observed via Settings.System.ACCELEROMETER_ROTATION (no new permission; the app stays network/permission-free).
  • Always — rotate with the device even when system rotation is locked (the prior behavior; useful lying in bed with rotation locked).
  • Portrait — never rotate.

The mode is stored in DataStore as an AutoRotateMode enum (mirroring the existing ThemeId pattern) and threaded through rememberDeviceOrientation(mode), which gates the OrientationEventListener — and, in System mode, a ContentObserver on the system flag. Everything downstream (the window lock in AppOrientationController, the nav-fade guard, and the timer's in-Compose counter-rotation) follows from the resolved orientation, so no per-call-site branching was needed.

Implementation notes

  • New files: AutoRotateMode enum, AutoRotateModeDialog (mirrors ScreenLockMethodDialog, with the selected option accent-tinted per the theme-picker's selection language), and AppOrientationViewModel (lets the ViewModel-less SleepTimerNavHost observe the setting).
  • The ContentObserver only exists in the composition while in System mode, so it self-disposes when the mode changes; it's process-scoped, so quick-settings flips made while backgrounded still land before the user returns.
  • Strings added to both values/ and values-de/.

Verification

  • ./gradlew assembleDebug lint — green.
  • Grep-confirmed no source references to old symbols remain.
  • Not yet run on a device. Worth exercising there: all three modes × system-rotate on/off, mid-session quick-settings flips (foreground + backgrounded-then-return), and persistence across restart.

🤖 Generated with Claude Code

Add a rotation-mode setting so users can control screen orientation
independently of the previously hard-wired behavior.

A new "Auto-rotate" row in Settings > Appearance opens a dialog with
three modes:
- System (default): rotate only while the OS auto-rotate flag is on,
  observed via Settings.System.ACCELEROMETER_ROTATION (no new permission)
- Always: rotate regardless of the system lock (prior behavior)
- Portrait: never rotate

The mode is threaded through rememberDeviceOrientation, which gates the
OrientationEventListener (and the system-flag ContentObserver in System
mode) so both the window lock and the timer's in-Compose counter-rotation
follow the setting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Xitee1 Xitee1 merged commit 17aed19 into main Jul 6, 2026
1 check passed
@Xitee1 Xitee1 deleted the feat/rotation-mode-setting branch July 6, 2026 17:11
@Xitee1

Xitee1 commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Closes #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant