Skip to content

Add keep screen on feature to FrontendScreen#6868

Open
TimoPtr wants to merge 2 commits into
mainfrom
feature/alwayson
Open

Add keep screen on feature to FrontendScreen#6868
TimoPtr wants to merge 2 commits into
mainfrom
feature/alwayson

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented May 20, 2026

Summary

Add keep screen on feature to FrontendScreen by exposing a flow from the preference to react on changes.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Copilot AI review requested due to automatic review settings May 20, 2026 07:06
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via LocalStorage.observeChanges(...) with immediate initial emission
  • Exposed keepScreenOnEnabled: StateFlow<Boolean> on FrontendViewModel driven by the preference flow
  • Applied the preference in FrontendScreen via a DisposableEffect that sets/clears View.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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants