Compare commits

...
Author SHA1 Message Date
makiolaj 6f0fae450d Release v2.25.0-beta.3
Beta — Codeberg pre-release / detect (push) Successful in 5s
Beta — Codeberg pre-release / beta (push) Successful in 11m14s
2026-11-25 21:03:08 +01:00
makiolaj 2b6a200d6d Merge fix/543-month-title-case into release/2.25.0 2026-11-25 21:02:21 +01:00
makiolaj d0b4b04986 fix(#543): pin floret-kit to main (capitalizeStart, floret-kit#34) 2026-11-25 20:55:42 +01:00
makiolaj e3b5f01f7e fix(#543): capitalise only standalone labels, cover multi-day selection and agenda spans 2026-11-25 20:50:12 +01:00
makiolaj 6e2260134a fix(#543): capitalise month and day names at the start of titles and labels 2026-11-25 20:43:27 +01:00
makiolaj d29faf336f Shorten older changelog entries 2026-11-25 20:13:18 +01:00
makiolaj f3c3f5237f Shorten changelog entries, per-beta changelog sections 2026-11-25 20:10:12 +01:00
makiolaj f9b4ebd167 Release v2.25.0-beta.2
Beta — Codeberg pre-release / detect (push) Successful in 3s
Beta — Codeberg pre-release / beta (push) Successful in 11m51s
2026-11-25 16:32:09 +01:00
makiolaj 08df8ca77c Merge fix/459-summary-pointer into release/2.25.0 2026-11-25 16:28:38 +01:00
makiolaj 9a872bd3d9 Merge fix/143-hide-in-view-label into release/2.25.0 2026-11-25 16:28:38 +01:00
makiolaj 2e65421f68 Merge fix/530-widget-back-home into release/2.25.0 2026-11-25 16:28:38 +01:00
makiolaj a705c89656 Merge fix/516-interval-off into release/2.25.0 2026-11-25 16:28:38 +01:00
makiolaj b328fa8e42 Merge fix/502-imported-series-edit into release/2.25.0 2026-11-25 16:28:38 +01:00
makiolaj c14775d4e5 fix(#459): review round 4 - reveal the whole summary block once it has expanded, mark the pointer row with an icon 2026-11-25 15:54:08 +01:00
makiolaj 47e737f8ec fix(#459): review round 3 - the pointer turns the summary on and closes through onDismiss 2026-11-25 15:32:30 +01:00
makiolaj 7a8c41c73d fix(#143): review round 3 - name the view in the row notes, entry summary and picker hint 2026-11-25 15:32:27 +01:00
makiolaj 830e48c5e7 fix(#516): review round 4 - id suffix sticks, run-now rewrites every copy again, unchanged blocked series don't count as success 2026-11-25 15:31:55 +01:00
makiolaj 4a14ebde2d fix(#516): review round 3 - restore missing stable copies on change runs, blocked series reported once, kept copies of deselected calendars suffix the name 2026-11-25 15:20:11 +01:00
makiolaj fc1a76f274 fix(#502): review round 3 - length checked before inserting, sync cancel and all-day spans covered 2026-11-25 15:17:15 +01:00
makiolaj 2f51260f9d fix(#502): review round 2 - length only checked where the series is re-expanded, zero spans kept 2026-11-25 12:30:34 +01:00
makiolaj 85cf59ad82 fix(#502): review round 1 - occurrence span first, no guessed length, move path covered 2026-11-25 12:23:38 +01:00
makiolaj 732548a989 fix(#516): keep a blocked series' hash, back up when a settings restore switches the interval 2026-11-25 12:16:32 +01:00
makiolaj 0652859ecc fix(#502): series rows without a usable DURATION no longer lose their occurrences on a single edit or delete 2026-11-25 12:16:05 +01:00
makiolaj c4926145f3 fix(#459): reuse the summary's hint, pass the pointer as footer 2026-11-25 12:13:15 +01:00
makiolaj 613ddfb532 fix(#143): give the named title a fresh key, keep docs in step 2026-11-25 12:13:15 +01:00
makiolaj 242ccd3b70 fix(#516): don't retry a run only blocked series failed, back up on any interval switch 2026-11-25 12:12:22 +01:00
makiolaj 4d342c98ad fix(#516): flag series the undated copy can't cover, back up when the interval returns 2026-11-25 12:08:44 +01:00
makiolaj 770a4756a4 fix(#459): move the summary pointer into a picker footer, hide it once on 2026-11-25 12:07:51 +01:00
makiolaj 2eeabb40c8 fix(#143): quote the view name and share the title 2026-11-25 12:07:50 +01:00
makiolaj f14f6f32f4 fix(#459): point the set-time reminder picker to the daily summary 2026-11-25 12:04:13 +01:00
makiolaj 81c38b424d fix(#143): name the view in the hide-in-view label 2026-11-25 12:04:13 +01:00
makiolaj 91cb57f940 fix(#516): hide the interval switch without after-change backups and test the interval rules 2026-11-25 12:03:36 +01:00
makiolaj b15b324965 fix(#516): let the backup interval be switched off while backing up after changes 2026-11-20 22:15:57 +01:00
47 changed files with 1067 additions and 1605 deletions

No files matched your search

+1
View File
@@ -74,3 +74,4 @@ Gemfile.lock
# Claude Code
/CLAUDE.md
.kotlin/
+414 -1444
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -32,8 +32,8 @@ android {
// (up to 2.22.3: 2.22.3 -> 22203; from 2.22.4: 2.23.0-beta.1 -> 2230001,
// 2.22.4 -> 2220499), and CI fails if the committed one doesn't match.
// See docs/RELEASING.md.
versionCode = 2250001
versionName = "2.25.0-beta.1"
versionCode = 2250003
versionName = "2.25.0-beta.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@@ -32,7 +32,9 @@ import de.jeanlucmakiola.calendula.data.ics.IcsExporter
import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
import de.jeanlucmakiola.calendula.domain.backup.BackupFilePlan
import de.jeanlucmakiola.calendula.domain.backup.BackupTarget
import de.jeanlucmakiola.calendula.domain.backup.backedUp
import de.jeanlucmakiola.calendula.domain.backup.backupFingerprint
import de.jeanlucmakiola.calendula.domain.backup.backupRunLatestOnly
import de.jeanlucmakiola.calendula.domain.backup.backupTargets
import de.jeanlucmakiola.calendula.domain.backup.inBackupOrder
import de.jeanlucmakiola.calendula.domain.backup.latestHeldElsewhere
@@ -76,8 +78,8 @@ object BackupScheduler {
/**
* Reconcile the scheduled work with the saved settings: enqueue a unique
* periodic request when backup is on and a folder is set, otherwise cancel
* it. WorkManager persists the request across reboots on its own.
* periodic request when backup is on, a folder is set and the interval
* isn't switched off (#516), otherwise cancel it. WorkManager persists the request across reboots on its own.
*
* The first run is delayed by one interval so it doesn't follow an immediate
* [runNow] with a near-identical copy. With backing up after changes on
@@ -109,16 +111,20 @@ object BackupScheduler {
stopWatching()
return
}
// WorkManager's own floor is 15 min; the UI floors the user choice at 30.
val interval = prefs.autoBackupIntervalMinutes.first().coerceAtLeast(15L)
val request = PeriodicWorkRequestBuilder<BackupWorker>(interval, TimeUnit.MINUTES)
.setInitialDelay(interval, TimeUnit.MINUTES)
.build()
workManager.enqueueUniquePeriodicWork(
WORK_NAME,
ExistingPeriodicWorkPolicy.UPDATE,
request,
)
if (prefs.autoBackupScheduled.first()) {
// WorkManager's own floor is 15 min; the UI floors the user choice at 30.
val interval = prefs.autoBackupIntervalMinutes.first().coerceAtLeast(15L)
val request = PeriodicWorkRequestBuilder<BackupWorker>(interval, TimeUnit.MINUTES)
.setInitialDelay(interval, TimeUnit.MINUTES)
.build()
workManager.enqueueUniquePeriodicWork(
WORK_NAME,
ExistingPeriodicWorkPolicy.UPDATE,
request,
)
} else {
workManager.cancelUniqueWork(WORK_NAME)
}
if (!prefs.autoBackupOnChange.first()) {
stopWatching()
} else if (watchDropped || !BackupChangeJob.isPending(context)) {
@@ -238,7 +244,7 @@ class BackupWorker(
if (changeRun && !prefs.autoBackupOnChange.first()) return Result.success()
val folder = prefs.autoBackupFolderUri.first() ?: return Result.failure()
val outcome = try {
runBackup(deps, prefs, folder.toUri(), latestOnly = changeRun)
runBackup(deps, prefs, folder.toUri(), changeRun, prefs.autoBackupScheduled.first())
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
@@ -261,17 +267,28 @@ class BackupWorker(
return if (outcome == RunOutcome.Failed && !changeRun) Result.retry() else Result.success()
}
private enum class RunOutcome { Written, PartlyFailed, Failed, NothingToDo }
/** [Blocked]: failed only on series no retry can back up, so it isn't retried. */
private enum class RunOutcome { Written, PartlyFailed, Failed, Blocked, NothingToDo }
/** How a stable copy's write went: under its own name, under one the provider picked, or not at all. */
private enum class LatestWrite { Landed, Renamed, Failed }
/**
* Writes each series and prunes it only once its new file has landed. A
* [latestOnly] run (#516) leaves the dated files and their retention to the
* change run (#516) leaves the dated files and their retention to the
* schedule and rewrites only the stable copies whose calendars changed.
* With the interval off, no run writes dated files, so a series whose
* stable name a file of the user's holds counts as failed (a change run
* only when its content changed).
*/
private suspend fun runBackup(deps: Deps, prefs: SettingsPrefs, folder: Uri, latestOnly: Boolean): RunOutcome {
private suspend fun runBackup(
deps: Deps,
prefs: SettingsPrefs,
folder: Uri,
changeRun: Boolean,
intervalOn: Boolean,
): RunOutcome {
val latestOnly = backupRunLatestOnly(changeRun, intervalOn)
val repository = deps.repository()
val exporter = deps.exporter()
if (!applicationContext.hasPermission(Manifest.permission.READ_CALENDAR)) return RunOutcome.Failed
@@ -303,12 +320,18 @@ class BackupWorker(
val trackHashes = prefs.autoBackupOnChange.first()
if (!trackHashes && fingerprints.isNotEmpty()) prefs.updateAutoBackupFingerprints(folder.toString()) { emptyMap() }
// A change run hashes first (null: unreadable) and leaves the folder alone when nothing moved.
val preHashes: Map<String, String?> = if (latestOnly) {
val preHashes: Map<String, String?> = if (changeRun) {
targets.associate { target -> target.key to export(target)?.let { fingerprintOf(target, it) } }
} else {
emptyMap()
}
if (latestOnly && targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } }) {
// With the interval off, unless a stable copy went missing: no scheduled run would restore it.
fun copyListed(target: BackupTarget) = latestFileName(target.baseName) in listing.files ||
ledger[latestLedgerKey(target.key)].orEmpty().any { it in listing.files }
if (changeRun &&
targets.all { preHashes[it.key].let { hash -> hash != null && hash == fingerprints[it.key] } } &&
(intervalOn || !listing.complete || targets.all(::copyListed))
) {
return RunOutcome.NothingToDo
}
val plans = planBackupFiles(
@@ -382,19 +405,36 @@ class BackupWorker(
var written = 0
var failed = 0
var blocked = 0
var stillBlocked = 0
val landedLatest = mutableSetOf<String>()
for (plan in plans) {
val target = plan.target
if (latestOnly) {
val hash = preHashes[target.key] ?: run {
val hash = if (changeRun) {
preHashes[target.key] ?: run {
failed++
continue
}
rememberBlocked(plan, hash)
if (!plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) {
if (plan.latestName in listing.files) landedLatest += target.key
} else {
null
}
if (!plan.backedUp(intervalOn)) {
// Its hash still goes on record, so a later change run can stop early.
val blockedHash = hash ?: if (trackHashes) export(target)?.let { fingerprintOf(target, it) } else null
blockedHash?.let { rememberBlocked(plan, it) }
// A change run doesn't fail again on one that didn't change, nor report the run a success.
if (changeRun && hash == fingerprints[target.key]) {
stillBlocked++
continue
}
failed++
blocked++
continue
}
if (hash != null) rememberBlocked(plan, hash)
if (hash != null && !plan.needsRefresh(hash, fingerprints, listing.files.keys, listing.complete)) {
if (plan.latestName in listing.files) landedLatest += target.key
continue
}
// Read again rather than held since the pre-pass: one series' text in memory at a time.
val text = export(target) ?: run {
@@ -402,7 +442,7 @@ class BackupWorker(
continue
}
val fingerprint = fingerprintOf(target, text)
if (!latestOnly) rememberBlocked(plan, fingerprint)
if (!changeRun) rememberBlocked(plan, fingerprint)
val bytes = text.toByteArray(Charsets.UTF_8)
// Not cancellable once a file exists: it must reach the ledger.
withContext(NonCancellable) {
@@ -426,8 +466,9 @@ class BackupWorker(
}
}
return when {
failed == 0 && written == 0 -> RunOutcome.NothingToDo
failed == 0 && (written == 0 || stillBlocked > 0) -> RunOutcome.NothingToDo
failed == 0 -> RunOutcome.Written
written == 0 && failed == blocked -> RunOutcome.Blocked
written == 0 -> RunOutcome.Failed
else -> RunOutcome.PartlyFailed
}
@@ -18,6 +18,7 @@ import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
import de.jeanlucmakiola.calendula.data.prefs.SpecialDatesStalledReason
import de.jeanlucmakiola.calendula.data.fonts.CustomFontStore
import de.jeanlucmakiola.calendula.data.prefs.SettingsKeys
import de.jeanlucmakiola.calendula.data.prefs.autoBackupScheduled
import de.jeanlucmakiola.calendula.data.reminders.ReminderScanner
import de.jeanlucmakiola.calendula.domain.FontRole
import de.jeanlucmakiola.calendula.widget.requestWidgetRedraw
@@ -128,7 +129,12 @@ class SettingsBackupEngine @Inject constructor(
}
}
step("reminders") { reminderScanner.scan() }
step("auto backup") { BackupScheduler.reconcile(context, settingsPrefs) }
step("auto backup") {
BackupScheduler.reconcile(context, settingsPrefs)
// Like the settings screen, an import that switches the interval (#516) backs up right away.
val active = after[SettingsKeys.autoBackupEnabled] && after[SettingsKeys.autoBackupFolderUri] != null
if (active && before.autoBackupScheduled != after.autoBackupScheduled) BackupScheduler.runNow(context)
}
plan.launcherName?.let { name ->
step("launcher name") { if (launcherNames.current() != name) launcherNames.set(name) }
}
@@ -64,6 +64,7 @@ internal object SettingsBackupSchema {
SettingsKeys.autoBackupCombinedStored,
SettingsKeys.autoBackupKeep,
SettingsKeys.autoBackupOnChange,
SettingsKeys.autoBackupScheduledStored,
SettingsKeys.specialDatesEnabled,
SettingsKeys.specialDatesShowYear,
) + SettingsKeys.specialDateTypeEnabled.values + SettingsKeys.specialDatesTitleTemplate.values
@@ -1270,7 +1270,7 @@ class AndroidCalendarDataSource @Inject constructor(
form: EventForm,
allDayReminderTimeMinutes: Int,
): Long {
val row = querySeriesRow(eventId)
val row = querySeriesRow(eventId, beginMillis)
// Not a series, so there is no occurrence to single out: the row *is* the
// event, and an exception with nothing to be an exception to would leave
// an orphan holding the edit (the same test deleteOccurrence makes).
@@ -1349,6 +1349,8 @@ class AndroidCalendarDataSource @Inject constructor(
// Reminders, guests and colour come along like any new event, and so does
// a fresh UID — the detached row is a separate event now, and sharing the
// parent's would collide with it in .ics restore dedup.
// Fail before inserting: the EXDATE write below needs a usable length.
row.writeDuration()
val detachedId = insertEvent(form.toDetachedOccurrence(), allDayReminderTimeMinutes)
// Rows touched, not occurrences excluded — 1 whenever the series row still
// exists. It catches the row disappearing under us, not an EXDATE the
@@ -1384,7 +1386,7 @@ class AndroidCalendarDataSource @Inject constructor(
updated: EventForm,
allDayReminderTimeMinutes: Int,
): Long {
val row = querySeriesRow(eventId)
val row = querySeriesRow(eventId, beginMillis)
// From the first occurrence on (or with no rule to split) this is
// just a series update.
if (row.rrule.isNullOrBlank() || beginMillis <= row.dtStartMillis) {
@@ -1392,6 +1394,8 @@ class AndroidCalendarDataSource @Inject constructor(
return eventId
}
// Insert the new series first: if it fails, the original is untouched.
// Fail before inserting: truncating the original needs a usable length.
row.writeDuration()
val newEventId = insertEvent(updated, allDayReminderTimeMinutes)
carrySplitExdate(newEventId, row, beginMillis, original, updated)
truncateSeries(eventId, row, beginMillis)
@@ -1447,7 +1451,7 @@ class AndroidCalendarDataSource @Inject constructor(
}
override fun deleteEventFromOccurrence(eventId: Long, beginMillis: Long) {
val row = querySeriesRow(eventId)
val row = querySeriesRow(eventId, beginMillis)
// From the first occurrence on = the whole series; also the fallback
// when there is no RRULE to truncate.
if (row.rrule.isNullOrBlank() || beginMillis <= row.dtStartMillis) {
@@ -1476,8 +1480,12 @@ class AndroidCalendarDataSource @Inject constructor(
updateEventRow(eventId, values, "truncate series event id=$eventId begin=$beginMillis")
}
/** The series anchor: every time-related column of the Events row. */
private fun querySeriesRow(eventId: Long): SeriesRow = resolver.query(
/**
* The series anchor: every time-related column of the Events row. A recurring
* row with no usable DURATION gets one derived ([seriesDuration]), from the
* expanded occurrence at [occurrenceMillis] when DTEND can't supply it.
*/
private fun querySeriesRow(eventId: Long, occurrenceMillis: Long? = null): SeriesRow = resolver.query(
eventUri(eventId),
arrayOf(
CalendarContract.Events.DTSTART,
@@ -1488,11 +1496,12 @@ class AndroidCalendarDataSource @Inject constructor(
CalendarContract.Events._SYNC_ID,
CalendarContract.Events.EXDATE,
CalendarContract.Events.RDATE,
CalendarContract.Events.DTEND,
),
null, null, null,
)?.use { c ->
if (c.moveToFirst()) {
SeriesRow(
val row = SeriesRow(
dtStartMillis = c.getLong(0),
rrule = c.getString(1),
timezone = c.getString(2),
@@ -1502,11 +1511,27 @@ class AndroidCalendarDataSource @Inject constructor(
exdate = c.getString(6),
rdate = c.getString(7),
)
if (!row.recurs || !row.duration.isNullOrBlank()) return@use row
row.copy(
dtEndMillis = if (c.isNull(8)) null else c.getLong(8),
occurrenceSpanMillis = occurrenceMillis?.let { occurrenceSpan(eventId, it) },
)
} else {
null
}
} ?: throw WriteFailedException("read series row of event id=$eventId")
/** Length of the already-expanded occurrence of [eventId] starting at [beginMillis]. */
private fun occurrenceSpan(eventId: Long, beginMillis: Long): Long? {
return resolver.query(
instancesUri(beginMillis, beginMillis + 1),
arrayOf(CalendarContract.Instances.BEGIN, CalendarContract.Instances.END),
"${CalendarContract.Instances.EVENT_ID} = ? AND ${CalendarContract.Instances.BEGIN} = ?",
arrayOf(eventId.toString(), beginMillis.toString()),
null,
)?.use { c -> if (c.moveToFirst()) c.getLong(1) - c.getLong(0) else null }
}
private data class SeriesRow(
val dtStartMillis: Long,
val rrule: String?,
@@ -1517,6 +1542,9 @@ class AndroidCalendarDataSource @Inject constructor(
val syncId: String? = null,
val exdate: String? = null,
val rdate: String? = null,
/** Only read for a series with no DURATION, to derive one ([writeDuration]). */
val dtEndMillis: Long? = null,
val occurrenceSpanMillis: Long? = null,
) {
/**
* Whether this row expands into more than itself. RDATE counts as much as
@@ -1526,14 +1554,23 @@ class AndroidCalendarDataSource @Inject constructor(
*/
val recurs: Boolean get() = !rrule.isNullOrBlank() || !rdate.isNullOrBlank()
/**
* DURATION for a write that re-expands the series. Refuses rather than
* writing none, which would leave the provider nothing to expand (#502).
*/
fun writeDuration(): String = duration?.takeIf { it.isNotBlank() }
?: seriesDuration(dtStartMillis, dtEndMillis, occurrenceSpanMillis, allDay != 0)
?: throw WriteFailedException("series has no usable length")
/**
* The time/recurrence set a series write carries together: the provider
* re-expands instances only from what the update itself holds.
*/
fun timeColumns(): ContentValues = ContentValues().apply {
put(CalendarContract.Events.DTSTART, dtStartMillis)
putNull(CalendarContract.Events.DTEND)
put(CalendarContract.Events.RRULE, rrule)
put(CalendarContract.Events.DURATION, duration)
put(CalendarContract.Events.DURATION, writeDuration())
put(CalendarContract.Events.EVENT_TIMEZONE, timezone)
put(CalendarContract.Events.ALL_DAY, allDay)
}
@@ -1545,7 +1582,7 @@ class AndroidCalendarDataSource @Inject constructor(
dtStartMillis = dtStartMillis,
rrule = rrule,
rdate = rdate,
duration = duration,
duration = writeDuration(),
timezone = timezone,
allDay = allDay,
)
@@ -1732,7 +1769,7 @@ class AndroidCalendarDataSource @Inject constructor(
}
override fun deleteOccurrence(eventId: Long, beginMillis: Long) {
val row = querySeriesRow(eventId)
val row = querySeriesRow(eventId, beginMillis)
// Not a series, so the row *is* the event: an exclusion would put a
// recurrence set on a one-off, an exception would leave an orphan.
if (!row.recurs) {
@@ -1762,7 +1799,7 @@ class AndroidCalendarDataSource @Inject constructor(
val values = buildOccurrenceCancelValues(
originalInstanceMillis = beginMillis,
dtStartMillis = beginMillis,
duration = row.duration,
duration = row.writeDuration(),
timezone = row.timezone,
allDay = row.allDay,
)
@@ -369,7 +369,8 @@ internal fun buildMovedMasterValues(
/** The recurring copy's DURATION: its own if present, else derived from DTEND. */
private fun MasterEventSnapshot.movedDuration(): String = duration?.takeIf { it.isNotBlank() }
?: rfc2445Duration((dtEndMillis ?: dtStartMillis) - dtStartMillis, isAllDay)
?: seriesDuration(dtStartMillis, dtEndMillis ?: dtStartMillis, occurrenceSpanMillis = null, isAllDay = isAllDay)
?: throw WriteFailedException("move series with no usable length")
/**
* Raw provider snapshot of one exception row of a recurring series (a modified
@@ -454,6 +455,29 @@ internal fun buildOccurrenceExdateValues(
existingExdate, listOf(occurrenceMillis), dtStartMillis, rrule, rdate, duration, timezone, allDay,
)
/**
* DURATION for a series row that has none. Rows from other tools can carry a
* DTEND (sometimes 0) instead; rewriting them without a DURATION leaves the
* provider nothing to expand, and every occurrence vanishes (#502). The span of
* an occurrence the provider actually expanded wins over DTEND; null when
* neither gives a length (a DTEND before DTSTART), so the caller fails
* instead of guessing.
*/
internal fun seriesDuration(
dtStartMillis: Long,
dtEndMillis: Long?,
occurrenceSpanMillis: Long?,
isAllDay: Boolean,
): String? {
val span = occurrenceSpanMillis?.takeIf { it >= 0 }
?: dtEndMillis?.minus(dtStartMillis)?.takeIf { it >= 0 }
?: return null
if (!isAllDay) return rfc2445Duration(span, isAllDay = false)
// Whole days, rounded: a span read across a DST change or zone offset is a few hours off.
val days = ((span + MILLIS_PER_DAY / 2) / MILLIS_PER_DAY).coerceAtLeast(1)
return rfc2445Duration(days * MILLIS_PER_DAY, isAllDay = true)
}
/** [buildOccurrenceExdateValues] excluding every one of [occurrences] in one write. */
internal fun buildOccurrencesExdateValues(
existingExdate: String?,
@@ -469,6 +493,7 @@ internal fun buildOccurrencesExdateValues(
mergedExdate(exdate, millis, allDay != 0, timezone)
},
CalendarContract.Events.DTSTART to dtStartMillis,
CalendarContract.Events.DTEND to null,
CalendarContract.Events.RRULE to rrule,
CalendarContract.Events.RDATE to rdate,
CalendarContract.Events.DURATION to duration,
@@ -9,6 +9,7 @@ import de.jeanlucmakiola.calendula.domain.DefaultCalendarRef
import de.jeanlucmakiola.calendula.domain.EventFormField
import de.jeanlucmakiola.calendula.domain.FontRole
import de.jeanlucmakiola.calendula.domain.backup.BackupSelection
import de.jeanlucmakiola.calendula.domain.backup.backupIntervalOn
import de.jeanlucmakiola.calendula.domain.backup.COMBINED_SERIES
import de.jeanlucmakiola.calendula.domain.backup.DEFAULT_BACKUP_KEEP
import de.jeanlucmakiola.calendula.domain.backup.LEGACY_BACKUP_FILE
@@ -229,6 +230,11 @@ class SettingsPrefs @Inject constructor(
val autoBackupKeep: Flow<Int> = prefs.flow(SettingsKeys.autoBackupKeep)
val autoBackupLedger: Flow<BackupLedger> = prefs.flow(SettingsKeys.autoBackupLedger)
val autoBackupOnChange: Flow<Boolean> = prefs.flow(SettingsKeys.autoBackupOnChange)
val autoBackupScheduled: Flow<Boolean> = prefs.snapshot { it.autoBackupScheduled }
/** Read together, so the screen never shows one updated without the other. */
val autoBackupOnChangeAndScheduled: Flow<Pair<Boolean, Boolean>> =
prefs.snapshot { it[SettingsKeys.autoBackupOnChange] to it.autoBackupScheduled }
val autoBackupFingerprints: Flow<BackupFingerprints> = prefs.flow(SettingsKeys.autoBackupFingerprints)
val specialDatesEnabled: Flow<Boolean> = prefs.flow(SettingsKeys.specialDatesEnabled)
val specialDatesTypes: Flow<Set<SpecialDateType>> = prefs.snapshot { it.specialDatesTypes }
@@ -523,7 +529,28 @@ class SettingsPrefs @Inject constructor(
suspend fun setAutoBackupKeep(keep: Int) = prefs.set(SettingsKeys.autoBackupKeep, keep)
suspend fun setAutoBackupOnChange(enabled: Boolean) = prefs.set(SettingsKeys.autoBackupOnChange, enabled)
/** Returns whether this switched the interval on or off. */
suspend fun setAutoBackupOnChange(enabled: Boolean): Boolean = editAutoBackupScheduled {
applyAutoBackupOnChange(it, enabled)
}
/**
* Off only sticks while backing up after changes is on; see
* [applyAutoBackupOnChange]. Returns whether this switched the interval.
*/
suspend fun setAutoBackupScheduled(enabled: Boolean): Boolean = editAutoBackupScheduled {
if (enabled || it[SettingsKeys.autoBackupOnChange]) it[SettingsKeys.autoBackupScheduledStored] = enabled
}
private suspend fun editAutoBackupScheduled(transform: (MutablePreferences) -> Unit): Boolean {
var switched = false
prefs.edit {
val before = it.autoBackupScheduled
transform(it)
switched = it.autoBackupScheduled != before
}
return switched
}
/**
* Atomic, so a run's ledger writes never undo one made meanwhile (pinning
@@ -1048,6 +1075,9 @@ object SettingsKeys {
/** Whether a change to a backed-up calendar also refreshes the stable copies (#516). Opt-in. */
val autoBackupOnChange: Pref<Boolean> = booleanPref("auto_backup_on_change", false)
/** Whether the dated backups run on the interval; read as [Preferences.autoBackupScheduled]. */
val autoBackupScheduledStored: Pref<Boolean> = booleanPref("auto_backup_scheduled", true)
/** Content hash of each series' stable copy, so a change run skips untouched ones (#516). */
val autoBackupFingerprints: Pref<BackupFingerprints> =
nullableStringPref("auto_backup_fingerprints").map(::parseBackupFingerprints, ::persistBackupFingerprints)
@@ -1107,6 +1137,20 @@ val Preferences.autoBackupSelection: BackupSelection
excluded = this[SettingsKeys.autoBackupExcluded],
)
/** Whether the dated backups run on the interval; see [backupIntervalOn]. */
val Preferences.autoBackupScheduled: Boolean
get() = backupIntervalOn(this[SettingsKeys.autoBackupScheduledStored], this[SettingsKeys.autoBackupOnChange])
/**
* Turning it off brings the interval back for good, and turning it on starts
* with the interval on, so an interval-off stored without it (a settings
* import) never takes effect.
*/
internal fun applyAutoBackupOnChange(prefs: MutablePreferences, enabled: Boolean) {
if (!enabled || !prefs[SettingsKeys.autoBackupOnChange]) prefs[SettingsKeys.autoBackupScheduledStored] = true
prefs[SettingsKeys.autoBackupOnChange] = enabled
}
/**
* Unset means an install from before #411: one that already had a backup
* folder keeps the single file it was writing, anything else gets per-calendar
@@ -14,13 +14,14 @@ import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
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
@@ -54,15 +55,12 @@ 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) ->
context.getString(R.string.digest_day_relative, context.getString(R.string.reminder_day_tomorrow), date)
else -> date
else -> date.capitalizeStart(locale)
}
val allDay = context.getString(R.string.event_detail_all_day)
val lines = listed.map { entry ->
@@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.data.reminders
import de.jeanlucmakiola.calendula.domain.runsMidnightToMidnight
import de.jeanlucmakiola.calendula.ui.common.timeOfDayFormatter
import de.jeanlucmakiola.floret.locale.capitalizeStart
import java.time.DayOfWeek
import java.time.Instant
import java.time.LocalDate
@@ -121,7 +122,7 @@ private fun relativeDayPrefix(
1L -> tomorrowLabel
-1L -> yesterdayLabel
else -> if (isSameWeek(day, today, firstDayOfWeek)) {
day.dayOfWeek.getDisplayName(TextStyle.SHORT, locale)
day.dayOfWeek.getDisplayName(TextStyle.SHORT, locale).capitalizeStart(locale)
} else {
dateFormat.format(day)
}
@@ -129,10 +129,12 @@ private val STAMP_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern(STAMP_
* something follows shouldn't move because another calendar took the same
* name. So the series holding the stable copy of the name in [ledger] keeps
* it, then one holding dated files under it; series that already write under
* their id suffix keep that; with no claim at all the lowest id keeps the
* their id suffix keep that, clash or not; with no claim at all the lowest id keeps the
* name. The others take their id as a suffix until every name in the run is
* distinct. Ledger names gone from the folder ([existing], when known) claim
* nothing. A calendar named like the combined file is always suffixed.
* distinct. A stable copy a series outside the run still holds (a calendar
* taken out of the backup) is kept, so a calendar now named like it is
* suffixed too. Ledger names gone from the folder ([existing], when known)
* claim nothing. A calendar named like the combined file is always suffixed.
*/
fun backupTargets(
calendars: List<CalendarSource>,
@@ -148,16 +150,26 @@ fun backupTargets(
}
val present = if (existing == null) ledger else ledger.mapValues { (_, names) -> names.filter { it in existing } }
val bases = calendars.associateTo(LinkedHashMap()) {
it.id to safeFileName(it.displayName, MAX_BASE_BYTES, fallback = "calendar")
val base = safeFileName(it.displayName, MAX_BASE_BYTES, fallback = "calendar")
val suffixed = "$base-${it.id}"
it.id to if (present.holdsLatest(it.id.toString(), suffixed)) suffixed else base
}
val runKeys = calendars.map { latestLedgerKey(it.id.toString()) }.toSet()
val heldOutside = present.filterKeys { it.startsWith(LATEST_PREFIX) && it !in runKeys }
.values.flatten().map { it.lowercase() }.toSet()
while (true) {
val clashing = bases.entries.groupBy({ it.value.lowercase() }, { it.key })
.filter { (lower, ids) -> ids.size > 1 || lower == COMBINED_BACKUP_BASE.lowercase() }
if (clashing.isEmpty()) break
clashing.forEach { (lower, ids) ->
val keeper = if (lower == COMBINED_BACKUP_BASE.lowercase()) null else present.keeperOf(ids, bases)
ids.filter { it != keeper }.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" }
if (clashing.isNotEmpty()) {
clashing.forEach { (lower, ids) ->
val keeper = if (lower == COMBINED_BACKUP_BASE.lowercase()) null else present.keeperOf(ids, bases)
ids.filter { it != keeper }.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" }
}
continue
}
val taken = bases.filterValues { latestFileName(it).lowercase() in heldOutside }.keys
if (taken.isEmpty()) break
taken.forEach { id -> bases[id] = "${bases.getValue(id)}-$id" }
}
return calendars.map { calendar ->
BackupTarget(
@@ -311,6 +323,18 @@ fun parseBackupLedger(stored: String?): BackupLedger =
parts.first().takeIf { it.isNotEmpty() && names.isNotEmpty() }?.let { it to names }
}.toMap()
/** The interval can only be off while backing up after changes is on (#516), or nothing would ever run. */
fun backupIntervalOn(stored: Boolean, onChange: Boolean): Boolean = stored || !onChange
/** Without the interval there are no dated files, so every run only refreshes the stable copies. */
fun backupRunLatestOnly(changeRun: Boolean, intervalOn: Boolean): Boolean = changeRun || !intervalOn
/**
* Whether a run can back this series up at all: without dated files, only
* through its stable copy, which a file of the user's can block.
*/
fun BackupFilePlan.backedUp(intervalOn: Boolean): Boolean = intervalOn || latestName != null
/** Closest offered retention count to [stored], so a stray value still shows a row. */
fun normalizeBackupKeep(stored: Int): Int =
BACKUP_KEEP_OPTIONS.minBy { kotlin.math.abs(it - stored) }
@@ -369,7 +393,7 @@ fun parseBackupFingerprints(stored: String?): BackupFingerprints =
* only when its content moved on from what the copy holds (a rename changes
* the name written into it), or the copy is missing. Never when the name belongs to a file of the user's,
* nor when a [complete]-less listing doesn't show the copy: writing then would
* add a duplicate beside it, so that is left to the scheduled run.
* add a duplicate beside it, so that is left to the next run that isn't a change run.
*/
fun BackupFilePlan.needsRefresh(
fingerprint: String,
@@ -207,7 +207,7 @@ fun CalendarHost(
LaunchedEffect(detailKey) { requests.leaveTarget = requests.leaveTarget.afterDetail(detailKey) }
val onOpenDetail: (EventInstance) -> Unit = { event -> detailKey = event.occurrenceKey() }
// The drawer's "Hide in this view" picker (#517). It is its own window over
// The drawer's "Hide in “<view>” view" picker (#517). It is its own window over
// everything here, so each external request below closes it first.
var showViewCalendars by rememberSaveable { mutableStateOf(false) }
@@ -1,5 +1,6 @@
package de.jeanlucmakiola.calendula.ui.agenda
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.LocalDate
@@ -118,7 +119,7 @@ fun agendaRangeWindowSummary(
val startFmt = if (start.year == end.year) dayMonth else dayMonthYear
"${startFmt.format(javaStart)} – ${dayMonthYear.format(javaEnd)}"
}
}
}.capitalizeStart(locale)
}
private const val CUSTOM_PREFIX = "CUSTOM:"
@@ -46,6 +46,7 @@ import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.identity.animateItemMotion
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DateTimeUnit
@@ -212,7 +213,7 @@ private fun formatAgendaDate(date: LocalDate): String {
val java = date.toJavaLocalDate()
// Weekday + date in the locale's own field order (e.g. "Wed, Jun 17, 2026"
// vs "Mi., 17. Juni 2026") rather than a hardcoded day-month-year layout.
return localizedDateFormatter(locale, "EEEdMMMy").format(java)
return localizedDateFormatter(locale, "EEEdMMMy").format(java).capitalizeStart(locale)
}
/**
@@ -371,13 +371,29 @@ private fun BackupContent(
)
GroupedRow(
title = stringResource(R.string.calendars_auto_backup_interval),
summary = backupIntervalLabel(autoBackup.intervalMinutes),
summary = if (autoBackup.scheduled) {
backupIntervalLabel(autoBackup.intervalMinutes)
} else {
stringResource(R.string.calendars_auto_backup_interval_off)
},
position = Position.Middle,
onClick = onEditInterval,
// Off is only offered alongside backing up after changes, or nothing would run.
trailing = if (autoBackup.onChange) {
{ Switch(checked = autoBackup.scheduled, onCheckedChange = viewModel::setAutoBackupScheduled) }
} else {
null
},
onClick = if (autoBackup.scheduled) onEditInterval else ({ viewModel.setAutoBackupScheduled(true) }),
)
GroupedSwitchRow(
title = stringResource(R.string.calendars_auto_backup_on_change),
summary = stringResource(R.string.calendars_auto_backup_on_change_summary),
summary = stringResource(
if (autoBackup.scheduled) {
R.string.calendars_auto_backup_on_change_summary
} else {
R.string.calendars_auto_backup_on_change_only_summary
},
),
checked = autoBackup.onChange,
onCheckedChange = viewModel::setAutoBackupOnChange,
position = Position.Middle,
@@ -404,14 +420,17 @@ private fun BackupContent(
),
checked = autoBackup.combined,
onCheckedChange = viewModel::setAutoBackupCombined,
position = Position.Middle,
)
GroupedRow(
title = stringResource(R.string.calendars_auto_backup_keep),
summary = backupKeepLabel(autoBackup.keep),
position = Position.Bottom,
onClick = onEditKeep,
position = if (autoBackup.scheduled) Position.Middle else Position.Bottom,
)
// Retention only applies to the dated files the interval writes.
if (autoBackup.scheduled) {
GroupedRow(
title = stringResource(R.string.calendars_auto_backup_keep),
summary = backupKeepLabel(autoBackup.keep),
position = Position.Bottom,
onClick = onEditKeep,
)
}
GroupedHint(
if (selectedCount == 0) {
stringResource(R.string.calendars_auto_backup_nothing_selected)
@@ -109,9 +109,9 @@ class CalendarsViewModel @Inject constructor(
settingsPrefs.autoBackupSelection,
settingsPrefs.autoBackupCombined,
settingsPrefs.autoBackupKeep,
settingsPrefs.autoBackupOnChange,
) { base, selection, combined, keep, onChange ->
base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange)
settingsPrefs.autoBackupOnChangeAndScheduled,
) { base, selection, combined, keep, (onChange, scheduled) ->
base.copy(selection = selection, combined = combined, keep = keep, onChange = onChange, scheduled = scheduled)
}
.flowOn(io)
.stateWhileSubscribed(
@@ -296,8 +296,21 @@ class CalendarsViewModel @Inject constructor(
fun setAutoBackupOnChange(enabled: Boolean) {
viewModelScope.launch {
settingsPrefs.setAutoBackupOnChange(enabled)
val switched = settingsPrefs.setAutoBackupOnChange(enabled)
reschedule()
if (switched) runBackupIfActive()
}
}
/**
* Switching the interval backs up right away: back on, rather than an
* interval later; off, so a series only its dated files covered shows up.
*/
fun setAutoBackupScheduled(enabled: Boolean) {
viewModelScope.launch {
val switched = settingsPrefs.setAutoBackupScheduled(enabled)
reschedule()
if (switched) runBackupIfActive()
}
}
@@ -356,6 +369,7 @@ data class AutoBackupUiState(
val combined: Boolean = false,
val keep: Int = DEFAULT_BACKUP_KEEP,
val onChange: Boolean = false,
val scheduled: Boolean = true,
)
/** Outcome of a whole-calendar backup, surfaced once to the screen. */
@@ -1,5 +1,6 @@
package de.jeanlucmakiola.calendula.ui.common
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import java.util.Locale
@@ -30,5 +31,5 @@ fun formatCalendarTitle(
forceYear: Boolean = false,
): String {
val fields = if (date.year == currentYear && !forceYear) skeleton else skeleton + "y"
return localizedDateFormatter(locale, fields).format(date)
return localizedDateFormatter(locale, fields).format(date).capitalizeStart(locale)
}
@@ -2,6 +2,7 @@ package de.jeanlucmakiola.calendula.ui.common
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
@@ -131,7 +132,8 @@ fun FixedTimeReminderEditor(
* Picker for a fixed-time default (#459), full-screen: off, or a reminder at a
* set time edited in place — and, on a per-calendar picker ([inheritedLabel]
* non-null), deferring to the global default, [inherited], which also seeds the
* editor. Applies live; the user leaves via back.
* editor. Applies live; the user leaves via back, or through [footer], which
* follows the options and gets [onDismiss].
*/
@Composable
fun FixedTimeReminderPicker(
@@ -141,6 +143,7 @@ fun FixedTimeReminderPicker(
onDismiss: () -> Unit,
inheritedLabel: String? = null,
inherited: FixedTimeReminder? = null,
footer: @Composable ColumnScope.(dismiss: () -> Unit) -> Unit = {},
) {
var current by rememberSaveable(stateSaver = FixedTimeOverrideSaver) { mutableStateOf(selected) }
var editing by rememberSaveable { mutableStateOf(false) }
@@ -192,6 +195,7 @@ fun FixedTimeReminderPicker(
},
)
}
footer(onDismiss)
}
}
@@ -18,6 +18,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.calendula.domain.EventInstance
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import java.time.ZoneId
@@ -92,5 +93,5 @@ private fun formatSelectionWhen(event: EventInstance, use24Hour: Boolean, locale
"${day.format(start)} · ${time.format(start)}–${time.format(end)}"
} else {
"${day.format(start)}, ${time.format(start)} – ${day.format(end)}, ${time.format(end)}"
}
}.capitalizeStart(locale)
}
@@ -104,6 +104,7 @@ import de.jeanlucmakiola.calendula.ui.common.rememberFieldCopier
import de.jeanlucmakiola.calendula.ui.common.icuTimeZoneRegion
import de.jeanlucmakiola.calendula.ui.common.LocalSoftenColors
import de.jeanlucmakiola.calendula.ui.common.eventAccent
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.calendula.ui.common.LocalUse24HourFormat
import de.jeanlucmakiola.calendula.ui.common.timeOfDayFormatter
@@ -849,7 +850,7 @@ private fun formatWhen(
val startDate = instance.start.toJavaLocalDateTime(utc).toLocalDate()
val lastDate = (instance.end - 1.seconds).toJavaLocalDateTime(utc).toLocalDate()
return if (startDate == lastDate) {
allDayLabel to dateFull.format(startDate)
allDayLabel to dateFull.format(startDate).capitalizeStart(locale)
} else {
allDayLabel to "${dateMedium.format(startDate)} – ${dateMedium.format(lastDate)}"
}
@@ -859,7 +860,7 @@ private fun formatWhen(
val startTime = withRepeatedHourZone(timeShort.format(startLdt), instance.start, zone, locale)
val endTime = withRepeatedHourZone(timeShort.format(endLdt), instance.end, zone, locale)
return if (startLdt.toLocalDate() == endLdt.toLocalDate()) {
dateFull.format(startLdt.toLocalDate()) to "$startTime – $endTime"
dateFull.format(startLdt.toLocalDate()).capitalizeStart(locale) to "$startTime – $endTime"
} else {
val start = "${dateMedium.format(startLdt.toLocalDate())} $startTime"
val end = "${dateMedium.format(endLdt.toLocalDate())} $endTime"
@@ -38,6 +38,7 @@ import de.jeanlucmakiola.calendula.ui.common.CalendarAccountGroup
import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip
import de.jeanlucmakiola.calendula.ui.common.CalendarView
import de.jeanlucmakiola.calendula.ui.common.accountGroupTitle
import de.jeanlucmakiola.calendula.ui.common.label
import de.jeanlucmakiola.calendula.ui.common.orUnnamed
import de.jeanlucmakiola.floret.components.GroupedListInset
import de.jeanlucmakiola.floret.components.GroupedRow
@@ -70,6 +71,7 @@ fun CalendarFilterList(
hidden = s.hidden,
hiddenInView = hiddenInView,
hiddenOnlyHere = hiddenInView.size,
currentView = currentView,
onHideInView = onHideInView,
onToggleCalendar = viewModel::toggleCalendar,
onToggleGroup = viewModel::toggleGroup,
@@ -90,11 +92,13 @@ private fun FilterList(
hidden: Set<Long>,
hiddenInView: Set<Long>,
hiddenOnlyHere: Int,
currentView: CalendarView,
onHideInView: () -> Unit,
onToggleCalendar: (Long) -> Unit,
onToggleGroup: (List<Long>) -> Unit,
modifier: Modifier = Modifier,
) {
val viewName = currentView.label()
Column(modifier = modifier.fillMaxWidth()) {
groups.forEach { group ->
val ids = group.calendars.map { it.id }
@@ -107,7 +111,7 @@ private fun FilterList(
val visible = cal.id !in hidden
GroupedRow(
title = cal.displayName.orUnnamed(),
summary = if (cal.id in hiddenInView) stringResource(R.string.filter_hidden_in_view) else null,
summary = if (cal.id in hiddenInView) stringResource(R.string.filter_hidden_in_named_view, viewName) else null,
position = positionOf(index, group.calendars.size),
minHeight = 56.dp,
leading = { CalendarColorChip(cal.color) },
@@ -124,11 +128,11 @@ private fun FilterList(
// The per-view hide (#517): the drawer filter above hides everywhere, this only here.
Spacer(Modifier.height(8.dp))
GroupedRow(
title = stringResource(R.string.view_calendars_title),
title = stringResource(R.string.view_hide_in_title, viewName),
summary = if (hiddenOnlyHere > 0) {
pluralStringResource(R.plurals.drawer_hidden_in_view_count, hiddenOnlyHere, hiddenOnlyHere)
pluralStringResource(R.plurals.drawer_hidden_in_named_view_count, hiddenOnlyHere, hiddenOnlyHere, viewName)
} else {
stringResource(R.string.drawer_hidden_in_view_none)
stringResource(R.string.drawer_hidden_in_named_view_none, viewName)
},
position = Position.Alone,
minHeight = 56.dp,
@@ -12,6 +12,7 @@ import de.jeanlucmakiola.calendula.ui.common.CalendarColorChip
import de.jeanlucmakiola.calendula.ui.common.CalendarView
import de.jeanlucmakiola.calendula.ui.common.accountGroupTitle
import de.jeanlucmakiola.calendula.ui.common.calendarsHiddenIn
import de.jeanlucmakiola.calendula.ui.common.label
import de.jeanlucmakiola.calendula.ui.common.orUnnamed
import de.jeanlucmakiola.floret.components.FullScreenPicker
import de.jeanlucmakiola.floret.components.GroupedHint
@@ -30,8 +31,9 @@ fun ViewCalendarsPicker(
onSetHidden: (calendarId: Long, hidden: Boolean) -> Unit,
onDismiss: () -> Unit,
) {
val viewName = view.label()
FullScreenPicker(
title = stringResource(R.string.view_calendars_title),
title = stringResource(R.string.view_hide_in_title, viewName),
onDismiss = onDismiss,
predictiveBack = true,
) {
@@ -42,7 +44,7 @@ fun ViewCalendarsPicker(
// Seeded once, then ahead of the store: the picker is the only
// writer while open, so a quick second tap still flips.
var hidden by remember(view) { mutableStateOf(state.hiddenViews.calendarsHiddenIn(view)) }
GroupedHint(stringResource(R.string.view_calendars_hint), verticalPadding = 8.dp)
GroupedHint(stringResource(R.string.view_calendars_named_hint, viewName), verticalPadding = 8.dp)
state.groups.forEach { group ->
GroupedSectionHeader(accountGroupTitle(group))
MultiOptionRows(
@@ -31,6 +31,7 @@ import de.jeanlucmakiola.calendula.ui.common.morphEvent
import de.jeanlucmakiola.calendula.ui.common.jumpToPage
import de.jeanlucmakiola.calendula.ui.common.rememberCalendarPageSpec
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.locale.capitalizeStart
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.drop
import androidx.compose.animation.ExperimentalSharedTransitionApi
@@ -798,7 +799,7 @@ internal fun WeekdayHeader(weekStart: DayOfWeek, showWeekNumbers: Boolean) {
val isWeekend = dow == DayOfWeek.SATURDAY || dow == DayOfWeek.SUNDAY
val javaDow = dow.toJavaDayOfWeek()
Text(
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale),
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
style = MaterialTheme.typography.labelMedium,
color = if (isWeekend) MaterialTheme.colorScheme.onSurfaceVariant
else MaterialTheme.colorScheme.onSurface,
@@ -2842,6 +2843,7 @@ private fun shortMonthName(date: LocalDate): String {
return remember(date.month, locale) {
date.month.toJavaMonth()
.getDisplayName(JavaTextStyle.SHORT, locale)
.capitalizeStart(locale)
}
}
@@ -88,6 +88,7 @@ import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.SnackChip
import de.jeanlucmakiola.floret.components.SnackChipHeight
import de.jeanlucmakiola.floret.components.SnackChipMargin
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.calendula.ui.common.EventDimAlpha
@@ -470,6 +471,7 @@ private fun monthLabel(month: SearchMonth): String {
return remember(month.year, month.monthNumber, locale) {
localizedDateFormatter(locale, "LLLLy")
.format(java.time.LocalDate.of(month.year, month.monthNumber, 1))
.capitalizeStart(locale)
}
}
@@ -4,6 +4,7 @@ import de.jeanlucmakiola.floret.identity.collapseExit
import de.jeanlucmakiola.floret.identity.expandEnter
import androidx.compose.foundation.layout.Column
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.EnterExitState
import android.Manifest
import android.content.Context
import android.content.Intent
@@ -19,10 +20,13 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.relocation.BringIntoViewRequester
import androidx.compose.foundation.relocation.bringIntoViewRequester
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
import androidx.compose.material.icons.automirrored.filled.OpenInNew
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.NotificationsActive
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -108,6 +112,7 @@ internal fun NotificationsScreen(
var showFixedDefault by remember { mutableStateOf(false) }
var showDigestDay by remember { mutableStateOf(false) }
var showDigestTime by remember { mutableStateOf(false) }
var revealDigest by rememberSaveable { mutableStateOf(false) }
val scope = rememberCoroutineScope()
val channelStatus by viewModel.channelStatus.collectAsStateWithLifecycle()
val digestBlocked by viewModel.digestBlocked.collectAsStateWithLifecycle()
@@ -193,9 +198,14 @@ internal fun NotificationsScreen(
Spacer(Modifier.height(24.dp))
DailyDigestRows(
reveal = revealDigest,
onRevealed = { revealDigest = false },
digest = state.dailyDigest,
blocked = channelStatus.appBlocked || digestBlocked,
onEnable = toggleDigest,
onEnable = {
revealDigest = false
toggleDigest(it)
},
onPickDay = { showDigestDay = true },
onPickTime = { showDigestTime = true },
onOpenSound = {
@@ -257,6 +267,29 @@ internal fun NotificationsScreen(
selected = state.defaultFixedTimeReminder?.let { FixedTimeOverride.At(it) } ?: FixedTimeOverride.Off,
onSelect = { viewModel.setDefaultFixedTimeReminder((it as? FixedTimeOverride.At)?.reminder) },
onDismiss = { showFixedDefault = false },
footer = { dismiss ->
// For those after one list of the day's events (#459).
if (!state.dailyDigest.enabled) {
Spacer(Modifier.height(24.dp))
GroupedRow(
title = stringResource(R.string.settings_digest_turn_on),
summary = stringResource(R.string.settings_digest_hint),
position = Position.Alone,
leading = {
Icon(
imageVector = Icons.Outlined.NotificationsActive,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
revealDigest = true
toggleDigest(true)
dismiss()
},
)
}
},
)
}
if (showDigestDay) {
@@ -328,7 +361,8 @@ internal fun NotificationsScreen(
/**
* The daily summary (#459): its switch, and once on, which day it lists, when,
* and its channel's system settings.
* and its channel's system settings. With [reveal], the block scrolls into view
* once those rows have expanded, then reports [onRevealed].
*/
@Composable
private fun DailyDigestRows(
@@ -338,47 +372,59 @@ private fun DailyDigestRows(
onPickDay: () -> Unit,
onPickTime: () -> Unit,
onOpenSound: () -> Unit,
reveal: Boolean,
onRevealed: () -> Unit,
) {
GroupedSwitchRow(
title = stringResource(R.string.settings_digest),
checked = digest.enabled,
onCheckedChange = onEnable,
summary = if (digest.enabled) {
stringResource(
R.string.settings_digest_summary,
stringResource(digestDayLabel(digest.day)),
settingsTimeOfDay(digest.timeMinutes),
)
} else {
stringResource(R.string.settings_digest_hint)
},
position = if (digest.enabled) Position.Top else Position.Alone,
)
AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) {
Column {
GroupedRow(
title = stringResource(R.string.settings_digest_day),
summary = stringResource(digestDayLabel(digest.day)),
position = Position.Middle,
onClick = onPickDay,
)
GroupedRow(
title = stringResource(R.string.settings_digest_time),
summary = settingsTimeOfDay(digest.timeMinutes),
position = Position.Middle,
onClick = onPickTime,
)
GroupedRow(
title = stringResource(R.string.settings_notification_sound),
summary = if (blocked) {
stringResource(R.string.settings_notifications_blocked_hint)
} else {
stringResource(R.string.settings_digest_sound_hint)
},
position = Position.Bottom,
trailing = { ExternalLinkIcon() },
onClick = onOpenSound,
)
val requester = remember { BringIntoViewRequester() }
Column(Modifier.bringIntoViewRequester(requester)) {
GroupedSwitchRow(
title = stringResource(R.string.settings_digest),
checked = digest.enabled,
onCheckedChange = onEnable,
summary = if (digest.enabled) {
stringResource(
R.string.settings_digest_summary,
stringResource(digestDayLabel(digest.day)),
settingsTimeOfDay(digest.timeMinutes),
)
} else {
stringResource(R.string.settings_digest_hint)
},
position = if (digest.enabled) Position.Top else Position.Alone,
)
AnimatedVisibility(visible = digest.enabled, enter = expandEnter(), exit = collapseExit()) {
val settled = !transition.isRunning && transition.currentState == EnterExitState.Visible
LaunchedEffect(settled, reveal) {
if (settled && reveal) {
requester.bringIntoView()
onRevealed()
}
}
Column {
GroupedRow(
title = stringResource(R.string.settings_digest_day),
summary = stringResource(digestDayLabel(digest.day)),
position = Position.Middle,
onClick = onPickDay,
)
GroupedRow(
title = stringResource(R.string.settings_digest_time),
summary = settingsTimeOfDay(digest.timeMinutes),
position = Position.Middle,
onClick = onPickTime,
)
GroupedRow(
title = stringResource(R.string.settings_notification_sound),
summary = if (blocked) {
stringResource(R.string.settings_notifications_blocked_hint)
} else {
stringResource(R.string.settings_digest_sound_hint)
},
position = Position.Bottom,
trailing = { ExternalLinkIcon() },
onClick = onOpenSound,
)
}
}
}
}
@@ -53,6 +53,7 @@ import de.jeanlucmakiola.floret.components.OptionPicker
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.ReorderableColumn
import de.jeanlucmakiola.floret.components.ReorderableRowHeight
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import kotlinx.datetime.DayOfWeek
import java.time.format.TextStyle as JavaTextStyle
@@ -104,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 },
)
@@ -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) {
@@ -21,6 +21,7 @@ import de.jeanlucmakiola.calendula.ui.common.rememberViewSwitchSpec
import de.jeanlucmakiola.calendula.ui.common.jumpToPage
import de.jeanlucmakiola.calendula.ui.common.pagedHeight
import de.jeanlucmakiola.floret.identity.LocalFloretDarkTheme
import de.jeanlucmakiola.floret.locale.capitalizeStart
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.drop
import androidx.compose.foundation.background
@@ -1106,7 +1107,7 @@ private fun WeekDayHeader(
) {
// One line, as the gutter cell beside it assumes (see WeekNumberCell).
Text(
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale),
text = javaDow.getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
style = MaterialTheme.typography.labelSmall,
maxLines = 1,
overflow = TextOverflow.Clip,
@@ -11,6 +11,7 @@ import de.jeanlucmakiola.calendula.ui.agenda.agendaTimeLabel
import de.jeanlucmakiola.calendula.ui.common.formatTimeOfDay
import de.jeanlucmakiola.floret.glance.LocalWidgetBackground
import de.jeanlucmakiola.floret.glance.WidgetBackground
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
@@ -55,6 +55,7 @@ import de.jeanlucmakiola.calendula.domain.hasEnded
import de.jeanlucmakiola.calendula.ui.agenda.anchorTodayIfMissing
import de.jeanlucmakiola.calendula.ui.common.CalendarView
import de.jeanlucmakiola.calendula.ui.common.formatCalendarTitle
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.calendula.widget.widgetEventFill
import de.jeanlucmakiola.calendula.ui.common.eventAccent
@@ -669,7 +670,7 @@ private fun agendaDayLabel(context: Context, date: LocalDate, today: LocalDate):
val java = java.time.LocalDate.of(date.year, date.month.ordinal + 1, date.day)
// Weekday + date in the locale's own field order (compact: no year), rather
// than a hardcoded day-month layout.
val formatted = localizedDateFormatter(locale, if (date.year == today.year) "EEEdMMM" else "EEEdMMMy").format(java)
val formatted = localizedDateFormatter(locale, if (date.year == today.year) "EEEdMMM" else "EEEdMMMy").format(java).capitalizeStart(locale)
return if (relative != null) "$relative · $formatted" else formatted
}
@@ -680,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())
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,
@@ -38,6 +38,7 @@ import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.GroupedSectionHeader
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.currentLocale
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.TimeZone
@@ -149,7 +150,7 @@ private fun CountdownEventPicker(
val formatter = remember(locale) { localizedDateFormatter(locale, "EEEdMMMy") }
LazyColumn(contentPadding = PaddingValues(top = 8.dp, bottom = 24.dp)) {
itemsIndexed(matches, key = { _, it -> it.event.eventId }) { index, candidate ->
val date = formatter.format(candidate.event.start.toLocalDateTime(candidate.event.dateZone(zone)).date.toJavaLocalDate())
val date = formatter.format(candidate.event.start.toLocalDateTime(candidate.event.dateZone(zone)).date.toJavaLocalDate()).capitalizeStart(locale)
GroupedRow(
title = candidate.event.title.ifBlank { stringResource(R.string.event_untitled) },
summary = if (candidate.repeats) stringResource(R.string.widget_config_countdown_repeats, date) else date,
@@ -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)}"
}
}
@@ -45,6 +45,7 @@ import de.jeanlucmakiola.floret.glance.WidgetShapedBox
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.LocalDate
@@ -83,6 +83,7 @@ import de.jeanlucmakiola.calendula.widget.widgetCardColor
import de.jeanlucmakiola.calendula.widget.widgetEntryPoint
import de.jeanlucmakiola.calendula.widget.widgetSettings
import de.jeanlucmakiola.calendula.widget.widgetState
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import kotlinx.datetime.toJavaLocalDate
import de.jeanlucmakiola.calendula.widget.widgetTimeLabel
@@ -417,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())
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
@@ -73,6 +73,7 @@ import de.jeanlucmakiola.floret.glance.WidgetMessage
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
@@ -251,7 +252,7 @@ private fun TodayPill(today: LocalDate) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale),
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onPrimary, fontSize = 11.sp, textAlign = TextAlign.Center),
)
@@ -60,6 +60,7 @@ import de.jeanlucmakiola.floret.glance.WidgetMessage
import de.jeanlucmakiola.floret.glance.currentRefreshStamp
import de.jeanlucmakiola.floret.glance.refreshStamp
import de.jeanlucmakiola.floret.glance.wallpaperBacking
import de.jeanlucmakiola.floret.locale.capitalizeStart
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.LocalDate
@@ -137,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),
@@ -170,12 +171,12 @@ private fun DateHeader(today: LocalDate, height: Dp) {
Spacer(GlanceModifier.width(8.dp))
Column {
Text(
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.FULL, locale),
text = today.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.FULL, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onSurface, fontSize = 13.sp, fontWeight = FontWeight.Medium),
)
Text(
text = java.time.Month.of(today.month.ordinal + 1).getDisplayName(JavaTextStyle.FULL_STANDALONE, locale),
text = java.time.Month.of(today.month.ordinal + 1).getDisplayName(JavaTextStyle.FULL_STANDALONE, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = GlanceTheme.colors.onSurfaceVariant, fontSize = 12.sp),
)
@@ -63,6 +63,7 @@ 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.locale.localizedDateFormatter
import de.jeanlucmakiola.floret.prefs.ThemeMode
import kotlinx.datetime.DateTimeUnit
@@ -164,7 +165,7 @@ private fun DayTile(date: LocalDate, data: DaysWidgetData.Ready) {
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = date.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale),
text = date.dayOfWeek.toJavaDayOfWeek().getDisplayName(JavaTextStyle.SHORT, locale).capitalizeStart(locale),
maxLines = 1,
style = TextStyle(color = ink, fontSize = 11.sp, textAlign = TextAlign.Center),
)
+15 -7
View File
@@ -808,6 +808,7 @@
<string name="settings_fixed_reminder_hint">Added to new timed events, e.g. the evening before. It follows the event when you move it to another time.</string>
<!-- Daily summary notification (#459) -->
<string name="settings_digest">Daily summary</string>
<string name="settings_digest_turn_on">Turn on daily summary</string>
<string name="settings_digest_hint">One notification listing a day\'s events</string>
<!-- %1$s is settings_digest_day_today/tomorrow, %2$s a clock time. -->
<string name="settings_digest_summary">%1$s at %2$s</string>
@@ -967,14 +968,19 @@
<string name="calendars_hide_in_views_hint">Events from “%1$s” stay out of the views checked here. Reminders, search and widgets still include them.</string>
<string name="calendars_hide_in_views_none">Shown in every view</string>
<string name="calendars_hidden_in">Hidden in %1$s</string>
<string name="filter_hidden_in_view">Hidden in this view</string>
<string name="view_calendars_title">Hide in this view</string>
<plurals name="drawer_hidden_in_view_count">
<item quantity="one">%d calendar hidden in this view</item>
<item quantity="other">%d calendars hidden in this view</item>
<!-- %1$s: the quoted view name, as in view_hide_in_title. -->
<string name="filter_hidden_in_named_view">Hidden in “%1$s” view</string>
<!-- %1$s is the view's name as the view switcher shows it, e.g. "Month" or "3 days". It is a quoted label: phrase around it instead of inflecting it. -->
<string name="view_hide_in_title">Hide in “%1$s” view</string>
<!-- %2$s: the quoted view name, as in view_hide_in_title. -->
<plurals name="drawer_hidden_in_named_view_count">
<item quantity="one">%1$d calendar hidden in “%2$s” view</item>
<item quantity="other">%1$d calendars hidden in “%2$s” view</item>
</plurals>
<string name="drawer_hidden_in_view_none">Leave calendars out of this view only</string>
<string name="view_calendars_hint">Checked calendars stay out of this view only. Reminders, search and widgets still include them.</string>
<!-- %1$s: the quoted view name, as in view_hide_in_title. -->
<string name="drawer_hidden_in_named_view_none">Leave calendars out of the “%1$s” view only</string>
<!-- %1$s: the quoted view name, as in view_hide_in_title. -->
<string name="view_calendars_named_hint">Checked calendars stay out of the “%1$s” view only. Reminders, search and widgets still include them.</string>
<string name="view_calendars_hidden_everywhere">Hidden in every view from the menu</string>
<string name="color_name_mauve">Mauve</string>
<string name="color_name_red">Red</string>
@@ -1034,8 +1040,10 @@
<string name="calendars_auto_backup_interval">Interval</string>
<string name="calendars_auto_backup_every">Every %1$s</string>
<string name="calendars_auto_backup_interval_min">Minimum 30 minutes.</string>
<string name="calendars_auto_backup_interval_off">Off, only after changes</string>
<string name="calendars_auto_backup_on_change">Also back up after changes</string>
<string name="calendars_auto_backup_on_change_summary">Updates the undated copy a few minutes after events change. Dated backups stay on the interval.</string>
<string name="calendars_auto_backup_on_change_only_summary">Updates the undated copy a few minutes after events change. No dated backups.</string>
<string name="calendars_auto_backup_calendars">Calendars</string>
<plurals name="calendars_auto_backup_calendars_count">
<item quantity="one">%d calendar</item>
@@ -13,6 +13,7 @@ import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.LocalTime
import kotlinx.datetime.UtcOffset
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.time.ZoneId
import kotlin.time.Instant
@@ -500,6 +501,58 @@ class EventWriteMapperTest {
.isEqualTo(CalendarContract.Events.STATUS_CANCELED)
}
// --- seriesDuration (#502) ---
@Test
fun `series duration prefers the expanded occurrence over dtend`() {
// DTEND as the end of the whole series must not stretch every occurrence.
assertThat(seriesDuration(1_000_000L, 9_000_000_000L, 3_600_000L, isAllDay = false)).isEqualTo("P3600S")
}
@Test
fun `series duration falls back to dtend when it lies after dtstart`() {
assertThat(seriesDuration(1_000_000L, 8_200_000L, null, isAllDay = false)).isEqualTo("P7200S")
}
@Test
fun `series duration ignores a zero dtend and uses the occurrence span`() {
assertThat(seriesDuration(1_790_852_400_000L, 0L, 7_200_000L, isAllDay = false)).isEqualTo("P7200S")
}
@Test
fun `series duration gives up rather than guessing`() {
assertThat(seriesDuration(1_000L, 0L, null, isAllDay = false)).isNull()
assertThat(seriesDuration(1_000L, null, null, isAllDay = true)).isNull()
}
@Test
fun `all-day series duration rounds to whole days`() {
// 47 h: a two-day occurrence read across a DST change.
assertThat(seriesDuration(0L, null, 47L * 3_600_000L, isAllDay = true)).isEqualTo("P2D")
}
@Test
fun `series duration keeps a zero length the provider already shows`() {
assertThat(seriesDuration(1_000L, 0L, 0L, isAllDay = false)).isEqualTo("P0S")
assertThat(seriesDuration(1_000L, 1_000L, null, isAllDay = true)).isEqualTo("P1D")
}
@Test
fun `exdate drop clears a stray dtend on the series`() {
val values = buildOccurrenceExdateValues(
existingExdate = null,
occurrenceMillis = 1_784_102_400_000L,
dtStartMillis = 1_783_929_600_000L,
rrule = "FREQ=DAILY;COUNT=5",
rdate = null,
duration = "PT1H",
timezone = "Europe/Berlin",
allDay = 0,
)
assertThat(values).containsKey(CalendarContract.Events.DTEND)
assertThat(values[CalendarContract.Events.DTEND]).isNull()
}
// --- buildOccurrenceExdateValues ("delete only this event", no _sync_id) ---
@Test
@@ -1194,6 +1247,14 @@ class EventWriteMapperTest {
description = "",
)
@Test
fun `moved series with a zero dtend and no duration is refused, not copied broken`() {
val snapshot = masterSnapshot(dtEndMillis = 0L, rrule = "FREQ=WEEKLY;BYDAY=TH")
assertThrows<WriteFailedException> {
buildMovedMasterValues(snapshot, targetCalendarId = 9L, uid = "u@calendula")
}
}
@Test
fun `moved one-off carries target calendar, uid and DTEND but no recurrence`() {
val values = buildMovedMasterValues(masterSnapshot(), targetCalendarId = 9L, uid = "u@calendula")
@@ -5,6 +5,7 @@ import de.jeanlucmakiola.calendula.testSettings
import de.jeanlucmakiola.floret.reminders.ReminderOverride
import androidx.compose.ui.unit.dp
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import com.google.common.truth.Truth.assertThat
import de.jeanlucmakiola.calendula.domain.CalendarSource
@@ -932,6 +933,71 @@ class SettingsPrefsTest {
assertThat(prefs.autoBackupKeep.first()).isEqualTo(10)
}
@Test
fun `the backup interval is on by default and can only go off alongside after-change backups`(@TempDir tempDir: Path) = runTest {
val prefs = testSettings(tempDir)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
prefs.setAutoBackupScheduled(false)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
prefs.setAutoBackupOnChange(true)
prefs.setAutoBackupScheduled(false)
assertThat(prefs.autoBackupScheduled.first()).isFalse()
prefs.setAutoBackupScheduled(true)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
}
@Test
fun `turning after-change backups off brings the interval back for good`(@TempDir tempDir: Path) = runTest {
val prefs = testSettings(tempDir)
prefs.setAutoBackupIntervalMinutes(6 * 60L)
prefs.setAutoBackupOnChange(true)
prefs.setAutoBackupScheduled(false)
prefs.setAutoBackupOnChange(false)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
assertThat(prefs.autoBackupIntervalMinutes.first()).isEqualTo(6 * 60L)
prefs.setAutoBackupOnChange(true)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
}
@Test
fun `the interval setters report whether they switched it`(@TempDir tempDir: Path) = runTest {
val prefs = testSettings(tempDir)
assertThat(prefs.setAutoBackupScheduled(false)).isFalse()
assertThat(prefs.setAutoBackupOnChange(true)).isFalse()
assertThat(prefs.setAutoBackupScheduled(false)).isTrue()
assertThat(prefs.setAutoBackupScheduled(false)).isFalse()
assertThat(prefs.setAutoBackupOnChange(false)).isTrue()
assertThat(prefs.autoBackupOnChangeAndScheduled.first()).isEqualTo(false to true)
}
@Test
fun `switching the interval off without after-change backups leaves nothing behind`(@TempDir tempDir: Path) = runTest {
val prefs = testSettings(tempDir)
prefs.setAutoBackupScheduled(false)
prefs.setAutoBackupOnChange(true)
assertThat(prefs.autoBackupScheduled.first()).isTrue()
}
@Test
fun `an interval-off stored without after-change backups doesn't stick once they go on`(@TempDir tempDir: Path) = runTest {
val store = testDataStore(tempDir, "test_settings")
val prefs = SettingsPrefs(store)
store.updateData { p ->
val m = p.toMutablePreferences()
m[booleanPreferencesKey("auto_backup_scheduled")] = false
m
}
assertThat(prefs.autoBackupScheduled.first()).isTrue()
assertThat(prefs.setAutoBackupOnChange(true)).isFalse()
assertThat(prefs.autoBackupScheduled.first()).isTrue()
}
@Test
fun `a pre-411 install adopts its old file when the layout is pinned in place`(@TempDir tempDir: Path) = runTest {
val store = testDataStore(tempDir, "test_settings")
@@ -107,6 +107,26 @@ class BackupPlanTest {
.containsExactly("Fitness", "Fitness-20").inOrder()
}
@Test
fun `a stable copy kept for a calendar out of the backup isn't taken over or left blocking`() {
val ledger = mapOf(latestLedgerKey("9") to listOf("Fitness.ics"))
val target = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, setOf("Fitness.ics")).single()
assertThat(target.baseName).isEqualTo("Fitness-20")
val plan = planBackupFiles(listOf(target), ledger, setOf("Fitness.ics"), at, keep = 3).single()
assertThat(plan.backedUp(intervalOn = false)).isTrue()
val gone = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, existing = emptySet()).single()
assertThat(gone.baseName).isEqualTo("Fitness")
}
@Test
fun `a series writing under its id suffix keeps it once the clash is gone`() {
val ledger = mapOf(latestLedgerKey("20") to listOf("Fitness-20.ics"))
val target = backupTargets(listOf(cal(20L, "Fitness")), combined = false, ledger, setOf("Fitness.ics", "Fitness-20.ics"))
.single()
assertThat(target.baseName).isEqualTo("Fitness-20")
}
@Test
fun `a calendar named like the combined file doesn't share its series`() {
val target = backupTargets(listOf(cal(4L, COMBINED_BACKUP_BASE)), combined = false).single()
@@ -402,4 +422,30 @@ class BackupPlanTest {
assertThat(one.inBackupOrder()).isEqualTo(other.inBackupOrder())
assertThat(one.inBackupOrder().map { it.uid }).containsExactly("a", "b").inOrder()
}
@Test
fun `the interval stays on unless after-change backups cover for it`() {
assertThat(backupIntervalOn(stored = true, onChange = false)).isTrue()
assertThat(backupIntervalOn(stored = false, onChange = false)).isTrue()
assertThat(backupIntervalOn(stored = true, onChange = true)).isTrue()
assertThat(backupIntervalOn(stored = false, onChange = true)).isFalse()
}
@Test
fun `only a run with the interval on writes dated files`() {
assertThat(backupRunLatestOnly(changeRun = false, intervalOn = true)).isFalse()
assertThat(backupRunLatestOnly(changeRun = true, intervalOn = true)).isTrue()
assertThat(backupRunLatestOnly(changeRun = false, intervalOn = false)).isTrue()
assertThat(backupRunLatestOnly(changeRun = true, intervalOn = false)).isTrue()
}
@Test
fun `without the interval a series whose stable name is the user's goes unbacked`() {
val free = planBackupFiles(listOf(work), emptyMap(), emptySet(), at, keep = 3).single()
val blocked = planBackupFiles(listOf(work), emptyMap(), setOf("Work.ics"), at, keep = 3).single()
assertThat(free.backedUp(intervalOn = false)).isTrue()
assertThat(blocked.backedUp(intervalOn = false)).isFalse()
assertThat(blocked.backedUp(intervalOn = true)).isTrue()
}
}
+16 -3
View File
@@ -420,8 +420,8 @@ separate in-app declutter that never touches reminders. Narrower still is the pe
(`SettingsPrefs.perCalendarHiddenViews`, #270): each view model asks for its
events through `instancesWithout(range, calendarsHiddenIn(view, …))`, which drops
the calendars hidden in that one view on top of the repository's filters; reminders, search and widgets read
the repository and never see it. The drawer's "Hide in this view" entry (#517) edits the same
set for the view on show, and the drawer's per-row "Hidden in this view" notes read it.
the repository and never see it. The drawer's "Hide in “<view>” view" entry (#517, #143) edits the same
set for the view on show, and the drawer's per-row "Hidden in “<view>” view" notes read it.
**A channel per calendar (#145).** `ReminderChannels` keeps one notification
channel per calendar, grouped by account (one that syncs no events only gets
@@ -630,7 +630,7 @@ process start (the boot receivers start one), without replacing a waiting watch.
Runs share the scheduled backup's lock. A change run only rewrites the stable
copies and never retries: the dated files and their retention stay on the
interval, so a day of edits can't rotate the history out. Every run that writes
something is recorded on the status line; the failure notification comes once
something, or fails to, is recorded on the status line; the failure notification comes once
per failure streak, as it reaches the threshold, and the next success of any run
clears it. Since the trigger fires for any provider change (reminders, other
calendars, sync bookkeeping), each series' file (events in a fixed order) is
@@ -642,6 +642,19 @@ rewritten. A copy that went missing is restored by the next run that lists the
folder; one a still-loading listing doesn't show, or one edited in place outside
the app, is left to the next scheduled run.
While the option is on, the interval itself can be switched off
(`auto_backup_scheduled`, read through `backupIntervalOn`, so it never counts as
off without the option): the periodic work is cancelled and no run writes or
prunes dated files. Run-now then rewrites every stable copy, change runs the
changed ones and any missing from a complete listing (checked even when no hash
moved, since no scheduled run would restore them), and a series whose stable
name a file of the user's holds counts as failed (not retried), since nothing
else backs it up. A change run fails on it again only once its content changed,
and while it stays unchanged doesn't record the run as a success either. Turning the option on or off sets the interval back
on, at the interval it had; any switch of the interval backs up right away.
What the text above leaves to the next scheduled run then waits for the next
run-now.
**A backup carries the series' deleted and moved occurrences.** `EXDATE` lives on
the master row and is part of `EventExportProjection`; `IcsWriter` marks an
all-day series' exclusions `VALUE=DATE`, because RFC 5545 ties `EXDATE`'s value
+10 -5
View File
@@ -53,6 +53,10 @@ Published version codes so far: `v0.1.0`→100 … `v2.0.0`→20000 …
`## [X.Y.Z] — <date>` heading (Keep a Changelog format). The text between
that heading and the next `## [` becomes both the Gitea release notes and
the F-Droid per-version changelog.
Entries are short bullets, one line each, ending with the issue refs —
e.g. `- Default calendar for new events ([#429])`. No bold lead-ins or
explanations; the issue has the details.
3. Bump the committed `versionName` (and `versionCode`, which
`scripts/version_info.sh` prints) in `app/build.gradle.kts` to the new version. **This bump is what triggers the
release** when the branch merges to `main`. Then write the per-version
@@ -121,11 +125,12 @@ and to the stable release.
1. **On `release/vX.Y.Z`**, with the features merged in, set
`versionName = "X.Y.Z-beta.1"` and the matching `versionCode`
(`scripts/version_info.sh` prints it; `2.23.0-beta.1` → `2230001`).
No What's New file — betas don't ship to the stores. Notes come from a
`## [X.Y.Z-beta.N]` section of `CHANGELOG.md` if you write one, otherwise
from `## [Unreleased]`. So keep the entries under `## [Unreleased]` while
betas are going out and only move them to `## [X.Y.Z]` when going stable:
once they're moved, a beta's notes come out empty.
No What's New file — betas don't ship to the stores. Write a
`## [X.Y.Z-beta.N] — <date>` section in `CHANGELOG.md` listing **only what
changed since the previous beta** (beta.1 lists everything so far); the
notes come from it, falling back to `## [Unreleased]` if it's missing.
Keep `## [Unreleased]` as the running total for the stable release and
rename it to `## [X.Y.Z]` when going stable; the beta sections stay.
2. **Optionally verify it on a device** with `scripts/verify-release.sh`, as for
a stable release.
3. **Push the branch to Codeberg.** When it reaches Gitea, `beta.yaml` sees a
+1 -1
View File
@@ -58,7 +58,7 @@ e.g. `"theme_mode": "DARK"`, `"multi_day_count": 4`,
`"default_reminder_minutes": "10,60"`. Only keys that have been set are
written. `SettingsBackupSchema.plain` lists them: appearance, fonts,
views, the agenda screen, the event form and its default calendar, reminders
and the daily summary, automatic backup (switch, interval, layout, retention,
and the daily summary, automatic backup (switch, interval and whether it runs, layout, retention,
backup on change) and contact special dates (switch, types, title
templates, year).
+3 -2
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Prints the release notes for VERSION from CHANGELOG.md. A beta without its own
# section falls back to [Unreleased], under a line saying what a beta is.
# [#N] issue refs become plain #N so the forge links them.
#
# scripts/release_notes.sh 2.22.4 > release-notes.md
set -euo pipefail
@@ -12,13 +13,13 @@ section() {
awk -v ver="$1" '
$0 ~ "^## \\[" ver "\\]" { flag = 1; next }
/^## \[/ { flag = 0 }
flag' CHANGELOG.md | sed -e '/./,$!d'
flag' CHANGELOG.md | sed -E -e '/./,$!d' -e 's/\[#([0-9]+)\]/#\1/g'
}
NOTES=$(section "$VERSION")
if [[ "$VERSION" == *-beta.* ]]; then
[ -n "$NOTES" ] || NOTES=$(section Unreleased)
printf '%s\n\n' "**Beta of ${VERSION%%-*}, for testing.** It updates in place to later betas and to the stable release. Obtainium only offers betas with *Include prereleases* switched on; F-Droid and Play never get them."
printf '%s\n\n' "**Beta of ${VERSION%%-*}, for testing.** Updates in place; not on F-Droid or Play (Obtainium: enable *Include prereleases*)."
fi
if [ -n "$NOTES" ]; then
printf '%s\n' "$NOTES"