Skip to content

OBLS-822 Capture DataWedge scans via intent broadcast#423

Open
olewandowski1 wants to merge 1 commit into
developfrom
OBLS-822
Open

OBLS-822 Capture DataWedge scans via intent broadcast#423
olewandowski1 wants to merge 1 commit into
developfrom
OBLS-822

Conversation

@olewandowski1

Copy link
Copy Markdown
Collaborator

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.)

Copilot AI 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.

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 useScanListener to 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 removed useEventListener.
  • Updated ScannerInput to 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

  • onBarCodeScan always dispatches searchBarcode even 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();
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.

2 participants