Ahaisting
12/08/2022, 2:23 PMLocalConfiguration.current
like resources()
does (https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/Resources.android.kt;l=31-34?q=Resources.android) and I have configChanges
added to manifest.
@Composable
fun LocalDateTime.localized(): String {
LocalConfiguration.current // was hoping this would recompose when it changes, like resources() call
LocalContext.current // same here
val pattern = if (DateFormat.is24HourFormat(LocalContext.current)) {
"H:mm"
} else {
"h:mm a"
}
// format the date:
anyone have any ideas?Albert Chang
12/08/2022, 3:58 PMAlbert Chang
12/08/2022, 3:59 PMAhaisting
12/08/2022, 5:06 PMThe time format is a system setting, not a part of configuration.How did you know this? Is there somewhere in source I can look this up?
Alex Vanyo
12/08/2022, 7:26 PMDateFormat
it looks like it depends on the system setting, and the locale as a fallback.
I think another option here is listening for the ACTION_TIME_CHANGED broadcast as a signal for when this might changeAhaisting
12/08/2022, 7:37 PMSettings.System.getStringForUser
wasn’t something that was part of Configuration
I just confirmed that when I change the locale of the device (for example from English (United States), which uses 12 hour format, to Español (España), which uses 24 hour format) recomposition is triggered, because LocalConfiguration.current
changes. Changing just the setting for “use 24 hour format” doesn’t cause config to change, so no recomposition 👍