android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
16.61k stars 3.01k forks source link

Refactor chrome tab toolbar dark mode on/off #1499

Open yongsuk44 opened 3 months ago

yongsuk44 commented 3 months ago

Modified to change the Chrome toolbar color according to the system scheme during dark mode transitions. Although specific colors can be applied using setColorSchemeParams, using the default values should be sufficient.

https://github.com/android/nowinandroid/assets/38935359/042b8863-f0ca-45f3-bbaf-7f26ad42ef87

After.webm

Jaehwa-Noh commented 3 months ago

There's no way to change dark mode for content? Your demo seems to change just status and action bar.

yongsuk44 commented 3 months ago

There's no way to change dark mode for content? Your demo seems to change just status and action bar.

@Jaehwa-Noh It will change on web pages that support dark mode. :)

https://github.com/android/nowinandroid/assets/38935359/2fa722ff-48ca-4163-9c92-192e79b923ef

Ibodwe commented 3 months ago

If I use this method, wouldn't there be inconsistencies when the app selects a light or dark theme instead of the system theme?

yongsuk44 commented 3 months ago

@Ibodwe If it is a WebView that needs to interact with the app, it should indeed change according to the app theme as you mentioned. However, since it is a WebView solely for web pages, it has been implemented as it is now.

dturner commented 3 months ago

This is an interesting idea, however, the original code served a purpose: it sets the chrome custom tab toolbar color to the app's background color. It's a way of passing the app's branding to the webview. It shouldn't be removed. Ideally what should happen when day/night mode changes is the custom tab toolbar color should change to whatever the background color of the app is, however, I don't think that's possible.

I will leave this open just in case it is.