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

Modern-Apps.git / photos / AGENTS.md

AGENTS.md13.0 KiBRenderedCodeRaw

AGENTS.md — photos/ (':photos')

Scoped supplement. Global rules in root AGENTS.md apply. Stay inside photos/ + allowed shared modules. Do not root-scan.

Install: ./install photos (dev by default).

  • Gradle: :photos / dir: photos/
  • Package roots present: ui, data, domain, platform, service, widget, intents
  • Entry files: MainActivity.kt, Route.kt, Navigation.kt
  • Deps: :library:map, :library:image, :library:ml, :library:room, :library:ink, :library:widgets, :library:biometric, :library:ocr, :library:downloadservice
  • Metadata: metadata_data/photos.md (present)
  • Rust: yes / screenshotTest: yes

Overview

Purpose: A photos app with a full non-destructive editor and on-device AI search — faces, text, and content all indexed locally. Internet only for basemap tiles behind the map view. Key features:

  • Gallery with adjustable grid, albums, people (on-device face grouping), map view, trash, and separate photo/video editors (EditActivity/VideoEditActivity)
  • Non-destructive editor: curves, HSL, levels, healing, liquify, layers, selective edits, undo/redo — edits stored as data/*Data docs, composited by LayerCompositor
  • On-device search by content (CLIP), by text (OCR layout), and by person (face recognition + segmentation); biometric-locked secure folder with optional relock-on-exit
  • Wallpaper/live-wallpaper, Glance home widget, motion-photo support, and background sync worker

Architecture / data-flow: ui/ pages over platform/ ViewModels (GalleryViewModel, PhotoEditViewModel, VideoEditViewModel, PhotoMapViewModel, SecureFolderViewModel) → data/ Room (PhotoDatabase, VaultDatabase, PhotosRepository/VaultRepository) plus MediaStore indexing (AlbumMediaStore); ML (faces, CLIP, OCR, segmentation) runs on :library:ml with a Rust native bridge (PhotosNative). onCreateBeforeContent: widget previews + ImageLoader.init; Content() provides the column-count state behind a media-permissions gate into inline Navigation(). Entry points + reading order: Route (Gallery / PhotoPage / Map / People / Albums / Trash / SecureFolder / VaultViewer / Wallpaper, inline) → MainActivity.kt → ui/GalleryPage.kt → platform/GalleryViewModel.kt → data/PhotosRepository.kt. Gotchas:

  • Re-tapping a photo replaces the viewer (pushPhoto/setLast) instead of stacking — don't add() photo routes or back steps through stale viewers
  • ACTION_VIEW from another app (e.g. the camera) makes that one photo the stack root with no gallery beneath; in-app back handling must not swallow the system predictive-back gesture there
  • MaFragmentActivity (not MaActivity) — biometric + fragment-hosting requirement
  • Widget code is flat in widget/ (widget + receiver in one file); ViewModels/ML/compositing live in platform/, pure helpers in domain/
  • MediaStore sync writes already-known rows by column (PhotoDao.updateSyncFields), never as rebuilt-row upserts: the sync projection excludes the OCR/CLIP payload columns, so an upsert of a changed row would null its OCR text/geometry and CLIP embedding while leaving the scanned flags set
  • Upgrades from app versions before v2.6.0 start with a fresh local database (supported upgrade floor: Photo DB v12 and Vault DB v1; Photo DB versions 1–11 open destructively, v12 onward migrates normally; Vault DB has no pre-floor versions)

Key files

Root — entry + navigation

  • com/vayunmathur/photos/MainActivity.kt — entry, pushPhoto, relock logic
  • com/vayunmathur/photos/Route.kt — sealed Route incl. dialog destinations
  • com/vayunmathur/photos/Navigation.kt — nav graph + dialog entries

data/ — Room + edit-document model

  • com/vayunmathur/photos/data/PhotosRepository.kt
  • com/vayunmathur/photos/data/PhotoDatabase.kt
  • com/vayunmathur/photos/data/Photo.kt
  • com/vayunmathur/photos/data/VaultRepository.kt
  • com/vayunmathur/photos/data/VaultDatabase.kt
  • com/vayunmathur/photos/data/EditDocument.kt
  • com/vayunmathur/photos/data/ImageAdjustments.kt
  • com/vayunmathur/photos/data/FxAdjustments.kt
  • com/vayunmathur/photos/data/MoreAdjustmentsData.kt
  • com/vayunmathur/photos/data/LayerData.kt
  • com/vayunmathur/photos/data/LayerBlendMode.kt
  • com/vayunmathur/photos/data/CurvesData.kt
  • com/vayunmathur/photos/data/LevelsData.kt
  • com/vayunmathur/photos/data/HslData.kt
  • com/vayunmathur/photos/data/ColorBalanceData.kt
  • com/vayunmathur/photos/data/ChannelMixerData.kt
  • com/vayunmathur/photos/data/BlackAndWhiteData.kt
  • com/vayunmathur/photos/data/BlurData.kt
  • com/vayunmathur/photos/data/SharpenData.kt
  • com/vayunmathur/photos/data/NoiseData.kt
  • com/vayunmathur/photos/data/HealingData.kt
  • com/vayunmathur/photos/data/ContentAwareData.kt
  • com/vayunmathur/photos/data/LiquifyData.kt
  • com/vayunmathur/photos/data/DodgeBurnData.kt
  • com/vayunmathur/photos/data/GradientMapData.kt
  • com/vayunmathur/photos/data/StylizeData.kt
  • com/vayunmathur/photos/data/PerspectiveData.kt
  • com/vayunmathur/photos/data/SelectionData.kt
  • com/vayunmathur/photos/data/SelectiveEditData.kt
  • com/vayunmathur/photos/data/Drawing.kt
  • com/vayunmathur/photos/data/PaintOpsData.kt
  • com/vayunmathur/photos/data/SmudgeData.kt
  • com/vayunmathur/photos/data/OcrLayout.kt
  • com/vayunmathur/photos/data/FaceData.kt
  • com/vayunmathur/photos/data/RedEyeData.kt
  • com/vayunmathur/photos/data/VideoEditState.kt
  • com/vayunmathur/photos/data/BitmapExtensions.kt

domain/ — OCR, motion-photo and face-grouping logic (pure)

  • com/vayunmathur/photos/domain/PhotoOcr.kt
  • com/vayunmathur/photos/domain/MotionPhotoXmp.kt
  • com/vayunmathur/photos/domain/FaceAlignment.kt — five-point ArcFace alignment
  • com/vayunmathur/photos/domain/FaceQuality.kt — which faces may form people
  • com/vayunmathur/photos/domain/FaceClustering.kt — batch average-linkage grouping
  • com/vayunmathur/photos/domain/FaceClusterIdentity.kt — keeps person ids/names across regroups

intents/ — assistant IPC (metadata only)

  • com/vayunmathur/photos/intents/SearchPhotosIntent.kt — photos_search_photos: filtered (file-name/folder/date) metadata search over PhotoDao.searchPhotoMetadata; returns the matching count plus at most 10 hits (library.intents.photos.PhotoHitData: id, file name, taken date, dimensions, album, MIME). Never returns image bytes, thumbnails, URIs/paths, location, OCR text or embeddings; trashed items are excluded in SQL and the secure-folder vault is never opened. Guarded by the signature permission com.vayunmathur.photos.permissions.ACCESS_PHOTOS.
  • com/vayunmathur/photos/intents/PhotosSearchContract.kt — provider-side validation/clamping (limit 1–10, text/date-range normalisation) and row→hit mapping

widget/ — home widget

  • com/vayunmathur/photos/widget/PhotoGlanceWidget.kt — includes PhotoGlanceWidgetReceiver (one widget, one file)

platform/ — motion-photo

  • com/vayunmathur/photos/platform/MotionPhotoVideo.kt

service/ — live wallpaper

  • com/vayunmathur/photos/service/LiveWallpaperService.kt

ui/ — gallery, albums, people, map

  • com/vayunmathur/photos/ui/GalleryPage.kt
  • com/vayunmathur/photos/ui/GalleryScreen.kt
  • com/vayunmathur/photos/ui/GalleryGrouping.kt
  • com/vayunmathur/photos/ui/AlbumsPage.kt
  • com/vayunmathur/photos/ui/AlbumsScreen.kt
  • com/vayunmathur/photos/ui/AlbumDetailPage.kt
  • com/vayunmathur/photos/ui/AlbumDetailScreen.kt
  • com/vayunmathur/photos/ui/PeoplePage.kt
  • com/vayunmathur/photos/ui/MapPage.kt
  • com/vayunmathur/photos/ui/TrashPage.kt
  • com/vayunmathur/photos/ui/TrashScreen.kt — stateless trash grid (preview seam)
  • com/vayunmathur/photos/ui/RememberAlbumMoveLauncher.kt — MANAGE_MEDIA + MediaStore write-request launcher for album dialog routes
  • com/vayunmathur/photos/ui/VideoEditNavigation.kt — video-editor nav host incl. save dialog entry

ui/dialogs/ — dialog route contents (stateless)

  • com/vayunmathur/photos/ui/dialogs/AlbumNameDialog.kt
  • com/vayunmathur/photos/ui/dialogs/AlbumPickerDialog.kt
  • com/vayunmathur/photos/ui/dialogs/DeleteAlbumDialog.kt
  • com/vayunmathur/photos/ui/dialogs/DeletePersonDialog.kt
  • com/vayunmathur/photos/ui/dialogs/SecureFolderRelockDialog.kt
  • com/vayunmathur/photos/ui/dialogs/SaveDialog.kt
  • com/vayunmathur/photos/ui/ImageFit.kt

ui/ — viewer + metadata

  • com/vayunmathur/photos/ui/PhotoPage.kt
  • com/vayunmathur/photos/ui/PhotoDetailView.kt
  • com/vayunmathur/photos/ui/PhotoDetailSection.kt
  • com/vayunmathur/photos/ui/PhotoDetailMedia.kt
  • com/vayunmathur/photos/ui/PhotoMetadataCard.kt
  • com/vayunmathur/photos/ui/PhotoFilmstrip.kt
  • com/vayunmathur/photos/ui/PhotoViewerActions.kt
  • com/vayunmathur/photos/ui/PhotoViewerWideLayout.kt
  • com/vayunmathur/photos/ui/EditRoute.kt
  • com/vayunmathur/photos/ui/EditActivity.kt
  • com/vayunmathur/photos/ui/FaceBoxLayer.kt
  • com/vayunmathur/photos/ui/OcrTextLayer.kt
  • com/vayunmathur/photos/ui/PanoramaFlatView.kt
  • com/vayunmathur/photos/ui/PanoramaSphereView.kt

ui/ — editor panels + canvas

  • com/vayunmathur/photos/ui/EditPhotoPage.kt
  • com/vayunmathur/photos/ui/EditPhotoEditorState.kt
  • com/vayunmathur/photos/ui/EditPhotoModels.kt
  • com/vayunmathur/photos/ui/EditPhotoModelHelpers.kt
  • com/vayunmathur/photos/ui/EditPhotoCanvas.kt
  • com/vayunmathur/photos/ui/EditPhotoPanels.kt
  • com/vayunmathur/photos/ui/EditPhotoActivePanel.kt
  • com/vayunmathur/photos/ui/EditPhotoAdjustPanels.kt
  • com/vayunmathur/photos/ui/EditPhotoBrushPanels.kt
  • com/vayunmathur/photos/ui/EditPhotoSelectionPanels.kt
  • com/vayunmathur/photos/ui/EditPhotoBottomControls.kt
  • com/vayunmathur/photos/ui/EditPhotoCropOverlay.kt
  • com/vayunmathur/photos/ui/EditPhotoToolOverlays.kt
  • com/vayunmathur/photos/ui/EditPhotoModeEffect.kt
  • com/vayunmathur/photos/ui/EditPhotoTextDialog.kt
  • com/vayunmathur/photos/ui/AdvancedPanels.kt
  • com/vayunmathur/photos/ui/BlurPanel.kt
  • com/vayunmathur/photos/ui/BlurOverlay.kt
  • com/vayunmathur/photos/ui/CurvesPanel.kt
  • com/vayunmathur/photos/ui/HslPanel.kt
  • com/vayunmathur/photos/ui/HealingPanel.kt
  • com/vayunmathur/photos/ui/HealingOverlay.kt
  • com/vayunmathur/photos/ui/LayersPanel.kt
  • com/vayunmathur/photos/ui/LayerRows.kt
  • com/vayunmathur/photos/ui/MaskOverlay.kt
  • com/vayunmathur/photos/ui/SelectiveEditPanel.kt
  • com/vayunmathur/photos/ui/DrawingSettingsPage.kt

ui/ — video editor + wallpaper + vault

  • com/vayunmathur/photos/ui/VideoEditRoute.kt
  • com/vayunmathur/photos/ui/VideoEditActivity.kt
  • com/vayunmathur/photos/ui/VideoEditPage.kt
  • com/vayunmathur/photos/ui/VideoEditPanels.kt
  • com/vayunmathur/photos/ui/VideoEditPreview.kt
  • com/vayunmathur/photos/ui/VideoEditCropOverlay.kt
  • com/vayunmathur/photos/ui/VideoEditDialogs.kt
  • com/vayunmathur/photos/ui/VideoPlayer.kt
  • com/vayunmathur/photos/ui/WallpaperPage.kt
  • com/vayunmathur/photos/ui/WallpaperPreview.kt
  • com/vayunmathur/photos/ui/WallpaperControls.kt
  • com/vayunmathur/photos/ui/SecureFolderPage.kt
  • com/vayunmathur/photos/ui/VaultViewerPage.kt
  • com/vayunmathur/photos/ui/VaultViewerScreen.kt

platform/ — ViewModels, ML, compositing, sync

  • com/vayunmathur/photos/platform/GalleryViewModel.kt
  • com/vayunmathur/photos/platform/GalleryUiContract.kt
  • com/vayunmathur/photos/platform/PhotoEditViewModel.kt
  • com/vayunmathur/photos/platform/VideoEditViewModel.kt
  • com/vayunmathur/photos/platform/PhotoMapViewModel.kt
  • com/vayunmathur/photos/platform/SecureFolderViewModel.kt
  • com/vayunmathur/photos/platform/SecureFolderManager.kt
  • com/vayunmathur/photos/platform/LayerCompositor.kt
  • com/vayunmathur/photos/domain/UndoRedoManager.kt
  • com/vayunmathur/photos/platform/OverlayRendering.kt
  • com/vayunmathur/photos/platform/FaceRecognizer.kt
  • com/vayunmathur/photos/platform/FaceCropTransformation.kt
  • com/vayunmathur/photos/platform/MlSegmentation.kt
  • com/vayunmathur/photos/platform/ClipEmbedder.kt
  • com/vayunmathur/photos/platform/ClipTokenizer.kt
  • com/vayunmathur/photos/platform/ImageLoader.kt
  • com/vayunmathur/photos/domain/PanoXmpParser.kt
  • com/vayunmathur/photos/platform/PhotosNative.kt — Rust bridge
  • com/vayunmathur/photos/platform/AlbumMediaStore.kt
  • com/vayunmathur/photos/platform/SyncWorker.kt
  • com/vayunmathur/photos/platform/SyncWorkerHelper.kt
  • com/vayunmathur/photos/platform/LiveWallpaperLauncher.kt
  • com/vayunmathur/photos/platform/WallpaperHelper.kt
  • com/vayunmathur/photos/platform/AppBackupAgent.kt — platform backup agent: carries the photo database (file passwords-db, named by PHOTO_DB_NAME in data/PhotoDatabase.kt with its photosDbConfigs) through SqlCipherDbCodec plus the datastore_default file, so face/people metadata (person names, hidden flags, face/OCR/CLIP payloads) survives a restore re-encrypted under the new device's key. The raw SQLCipher file and secure_prefs never ship (non-exportable keystore wrapping); gallery photos are MediaStore content and stay out of the payload. The secure-folder vault (vault-db + secure_vault, keyed by the user's password) travels raw only on device transfer and through its own in-app password export, never in cloud backup. Extraction rules in src/main/res/xml/data_extraction_rules.xml govern device transfer and mirror these exclusions

Verify (this module only)

./gradlew :photos:compileDevKotlin
./gradlew :photos:lint
./gradlew :photos:checkMetadata