Skip to content

Add pinch-to-zoom and auto-zoom to the QR scanner#259

Open
Merkost wants to merge 3 commits into
G00fY2:mainfrom
Merkost:feature/zoom
Open

Add pinch-to-zoom and auto-zoom to the QR scanner#259
Merkost wants to merge 3 commits into
G00fY2:mainfrom
Merkost:feature/zoom

Conversation

@Merkost

@Merkost Merkost commented Oct 12, 2025

Copy link
Copy Markdown

Add pinch-to-zoom and auto-zoom to the QR scanner

What

Two new opt-in options on ScannerConfig.Builder:

ScannerConfig.build {
  setUsePinchToZoom(true) // default: false — user pinches preview to zoom
  setUseAutoZoom(true)    // default: false — ML Kit zooms automatically for small/distant codes
}

How

  • Pinch-to-zoom: camera setup switched from manually built Preview + ImageAnalysis use cases to LifecycleCameraController, which exposes isPinchToZoomEnabled natively.
  • Auto-zoom: ML Kit's ZoomSuggestionOptions is attached to BarcodeScannerOptions, with the zoom callback forwarded to LifecycleCameraController.setZoomRatio(...). Max zoom is read from CameraInfo.zoomState once the camera is initialized.

Closes #214.

Behavior changes to be aware of

  • Both options default to false — existing apps see no change.
  • Tap-to-focus is now always on. (Happy to gate this behind a separate option if you'd prefer.)
  • The explicit 1280×720 analysis resolution was removed; LifecycleCameraController picks its own default. ML Kit scanning still works in manual testing.

Test plan

  • Run the sample app on a real device.
  • Pinch with setUsePinchToZoom(true) → preview zooms.
  • Hold a small/distant code with setUseAutoZoom(true) → camera zooms automatically.
  • Both flags off → no zoom behavior.
  • Torch toggle still shows/hides correctly.
  • Front camera still works.

Notes

  • Public API change is additive only: two new Builder methods.
  • README's Quick Start block should get matching lines — happy to add them if you'd like.

@sonarqubecloud

Copy link
Copy Markdown

# Conflicts:
#	quickie/src/main/kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt
@Merkost Merkost changed the title feat(Zoom): added pinch-to-zoom functionality to QR scanner Add pinch-to-zoom to the QR scanner Jun 9, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@Merkost Merkost changed the title Add pinch-to-zoom to the QR scanner Add pinch-to-zoom and auto-zoom to the QR scanner Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add auto-zoom option to ScannerConfig

1 participant