Skip to content

Introduce screen orientation feature to FrontendScreen#6869

Open
TimoPtr wants to merge 1 commit into
mainfrom
feature/screen_orientation
Open

Introduce screen orientation feature to FrontendScreen#6869
TimoPtr wants to merge 1 commit into
mainfrom
feature/screen_orientation

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented May 20, 2026

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

  • 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.

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.

Copilot AI review requested due to automatic review settings May 20, 2026 08:20
@TimoPtr TimoPtr requested a review from jpelgrom May 20, 2026 08:20
@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 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 ScreenOrientation enum + typed get/save APIs and a dedicated screenOrientationFlow() in PrefsRepository.
  • Apply the preference in Compose via ScreenOrientationEffect (with restoration on dispose) and expose it from FrontendViewModel.
  • 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

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