Skip to content

feat: consolidate dialogs#4506

Merged
jamesarich merged 7 commits into
mainfrom
fix/channel-scan
Feb 8, 2026
Merged

feat: consolidate dialogs#4506
jamesarich merged 7 commits into
mainfrom
fix/channel-scan

Conversation

@jamesarich

@jamesarich jamesarich commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors alert and dialog handling in the app to use a centralized, flexible alert management system, and streamlines Meshtastic URI processing. The changes unify how dialogs are displayed, simplify the UI state management, and improve code maintainability by reducing boilerplate and duplicating logic.

Alert and Dialog System Refactor:

  • Replaces ad-hoc alert dialog handling with a centralized AlertManager and a unified MeshtasticDialog component, allowing for more flexible, composable, and maintainable alert dialogs throughout the app. The UIState ViewModel now delegates alert state to AlertManager, and dialog display logic in Main.kt is consolidated to use MeshtasticDialog for all alert types. [1] [2] [3] [4] [5]

  • The alert system now supports resource-based titles/messages, composable content, customizable confirm/dismiss buttons, and multiple-choice dialogs, reducing boilerplate and improving localization. [1] [2]

  • Updates the developer documentation (AGENTS.md) to instruct developers to use the new dialog components.

Meshtastic URI Handling Improvements:

  • Refactors Meshtastic URI processing to use a new dispatchMeshtasticUri utility, replacing the previous handleMeshtasticUri and related logic. This simplifies how scanned/contact/channel URIs are handled in both MainActivity and UIState. [1] [2] [3] [4] [5]

Client Notification and Traceroute Handling:

  • Client notifications are now displayed via the new alert system, including special handling for compromised key warnings, and are cleared via callbacks. [1] [2]

  • Traceroute responses are now handled as flows instead of LiveData, and their dialogs use the new alert system with improved formatting and error handling. [1] [2] [3]

General Codebase Cleanup:

  • Removes unused imports and legacy dialog components, and updates usages to the new dialog and alert system. [1] [2] [3] [4]

Version Check Dialogs:

  • Updates version check dialogs to use the new alert system with resource-based messages and improved user interaction. [1] [2]

This commit improves the handling of Meshtastic QR codes and URLs for both contacts and channels.

- Introduces a unified URI handler (`handleScannedUri`) to correctly parse both contact (`/v/` or `/v`) and channel (`/e/` or `/e`) URLs, including a fallback mechanism.
- Refactors the `ImportFab` and related UI components to be context-aware, displaying appropriate text for either contact or channel sharing.
- Expands URL validation to accept both short (`/v`, `/e`) and long (`/contact/v`, `/channel/e`) path formats, as well as `www.meshtastic.org` hosts.
- Adds a dialog to display scanned channel set information on the contacts screen.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 8, 2026 17:26
@github-actions github-actions Bot added the bugfix PR tag label Feb 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves how the Android client imports Meshtastic share links/QR codes by broadening accepted URL forms, centralizing scan routing, and updating import UI text based on whether the user is importing a contact or channels.

Changes:

  • Added/updated handleScannedUri routing logic to interpret scanned URIs as either Shared Contact or Channel Set (with fallback).
  • Refactored ImportFab / AddContactFAB to show contact- vs channel-specific labels/titles.
  • Expanded URL validation for toSharedContact() and toChannelSet() to accept www.meshtastic.org and short path forms (/v, /e).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
feature/node/src/main/kotlin/org/meshtastic/feature/node/list/NodeListViewModel.kt Adds unified scan routing for contact vs channel URIs.
core/ui/src/main/kotlin/org/meshtastic/core/ui/component/ImportFab.kt Makes import UI strings context-aware for contact vs channel importing.
core/ui/src/main/kotlin/org/meshtastic/core/ui/component/ContactSharing.kt Broadens Shared Contact URL validation (host/path variants).
core/model/src/main/kotlin/org/meshtastic/core/model/util/ChannelSet.kt Broadens Channel Set URL validation (host/path variants).
app/src/main/java/com/geeksville/mesh/ui/contact/Contacts.kt Displays scanned channel set dialog on the conversations/contacts screen and tweaks import FAB context flag usage.
app/src/main/java/com/geeksville/mesh/model/UIState.kt Updates unified scan routing in the shared UI ViewModel.

Comment thread core/ui/src/main/kotlin/org/meshtastic/core/ui/component/ContactSharing.kt Outdated
Comment thread app/src/main/java/com/geeksville/mesh/ui/contact/Contacts.kt Outdated
Comment thread app/src/main/java/com/geeksville/mesh/model/UIState.kt Outdated
Comment thread app/src/main/java/com/geeksville/mesh/model/UIState.kt Outdated
@codecov

