Android: Color status bar according to hass theme

Created on 13 Nov 2019  路  14Comments  路  Source: home-assistant/android

Android Status Bar color is defaulting to the colorPrimaryDark of the app theme. Looks like this is "hassio blue" which makes it ugly (see image).

  • Set android "colorPrimaryDark" to the corresponding color in the hassio theme (i think the top bar in hassio is colored by hassio theme "text-color"?

hassio

enhancement

Most helpful comment

@dshokouhi Yep, the device I test with (Nexus 6) it works great.... but it's a couple versions behind, My Pixel 2 doesn't work. I normally don't test on it because I would need to uninstall the firebase version. I'm going to do 2 things, make it so a debug build can be installed beside a "production" build and fix the themeing on newer devices.

All 14 comments

I have that problem too

So an initial implementation could look at the HTML source and extract the theme from the <meta name='theme-color'> tag. We could use this JS:

document.querySelector('meta[name=theme-color]').content

This would be a good first approach. This won't work when a user changes the theme though. If we want to add support for that, we should first update the frontend first to notify the app via the external bus https://developers.home-assistant.io/docs/en/frontend_external_bus.html

Opened an issue at the frontend to track reporting the primary color via the external bus. https://github.com/home-assistant/home-assistant-polymer/issues/4220

When implemented in the app, we should cache the primary color value, and update it whenever the frontend gives us a new value.

One quick fix here is to use theme_color which is returned from get_config webhook.

It's not perfect but probably hits 90% use cases.

This is not implemented yet, right?

want to know that too

Just tested build 80 and I force closed the app and reopened and it did not update the status bar. I tried to clear data in the app and log back in, change the theme and then force close the app but it still did not update. Is there a specific theme variable that needs to be set that I am missing?

I noticed when I got to my production instance too, already fixed: https://github.com/home-assistant/home-assistant-android/pull/270

@JBassett latest build (81) does not seem to be working when I force close the app and re-open, are you seeing the same thing?

@dshokouhi Yep, the device I test with (Nexus 6) it works great.... but it's a couple versions behind, My Pixel 2 doesn't work. I normally don't test on it because I would need to uninstall the firebase version. I'm going to do 2 things, make it so a debug build can be installed beside a "production" build and fix the themeing on newer devices.

Hi, is there some progress on this?

After digging in we are doing what we can for now, another story has been opened to set theme of current app instead of overall theme: https://github.com/home-assistant/home-assistant-android/issues/272

However if you call the frontend.set_theme service and close and reopen the app the status bar will match.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simbesh picture simbesh  路  3Comments

acme-szala picture acme-szala  路  3Comments

aleksandrov1995 picture aleksandrov1995  路  4Comments

Hypfer picture Hypfer  路  3Comments

N-Schaef picture N-Schaef  路  5Comments