fix(#543): capitalise only standalone labels, cover multi-day selection and agenda spans
This commit is contained in:
1 parent
6e2260134a
commit
e3b5f01f7e
12 files changed
+23
-21
No files matched your search
@@ -15,13 +15,13 @@ import de.jeanlucmakiola.calendula.data.prefs.is24Hour
|
||||
import de.jeanlucmakiola.calendula.data.prefs.resolveFirstDay
|
||||
import de.jeanlucmakiola.calendula.domain.reminders.ReminderEventInstance
|
||||
import de.jeanlucmakiola.floret.locale.capitalizeStart
|
||||
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.datetime.isoDayNumber
|
||||
import kotlinx.datetime.toKotlinLocalDate
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
@@ -55,10 +55,7 @@ class DailyDigestNotifier @Inject constructor(
|
||||
val firstDayOfWeek = DayOfWeek.of(settingsPrefs.weekStart.first().resolveFirstDay(locale).isoDayNumber)
|
||||
// The date rides along: the summary stays up into the day it lists,
|
||||
// when "Tomorrow" alone would point at the wrong one.
|
||||
val date = DateTimeFormatter.ofPattern(
|
||||
android.text.format.DateFormat.getBestDateTimePattern(locale, "EEEdMMM"),
|
||||
locale,
|
||||
).format(day)
|
||||
val date = localizedDateFormatter(locale, "EEEdMMM").format(day)
|
||||
val dayLabel = when (day) {
|
||||
today -> context.getString(R.string.digest_day_relative, context.getString(R.string.reminder_day_today), date)
|
||||
today.plusDays(1) ->
|
||||
|
||||
@@ -114,12 +114,12 @@ fun agendaRangeWindowSummary(
|
||||
return when {
|
||||
range == AgendaRange.Day -> dayMonthYear.format(javaStart)
|
||||
range == AgendaRange.ThisMonth && !monthAsSpan ->
|
||||
localizedDateFormatter(locale, "LLLLy").format(javaStart).capitalizeStart(locale)
|
||||
localizedDateFormatter(locale, "LLLLy").format(javaStart)
|
||||
else -> {
|
||||
val startFmt = if (start.year == end.year) dayMonth else dayMonthYear
|
||||
"${startFmt.format(javaStart)} – ${dayMonthYear.format(javaEnd)}"
|
||||
}
|
||||
}
|
||||
}.capitalizeStart(locale)
|
||||
}
|
||||
|
||||
private const val CUSTOM_PREFIX = "CUSTOM:"
|
||||
@@ -90,8 +90,8 @@ private fun formatSelectionWhen(event: EventInstance, use24Hour: Boolean, locale
|
||||
val endsSameDay = end.toLocalDate() == start.toLocalDate() ||
|
||||
(end.toLocalTime().toSecondOfDay() == 0 && end.toLocalDate() == start.toLocalDate().plusDays(1))
|
||||
return if (endsSameDay) {
|
||||
"${day.format(start).capitalizeStart(locale)} · ${time.format(start)}–${time.format(end)}"
|
||||
"${day.format(start)} · ${time.format(start)}–${time.format(end)}"
|
||||
} else {
|
||||
"${day.format(start)}, ${time.format(start)} – ${day.format(end)}, ${time.format(end)}"
|
||||
}
|
||||
}.capitalizeStart(locale)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ internal fun ViewsScreen(
|
||||
)
|
||||
GroupedRow(
|
||||
title = stringResource(R.string.settings_week_start),
|
||||
summary = weekStartLabel(state.weekStart),
|
||||
summary = weekStartLabel(state.weekStart).capitalizeStart(currentLocale()),
|
||||
position = Position.Middle,
|
||||
onClick = { showWeekStart = true },
|
||||
)
|
||||
@@ -517,7 +517,6 @@ internal fun weekStartLabel(pref: WeekStartPref): String = when (pref) {
|
||||
// Localised weekday name, so no per-day string resource is needed.
|
||||
is WeekStartPref.Day -> pref.day.toJavaDayOfWeek()
|
||||
.getDisplayName(JavaTextStyle.FULL, currentLocale())
|
||||
.capitalizeStart(currentLocale())
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -14,6 +14,7 @@ import de.jeanlucmakiola.floret.components.FullScreenPicker
|
||||
import de.jeanlucmakiola.floret.components.GroupedHint
|
||||
import de.jeanlucmakiola.floret.components.OptionRows
|
||||
import de.jeanlucmakiola.floret.components.ViewPreviewFrame
|
||||
import de.jeanlucmakiola.floret.locale.capitalizeStart
|
||||
import de.jeanlucmakiola.floret.locale.currentLocale
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ internal fun WeekStartPicker(
|
||||
OptionRows(
|
||||
options = options,
|
||||
selected = selected,
|
||||
label = { weekStartLabel(it) },
|
||||
label = { weekStartLabel(it).capitalizeStart(currentLocale()) },
|
||||
onSelect = onSelect,
|
||||
summary = { option ->
|
||||
if (option == WeekStartPref.Auto) {
|
||||
|
||||
@@ -70,7 +70,7 @@ internal fun relativeDayLabel(context: Context, date: LocalDate, today: LocalDat
|
||||
val locale = widgetLocale()
|
||||
return relativeDayWord(context, date, today) ?: when {
|
||||
date < today.plus(7, DateTimeUnit.DAY) && date > today ->
|
||||
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, locale).capitalizeStart(locale)
|
||||
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, locale)
|
||||
else -> localizedDateFormatter(locale, "dMMM").format(date.toJavaLocalDate())
|
||||
}
|
||||
}
|
||||
@@ -681,8 +681,10 @@ private fun monthName(date: LocalDate, today: LocalDate): String = formatCalenda
|
||||
skeleton = "LLLL",
|
||||
)
|
||||
|
||||
private fun weekdayShort(date: LocalDate): String =
|
||||
date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, widgetLocale()).capitalizeStart(widgetLocale())
|
||||
private fun weekdayShort(date: LocalDate): String {
|
||||
val locale = widgetLocale()
|
||||
return date.dayOfWeek.toJavaDayOfWeek().getDisplayName(java.time.format.TextStyle.SHORT, locale).capitalizeStart(locale)
|
||||
}
|
||||
|
||||
private fun eventTimeSummary(
|
||||
context: Context,
|
||||
|
||||
@@ -52,12 +52,14 @@ import de.jeanlucmakiola.calendula.widget.formatWidgetTime
|
||||
import de.jeanlucmakiola.calendula.widget.relativeDayLabel
|
||||
import de.jeanlucmakiola.calendula.widget.systemZone
|
||||
import de.jeanlucmakiola.calendula.widget.widgetAppearance
|
||||
import de.jeanlucmakiola.calendula.widget.widgetLocale
|
||||
import de.jeanlucmakiola.floret.glance.wallpaperBacking
|
||||
import de.jeanlucmakiola.floret.glance.WidgetData
|
||||
import de.jeanlucmakiola.floret.glance.WidgetMessage
|
||||
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
|
||||
import de.jeanlucmakiola.floret.glance.refreshStamp
|
||||
import de.jeanlucmakiola.floret.glance.themedColor
|
||||
import de.jeanlucmakiola.floret.locale.capitalizeStart
|
||||
import de.jeanlucmakiola.floret.prefs.ThemeMode
|
||||
import kotlinx.datetime.DateTimeUnit
|
||||
import kotlinx.datetime.minus
|
||||
@@ -206,14 +208,15 @@ private fun whenText(context: Context, event: EventInstance, data: CountdownData
|
||||
val at = if (running) counted.end else counted.start
|
||||
val date = at.toLocalDateTime(systemZone()).date
|
||||
val day = relativeDayLabel(context, date, data.today)
|
||||
val locale = widgetLocale()
|
||||
val wholeDays = event.coversWholeDays(systemZone())
|
||||
return when {
|
||||
wholeDays && running -> context.getString(
|
||||
R.string.widget_countdown_until,
|
||||
relativeDayLabel(context, date.minus(1, DateTimeUnit.DAY), data.today),
|
||||
)
|
||||
wholeDays -> "$day · ${context.getString(R.string.event_detail_all_day)}"
|
||||
wholeDays -> "${day.capitalizeStart(locale)} · ${context.getString(R.string.event_detail_all_day)}"
|
||||
running -> context.getString(R.string.agenda_span_ends, "$day · ${formatWidgetTime(at, data.is24Hour)}")
|
||||
else -> "$day · ${formatWidgetTime(at, data.is24Hour)}"
|
||||
else -> "${day.capitalizeStart(locale)} · ${formatWidgetTime(at, data.is24Hour)}"
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ internal fun DateWidgetContent(today: LocalDate, appearance: WidgetAppearance, a
|
||||
val size = LocalSize.current
|
||||
val fontScale = context.resources.configuration.fontScale
|
||||
val side = (minOf(size.width, size.height - WeekdayLine * fontScale) - 8.dp).coerceIn(32.dp, 120.dp)
|
||||
val label = localizedDateFormatter(widgetLocale(), "EEEEdMMMM").format(today.toJavaLocalDate()).capitalizeStart(widgetLocale())
|
||||
val label = localizedDateFormatter(widgetLocale(), "EEEEdMMMM").format(today.toJavaLocalDate())
|
||||
val weekday = TextStyle(
|
||||
color = GlanceTheme.colors.onSurface,
|
||||
fontSize = 12.sp,
|
||||
|
||||
@@ -418,7 +418,7 @@ private fun DayList(day: LocalDate, data: MonthDayData.Ready, preview: Boolean)
|
||||
val metrics = compactRowMetrics(data.options.textSize, context.resources.configuration.fontScale)
|
||||
val openDay = actionStartActivity(MainActivity.openDateIntent(context, day))
|
||||
Column(modifier = GlanceModifier.fillMaxSize()) {
|
||||
val date = localizedDateFormatter(widgetLocale(), "EEEdMMM").format(day.toJavaLocalDate()).capitalizeStart(widgetLocale())
|
||||
val date = widgetLocale().let { localizedDateFormatter(it, "EEEdMMM").format(day.toJavaLocalDate()).capitalizeStart(it) }
|
||||
val label = when (day) {
|
||||
source.today, source.today.plus(1, DateTimeUnit.DAY) -> "${relativeDayLabel(context, day, source.today)} · $date"
|
||||
else -> date
|
||||
|
||||
@@ -138,7 +138,7 @@ internal fun UpcomingWidgetContent(data: DaysWidgetData, appearance: WidgetAppea
|
||||
val time = widgetTimeLabel(context, event, day, data.is24Hour)
|
||||
WidgetEventRow(
|
||||
event = event,
|
||||
secondary = if (day == data.today) time else "${relativeDayLabel(context, day, data.today)} · $time",
|
||||
secondary = if (day == data.today) time else "${relativeDayLabel(context, day, data.today).capitalizeStart(widgetLocale())} · $time",
|
||||
soften = data.soften,
|
||||
metrics = metrics,
|
||||
position = positionOf(index, events.size),
|
||||
|
||||
@@ -149,7 +149,7 @@ private fun DayTile(date: LocalDate, data: DaysWidgetData.Ready) {
|
||||
// A declined or cancelled event is no plan for the day, so it adds no dot and no count (#388).
|
||||
val events = data.eventsOn(date).filterNot { it.isCrossedOut }
|
||||
val colors = events.map { it.color }.distinct()
|
||||
val label = localizedDateFormatter(locale, "EEEEdMMMM").format(date.toJavaLocalDate()).capitalizeStart(locale)
|
||||
val label = localizedDateFormatter(locale, "EEEEdMMMM").format(date.toJavaLocalDate())
|
||||
Column(
|
||||
modifier = GlanceModifier
|
||||
.fillMaxSize()
|
||||
|
||||
Reference in new issue
Block a user