jkuester / unlauncher

Android minimalistic launcher
https://jkuester.github.io/unlauncher/
MIT License
319 stars 47 forks source link

fix(#131): set proper system UI colors for status and nav bars #145

Closed jkuester closed 1 year ago

jkuester commented 1 year ago

Closes #131

The colors of the Navigation bar at the bottom of the screen have always just been left to the default (dark) system color. This looks fine for the dark themes, but as noted in the issue, it does not look great for the light themes.

@hayribakici set a good initial starting point in this PR, but unfortunately, upon testing I found that modifying the theme resources was not going to work the best across a wide range of Android versions (or at least I could not figure it out).

That PR launched me down the rabbit-hole of trying to understand the right way to do this. I ended up finding layers of different support for various system APIs and functionality all for customizing the look of the status bar at the top and the navigation bar at the bottom.

This PR adds a new SystemUiManager class that encapsulates all this logic and will use the proper functionality for the particular Android version the app is running on.

I have tested on the following Android versions:

jkuester commented 1 year ago

Actually, now that I look at things again, perhaps I can remove some of my code here by combining my solution with @hayribakici's... :thinking: If we just set the bar colors in the theme config we would not have to worry about doing that work in the code. (Though I think we still need to manually set the Dark/Light System UI colors in the code due to Android compatibility issues.) I will give this a shot before merging/closing anything....

jkuester commented 1 year ago

Ah, never-mind. I remembered why setting the colors in the theme XMLs will not work. Basically, before Android 8 you cannot make the Android System UI colors compatible with a light background for the navigation bar. So, if you set a white background (or any other super light color) in the theme, then the background will wash out the System UI buttons and make them hard to see. So, I think for now it is best just to handle all the colors programatically. (Technically could include the new theming colors and overwrite all the theme configuration in a values-26 directory, but it seems cleaner to do it all in the code at this point.)