Widget text doesn't respond to system night mode
TwSphinx54 opened this issue ยท 5 comments
When the system is set to 'follow the system', font color in the widget won't change automatically. So there will be black characters above dark background when the system automatically changes to dark mode.
Only click the widget manually can refresh the font and icon color in the widget.
Thanks very much for your work. :)
Hello :) Unfortunately, this is a known bug with the Android widget API - it just doesn't work as nicely on some launchers. Could you please tell me your Android version, device and launcher? Thanks for the issue!
- Android 11
- Samsung Galaxy A70s
- Microsoft Luncher
Thank you for the explanation. That gives me a new reason to buy a phone with higher android version.
Haha, any reason is good enough when you want to buy a new phone ๐ Thank you for the details, I'll check it out when I get the chance.
This can be recreated on any Android 11 device with the following steps:
- Put Widget on home screen
- Kill the app (swipe it from recents)
- Change system theme
Expected:
- Widget background, text and weather icons update to new colors
Actual:
- Widget background updates, but the text and icons don't
The issue seems to be that R.drawable.widget_bg
applies the correct background color because it's present in drawable
and drawable-night
, but the Glance widget does not update itself with the correct text and icon colors. To fix this, I tried:
- Creating a custom Bitmap and setting it as the widget background with
ImageProvider(customBitmap)
. The reasoning was that if Glance does not update the text and icon colors, this would prevent it from updating the background as well, which would just ignore the device theme change. This did not work because a Bitmap needs a width and height to be drawn. I tried usingLocalSize
, but this is not the actual size of the widget, so the Bitmap ends up with stretched corners as it tries to fill the entire widget background. - Creating a
widget_text_color
value invalues/colors.xml
andvalues-night/colors.xml
and using it if SDK < 31. The reasoning was if it pulls the background resource correctly, it should pull the color resource too. It didn't work, and I don't know why. Probably a bug or oversight in the library. - Creating a
ColorProvider(day = Color.Black, night = Color.White)
and using it as text color if SDK < 31. This did not work, but it's not much different from the original implementation, so it somewhat makes sense.
I'll revisit this when they push a new version of the Glance Widget library. If they don't drop support for it altogether, since it was last updated Oct 2022 ๐