codecov Bot commented Feb 8, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
241 1 240 1
View the top 1 failed test(s) by shortest run time
org.meshtastic.feature.firmware.ota.BleOtaTransportNordicMockTest::full ota flow with nordic mocks
Stack Traces | 0.096s run time
java.lang.IllegalStateException: Peripheral not connected
	at no.nordicsemi.kotlin.ble.client.mock.PeripheralSpec.estimateTransferDuration-3nIYWDw$client_mock(PeripheralSpec.kt:275)
	at no.nordicsemi.kotlin.ble.client.mock.PeripheralSpec$simulateValueUpdate$1.invokeSuspend(PeripheralSpec.kt:535)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@jamesarich jamesarich added this pull request to the merge queue Feb 8, 2026
@jamesarich jamesarich removed this pull request from the merge queue due to a manual request Feb 8, 2026
This commit refactors the handling of Meshtastic URIs (`meshtastic.org/e/...` for channels and `meshtastic.org/v/...` for contacts) to be more flexible and robust.

Key changes include:
- Accepting URIs with the `www.` subdomain (e.g., `www.meshtastic.org`).
- Supporting longer path formats like `/channel/e/` and `/contact/v/`.
- Introducing a centralized `handleMeshtasticUri` dispatcher to streamline URI processing and reduce duplicate logic.
- Renaming the `isContactContext` parameter to the more descriptive `isSharedContactContext` for better clarity in the UI.
- Adding comprehensive unit tests to validate the new URI path and host variations.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit introduces several refactoring improvements:

-   **`AlertManager`**: A new singleton `AlertManager` is created to decouple alert logic from ViewModels and provide a global way to display alerts. The `UIState` ViewModel is updated to use this new manager.
-   **`SharedContact` utils**: Utility functions for `SharedContact` (e.g., `toSharedContact`, `getSharedContactUrl`, `compareUsers`) have been moved from `core/ui` to `core/model` for better separation of concerns.
-   **`MeshtasticImportFAB`**: The `AddContactFAB` has been renamed to a more generic `MeshtasticImportFAB` and refactored to handle the shared contact import dialog internally.
-   **URI Dispatching**: A new `dispatchMeshtasticUri` extension function is introduced in `core/model` to centralize and simplify the parsing and handling of Meshtastic URIs (for both contacts and channels), including fallback logic. ViewModels and `MainActivity` now use this unified handler.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit refactors the `AlertManager` to be more flexible and powerful.

Key changes include:
-   Supporting `StringResource` for titles and messages to simplify localization.
-   Allowing custom `ComposableContent` for alert bodies.
-   Adding options for custom confirm and dismiss button text, also with `StringResource` support.
-   Replacing the custom `SimpleAlertDialog` in `Main.kt` with a standard `androidx.compose.material3.AlertDialog` that uses the new `AlertManager` capabilities.
-   Adding unit and UI tests for `AlertManager` to ensure its functionality.
-   Introducing `AlertPreviewRenderer` to facilitate previews and testing of different alert types.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Adds unit and instrumentation tests for `SharedContact` URL parsing and round-trip conversion. These tests verify that various valid URL formats (including `www.` subdomain and longer paths) are correctly parsed, and invalid hosts are rejected.

This commit also introduces UI tests for the `MeshtasticImportFAB` component to ensure it expands correctly and displays the shared contact import dialog when provided with contact data.

Additionally, some minor code formatting and cleanup have been applied across the codebase.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
…g component

This commit introduces a new `MeshtasticDialog` composable to standardize the appearance and implementation of dialogs throughout the application. The new component is highly configurable and replaces numerous custom `AlertDialog` implementations.

Key changes:
- **New `MeshtasticDialog`:** A reusable dialog with consistent styling, supporting titles, messages (text, resource, HTML), icons, and custom button configurations.
- **Removed `SimpleAlertDialog`:** The previous generic dialog has been removed and all its usages are replaced by `MeshtasticDialog`.
- **Refactored Dialogs:** Updated various screens to use the new `MeshtasticDialog`, including:
    - Node action confirmations (favorite, ignore, mute, remove)
    - Contact deletion and mute dialogs
    - Firmware update disclaimers and instructions
    - Channel and security key management dialogs
    - QR code, URL, and NFC import/scan dialogs
- **Introduced `AlertManager`:** A centralized manager to display global alerts and dialogs, now used for features like cleaning the node database and deleting debug logs.
- **Node Management Actions:** Node management logic (favorite, ignore, mute, remove) is consolidated and now shows confirmation dialogs before executing the action.
- **Minor UI Enhancements:** Added test tags to FAB menu items for better UI testing.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich changed the title fix: Improve QR code and URL handling feat: consolidate dialogs Feb 8, 2026
This commit introduces a new `importDialog` composable parameter to the `MeshtasticImportFAB`. This allows callers to provide a custom implementation for the import dialog, increasing the component's reusability.

The changes also include:
- Refactoring `AlertPreviews.kt` for cleaner composable message and callback handling.
- Updating the `ImportFabUiTest` to verify the custom dialog functionality.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich added this pull request to the merge queue Feb 8, 2026
Merged via the queue into main with commit ea6d1ff Feb 8, 2026
7 checks passed
@jamesarich jamesarich deleted the fix/channel-scan branch February 8, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants