Assigned
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
ji...@motemote.kr <ji...@motemote.kr> #3
za...@google.com <za...@google.com> #4
Are you doing work in the code that generates the composables for the list that could be blocking it?
It will be very hard to diagnose an issue here without more information.
ji...@motemote.kr <ji...@motemote.kr> #5
class AppWidgetTodo : GlanceAppWidget() {
override val sizeMode: SizeMode = SizeMode.Responsive(
setOf(
DpSize(250.dp, 100.dp),
DpSize(300.dp, 100.dp),
DpSize(300.dp, 250.dp),
)
)
override suspend fun provideGlance(context: Context, id: GlanceId) {
provideContent {
Content()
}
}
@Composable
fun Content() {
GlanceTheme {
Column(
modifier = GlanceModifier
.fillMaxSize()
.padding(16.dp)
.appWidgetBackground()
.background(GlanceTheme.colors.background)
) {
Text(
text = LocalContext.current.getString(R.string.app_widget_todo_title),
modifier = GlanceModifier
.fillMaxWidth()
.padding(8.dp),
style = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 18.sp,
),
)
CountChecked()
LazyColumn {
items(groceryStringIds) { id ->
CheckBoxItem(id)
}
}
}
}
}
}
@Composable
private fun CheckBoxItem(id: Int) {
val prefs = currentState<Preferences>()
val checked = prefs[booleanPreferencesKey(id.toString())] ?: false
CheckBox(
text = LocalContext.current.getString(id),
checked = checked,
onCheckedChange = actionRunCallback<CheckboxClickAction>(
actionParametersOf(
toggledStringIdKey to id.toString(),
),
),
modifier = GlanceModifier.padding(12.dp),
)
}
@Composable
private fun CountChecked() {
val prefs = currentState<Preferences>()
val checkedCount = groceryStringIds.filter {
prefs[booleanPreferencesKey(it.toString())] ?: false
}.size
Text(
text = "$checkedCount checkboxes checked",
modifier = GlanceModifier.padding(start = 8.dp),
)
}
private val toggledStringIdKey = ActionParameters.Key<String>("ToggledStringIdKey")
private val groceryStringIds = listOf(
R.string.grocery_list_milk,
R.string.grocery_list_eggs,
R.string.grocery_list_tomatoes,
R.string.grocery_list_bacon,
R.string.grocery_list_butter,
R.string.grocery_list_cheese,
R.string.grocery_list_potatoes,
R.string.grocery_list_broccoli,
R.string.grocery_list_salmon,
R.string.grocery_list_yogurt,
)
class CheckboxClickAction : ActionCallback {
override suspend fun onAction(
context: Context,
glanceId: GlanceId,
parameters: ActionParameters,
) {
val toggledStringId = requireNotNull(parameters[toggledStringIdKey]) {
"Add $toggledStringIdKey parameter in the ActionParameters."
}
// The checked state of the clicked checkbox can be added implicitly to the parameters and
// can be retrieved by using the ToggleableStateKey
val checked = requireNotNull(parameters[ToggleableStateKey]) {
"This action should only be called in response to toggleable events"
}
updateAppWidgetState(context, glanceId) { state ->
state[booleanPreferencesKey(toggledStringId)] = checked
}
AppWidgetTodo().update(context, glanceId)
}
}
class AppWidgetTodoReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget = AppWidgetTodo()
}
here is sample code!
I tested galaxy note 10 + 5g, android S(12.0)
ji...@motemote.kr <ji...@motemote.kr> #6
Android api 33, everything was fine!
ji...@motemote.kr <ji...@motemote.kr> #7
when ACTION_TRIGGER_LAMBDA action received
notifyAppWidgetViewDataChanged fired every viewId
notifyAppWidgetViewDataChanged fired every viewId
Description
Version used: 1.0.0
Devices/Android versions reproduced on:
pixel 6 api 24 (adb)
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).
LazyColumn shows "loading..." view glanceContent updated
resize and updateWidget etc