Skip to content

Refactor, Modernize & Enhance Android Camera Samples with new features#636

Draft
madebymozart wants to merge 39 commits into
mainfrom
madebymozart/camera-samples-overhaul
Draft

Refactor, Modernize & Enhance Android Camera Samples with new features#636
madebymozart wants to merge 39 commits into
mainfrom
madebymozart/camera-samples-overhaul

Conversation

@madebymozart

@madebymozart madebymozart commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Overview

The legacy camera-samples repo was a loose collection of ~12 independent Gradle projects
(CameraXBasic, Camera2Basic, CameraXAdvanced, …), each with its own build, largely View-based
UI, and copy-pasted boilerplate. This PR replaces all of them with a single, modern, Compose-first
Camera Samples Catalog app
— one cohesive application that showcases Camera2 and CameraX
through small, self-contained samples that share a common architecture and design system.

783 files changed · +14.9k / −32.7k

Screenshots

Home catalog — all samples     Home catalog — filtered to Camera2

Highlights

  • One app, one build. A single Gradle project replaces the dozen standalone sample projects; a
    filterable catalog on the home screen routes to each sample.
  • Modular architecture. Shared code lives in :core-theme, :core-camera, and :core-ui, with
    one thin library module per sample under :samples/{api}-{feature}.
  • Layered & unidirectional. Every sample follows the same UiState → ViewModel → Controller → Screen pattern (documented in android_architecture.md) — a
    sealed interface Ui state, a @HiltViewModel exposing one StateFlow, a @Stable controller
    that owns the camera lifecycle, and a Screen that renders with when(state).
  • "Console" design system. A violet accent, Space Grotesk + Space Mono typography, a dense
    2-column catalog, a viewfinder HUD (accent focus reticle, rule-of-thirds, torch glow), and
    console-styled in-app settings menus.
  • createSample generator. ./gradlew createSample -PsampleName=… -PscreenName=… scaffolds a
    working, preview-only module and wires it into the build + catalog automatically.
  • Modern toolchain. compileSdk 37 (Android 17), JDK 17, Jetpack Compose + Material 3, Hilt,
    Navigation-Compose. Formatting is enforced with Spotless (ktlint + Apache license headers).
  • Modernized CI. The old per-project job matrix is replaced by a single root build that runs
    spotlessCheck + assembleDebug.

Samples

Each feature ships as a CameraX and/or Camera2 variant.

Sample API What it shows
Take a Photo CameraX / Camera2 Preview, tap-to-focus, capture a still
Take a Video CameraX (Recorder) / Camera2 (MediaRecorder) Record video to DCIM/Camera
Slow Motion Camera2 High-speed (constrained) recording
QR Scanner CameraX + ML Kit Real-time barcode/QR detection with overlay
Image Labeling CameraX + ML Kit On-device labels via ImageAnalysis
Extensions CameraX / Camera2 Night / Bokeh / HDR / Face Retouch / Auto
Viewfinder Effects Camera2 Real-time frame processing on the live preview
Zoom & Torch CameraX / Camera2 Zoom-ratio slider + torch toggle
Exposure CameraX Exposure-compensation slider
Manual Controls Camera2 Manual ISO / shutter / focus distance

Samples that depend on optional hardware (extensions, high-speed recording, manual sensor) detect
support at runtime and show a friendly "not supported on this device" state instead of crashing.

Module layout

app/                       catalog UI + Navigation-Compose NavHost
core-theme/                design system: color scheme, typography, AISampleCatalogTheme
core-camera/               Camera2/CameraX plumbing: controllers, previews, permissions, MediaStore
core-ui/                   shared Compose chrome: scaffold, controls, viewfinder HUD, capture review
samples/{api}-{feature}/   one library module per sample

Breaking changes

Removes the legacy standalone projects — Camera2Basic, Camera2Extensions, Camera2Video,
Camera2SlowMotion, CameraXBasic, CameraXAdvanced, CameraXExtensions, CameraXVideo,
CameraX-MLKit, HdrViewfinder, CameraUtils, and Presentations. Their functionality is
re-implemented and consolidated in the new catalog app.

Testing

  • ./gradlew assembleDebug and ./gradlew spotlessCheck pass from the project root.
  • Installed and smoke-tested on a Pixel 10 Pro (Android 17) and the Pixel 9 Pro XL emulator.

…iewfinder` for camera preview and remove unused MLKit dependencies.
…0x1920 and set viewfinder scale type to `FIT_CENTER`.
…introduce `createSample.gradle.kts` for sample generation, and remove `GeminiDataSource.kt`.
…age structure and update build configurations and the `camera2-takeaphoto` sample's package.
…ave recorded videos to the public Movies directory.
@madebymozart madebymozart requested a review from donovanfm June 24, 2026 00:39
@madebymozart madebymozart self-assigned this Jun 24, 2026
@madebymozart madebymozart added the enhancement New feature or request label Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a major cleanup of the repository by deleting several camera-related sample applications, including Camera2Basic, Camera2Extensions, Camera2SlowMotion, Camera2Video, CameraX-MLKit, and CameraX-TFLite, along with their associated source code, resources, and utility modules. Additionally, it updates the .editorconfig file with ktlint naming rules for Composable functions and modifies the CODEOWNERS file to assign new owners. There are no review comments to assess, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant