Add keep screen on feature to FrontendScreen#6868
Open
TimoPtr wants to merge 2 commits into
Open
Conversation
50 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires the existing “Keep screen on” preference into the new Compose-based frontend by exposing it as a reactive Flow from PrefsRepository, surfacing it as a StateFlow in FrontendViewModel, and applying it in FrontendScreen by toggling View.keepScreenOn while the screen is in composition.
Changes:
- Added
PrefsRepository.keepScreenOnFlow()and implemented it viaLocalStorage.observeChanges(...)with immediate initial emission - Exposed
keepScreenOnEnabled: StateFlow<Boolean>onFrontendViewModeldriven by the preference flow - Applied the preference in
FrontendScreenvia aDisposableEffectthat sets/clearsView.keepScreenOn, plus unit tests for the new flows/state
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| common/src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepository.kt | Adds public keepScreenOnFlow() API with KDoc describing emission semantics |
| common/src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt | Implements keepScreenOnFlow() using LocalStorage.observeChanges |
| common/src/test/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImplTest.kt | Adds unit test verifying keepScreenOnFlow() emits initial + updated values on key changes |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt | Adds keepScreenOnEnabled StateFlow for UI consumption |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt | Adds tests ensuring the ViewModel reflects changes and respects seeded values |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt | Collects keepScreenOnEnabled and applies it via KeepScreenOnEffect (View.keepScreenOn) |
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
Add keep screen on feature to
FrontendScreenby exposing a flow from the preference to react on changes.Checklist