Skip to content

feat: Add KMP URI handling, import, and QR code generation support#4856

Merged
jamesarich merged 8 commits intomainfrom
feat/imports
Mar 19, 2026
Merged

feat: Add KMP URI handling, import, and QR code generation support#4856
jamesarich merged 8 commits intomainfrom
feat/imports

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This pull request introduces several significant improvements and refactors to the codebase, focusing on QR code generation, multiplatform support, and UI feature detection. The most notable changes are the migration from ZXing to qrcode-kotlin for QR code generation, the addition of platform capability providers for barcode and NFC scanning, and updates to documentation and test coverage to reflect these architectural changes.

Key changes include:

QR Code Generation & Dependencies

  • Migrated QR code generation from ZXing to qrcode-kotlin, removing ZXing from dependencies and updating implementation to use rememberQrCodePainter in shared UI code. Platform-specific QR code utilities and the old ZXing-based code (QrUtils.kt and QrCodeUtils.kt) were removed. (core/model/build.gradle.kts, core/ui/build.gradle.kts, core/model/src/androidMain/kotlin/org/meshtastic/core/model/util/QrCodeUtils.kt, core/ui/src/androidMain/kotlin/org/meshtastic/core/ui/util/QrUtils.kt, core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/ContactSharing.kt, [1] [2] [3] [4] [5]

  • Updated documentation to instruct developers to use rememberQrCodePainter for QR code generation and not to use Android Bitmap or ZXing APIs in common code. (AGENTS.md, GEMINI.md, AGENTS.mdR80)

Platform Feature Detection

  • Introduced LocalBarcodeScannerSupported and LocalNfcScannerSupported composition locals to allow UI to detect and conditionally display barcode/NFC features based on platform support. Updated MainActivity.kt to provide these locals. (app/src/main/kotlin/org/meshtastic/app/MainActivity.kt, [1] [2]

  • Updated UI tests to verify the conditional display of import options depending on feature support. (core/ui/src/androidTest/kotlin/org/meshtastic/core/ui/component/ImportFabUiTest.kt, [1] [2] [3]

Code Organization & Refactoring

Documentation & Planning

Documentation Updates

  • Updated module documentation to include new feature modules (firmware, widget) and clarified their multiplatform targets. (AGENTS.md, GEMINI.md, AGENTS.mdL53-R53)

These changes modernize QR code support, improve multiplatform compatibility, and make feature support detection more robust and testable.

This commit enables deep link and URI handling for the desktop application, allowing it to process `meshtastic://` and `meshtastic.org` links from command line arguments and the operating system. It also integrates shared UI components for importing contacts and channels via QR codes or URIs.

Specific changes include:
- **Desktop URI Handling**:
    - Updated `main` to process Meshtastic URIs passed via command line arguments.
    - Implemented `setOpenURIHandler` using AWT Desktop API to handle URIs triggered by the OS.
    - Integrated `UIViewModel` into the desktop entry point to handle scanned/opened URIs.
- **UI & Navigation**:
    - Added `SharedContactDialog` and `ScannedQrCodeDialog` to `DesktopMainScreen` to handle incoming contact and channel sharing requests.
    - Integrated `MeshtasticImportFAB` into `DesktopAdaptiveContactsScreen` and `DesktopAdaptiveNodeListScreen` to allow manual URI/QR imports.
    - Added connection state checks to ensure import actions are only available when connected to a node.
- **Documentation & Build**:
    - Updated `kmp-status.md`, `AGENTS.md`, and `GEMINI.md` to reflect the addition of `feature:widget` (Android-only) and the KMP status of other modules.
    - Updated Kotlin to `2.3.20` and Koin to `4.2.0` in `agent-playbooks/README.md`.
- **Dependencies**: Injected `UIViewModel` into various desktop screens to manage shared application state for imports and dialogs.

Signed-off-by: James Rich <[email protected]>
…support

- Introduced LocalBarcodeScannerSupported and LocalNfcScannerSupported CompositionLocals in core:ui.
- Updated MeshtasticImportFAB to dynamically show/hide hardware-dependent items.
- Enabled scanner support flags in Android MainActivity.
- Added UI tests for supported and unsupported hardware scenarios in ImportFabUiTest.
- Replaced Android-only ZXing bitmap generation with qrcode-kotlin logic in commonMain.
- Implemented rememberQrCodePainter to draw raw QR matrices natively on the Compose Canvas.
- Ensured a 4-module quiet zone is drawn around the matrix to prevent scanning failures on dark backgrounds.
- Removed expect/actual bitmap constraints, making QR rendering fully functional across Android, Desktop, iOS, and Web.
- Removed ZXing dependencies from core:model and core:ui.
…ng on Desktop

- Moved ChannelScreen and ChannelsNavigation from androidMain to commonMain.
- Refactored ChannelScreen to use KMP abstractions for toast messages and error handling.
- Wired Desktop Messaging FAB to the shared Channels graph to display the inline QR Code sharing UI.
- Removed temporary top app bar actions from ChannelConfigScreen.
@github-actions github-actions bot added the enhancement New feature or request label Mar 19, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.41%. Comparing base (91f73b5) to head (b5ece4c).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tastic/core/ui/util/LocalBarcodeScannerProvider.kt 0.00% 1 Missing ⚠️
...meshtastic/core/ui/util/LocalNfcScannerProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4856      +/-   ##
==========================================
- Coverage   10.50%   10.41%   -0.10%     
==========================================
  Files         551      550       -1     
  Lines       18197    18183      -14     
  Branches     2717     2714       -3     
==========================================
- Hits         1912     1894      -18     
- Misses      16089    16093       +4     
  Partials      196      196              
Flag Coverage Δ
host-unit 10.41% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@jamesarich jamesarich merged commit 1e55e55 into main Mar 19, 2026
7 of 8 checks passed
@jamesarich jamesarich deleted the feat/imports branch March 19, 2026 18:36
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