K Merle
05/02/2024, 9:32 AMK Merle
05/02/2024, 10:01 AMMainActivity : AppCompatActivity()
breaks theme change while this doesnt
MainActivity : ComponentActivity()
Alex Styl
05/02/2024, 10:26 AMK Merle
05/02/2024, 10:27 AMAppCompatActivity
doesn't change theme on configuration change, i.e. if you started of with light
theme, changing in setting does not reflect change in app. Using ComponentActivity
does work. Seems like explicitly setting it up does the job:
private fun setSystemTheme() {
val uiModeManager = getSystemService(AppCompatActivity.UI_MODE_SERVICE) as UiModeManager
val isDarkTheme = uiModeManager.nightMode == UiModeManager.MODE_NIGHT_YES
AppCompatDelegate.setDefaultNightMode(
if (isDarkTheme) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO
)
}
K Merle
05/02/2024, 10:28 AMAppCompatActivity
cause of localization library we're using called Phrase.Alex Styl
05/02/2024, 10:31 AMComponentActivity()
is what the Android team recommends using with compose, so i would either open an issue at the library to change their code, or check the source of how ComponentActivity handles this.
You will get better help at #compose-androidyoussef
05/08/2024, 4:51 PMCompositionLocalProvider(
LocalAppDimens provides dims,
LocalOrientationMode provides orient,
LocalQrColorScheme provides remember {colorScheme} ,
while changing the theme it wont work