Assigned
Status Update
Comments
ch...@google.com <ch...@google.com>
ke...@bandlab.com <ke...@bandlab.com> #2
It happens only on pre-API 33 version, all good on API 33 and above.
Relevant comment:https://issuetracker.google.com/issues/240191036#comment4
Relevant comment:
ja...@gmail.com <ja...@gmail.com> #3
I'll post my minimal reproducible example here as well.
This highlights the issue for me when tested on multiple Android SDK versions
This highlights the issue for me when tested on multiple Android SDK versions
jm...@manager.one <jm...@manager.one> #4
Another "comment" to help
Jetpack Compose version: 1.7.6
Jetpack Compose component used: Noting, bug is from LocalConfiguration.current
Android Studio Build: 2024.2.2
Kotlin version: 2.1.0
If you implement per app language, any change in locale should trigger a configuration change, which will recompose where you use stringResources().
While you don't handle configChanges (with android:configChange in manifest):
- from API 24 to 31 -> activity recreated, nicely, language is updated, strings a translated -> it's ok
- since API 33 (or 32, not tested), idem but activty recreated with poorly effect (back screen flickering).
if you handle configChanges(locale|layoutDirection|screenLayout):
before api 33, nothing will be updated if locale change.
Code Sample to Reproduce:
1. clone official samplehttps://github.com/android/user-interface-samples/tree/main/PerAppLanguages/compose_app
2. launch sample and try to change language in emulator API 31 and API 33 -> all is ok
3. go to manifest and add android:configChanges="locale|layoutDirection|screenLayout" for mainActivity
4. try to change language in sample with emulator API 33 -> all is ok
5. try to change language in sample with emulator API 31 -> Not Working, recomposition is not triggered (LocalConfiguration seem to not be updated)
Dont forget "screenLayout" (not mentioned in documentationhttps://developer.android.com/guide/topics/resources/runtime-changes#example ), else activity will be recreated at the first change of Locale.
Jetpack Compose version: 1.7.6
Jetpack Compose component used: Noting, bug is from LocalConfiguration.current
Android Studio Build: 2024.2.2
Kotlin version: 2.1.0
If you implement per app language, any change in locale should trigger a configuration change, which will recompose where you use stringResources().
While you don't handle configChanges (with android:configChange in manifest):
- from API 24 to 31 -> activity recreated, nicely, language is updated, strings a translated -> it's ok
- since API 33 (or 32, not tested), idem but activty recreated with poorly effect (back screen flickering).
if you handle configChanges(locale|layoutDirection|screenLayout):
before api 33, nothing will be updated if locale change.
Code Sample to Reproduce:
1. clone official sample
2. launch sample and try to change language in emulator API 31 and API 33 -> all is ok
3. go to manifest and add android:configChanges="locale|layoutDirection|screenLayout" for mainActivity
4. try to change language in sample with emulator API 33 -> all is ok
5. try to change language in sample with emulator API 31 -> Not Working, recomposition is not triggered (LocalConfiguration seem to not be updated)
Dont forget "screenLayout" (not mentioned in documentation
Description
Jetpack Compose version: BOM 2023.10.01 , compiler 1.5.6
Jetpack Compose component(s) used: N/A
Android Studio Build: N/A
Kotlin version: 1.9.21
Steps to Reproduce or Code Sample to Reproduce:
"locale"
in the list ofconfigChanges
in the manifestConfigurationCompat.getLocales(LocalConfiguration.current).get(0)
in compositionAppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("languge-tag-here"))
Possible fixes that have worked for me so far, taken after a discussion herehttps://slack-chats.kotlinlang.org/t/16178817/does-anyone-have-a-sample-app-with-runtime-locale-changing-a#47c51048-1e62-4f94-83d2-7bd33ec48ecd
locale
to the list ofconfigChanges
in the manifest, which is optimally not where I'd like to go with a full compose appAppCompatDelegate.setApplicationLocales
does not do this properly. This is done throughas described in the linked kotlinlang slack thread.
Optimally however this should just work out of the box without any of the mentioned workarounds.