mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-14 09:13:42 +01:00
Capitalize weekday names in the scheduled-message time picker.
This commit is contained in:
@@ -296,7 +296,9 @@ object DateUtils : android.text.format.DateUtils() {
|
||||
} else if (isTomorrow(timestamp)) {
|
||||
context.getString(R.string.DateUtils_tomorrow)
|
||||
} else {
|
||||
localDateTime.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault())
|
||||
val locale = Locale.getDefault()
|
||||
// Many locales (e.g. Dutch, French, Spanish) render weekday names in lowercase, but this is used as a standalone label, so we want it capitalized.
|
||||
localDateTime.dayOfWeek.getDisplayName(TextStyle.FULL, locale).capitalizeFirstChar(locale)
|
||||
}
|
||||
val time = localDateTime.toLocalTime().formatHours(context)
|
||||
return context.getString(R.string.DateUtils_schedule_at, dayModifier, time)
|
||||
@@ -457,6 +459,13 @@ object DateUtils : android.text.format.DateUtils() {
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Uppercases the first character using the rules of the provided [locale]. A no-op for scripts that have no notion of case.
|
||||
*/
|
||||
private fun String.capitalizeFirstChar(locale: Locale): String {
|
||||
return replaceFirstChar { it.titlecase(locale) }
|
||||
}
|
||||
|
||||
private data class TemplateLocale(val template: String, val locale: Locale)
|
||||
|
||||
private data class Is24HourDateEntry(val value: Boolean, val lastUpdated: Long)
|
||||
|
||||
Reference in New Issue
Block a user