OBLS-822 Capture DataWedge scans via intent broadcast#423
Open
olewandowski1 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR switches barcode capture from keystroke/focus-dependent behavior to Zebra DataWedge’s intent-broadcast output, centralizing scan handling in a new listener hook and removing the prior event-listener implementation.
Changes:
- Added
useScanListenerto register a DataWedge broadcast receiver and forward scan intents to React callbacks. - Refactored
useBarcodeScanned(and the Scan screen) to consume scan intents instead of the removeduseEventListener. - Updated
ScannerInputto populate/submit on scan intents when focused.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/screens/Scan/index.tsx | Swaps to the refactored barcode-scan hook for Scan screen behavior. |
| src/hooks/useScanListener.ts | New hook to configure DataWedge profile and listen for broadcast scan intents. |
| src/hooks/useEventListener.ts | Removed legacy DataWedge event listener implementation. |
| src/hooks/useBarcodeScanned.ts | Refactored scan/search flow to use useScanListener instead of useEventListener. |
| src/components/ScannerInput.tsx | Adds scan-intent listener to update and submit input when focused; avoids duplicate submits. |
Comments suppressed due to low confidence (1)
src/hooks/useBarcodeScanned.ts:18
onBarCodeScanalways dispatchessearchBarcodeeven when the query is empty.onEmptyQuery()only shows a popup and then execution continues, which can trigger network calls / state updates with an empty barcode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+46
| function extractScan(intent: Record<string, any>): ScanResult | null { | ||
| const data = intent?.[ACTION.DATA_STRING] ?? intent?.data; | ||
| if (!data) { | ||
| return null; | ||
| } | ||
| const labelType = intent?.[ACTION.LABEL_TYPE] ?? intent?.labelType; | ||
| return { data: String(data).trim(), labelType: labelType ? String(labelType) : undefined }; | ||
| } |
Comment on lines
14
to
16
| const Scan = () => { | ||
| const barcodeData = onBarcodeScanned(); | ||
| const barcodeData = useBarcodeScanned(); | ||
| const navigation = useNavigation(); |
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.
https://openboxes.atlassian.net/browse/OBLS-822
Changes
Instead of chasing the focus/input-connection race on the keystroke path, capture scans via DataWedge's intent (broadcast) output, which is independent of which field is focused.
How to test (no Zebra required)
Run the app, open a scan screen, and from a connected device/emulator:
adb shell am broadcast -a com.openboxes.android.ACTION --es com.symbol.datawedge.data_string "0123456789" --es com.symbol.datawedge.label_type "LABEL-TYPE-CODE128"The value should populate the field and drive the normal scan flow. (label_type is optional; the app only acts on data_string.)