-
-
Notifications
You must be signed in to change notification settings - Fork 759
Migrate WebViews activities to Jetpack Compose #5419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt
Fixed
Show fixed
Hide fixed
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt
Fixed
Show fixed
Hide fixed
factory = { context -> | ||
(factory() ?: WebView(context)).apply { | ||
// We want the modifier to determine the size so the WebView should match the parent | ||
this.layoutParams = FrameLayout.LayoutParams( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today, I discovered that this this.layoutParams = [...]
with match parent causes Webview to set correct CSS env(safe-area-insets-*)
values. I tested it on webview 137, on 119 it is not working.
But I am not sure if it really matters because it's not very stable or/and documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the debug build and did not see any issues on my end
Apologize but 1 minor difference I need to call out after testing a different PR, very minor. When you initially onboard and select your server this PR pushes down the login page. again not a big deal as user can login and the dashboard is not impacted by this but still a difference I saw :) |
I think that actually I fixed it. Could you try on Chrome? It's because now I'm fixing the FrameLayout to fill the parents where because it was a wrap content. |
in chrome on the same device it actually matches the changes in this PR 🙈 never noticed because I always use the app haha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on a modern real device and old emulator and seems to work OK. Code looks mostly good to.
Haze's blur seems a lot stronger/blurrier than the other library. On my dashboard I have a sensor card and with the old library I can see some yellow when blurred, but definitely not with the new one. Not an issue for me, just noting it.
There is a merge conflict.
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/webview/HAWebView.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt
Outdated
Show resolved
Hide resolved
LeakCanary is also giving me this, which I think is new from this PRs code but it's very generic. Trace
|
I will use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blur change hasn't made a noticeable difference, but it's OK.
Summary
The application have multiple activities that uses WebViews. This PR migrate all the screens from XML views to Jetpack Compose. The end goal is for easier management of edge to edge so that this PR #5387 can be merged.
A first initiative was made #5346 and followed by #5390. On the latter we suggested to migrate to Compose to apply the same logic everywhere instead of dealing with XML and Compose.
The main challenge on this PR was on
WebViewActivity
that is quite complex. The MediaPlayer is displayed at a specific place on the screen given by the frontend through the external bus. It also has some bluring to hide the content of the WebView when the app is locked.For the Bluring I've introduce the Haze library. For the player I've used the
HAMediaPlayer
made in #5408Checklist
Screenshots
We cannot make a screenshot of the app in lock state because of biometric bottom is marked as
SECURE
.WebViewMedia.mp4
Any other notes
I tried to limit as maximum the changes on the
WebViewActivity
to make the review easy, but to be honest it was hard a lot of things could be improved.When adding
haze-materials
to the project it did brings material3 in our app and a new lint rule that verify that we are not mixing material 2 and 3, I've disabled it for now since it's too verbose and created an issue #5420