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

Stylianos Gakis

10/12/2023, 12:32 PM
WindowInsets + config changes question here. I am experiencing the behavior shown in this video when changing from light to dark mode
👀 1
I’ve made sure to try with
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode|grammaticalGender"
And with
android:configChanges=""
I did add
WindowCompat.setDecorFitsSystemWindows(window, false)
And using Material3
NavigationBar
which by default uses
WindowInsets.systemBarsForVisualComponents.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
for the inset there.
Filed this https://issuetracker.google.com/issues/304883136 just to see if I get a response there if I am doing something wrong there.
a

ascii

10/12/2023, 2:20 PM
How are you changing night mode without the QS toggle? ADB? Or you're toggling the theme automatically in code?
s

Stylianos Gakis

10/12/2023, 2:22 PM
ADB indeed. I did it this way here to make the video easier to see. But I get the exact same experience when toggling it the normal way, through the quick actions you get when dragging from the top (I really don’t remember the name now)
a

ascii

10/12/2023, 2:26 PM
Tried it myself, doesn't happen to me. I've got NavBar, all
configChanges
, and decor fits via
ComponentActivity.enableEdgeToEdge
. Nothing else I think.
s

Stylianos Gakis

10/12/2023, 2:28 PM
Are you also using
adjustResize
?
ComponentActivity.enableEdgeToEdge would be the next thing I wanted to try, but I thought it'd do the same thing as seDecorFitsSystemWindows but I could be wrong. Also that one is on a beta dependency atm. Do you see the same good behavior with seDecorFitsSystemWindows?
a

ascii

10/12/2023, 2:30 PM
No I'm not overriding
windowSoftInputMode
at all
s

Stylianos Gakis

10/12/2023, 2:31 PM
Right, but
windowSoftInputMode
really is needed to get proper backwards compatible experience to older Android OS versions. If you don’t mind, could you also test with it being
adjustResize
?
a

ascii

10/12/2023, 2:32 PM
Do you see the same good behavior with setDecorFitsSystemWindows?
Yes
s

Stylianos Gakis

10/12/2023, 2:33 PM
Thanks a lot for checking that out too! Prior discussion regarding adjustResize btw https://kotlinlang.slack.com/archives/CJLTWPH7S/p1678478920064349?thread_ts=1678303192.301849&cid=CJLTWPH7S
👀 1
a

ascii

10/12/2023, 2:33 PM
could you also test with it being
adjustResize
?
Still good haha
Maybe it's an XML theme thing more than Compose or anything else
s

Stylianos Gakis

10/12/2023, 2:40 PM
Wow okay what else could I be doing wrong then. This is a new sample project, pure compose, I don’t think I have anything defined in XML theme that would interfere with this
a

ascii

10/12/2023, 2:40 PM
I use
Theme.AppCompat.DayNight.NoActionBar
with this:
s

Stylianos Gakis

10/12/2023, 2:41 PM
Aha, well I don’t know what the last 5 things do here 😅
a

ascii

10/12/2023, 2:41 PM
Should not be relevant here but just for completeness
windowDrawsSystemBarBackgrounds
might be though
s

Stylianos Gakis

10/12/2023, 2:45 PM
Don’t see why why I’d need to add this here though to be honest, that should just be regarding how the system bars are styled, not how insets are handled. And in general, in a compose only world +
enableEdgeToEdge
I thought should be able to handle everything regarding insets here 🤔
a

Alex Vanyo

10/12/2023, 5:34 PM
This is a platform/launcher level issue. Changing dark mode in the system triggers a recreation of the navigation bar (the actual system UI component), which momentarily results in no navigation bar. It looks like your app is dutifully handling the intermediate zero insets and resizing though, which is good 😄
s

Stylianos Gakis

10/12/2023, 5:38 PM
Suffering from success. Handling the insets too well 😂
💯 1
Alright, sounds like not something I can handle then. I suppose it's not something users will experience too often though, so I should just let it be if I want to be a bit pragmatic here 🤷‍♂️
a

Alex Vanyo

10/12/2023, 5:42 PM
Yep nothing you can do from the app side, thank you for striving for perfection
s

Stylianos Gakis

10/12/2023, 5:43 PM
The insets obsession all started after watching this

https://youtu.be/rorofoIpo1A?si=k-3R6DydQERrI58g

It's all your fault 😂
😆 1
a

Alex Vanyo

10/12/2023, 5:52 PM
I’m not going to apologize 😄
😂 1
If you want to go deeper into the rabbit hole, the logic for the system UI for the taskbar being recreated is somewhere around here: https://cs.android.com/android/platform/superproject/main/+/main:packages/apps/Launc[…]nager.java;l=194;drc=64b79a9fad069fe9e1553bbdeee544bd23cf7f2c
thank you color 1
3 Views