Refactor Improv flow to be more modern and usable in FrontendScreen#6876
Open
TimoPtr wants to merge 2 commits into
Open
Refactor Improv flow to be more modern and usable in FrontendScreen#6876TimoPtr wants to merge 2 commits into
TimoPtr wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the Improv (BLE Wi‑Fi onboarding) flow to a more lifecycle-driven, Flow-based repository/API and moves the UI components under frontend/improv to make them reusable from FrontendScreen and easier to unit test.
Changes:
- Replaced the legacy
improvrepository with a newfrontend.improvrepository exposingscanDevices()andprovisionDevice()as collector-driven Flows, plus newImprovUIState/ProvisioningEventmodels - Updated WebView presenter + dialogs to use the new repository API and new Compose UI components (HA design system)
- Added unit tests for
ImprovRepositoryImpl
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/test/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImplTest.kt | Updates import to the new frontend.improv.ImprovRepository |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/improv/ImprovRepositoryImplTest.kt | Adds unit tests for permissions, scanning lifecycle, and provisioning event flow |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt | Switches presenter Improv scanning to scanDevices() and new permission API |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ui/ImprovSetupDialog.kt | Reworks dialog to use new ImprovUIState + provisioning flow and HA-themed sheet content |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ui/ImprovPermissionDialog.kt | Updates permission rationale dialog to use new UI + requiredPermissions API |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ui/ImprovSheetView.kt | Removes legacy Improv sheet UI implementation (moved to frontend) |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ui/ImprovSheetState.kt | Removes legacy sheet state model (replaced by ImprovUIState) |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ui/ImprovPermissionView.kt | Removes legacy permission view (moved to frontend) |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ImprovRepositoryImpl.kt | Removes legacy repository implementation |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ImprovRepository.kt | Removes legacy repository interface |
| app/src/main/kotlin/io/homeassistant/companion/android/improv/ImprovModule.kt | Removes legacy Hilt module (bindings moved to frontend module) |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ui/ImprovSheetView.kt | Adds new HA design system sheet body driven by ImprovUIState |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ui/ImprovPermissionView.kt | Adds new HA design system permission rationale content |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ProvisioningEvent.kt | Adds provisioning event model emitted by provisionDevice() |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ImprovUIState.kt | Adds UI state machine model for the Improv flow |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ImprovRepositoryImpl.kt | Adds new Flow-driven repository with WhileSubscribed scan management and provisioning flow |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ImprovRepository.kt | Adds new repository interface with requiredPermissions, scanDevices, provisionDevice |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/ImprovManagerFactory.kt | Adds factory abstraction to avoid Context in the repository and improve testability |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/improv/FrontendImprovModule.kt | Binds new repository and provides ImprovManagerFactory |
Comment on lines
+67
to
+70
| if (savedInstanceState == null) { | ||
| val name = arguments?.getString(ARG_NAME).orEmpty() | ||
| screenState.value = ImprovUIState.SearchingDevice(deviceName = name) | ||
| } |
| * sentinel returned by [WifiManager.getConnectionInfo] when the app lacks the location permission. | ||
| */ | ||
| private fun String?.takeIfDisplayable(): String? = takeIf { | ||
| !it.isNullOrBlank() && (Build.VERSION.SDK_INT < Build.VERSION_CODES.R || it !== WifiManager.UNKNOWN_SSID) |
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.
Summary
This is coming from splitting #6865 in two to isolate the refactor from the actual new code in the FrontendScreen. The idea of the refactor is to fully test the managers and make it more usable for the FrontendScreen.
I've also adjusted the UI, the screenshots are going to be made in the next PR since I want then on top of the FrontendScreen.
Checklist