Introduce screen orientation feature to FrontendScreen#6869
Open
TimoPtr wants to merge 1 commit into
Open
Conversation
50 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a typed screen-orientation preference (via a new ScreenOrientation enum) and wires it through preferences, presenters, and the Compose FrontendScreen so the dashboard can apply and react to the user’s selected orientation consistently across both the legacy WebViewActivity and the newer Compose-based frontend.
Changes:
- Add
ScreenOrientationenum + typed get/save APIs and a dedicatedscreenOrientationFlow()inPrefsRepository. - Apply the preference in Compose via
ScreenOrientationEffect(with restoration on dispose) and expose it fromFrontendViewModel. - Update legacy
WebViewActivity+ settings presenter integration, and add unit/UI tests for the new behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| common/src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepository.kt | Introduces ScreenOrientation enum and typed preference APIs/flow |
| common/src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt | Implements typed read/write + screenOrientationFlow() |
| common/src/test/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImplTest.kt | Adds unit tests for typed orientation read/write and flow emissions |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt | Exposes screenOrientation as a StateFlow sourced from prefs |
| app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt | Applies orientation to the hosting Activity via a composable effect |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt | Tests that screenOrientation StateFlow reflects pref flow updates |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenTest.kt | UI tests verifying orientation application + restoration on dispose |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenter.kt | Updates presenter API to return typed ScreenOrientation |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt | Adapts presenter implementation to typed API |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt | Simplifies requestedOrientation mapping using ScreenOrientation.activityInfo |
| app/src/main/kotlin/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt | Bridges PreferenceDataStore string values to typed enum and back |
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 the fixed screen orientation to the FrontendScreen, exposes the settings with an enum and adjust the old code to use the new enum from the preference.
Checklist
Any other notes
I know the string are in xml still but I prefer to duplicate it in one place and avoid using string everywhere and favor strong types. I suspect that we might drop the preference settings at some point in favor of something custom that would drop the duplication and only rely on the enum.