Status Update
Comments
za...@google.com <za...@google.com> #2
Hello,
I'm only a little familiar with Power Apps. Is your app a mobile app or a web app?
This link
The primary
If your app does not work on Android mobile devices, you can also consider the
da...@macrofactorapp.com <da...@macrofactorapp.com> #3
da...@macrofactorapp.com <da...@macrofactorapp.com> #4
I guess what I am really wanting to do is build custom themeables similar to the current glance components that are available. Something I could feed a ColorProviders into to and the colors update with the system theme change. Not sure if there are plans to open up that system or if it is even possible!
Also, thanks for all the work that everyone has put into glance so far. I have been reading through the new commits on GitHub and am excited for some of the new features that have been added!
da...@macrofactorapp.com <da...@macrofactorapp.com> #5
Follow up on this:
I am able to to get the automatic color changes when using the Glance restricted API where I can feed in a color resource
/** Returns a [ColorProvider] that resolves to the color resource. This should
* not be used outside of the Glance Libraries due to inconsistencies with regards
* to what process (app vs launcher) colors are resolved in
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun ColorProvider(@ColorRes resId: Int): ColorProvider {
return ResourceColorProvider(resId)
}
This of course is not great outside of testing.
It also does not solve the issue for when I need to create a custom drawable like for my implementation of a determinate circular progress bar.
Any thoughts on if the ColorProvider for color resources will become a non-restricted constructor? Also, interested if there are thoughts about how I could utilize a ColorProvider in my own drawable or hook into the layout resource generation that Glance is doing.
Edit: I also achieved a workaround for my drawable by breaking up the ring progress into a track and a progress drawable. I then write them to a bitmap, add them to two stacked Glance image and use the restricted API color provider to assign my color resource to the image color filter.
za...@google.com <za...@google.com> #6
You are correct that the theme change color switching is made possible by using resource ids for the colors. The launcher updates these on theme change without calling back to the app (we can't do a callback to apps on theme change, as it could result in too many apps all trying to start at the same time)
Do you have a system color token you're trying to use for the progress bar? or is it a runtime resolved color? You do have option of making a ColorProvider that has dark and light theme colors in it that switch at runtime.
If you can give a bit more detail about what you're trying to do I might be able to help.
Description
Component used: Jetpack Glance Version used: 1.1.1 Devices/Android versions reproduced on: Android 14 / Pixel 7 Pro Emulator
Let me preface this with that this is probably not a bug and more of me not understanding the android ecosystem.
Issue: When using GlanceTheme directly in components that take ColorProvider, I get automatic theme updates when system theme changes. When calculating a color at runtime (using color resources) and packing it into a ColorProvider/using it, I do not get automatic theme updates. There also seems to be no broadcast event I could listen to for theme changes to update the widgets. This is not a blocker because we can still update the widgets when a user is using our app, it just creates widgets with weird "in-between" themes.
Desired result: Trigger a rebuild for runtime calculated colors
Background: I am in the process of creating a new set of homescreen widgets using Glance. I am having issues though when I need colors that are calculated at runtime and updating those when the system theme changes.
I have a Color called "accentColor" that I am determining during runtime based on the configuration the user set up.
The first differentiator is "Style"
When option "1" is chosen, I pick the color from GlanceTheme, when option "2" is chosen I use a compat module to put the color from a resource.
I then need to evaluate this color using "getColor" like so: "GlanceTheme.colors.primary.getColor(LocalContext.current)" This is because I need a complimentary color that is a lower opacity.
I then use these colors for tinting images, coloring text, and passing into a custom CircularProgressBarDrawable I created.