Status Update
Comments
pb...@google.com <pb...@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
va...@gmail.com <va...@gmail.com> #3
za...@google.com <za...@google.com> #4
Zoe to investigate string resources or lint checks.
is...@google.com <is...@google.com>
ia...@google.com <ia...@google.com> #5
I think this should be higher than a P3. Right now every developer has three options:
- Try using stringResource because that's what they're used to from Jetpack Compose and it's even suggested by the tooling (
) -- this gives them a crash; newer Compose users won't find the stacktrace helpful since CompositionLocals are mostly hidden, meaning they may spend time trying to fix their configuration thinking it's a setup issueb/269961566 - Hardcode every string -- This is a terrible practice but what all the documentation is currently showing (e.g.,
https://developer.android.com/develop/ui/compose/glance/create-app-widget ) - Use the local context -- Non-obvious solution that doesn't trigger recomposition
A quick workaround for devs would be to create their own placeholder function like
@Composable
@ReadOnlyComposable
fun stringResource(@StringRes id: Int): String {
return LocalContext.current.getString(id)
}
But Glance doesn't appear to handle recomposing the widget if the system language is changed, so there should be a solution in Glance and there should be lint checks since most developers are going to assume they should use stringResource() from compose.ui.
za...@google.com <za...@google.com> #6
The concern with adding stringResource to Glance has been around not polluting the namespace for Compose UI developers.
We don't want it to be the case that adding the Glance library to a Compose UI app starts making the Glance specific stringResource be suggested when writing Compose UI code, as this would get tricky quite quickly.
We've also tried to avoid prefixing Glance functions with 'glance' because it becomes cumbersome, but in this case maybe it makes sense to have glanceStringResource()
, worth investigating whether type inference helps us here.
ia...@google.com <ia...@google.com> #7
It might be worth exploring options that would help the tooling side then. For example, if we recommend all widgets go into a widget module that Android Studio understands, maybe it can be smart about pulling in the right imports. Alternatively, maybe a Glance-specific annotation would give AS enough context. Or maybe AS has enough knowledge already by looking up the composable tree to see if the root is ultimately from Glance or not.
The concern about polluting the namespace goes beyond stringResource
because of other common composables like Text
, so it'd be great if we can solve this more holistically.
b9...@gmail.com <b9...@gmail.com> #8
Does it means that Glance currently still couldn't update ui when system language is changed?
va...@gmail.com <va...@gmail.com> #9
+1 to #8.
stringResource()
composable automatically triggers recomposition on locale change. However, this isn't the case with LocalContext.current.getString()
Description
Component used: glance & glance-appwidget
Version used: 1.0.0-alpha01
Devices/Android versions reproduced on: Pixel 2 XL
Trying to use stringResource fails with "CompositionLocal LocalConfiguration not present", please support stringResource composable in jetpack glance.