Hello, Quick question about using Compose in Andro...
# compose
p
Hello, Quick question about using Compose in Android apps with their own theming options which result in calls like > AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) Compose's
isSystemInDarkTheme
should return • the status of the device theme set in device settings or • the status of the app theme (set through
AppCompatDelegate.setDefaultNightMode...
) ? I see the latter, which I would expect (Compose cares about rendering in the app and the app has a different theme so that should be used instead of the system's) but the method name is a bit confusing then. Maybe Android being able to set it's own theme through
AppCompatDelegate.setDefaultNightMode(..)
is an edgecase which is not accounted in that method's naming?
s
Yeah perhaps the name is a bit misleading in this sense, but it returns what your app should render in, which should respect if the user has made an explicit choice in your app, and you have changed the theme using
AppCompatDelegate.setDefaultNightMode
. Do you want to be able to get the system's theme decision even if the user has made another decision in the app itself for some reason?
p
Thanks, I know on Android we can use
UiModeManager
to get the actual system theme. Wanted to confirm that that methods does what it should (return app's theme not the system one's) and then maybe propose to have it's name/documentation updated.
s
Funny you mention
UiModeManager
, I do realize that when we get a theme selection from the user, we do explicitly give that information to UiModeManager too https://github.com/HedvigInsurance/android/blob/e8a5047f022b70022ea0f08d9708a5977f[…]/app/app/src/main/kotlin/com/hedvig/android/app/MainActivity.kt but I don't quite remember 100% why I made this change. I think something regarding the theme being right on app startup while the splash screen was showing still before we get a chance to evaluate anything else. But in any case, setting
AppCompatDelegate.setDefaultNightMode
did not automatically also set it for
UiModeManager
👍 1
p
(Didn't know about the
UIModeManager
trick to get the right background for the splashscreen, is it okay if I borrow it?)
s
Oh feel absolutely free to do so, I wouldn't be sharing things if I wanted people not to copy them 😅 Just make sure it does what you want it to for you as well. It really is a bit blurry regarding what exact problem I was solving there. It may have something to do with the fact that our splash screen also goes black/white depending on the theme, and the status bar icons were wrong when we were doing it, or some flashing of the colors or something something, I really do not remember 😅
🙇 1