android icon indicating copy to clipboard operation
android copied to clipboard

Edge to edge support for webviews using <View> bars

Open Gregman-js opened this issue 8 months ago • 2 comments

Summary

  • Enable enableEdgeToEdge() for all
  • Changing active server supported (tested by changing server in settings)
  • Add <View> on top and bottom of <Webview>
  • Control above views height with InsetsUtil.kt
if (!serverHandleInsets) {
    statusBarBackground?.updateLayoutParams {
        height = safeInsets.top
    }
    navigationBarBackground?.updateLayoutParams {
        height = safeInsets.bottom
    }
} else {
// evaluateJavascript...
}
  • Support new and old status bar apis Android >= 15 will use Views background color Android < 15 will use Views background colors and statusBarColor on top
if (statusBarColor != 0 && !serverHandleInsets) {
    window.statusBarColor = statusBarColor
    binding.statusBarBackground.setBackgroundColor(statusBarColor)
} else {
    Timber.e("Skipping coloring status bar...")
}
if (navigationBarColor != 0 && !serverHandleInsets) {
    window.navigationBarColor = navigationBarColor
    binding.navigationBarBackground.setBackgroundColor(navigationBarColor)
} else {
    Timber.e("Skipping coloring navigation bar...")
}

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.

Screenshots

Link to pull request in documentation repositories

User Documentation: home-assistant/companion.home-assistant#

Developer Documentation: home-assistant/developers.home-assistant#

Any other notes

Gregman-js avatar Jun 04 '25 12:06 Gregman-js

@Gregman-js I'm working on migrating the webViews to compose so that we can handle this into one place.

TimoPtr avatar Jun 10 '25 07:06 TimoPtr

@Gregman-js here is the PR https://github.com/home-assistant/android/pull/5419 for the migration to Compose. It will be easier to apply your fix in compose and it will work for the other screens too.

You are more than welcome to review the PR :)

TimoPtr avatar Jun 17 '25 12:06 TimoPtr

@Gregman-js The PR about compose has been merged. Could you impl your proposal in compose only and apply it to the two places that uses a WebView. FYI we can't get the version of a server without being fully authenticated so in the onboarding we cannot assume that the frontend support edge to edge yet.

TimoPtr avatar Jun 24 '25 12:06 TimoPtr

It seems that in some case we have the capability to get the version of the server through mDNS https://github.com/home-assistant/android/blob/d3408300ddf984fb8363bd148142a7767d7eb146/app/src/main/kotlin/io/homeassistant/companion/android/onboarding/discovery/HomeAssistantSearcher.kt#L100

Then it won't work for ppl that set the address manually. But it would cover most of the case which is nice.

It's important because sometimes the users are making the setup of their home assistant instances directly on their phone so we want to make sure that edge to edge is properly handled to not hide anything.

TimoPtr avatar Jun 25 '25 14:06 TimoPtr

I did the inital version in compose here https://github.com/home-assistant/android/pull/5507 it adds the bar with the right color. I'll make a second PR with the needed changes to react to a frontend that is compatible. @Gregman-js if you want to take a look.

TimoPtr avatar Jul 08 '25 08:07 TimoPtr

Closing this PR since now we are using compose 👍🏻

TimoPtr avatar Aug 14 '25 16:08 TimoPtr