mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
2.9 KiB
2.9 KiB
Desktop URI Import Plan
Objective
Wire up SharedContact and ChannelSet import logic for the Desktop target. This enables the Desktop app to process deep links or URIs passed on startup via arguments or intercepted by the OS using java.awt.Desktop's OpenURIHandler.
Key Files & Context
desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt: Desktop app entry point. Must be updated to parse command line arguments and handle OS-level URI opening events.desktop/src/main/kotlin/org/meshtastic/desktop/ui/DesktopMainScreen.kt: The main UI composition. Must be updated to inject the sharedUIViewModeland render theSharedContactDialog/ScannedQrCodeDialogwhenrequestChannelSetorsharedContactRequestedare present.core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/viewmodel/UIViewModel.kt: Already handles URI dispatch and holds the requests, so no changes are needed here.
Implementation Steps
-
Update
DesktopMainScreen.kt- Import
org.meshtastic.core.ui.viewmodel.UIViewModel,org.koin.compose.viewmodel.koinViewModel,org.meshtastic.core.ui.share.SharedContactDialog,org.meshtastic.core.ui.qr.ScannedQrCodeDialog, andorg.meshtastic.core.model.ConnectionState. - Inject
UIViewModeldirectly intoDesktopMainScreenviaval uiViewModel = koinViewModel<UIViewModel>(). - Add observations for
uiViewModel.sharedContactRequestedanduiViewModel.requestChannelSet. - Just like in Android's
MainScreen, conditionally renderSharedContactDialogandScannedQrCodeDialogifconnectionState == ConnectionState.Connectedand either state contains a valid request. - Wire
onDismissclosures touiViewModel.clearSharedContactRequested()anduiViewModel.clearRequestChannelUrl().
- Import
-
Update
Main.kt(Desktop)- Alter
fun main()tofun main(args: Array<String>). - Resolve
UIViewModelafterkoinAppinitialization:val uiViewModel = koinApp.koin.get<UIViewModel>(). - Process the initial
argsand invokeuiViewModel.handleScannedUriusingMeshtasticUrifor any arguments that look like valid Meshtastic URIs (starting withhttpormeshtastic://). - Attempt to attach a
java.awt.desktop.OpenURIHandlerifjava.awt.Desktop.Action.APP_OPEN_URIis supported. When triggered, process the incomingevent.uristring using the samehandleScannedUrilogic.
- Alter
Verification & Testing
- Compile the desktop target with
./gradlew desktop:run --args="meshtastic://meshtastic/v/contact...". - Connect to a device via Desktop Connections or wait for connection.
- Validate that the corresponding Shared Contact or Channel Set dialog renders on screen.
- Verify that dismissing the dialogs properly clears the state in the view model.
- (Optional, macOS) If testing via packaged DMG, verify that opening a
.weblocor invokingopen meshtastic://...triggers theAPP_OPEN_URIhandler and routes through the UI.