https://kotlinlang.org logo
#compose
Title
# compose
m

merono

08/28/2020, 4:31 PM
🤔 Did recomposing on
Configuration
changes stop working recently? That’s what it seems like when I use the code snippet below and specify
android:configChanges="uiMode"
in my manifest.
Copy code
MaterialTheme(
    colors = if (isSystemInDarkTheme()) darkColors() else lightColors()
) {
    Box(
        Modifier.size(48.dp),
        backgroundColor = MaterialTheme.colors.onBackground
    )
}
The color of the
Box
doesn’t change when I toggle dark mode on my device (pixel 3), but I feel like it did on an older version of compose. The color does get updated correctly if I kill the app and re-open it. I’m seeing this behavior on
alpha01
and
dev17
, using API 29. I also tried similar things by using
ConfigurationAmbient.current
directly, and saw the same behavior. When debugging the app, I was able to see
AndroidComposeView.onConfigurationChanged
get called with the new
Configuration
though.
l

Louis Pullen-Freilich [G]

08/28/2020, 4:56 PM
This should still work, if you have a project that reproduces this could you file a bug?
👍 1
m

merono

08/28/2020, 5:47 PM
@Louis Pullen-Freilich [G] filed the bug here: https://issuetracker.google.com/issues/166667488
l

Louis Pullen-Freilich [G]

08/28/2020, 6:57 PM
Pretty strange, I tried using a recent snapshot build, and it seems to work - so I guess something must have fixed this since alpha01 release, not sure what. If you use the snapshot build ( add
Copy code
maven { url '<https://androidx.dev/snapshots/builds/6798052/artifacts/ui/repository>' }
inside the
Copy code
allProjects {
    repositories {
block, and then change the version to be:
compose_version = '1.0.0-SNAPSHOT'
) Does this then work correctly for you on your setup?
✔️ 1
m

merono

08/29/2020, 2:38 PM
I just tried using the snapshot build and it worked for me too. Thanks!
So I guess it would be fixed in either alpha02 or alpha03?
l

Louis Pullen-Freilich [G]

08/29/2020, 2:43 PM
Yup looks like it should be fixed in alpha02
👍 1
3 Views