Skip to content

feat: Add ML Kit zoom suggestions to the Barcode Scanner output (Andr… - #4201

Open
xTMNTxRaphaelx wants to merge 1 commit into
margelo:mainfrom
xTMNTxRaphaelx:feat/barcode-scanner-zoom-suggestion
Open

xTMNTxRaphaelx wants to merge 1 commit into
margelo:mainfrom
xTMNTxRaphaelx:feat/barcode-scanner-zoom-suggestion

Conversation

@xTMNTxRaphaelx

Copy link
Copy Markdown

Android ML Kit can detect that a QR is visible but too small to decode, and can suggest the zoom level needed to read it (ZoomSuggestionOptions). Previously, this information never reached the app, so we couldn't do the same automatic zoom that Google Lens does.

  • Added two optional fields to BarcodeScannerOutputOptions:
    • onZoomSuggested(zoomRatio) — called when ML Kit recommends zooming.
    • maxZoomRatio — caps the zoom level.
  • The Kotlin layer enables ZoomSuggestionOptions only when the callback is provided and reports the suggested ratio back to JS.
  • The React hook keeps the callback in a ref, so changing the callback doesn't recreate the scanner output configuration.
  • The app can then apply the suggested zoom automatically.
  • iOS is unchanged because ML Kit doesn't provide an equivalent API there; both fields are documented as Android-only.

Verification

On a OnePlus 8 with a dense desktop QR at arm's length:

Before: QR detected, but never decoded.
After: ML Kit suggested 1.9× once → app applied the zoom → QR decoded.

One implementation detail: the callback currently returns true to ML Kit regardless of whether JS actually applies the zoom, because the JS callback is asynchronous. If maintainers prefer, this could instead allow ML Kit to re-suggest when the zoom isn't applied.

@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown

@xTMNTxRaphaelx is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant