Skip to content

feat(sharing): Refactor QR/NFC scanning with ML Kit and CameraX#4471

Merged
jamesarich merged 4 commits into
mainfrom
feat/sharing-ux-refactor
Feb 6, 2026
Merged

feat(sharing): Refactor QR/NFC scanning with ML Kit and CameraX#4471
jamesarich merged 4 commits into
mainfrom
feat/sharing-ux-refactor

Conversation

@jamesarich

@jamesarich jamesarich commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

This commit overhauls the QR code and NFC scanning functionality, replacing the Zxing-Embedded library with a modern, unified solution based on ML Kit and CameraX. This refactoring centralizes scanning logic into new core:barcode and core:nfc modules, improving maintainability and user experience.

Key changes include:

  • Replaced the third-party Zxing-Embedded library with Google's ML Kit for barcode scanning and a custom CameraX implementation.
  • Introduced a unified Floating Action Button (FAB) menu for sharing/scanning contacts and channels, providing options for QR code, NFC, and manual URL entry.
  • Added new core:barcode and core:nfc modules to encapsulate scanning logic.
  • Implemented a new full-screen, in-app scanner UI using CameraX for a more integrated experience.
  • Created a generic QrDialog composable to standardize the display of QR codes and associated data, which now also maximizes screen brightness for better scannability.
  • Refactored channel and contact sharing screens to use the new centralized scanning and dialog components.
  • Added a unified URI handler (handleScannedUri) to process both channel and contact URIs from any scanning source.
  • Included NFC scanning capabilities for both contacts and Wi-Fi credentials.
  • Updated AndroidManifest to declare NFC support and handle Meshtastic URLs via NFC discovery.
Screen_recording_20260205_175035.mp4

This commit overhauls the QR code and NFC scanning functionality, replacing the Zxing-Embedded library with a modern, unified solution based on ML Kit and CameraX. This refactoring centralizes scanning logic into new `core:barcode` and `core:nfc` modules, improving maintainability and user experience.

Key changes include:
- Replaced the third-party Zxing-Embedded library with Google's ML Kit for barcode scanning and a custom CameraX implementation.
- Introduced a unified Floating Action Button (FAB) menu for sharing/scanning contacts and channels, providing options for QR code, NFC, and manual URL entry.
- Added new `core:barcode` and `core:nfc` modules to encapsulate scanning logic.
- Implemented a new full-screen, in-app scanner UI using CameraX for a more integrated experience.
- Created a generic `QrDialog` composable to standardize the display of QR codes and associated data, which now also maximizes screen brightness for better scannability.
- Refactored channel and contact sharing screens to use the new centralized scanning and dialog components.
- Added a unified URI handler (`handleScannedUri`) to process both channel and contact URIs from any scanning source.
- Included NFC scanning capabilities for both contacts and Wi-Fi credentials.
- Updated AndroidManifest to declare NFC support and handle Meshtastic URLs via NFC discovery.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@github-actions github-actions Bot added the enhancement New feature or request label Feb 6, 2026
@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 10.15625% with 115 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.56%. Comparing base (9e6de12) to head (44b0270).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../meshtastic/core/barcode/BarcodeScannerProvider.kt 0.00% 35 Missing ⚠️
.../meshtastic/feature/node/list/NodeListViewModel.kt 0.00% 19 Missing ⚠️
...org/meshtastic/core/ui/component/ContactSharing.kt 0.00% 18 Missing ⚠️
...otlin/org/meshtastic/core/model/util/ChannelSet.kt 0.00% 13 Missing ⚠️
.../main/kotlin/org/meshtastic/core/nfc/NfcScanner.kt 0.00% 10 Missing ⚠️
...tlin/org/meshtastic/core/ui/component/ImportFab.kt 0.00% 7 Missing ⚠️
...n/org/meshtastic/core/ui/util/ContextExtensions.kt 0.00% 4 Missing ⚠️
...src/main/java/com/geeksville/mesh/model/UIState.kt 0.00% 3 Missing ⚠️
...otlin/org/meshtastic/core/ui/component/QrDialog.kt 0.00% 2 Missing ⚠️
...ain/java/com/geeksville/mesh/ui/sharing/Channel.kt 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #4471      +/-   ##
========================================
+ Coverage   8.54%   8.56%   +0.01%     
========================================
  Files        420     427       +7     
  Lines      14216   14324     +108     
  Branches    2359    2382      +23     
========================================
+ Hits        1215    1227      +12     
- Misses     12781   12875      +94     
- Partials     220     222       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…t UI

This commit refactors URL and import handling by:

-   **Introducing `MeshtasticUrlConstants.kt`**: Centralizes all Meshtastic URL constants (`meshtastic.org`, `/e/`, `/v/`) into a single file in the `core:model` module for consistency.
-   **Creating `UriUtils.kt` with `handleMeshtasticUri`**: A new utility function in `core:model` to parse and dispatch `meshtastic.org` URIs based on their path (`/e/` for channels, `/v/` for contacts), ensuring a single point of entry for URI handling.
-   **Refactoring to a generic `ImportFab.kt`**: The contact sharing FAB logic has been extracted from `ContactSharing.kt` into a new, reusable `ImportFab` composable. This unified component now handles importing channels and contacts via QR, NFC, or URL.
-   **Updating existing code**:
    -   `ContactSharing.kt` and `ChannelSet.kt` are updated to use the new centralized constants.
    -   `NetworkConfigItemList.kt` now uses `handleMeshtasticUri` to correctly ignore Meshtastic URIs during Wi-Fi credential scans.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
The visibility of `formatAbbreviation` and `formatPosixOffset` in `ZoneIdExtensions.kt` has been changed from `internal` to `public` to allow their use in other modules.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
The visibility of several Composables in the debugging feature has been changed from `internal` to `public`. This allows them to be used in UI tests and previews.

The affected Composables are:
- `DebugPresetFilters`
- `DebugFilterBar`
- `DebugActiveFilters`
- `DebugSearchNavigation`
- `DebugSearchBar`
- `DebugSearchState`

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 9655176 Feb 6, 2026
8 checks passed
@jamesarich jamesarich deleted the feat/sharing-ux-refactor branch February 6, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant