Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / pdf / AGENTS.md

AGENTS.md5.0 KiBRenderedCodeRaw
1# AGENTS.md — pdf/ (':pdf')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `pdf/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install pdf (dev by default)._
6<!-- last-reviewed: 2026-10-16 -->
7- Gradle: :pdf / dir: pdf/
8- Package roots present: ui
9- Entry files: MainActivity.kt (no Route.kt — mode flags, not nav destinations)
10- Deps: :library:image, :library:ocr
11- Metadata: metadata_data/pdf.md (present)
12- Rust: yes / screenshotTest: yes
13
14## Overview
15**Purpose:** A simple open-source PDF viewer with capture and cut-and-glue assembly. No network permission at all — 100% offline.
16**Key features:**
17- Full viewer: text search, text selection, form fields, outlines, zoom state, print via share menu; several documents open as separate Recents entries
18- Capture mode: photograph pages with auto-framing, crop, and compose them into a PDF; cut-and-glue screen for assembling pages
19- Native Rust PDF engine (`PdfNative`) for parsing, rendering, and export
20**Architecture / data-flow:** `MainActivity` mode-flags (`data` / `isCapturing` / `isCutGlue`) over a single `util/PdfViewModel` + `util/PdfStateStore`, with `SafePdf*` utils wrapping the Rust engine for document access, page rendering, and edits; capture flows through `model/CapturedImage` → `AutoFrameDetector` → `ComposePdfDocument` → `PdfExporter`. `onCreateBeforeContent` only captures the launch intent's data URI; `Content()` picks viewer vs capture vs cut-glue vs picker.
21**Entry points + reading order:** `MainActivity.kt` (`InitialScreen` → viewer/capture/cut-glue) → `ui/SafePdfViewerScreen.kt` → `util/PdfViewModel.kt` → `util/SafePdfDocument.kt` → `util/SafePdfParser.kt`.
22**Gotchas:**
23- No navigation graph at all — the three modes are `rememberSaveable` flags in `Content()`, so don't add a `Route.kt` here
24- Started-with-intent launches `finish()` on back instead of returning to the picker; in-app launches reset to the picker
25- Card drift fixed: `util/` gained `FrameGeometry`, `FrameImageOps`, `SafePdfDocumentEdits`, `SafePdfPrimitives`; `ui/` is `SafePdf*` + capture/crop/cut-glue screens (no separate `domain/` or `platform/`)
26- Extra non-conforming dirs (`model/`, `util/`) hold real code — closed-roots migration pending
27
28## Key files
29### Root — entry (mode flags, no Route.kt)
30- com/vayunmathur/pdf/MainActivity.kt — InitialScreen, viewer/capture/cut-glue switch
31### model/ — capture model
32- com/vayunmathur/pdf/model/CapturedImage.kt
33### ui/ — viewer chrome + state
34- com/vayunmathur/pdf/ui/SafePdfViewerScreen.kt
35- com/vayunmathur/pdf/ui/SafePdfViewerState.kt
36- com/vayunmathur/pdf/ui/SafePdfViewerModels.kt
37- com/vayunmathur/pdf/ui/SafePdfViewerChrome.kt
38- com/vayunmathur/pdf/ui/SafePdfViewerLoad.kt
39- com/vayunmathur/pdf/ui/SafePdfViewerDialogs.kt
40- com/vayunmathur/pdf/ui/SafePdfPageViewer.kt
41- com/vayunmathur/pdf/ui/SafePdfPageCanvas.kt
42- com/vayunmathur/pdf/ui/SafePdfPageItem.kt
43- com/vayunmathur/pdf/ui/PdfViewerWideLayout.kt
44- com/vayunmathur/pdf/ui/PdfOutlineDrawer.kt
45- com/vayunmathur/pdf/ui/SafePdfTextSelection.kt
46- com/vayunmathur/pdf/ui/SafePdfFormFields.kt
47### ui/ — safe-draw rendering kit
48- com/vayunmathur/pdf/ui/SafePdfDrawContext.kt
49- com/vayunmathur/pdf/ui/SafePdfDrawState.kt
50- com/vayunmathur/pdf/ui/SafePdfDrawStrokes.kt
51- com/vayunmathur/pdf/ui/SafePdfDrawFills.kt
52- com/vayunmathur/pdf/ui/SafePdfDrawText.kt
53- com/vayunmathur/pdf/ui/SafePdfDrawImages.kt
54- com/vayunmathur/pdf/ui/SafePdfBlendModes.kt
55- com/vayunmathur/pdf/ui/SafePdfSelectionGlyphs.kt
56- com/vayunmathur/pdf/ui/SafePdfZoomState.kt
57### ui/ — edit overlays + tooling
58- com/vayunmathur/pdf/ui/SafePdfEditOverlay.kt
59- com/vayunmathur/pdf/ui/SafePdfEditPreview.kt
60- com/vayunmathur/pdf/ui/SafePdfEditToolbar.kt
61- com/vayunmathur/pdf/ui/SafePdfNonEditOverlay.kt
62- com/vayunmathur/pdf/ui/SafePdfToolMenus.kt
63- com/vayunmathur/pdf/ui/SafePdfStyleDialog.kt
64- com/vayunmathur/pdf/ui/SafePdfLaunchers.kt
65### ui/ — capture + assembly screens
66- com/vayunmathur/pdf/ui/CapturePdfScreen.kt
67- com/vayunmathur/pdf/ui/CropScreen.kt
68- com/vayunmathur/pdf/ui/CropScreenSection.kt
69- com/vayunmathur/pdf/ui/CutGlueScreen.kt
70- com/vayunmathur/pdf/ui/components/CameraPreview.kt
71- com/vayunmathur/pdf/ui/components/SubcroppedImage.kt
72### util/ — ViewModel, engine bridge, capture pipeline (migration pending)
73- com/vayunmathur/pdf/util/PdfViewModel.kt
74- com/vayunmathur/pdf/util/PdfStateStore.kt
75- com/vayunmathur/pdf/util/PdfNative.kt — Rust engine bridge
76- com/vayunmathur/pdf/util/SafePdfDocument.kt
77- com/vayunmathur/pdf/util/SafePdfDocumentEdits.kt
78- com/vayunmathur/pdf/util/SafePdfParser.kt
79- com/vayunmathur/pdf/util/SafePdfModels.kt
80- com/vayunmathur/pdf/util/SafePdfPrimitives.kt
81- com/vayunmathur/pdf/util/SafePdfImages.kt
82- com/vayunmathur/pdf/util/SafePdfListings.kt
83- com/vayunmathur/pdf/util/AutoFrameDetector.kt
84- com/vayunmathur/pdf/util/FrameGeometry.kt
85- com/vayunmathur/pdf/util/FrameImageOps.kt
86- com/vayunmathur/pdf/util/ComposePdfDocument.kt
87- com/vayunmathur/pdf/util/PdfExporter.kt
88
89## Verify (this module only)
90```
91./gradlew :pdf:compileDevKotlin
92./gradlew :pdf:lint
93./gradlew :pdf:checkMetadata
94```