# Reader processing and navigation

Parity stage 7 (Animetail diff rows R2, R3, R5, R6, R7, R8, R11, R12). All policies
live in shared code; preferences are stored in `DbSettings.features.reader`
(`DbReaderPreferences`) so the `DbSettings` constructor and the Room schema are
unchanged. Defaults keep the previous reader behavior.

## Paged and continuous preferences (R6)

`DbReaderModePreferences` exists twice: `paged` (LTR, RTL, vertical pager) and
`webtoon` (vertical continuous, webtoon, horizontal continuous). Each holds crop
borders, page-transition animation, tap zones, tap-zone layout, wide-page split
and wide-page rotation. A group is `null` until first changed; while `null` it is
derived from the legacy global fields (`cropBorders`, `animatePageTransitions`,
`usePageTapZones`, `readerNavigationLayout`), so existing settings carry into both
groups without a migration step and old backups restore unchanged. Settings →
Reader shows both groups; the in-reader sheet and the bottom-bar crop toggle edit
the group of the current mode.

## Split and rotate wide pages (R2, R3)

Page shapes come from the reader's existing Coil prefetch sampling. When splitting
is on for the current mode, `splitWidePagesInStream` replaces each landscape page
(`width > height`) in the reader stream with two halves (`ReaderPageHalf.First`,
`Second`) and maps the current position onto the same half; turning the option
off collapses halves back. Halves share the source page index, so progress,
history, page slider, colorized overrides and chapter page lists are unchanged,
and halves never pair into a double-page spread. A split page stays split when
its sampled shape is evicted, so positions do not shift underneath the reader.

The first half follows reading direction (left for LTR, right for RTL); *Invert
split order* swaps it. Rotation turns landscape bitmaps a quarter turn
(clockwise, counter-clockwise when inverted) and yields to splitting. Both run as
Coil transformations inside the existing decode pipeline next to border cropping
(Android `Bitmap`, Skia on desktop/iOS/web) with separate memory-cache keys.
Each half has its own zoom state.

## Chapter navigation (R7, R8)

- *Skip filtered chapters* (default on, the previous behavior) applies the title's
  chapter filters to previous/next chapter. Off uses every chapter, still honoring
  the duplicate-release preference.
- *Skip read chapters* (default off) removes read chapters after release selection,
  so a read chapter never falls back to an unread alternate release. The open
  chapter always stays in the sequence.
- *Always show chapter transition* (default on, the previous behavior). Off joins
  the next chapter's pages directly; like Mihon, the card still appears when
  chapter numbers skip ahead and at the last chapter.

## Image export (R11, R12)

The page actions sheet adds *Copy image*. When the long-pressed page is shown in a
two-page spread, *Save/Share/Copy both pages* merge the spread: both pages are
scaled to the taller height, placed in displayed order (mirrored for RTL) and
encoded as JPEG (quality 90). Merging reuses the tall-image splitter limits:
inputs up to 32 MiB, still images only, upright EXIF orientation, at most 24
million output pixels.

| Platform | Clipboard | Per-title save folder |
| --- | --- | --- |
| Android | `ClipboardManager` with a `FileProvider` content URI (readers get a temporary grant) | `Pictures/Yokan/<title>` via MediaStore `RELATIVE_PATH` (API 29+) |
| Desktop | AWT system clipboard (`imageFlavor`); Skia normalizes WebP/AVIF to PNG first | `~/Pictures/Yokan/<title>` |
| iOS | `UIPasteboard.general.image` | Photos album named after the title (requests read-write library access) |
| Web | Async Clipboard API with a PNG `ClipboardItem` | Not applicable (see blockers) |

Folder names keep Unicode but replace path separators, reserved characters and
control characters.

## Volume keys (R5)

*Volume keys turn pages* (default off): volume down is next page, volume up is
previous; *Invert volume keys* swaps them. Both key edges are consumed so the
system volume does not change. Implemented in the shared reader key handler.

## Platform blockers

- **iOS volume buttons:** iOS has no public API delivering hardware volume-button
  presses to a reading app. `AVCaptureEventInteraction` only works with an active
  camera capture session, and observing `AVAudioSession.outputVolume` changes the
  user's system volume, shows the volume HUD and cannot detect presses at the volume
  limits. The preference has no effect on iOS.
- **Desktop and web volume keys:** not applicable; the OS consumes media and
  volume keys before they reach the window.
- **Web save folder:** browsers choose the download location and strip directory
  components from download names, so the title folder cannot be created. Saved
  file names already start with the title.
- **Android 8–9 save folder:** MediaStore has no relative path before API 29;
  images are saved to the default Pictures collection as before.
- **Web clipboard:** requires a secure context and a browser that supports
  `ClipboardItem` image writes; failures show *Copy failed*.

## Verification

Tests: `ReaderProcessingTest` (common: split stream, half side/rotation choice,
pairing, hidden transitions, skip-read, legacy fallback and serialization, volume
keys, folder names, spread layout), `ReaderPageProcessingSkiaTest` (Skia half,
rotation and spread merge), `ImageSharingDesktopTest` (per-title folder).
Desktop, Android, iOS simulator ARM64 and Wasm compile. Focused desktop run
(reader, image sharing, feature preferences, chapter sequence, settings search,
routes, backup): 212 passed. Wasm browser run (reader processing, Skia
processing, reader runtime, chapter sequence, border crop): 35 passed.
