Skip to content

Add support for custom view in FrontendScreen#6790

Merged
TimoPtr merged 2 commits intomainfrom
feature/custom_view
May 6, 2026
Merged

Add support for custom view in FrontendScreen#6790
TimoPtr merged 2 commits intomainfrom
feature/custom_view

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 30, 2026

Summary

Add support for custom view coming from the WebView into the FrontendScreen. It is built on top of the ExoPlayer support PR #6771.

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.

@TimoPtr TimoPtr requested a review from jpelgrom April 30, 2026 10:28
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label Apr 30, 2026
@TimoPtr TimoPtr requested a review from Copilot April 30, 2026 12:34
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 adds support for rendering a WebView-provided “custom view” (typically fullscreen HTML5 video) inside the Compose-based FrontendScreen, building on the earlier ExoPlayer overlay work.

Changes:

  • Extend HAWebChromeClient with onShowCustomView/onHideCustomView callbacks
  • Add customView to FrontendViewState.Content and propagate it from FrontendViewModel
  • Render the custom view as a fullscreen Compose overlay in FrontendScreen, with unit/UI/screenshot test coverage

Reviewed changes

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/src/main/kotlin/io/homeassistant/companion/android/util/HAWebChromeClient.kt Adds custom view show/hide callbacks to WebChromeClient wrapper
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewState.kt Adds customView: View? to FrontendViewState.Content
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt Wires WebChromeClient callbacks to state updates + fullscreen events
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Displays a fullscreen overlay for customView and adds a test tag
app/src/test/kotlin/io/homeassistant/companion/android/util/HAWebChromeClientTest.kt Unit tests for forwarding show/hide custom view callbacks
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt Unit tests for ViewModel state changes + fullscreen events on custom view
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenTest.kt Compose UI tests asserting the overlay is shown/hidden based on state
app/src/screenshotTest/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest.kt Adds screenshot test coverage for the custom view overlay
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_tablet_landscape_62cae397_0.png Screenshot baseline for tablet landscape
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_tablet_2f22c4ea_0.png Screenshot baseline for tablet
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_small_phone_66e7bbf2_0.png Screenshot baseline for small phone
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_phone_landscape_9e00b29d_0.png Screenshot baseline for phone landscape
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_phone_e05166be_0.png Screenshot baseline for phone
app/src/screenshotTestFullDebug/reference/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest/FrontendScreen Content state with custom view overlay_foldable_c908f502_0.png Screenshot baseline for foldable

Comment thread app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Outdated
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 adds support for WebView “custom views” (typically fullscreen HTML5 video views provided via WebChromeClient.onShowCustomView) to the Compose-based FrontendScreen, building on the earlier FrontendScreen ExoPlayer overlay work.

Changes:

  • Extend HAWebChromeClient with onShowCustomView / onHideCustomView callbacks and add unit tests for them
  • Add a customView overlay to FrontendScreenContent using AndroidView, with Compose UI tests + screenshot test coverage
  • Refactor FrontendViewModel to provide a createWebChromeClient(...) factory so the custom view can stay UI-scoped (avoiding ViewModel leaks) while still emitting fullscreen events

Reviewed changes

Copilot reviewed 7 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
app/src/main/kotlin/io/homeassistant/companion/android/util/HAWebChromeClient.kt Adds forwarding for WebView custom view show/hide callbacks
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt Introduces createWebChromeClient(...) to wire fullscreen + permission/JS confirm handling without storing Views in VM state
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Adds UI-scoped customView state and renders it as a fullscreen overlay via AndroidView
app/src/test/kotlin/io/homeassistant/companion/android/util/HAWebChromeClientTest.kt Adds unit tests for custom view callbacks
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt Adds tests ensuring custom view callbacks + fullscreen events are emitted via the factory client
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenTest.kt Adds Compose UI tests verifying the overlay appears/doesn’t appear based on customView
app/src/screenshotTest/kotlin/io/homeassistant/companion/android/frontend/FrontendScreenScreenshotTest.kt Adds screenshot coverage for the custom view overlay
app/src/screenshotTestFullDebug/reference/...png Adds reference images for the new screenshot test

@TimoPtr TimoPtr force-pushed the feature/custom_view branch from 383f8e1 to 560a6f8 Compare May 4, 2026 07:10
@TimoPtr TimoPtr force-pushed the feature/exoplayer branch 2 times, most recently from 636dd8d to fc46f0d Compare May 4, 2026 09:38
@TimoPtr TimoPtr force-pushed the feature/custom_view branch from 560a6f8 to 86d11f1 Compare May 4, 2026 09:38
Base automatically changed from feature/exoplayer to main May 5, 2026 20:29
TimoPtr added 2 commits May 6, 2026 08:57
Instanciate the HAWebChromeClient from Compose to get the custom view
@TimoPtr TimoPtr force-pushed the feature/custom_view branch from 7dff587 to a4fa47f Compare May 6, 2026 06:59
@TimoPtr TimoPtr enabled auto-merge (squash) May 6, 2026 06:59
@TimoPtr TimoPtr merged commit ae8c3f8 into main May 6, 2026
24 checks passed
@TimoPtr TimoPtr deleted the feature/custom_view branch May 6, 2026 07:33
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.

3 participants