Skip to content

Add GTC (auto-rotate landscape pages) with scaling fixes - #162

Open
gwchua1976 wants to merge 7 commits into
Snd-R:mainfrom
gwchua1976:gtc-scaling-fixes
Open

Add GTC (auto-rotate landscape pages) with scaling fixes#162
gwchua1976 wants to merge 7 commits into
Snd-R:mainfrom
gwchua1976:gtc-scaling-fixes

Conversation

@gwchua1976

Copy link
Copy Markdown

Adds a GTC mode that rotates wide/landscape pages 90 degrees to fit device height when reading in portrait, locking orientation while active. Includes fixes for two scaling bugs found during testing: (1) SinglePageLayout zeroed min constraints instead of swapping them when computing the rotated layout box, causing the image to render at intrinsic size instead of filling it. (2) calculateScreenScale's gtcRotationApplied branch compared a target size computed in rotated-page space against the real (unrotated) screen area, producing an incorrect zoom factor. Fixed by swapping the target size back to real-screen orientation before the zoom-limit math.

Amapola and others added 6 commits August 10, 2026 08:39
Adds a toggleable 'GTC' reader setting (paged reader, single-page
layout). When enabled, pages whose longest side is horizontal
(landscape pages) are rotated 90 degrees on portrait devices so the
longest side aligns with the device height, and the image is scaled
to fit before display.

- New persisted setting: ImageReaderSettingsRepository.get/putGtcModeEnabled
  (ImageReaderSettings.gtcModeEnabled, DB column + migration V13)
- PagedReaderState: sizing/scaling pipeline swaps the target box for
  applicable pages so calculateSizeForArea/requestUpdate size the
  image correctly for the rotated orientation; interactive pan/zoom
  is bypassed for rotated pages in favor of a fit-to-screen display
- PagedReaderContent: SinglePageLayout rotates the measured page 90
  degrees via placeRelativeWithLayer when GTC applies
- Toggle added to both reading settings menus (desktop side menu and
  mobile bottom sheet), next to the existing scale type / layout
  options
Adds LockScreenOrientation, an expect/actual composable (Android
locks Activity.requestedOrientation to PORTRAIT and restores the
previous value on unlock/dispose; desktop and web are no-ops since
they have no OS-level orientation concept). Wired into
PagedReaderContent so it's active whenever GTC mode is enabled,
preventing the device from rotating into landscape while GTC's
portrait-relative sizing logic is in effect.
@gwchua1976

Copy link
Copy Markdown
Author

How to test

  1. Enable GTC mode in the reader settings.
  2. Open a book/chapter that has at least one landscape-oriented page (wider than tall).
  3. On an Android device with auto-rotate enabled, hold the device in portrait.
  4. Navigate to the landscape page - it should rotate 90 degrees automatically and scale to fill the screen height, with the device orientation locked to portrait while GTC is active.
  5. Navigate away from the landscape page (or disable GTC) - the orientation lock should release, and normal (portrait) pages should render unrotated as usual.

Isolates GTC-specific decision and scaling logic into its own object so
future upstream merges only need to reconcile small call sites in
PagedReaderState.kt and PagedReaderContent.kt instead of colliding with
inlined GTC logic. Also fixes a null WorkManager dependency crash in
App.kt's initWorkManager.
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