Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / camera / AGENTS.md
| 1 | # AGENTS.md — camera/ (':camera') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `camera/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install camera (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :camera / dir: camera/ |
| 8 | - Package roots present: ui, domain, platform |
| 9 | - Entry files: MainActivity.kt (no Route.kt — `Route` is inline, single-screen app) |
| 10 | - Deps: :library:ml |
| 11 | - Metadata: metadata_data/camera.md (present) |
| 12 | - Rust: yes / screenshotTest: hand-committed |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** The most featureful open-source camera app — usable as the system camera and from the lockscreen. 100% offline. |
| 16 | **Key features:** |
| 17 | - Photo + video capture (CameraX, works regardless of Camera2 extension support) with per-mode sessions: single, portrait, night, slo-mo, video |
| 18 | - Panorama stitching + night-burst alignment in the native Rust `camera_stitch` engine |
| 19 | - Portrait mode with on-device segmentation (MediaPipe selfie + MODNet matting on a Vulkan compute runtime, `.maml` assets) |
| 20 | - QR/barcode scanning (zxing) and optional GPS geotagging written into EXIF |
| 21 | **Architecture / data-flow:** Single-screen `ui/CameraScreen` + `util/CameraViewModel` over per-mode `util/` session objects; `domain/` holds pure lens-selection logic, `platform/` capability queries; heavy work (stitch, night align, bokeh) goes through Rust JNI (`StitchNative`) and lands in MediaStore via `MediaStoreSaver`. `onCreateBeforeContent` only honors the `ACTION_IMAGE_CAPTURE` capture-for-result intent; `Content()` sits behind a camera+mic permission gate. |
| 22 | **Entry points + reading order:** `MainActivity.kt` (`Route.Camera`/`Settings` inline) → `ui/CameraScreen.kt` → `util/CameraViewModel.kt` → `util/CameraSessions.kt` → `util/PanoramaEngine.kt` / `NightCaptureEngine.kt`. |
| 23 | **Gotchas:** |
| 24 | - `util/` is NOT a closed package root — the `util/`→closed-roots migration is pending; new platform/engine code still lands there, don't add more |
| 25 | - Screenshots are hand-captured (no metadata convention plugin — Layoutlib can't open a camera); committed listing images live under `metadata_data/photos/camera/phone/` |
| 26 | - Volume keys act as the shutter, gated on the camera route being foreground; Esc/space covers desktop keyboards |
| 27 | - `.maml` model assets ship uncompressed (`noCompress`) — never compress them |
| 28 | |
| 29 | ## Key files |
| 30 | ### Root — entry (Route inline, no Route.kt) |
| 31 | - com/vayunmathur/camera/MainActivity.kt |
| 32 | ### domain/ — pure lens-selection logic |
| 33 | - com/vayunmathur/camera/domain/LensModel.kt |
| 34 | - com/vayunmathur/camera/domain/LensSelectionLogic.kt |
| 35 | ### platform/ — capability queries |
| 36 | - com/vayunmathur/camera/platform/CameraCapabilities.kt |
| 37 | - com/vayunmathur/camera/platform/LensSelector.kt |
| 38 | ### ui/ — single screen + settings + panes |
| 39 | - com/vayunmathur/camera/ui/CameraScreen.kt |
| 40 | - com/vayunmathur/camera/ui/CameraScreenState.kt |
| 41 | - com/vayunmathur/camera/ui/CameraScreenKit.kt |
| 42 | - com/vayunmathur/camera/ui/CameraScreenEffects.kt |
| 43 | - com/vayunmathur/camera/ui/CameraPreviewBox.kt |
| 44 | - com/vayunmathur/camera/ui/CameraPreviewOverlays.kt |
| 45 | - com/vayunmathur/camera/ui/CameraOverlays.kt |
| 46 | - com/vayunmathur/camera/ui/CameraPanoramaOverlay.kt |
| 47 | - com/vayunmathur/camera/ui/CameraTopBar.kt |
| 48 | - com/vayunmathur/camera/ui/CameraBottomControls.kt |
| 49 | - com/vayunmathur/camera/ui/CameraShutterPane.kt |
| 50 | - com/vayunmathur/camera/ui/CameraShutterRow.kt |
| 51 | - com/vayunmathur/camera/ui/CameraModeBars.kt |
| 52 | - com/vayunmathur/camera/ui/CameraModesPane.kt |
| 53 | - com/vayunmathur/camera/ui/CameraSettingsBars.kt |
| 54 | - com/vayunmathur/camera/ui/CameraSettingsColumn.kt |
| 55 | - com/vayunmathur/camera/ui/CameraStatusIndicators.kt |
| 56 | - com/vayunmathur/camera/ui/CameraWideLayout.kt |
| 57 | - com/vayunmathur/camera/ui/LensBar.kt |
| 58 | - com/vayunmathur/camera/ui/SettingsPage.kt |
| 59 | - com/vayunmathur/camera/ui/CameraPostProcessingSettings.kt |
| 60 | ### util/ — ViewModel, sessions, engines, persistence (migration pending) |
| 61 | - com/vayunmathur/camera/util/CameraViewModel.kt |
| 62 | - com/vayunmathur/camera/util/CameraViewModelActions.kt |
| 63 | - com/vayunmathur/camera/util/CameraViewModelTypes.kt |
| 64 | - com/vayunmathur/camera/util/CameraStartup.kt |
| 65 | - com/vayunmathur/camera/util/CameraSessions.kt |
| 66 | - com/vayunmathur/camera/util/CameraPhotoSessions.kt |
| 67 | - com/vayunmathur/camera/util/CameraPhotoSessionSetup.kt |
| 68 | - com/vayunmathur/camera/util/CameraPhotoSessionShared.kt |
| 69 | - com/vayunmathur/camera/util/CameraPortraitSession.kt |
| 70 | - com/vayunmathur/camera/util/CameraSingleCapture.kt |
| 71 | - com/vayunmathur/camera/util/CameraPhotoCapture.kt |
| 72 | - com/vayunmathur/camera/util/CameraCaptureProcessing.kt |
| 73 | - com/vayunmathur/camera/util/CameraVideoSession.kt |
| 74 | - com/vayunmathur/camera/util/CameraVideoRecording.kt |
| 75 | - com/vayunmathur/camera/util/CameraSloMoSession.kt |
| 76 | - com/vayunmathur/camera/util/CameraManualControls.kt |
| 77 | - com/vayunmathur/camera/util/CameraControls.kt |
| 78 | - com/vayunmathur/camera/util/CameraNightMode.kt |
| 79 | - com/vayunmathur/camera/util/CameraNightCapture.kt |
| 80 | - com/vayunmathur/camera/util/NightCaptureEngine.kt |
| 81 | - com/vayunmathur/camera/util/PanoramaEngine.kt |
| 82 | - com/vayunmathur/camera/util/GpuStitcher.kt |
| 83 | - com/vayunmathur/camera/util/StitchNative.kt — JNI bridge into `camera_stitch` |
| 84 | - com/vayunmathur/camera/util/PanoXmp.kt |
| 85 | - com/vayunmathur/camera/util/PortraitBokeh.kt |
| 86 | - com/vayunmathur/camera/util/BokehAnalyzer.kt |
| 87 | - com/vayunmathur/camera/util/PhotoAnalyzer.kt |
| 88 | - com/vayunmathur/camera/util/MotionPhotoEncoder.kt |
| 89 | - com/vayunmathur/camera/util/MotionPhotoWriter.kt |
| 90 | - com/vayunmathur/camera/util/VideoProcessor.kt |
| 91 | - com/vayunmathur/camera/util/CodecSupport.kt |
| 92 | - com/vayunmathur/camera/util/MediaStoreSaver.kt |
| 93 | - com/vayunmathur/camera/util/CameraSettings.kt |
| 94 | - com/vayunmathur/camera/util/CameraSaveLocation.kt |
| 95 | - com/vayunmathur/camera/util/CameraSaveRouting.kt |
| 96 | |
| 97 | ## Verify (this module only) |
| 98 | ``` |
| 99 | ./gradlew :camera:compileDevKotlin |
| 100 | ./gradlew :camera:lint |
| 101 | ./gradlew :camera:checkMetadata |
| 102 | ``` |