feat: consolidate dialogs#4506
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
handleScannedUrirouting logic to interpret scanned URIs as either Shared Contact or Channel Set (with fallback). - Refactored
ImportFab/AddContactFABto show contact- vs channel-specific labels/titles. - Expanded URL validation for
toSharedContact()andtoChannelSet()to acceptwww.meshtastic.organd 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. |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AlertManagerand a unifiedMeshtasticDialogcomponent, allowing for more flexible, composable, and maintainable alert dialogs throughout the app. TheUIStateViewModel now delegates alert state toAlertManager, and dialog display logic inMain.ktis consolidated to useMeshtasticDialogfor 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:
dispatchMeshtasticUriutility, replacing the previoushandleMeshtasticUriand related logic. This simplifies how scanned/contact/channel URIs are handled in bothMainActivityandUIState. [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:
Version Check Dialogs: