Repository navigation
feat(android): let products scan codes with the app's scanner - #1319
Merged
valentinfernandez1 merged 20 commits intoOct 9, 2026
Merged
Conversation
…any format QrViewfinder, PermissionMissingHint and the scanner frame move from the scan feature to common, so other features draw the same scanner. QrCodeAnalyzer takes the ML Kit formats to read and reports the format of each code; the QR-only constructor keeps existing callers unchanged.
TrUAPIPrompts shows one kind of host screen at a time, answers a screen that never appears instead of holding the core, and closes the screen when the call is cancelled. The contact picker moves onto it, replacing its own context, holder and launcher, which left the picker open after a cancel.
AppScannerHostBridge serves scanner.scan with a full-screen viewfinder titled for the product, with its hint underneath. Every code goes through the core's ScanFilter: a match answers once, a wrong code shows a short message and scanning goes on. An App gets NotVisible unless one of its pages is on screen in the focused window. UPC-A is reported as EAN-13, as on iOS.
Contributor
|
This pull request touches an app, which is not built by default. Add a label for each build you want:
Each starts as soon as it is added and follows the branch from then on. |
Contributor
Bundle size reportCompared with
WebAssembly modules
Changed files (7)
Commit: 55083f5 |
Review of #1319: - The analyzer reports every code in a frame, so an unrelated code next to the product's cannot hide it. The QR-only constructor keeps reporting the first, as before. - A prompt whose screen never appears closes it too, and a screen that appears after its prompt ended, or is restored in a new process, closes itself instead of crashing or answering nobody. - Prompts close their own screen wherever it is in the back stack, and an answer no longer pops whatever sits on top. - Camera results that arrive after the screen is gone are ignored. - Any camera refusal shows the Settings dialog before answering. - Imports in files this change only touches keep their original order. - The README says the Android app draws the scanner.
Contributor
|
CI Status: 24 required jobs green, 17 passed and 7 skipped by path filter. All job results
Signing credentials: failure as of 2026-10-09, a release may fail Commit |
… top Review of #1319: - The scanner is a full-height sheet, not a screen. Opening a screen closed any sheet under it, including the product sheet whose product asked. - Closing a prompt pops it only when it is on top, so a sheet over it stays. A prompt left under another sheet closes itself when it is shown again. - Close and back always close the screen. Only the answer is given once. - A one-time camera denial answers CameraUnavailable, since Android asks again next time. Only a permanent denial shows the Settings dialog. - Any failure to show a prompt dismisses and closes it, and a screen that never appears fails the call instead of reporting that the user dismissed.
The reasons a prompt screen closes itself move to TrUAPIPrompts.current instead of being repeated in each view model, and a stale test comment is corrected.
valentinfernandez1
added this pull request to stack #1311
October 7, 2026 19:20
…the background A Worker has no page to check, so the app itself must be in front. Opening the scanner from the background would also fail to navigate and reach the product as a host error.
A scan waiting behind another one is checked once that one closes, since the user may have left the page by then. The check lives in the scanner prompt, which now serves scanner.scan itself. A Worker needs the app's activity resumed, which updates at once, where the process lifecycle lags behind.
valentinfernandez1
marked this pull request as ready for review
October 8, 2026 18:45
filvecchiato
approved these changes
Oct 8, 2026
filvecchiato
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. One thing to check inline.
The product gets the answer before the closing sheet hands window focus back to its page, so a scan made right away found the page off screen. An App's check now waits up to a second for its page to get focus back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Host scanner on Android
The Android app serves
scanner.scan. A product asks to scan, the app opens its own scanner, and the product gets back the code.What the user sees
Dismissed.CameraUnavailable. If it was refused for good, the app first shows its usual "open Settings" dialog.How it works
TrUAPIProductScansserves the scanner and is installed withsetScanner.NotVisible, and no scanner opens, unless one of its pages is on screen in the focused window. A page in a background tab, under a host sheet, or in a backgrounded app does not count. The check waits up to a second for the page to get focus back, since a closing host screen, such as the last scanner, holds it for a moment. A Worker getsNotVisibleunless the app is in front. The core already checked that the user tapped its card.ScanFilter, so Android accepts the same codes as every other host.Shared pieces
QrViewfinderand the scanner frame move from the scan feature tocommon, so both scanners draw the same thing.QrCodeAnalyzertakes the formats to read and reports every code in a frame with its format. The existing QR-only callers are unchanged.TrUAPIPromptsshows one kind of host screen at a time. It closes the screen when the product cancels, and fails the call if the screen never appears. The contact picker uses it too, so it now closes on cancel instead of staying open.Testing
:feature:products:impl:testReleaseUnitTest,:app:compileVanillaDebugKotlinand detekt pass locally.Dismissed.CameraUnavailable.