Bug P2
Status Update
Comments
he...@ataulm.com <he...@ataulm.com> #2
Same issue on 1.1.0. The ID and clickable for the chip changes, but the button uses the same resource (the colors for the button does change). In my case here (two code paths for different buttons) the icon does not update:
private fun tileLayout(
deviceParameters: DeviceParametersBuilders.DeviceParameters
): LayoutElement {
return PrimaryLayout.Builder(deviceParameters)
.setContent(
if (isOn) {
Button.Builder(this, ModifiersBuilders.Clickable.Builder().build())
.setIconContent(ICON_ID_ON)
.setButtonColors(ButtonColors.secondaryButtonColors(buttonColors))
.build()
} else {
Button.Builder(this, ModifiersBuilders.Clickable.Builder().build())
.setIconContent(ICON_ID_OFF)
.setButtonColors(ButtonColors.secondaryButtonColors(otherColors))
.build()
}
)
.setPrimaryChipContent(
CompactChip.Builder(
/* context = */ this,
/* text = */ if (isOn) "turn off" else "turn on",
/* clickable = */ ModifiersBuilders.Clickable.Builder()
.setId(if (isOn) "action_off" else "action_on")
.setOnClick(ActionBuilders.LoadAction.Builder().build())
.build(),
/* deviceParameters = */ deviceParameters
)
.setChipColors(ChipColors.primaryChipColors(MessagingTileTheme.colors))
.build()
)
.build()
}
resources (they are different XML icons):
override suspend fun resourcesRequest(
requestParams: RequestBuilders.ResourcesRequest
): ResourceBuilders.Resources {
return ResourceBuilders.Resources.Builder()
.setVersion(RESOURCES_VERSION)
.addIdToImageMapping(
ICON_ID_ON,
drawableResToImageResource(R.drawable.baseline_cloud_24)
)
.addIdToImageMapping(
ICON_ID_OFF,
drawableResToImageResource(R.drawable.baseline_cloud_off_24)
)
.build()
}
Description
Using:
androidx.wear.tiles:tiles:1.2.0-alpha07
androidx.wear.protolayout:protolayout-material:1.0.0-alpha11
Having my tile which is a single button whose icon depends on a condition. Clicking on the button flips the condition, and refreshes the layout, and therefore the icon.
Expected: the icon should be reflected on the tile
Actual: it's not.
If, in addition to changing the icon, I also change the size of the button, or its color, then it works as expected.
Here are repro steps:
git clone git@github.com:BoD/pillz.git
cd pillz
git checkout 8bc6817c79fac29fbbc651e14266077e9309ea24
MainTileService.kt
file, and uncomment the block that says "Uncomment that part... now it works"