summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-12 06:21:40 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-12 06:21:40 +0000
commit84252756c687044d73a0ea5cebf8088c7c9ed3e8 (patch)
tree0f76a627ee9fb4037d83a57270a3426694b69c2f /android
parenta43cc7b8f007a86742756bd4b67f9ba1c204bbd0 (diff)
fix(widget): pin all-day calendar events to the top instead of losing them
WidgetItem.isAllDay was carried by the client's data model but nothing ever read it. All-day events had no Start at all, so they fell into the same floating-task queue as ordinary untimed tasks; if enough tasks were ahead of one in the queue, SlotPacker could assign it an hour slot past the visible grid range entirely -- not merely unpinned, actually invisible. Server: TimelineItemToWidgetItem now populates Start for all-day CALENDAR EVENTS specifically (their real event date), while leaving undated doot/gtask tasks -- also flagged IsAllDay as a "no specific time" fallback, a different concept -- on the existing nil-Start floating behavior. Client: all-day events are filtered out of the hourly grid/floating-task pipeline entirely, bucketed by day using the new Start date, and rendered in a new pinned AllDayRow section right after the TODAY/TOMORROW headers.
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt60
1 files changed, 53 insertions, 7 deletions
diff --git a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
index d8f1140..7674ddb 100644
--- a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
+++ b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
@@ -63,17 +63,39 @@ class DootWidget : GlanceAppWidget() {
fun WidgetRoot(items: List<WidgetItem>, now: Instant) {
val zone = ZoneId.systemDefault()
val nowZoned: ZonedDateTime = now.atZone(zone)
- val allScheduled = items.filter { it.start != null }.sortedBy { Instant.parse(it.start!!) }
+ val todayStart = nowZoned.toLocalDate().atStartOfDay(zone).toInstant()
+ val tomorrowStart = nowZoned.toLocalDate().plusDays(1).atStartOfDay(zone).toInstant()
+ val tomorrowEnd = tomorrowStart.plus(1, ChronoUnit.DAYS)
+
+ // All-day CALENDAR EVENTS (isAllDay && type == "event" -- see
+ // TimelineItemToWidgetItem's doc comment for why undated doot/gtask
+ // tasks, which are also flagged isAllDay, are deliberately excluded
+ // here) are pinned to the top of their day's section and never compete
+ // for hourly grid slots or floating-task packing. Previously they had
+ // no Start at all and fell into the same floating-task queue as
+ // ordinary untimed tasks, where enough tasks ahead of them in the queue
+ // could push their assigned slot past the visible grid range entirely
+ // -- not merely unpinned, actually invisible.
+ val allDayEvents = items.filter { it.isAllDay && it.type == "event" }
+ val rest = items.filter { !(it.isAllDay && it.type == "event") }
+ val todayAllDay = allDayEvents.filter { item ->
+ val s = item.start?.let { runCatching { Instant.parse(it) }.getOrNull() }
+ s == null || (s >= todayStart && s < tomorrowStart)
+ }
+ val tomorrowAllDay = allDayEvents.filter { item ->
+ val s = item.start?.let { runCatching { Instant.parse(it) }.getOrNull() }
+ s != null && s >= tomorrowStart && s < tomorrowEnd
+ }
+
+ val allScheduled = rest.filter { it.start != null }.sortedBy { Instant.parse(it.start!!) }
// Past tasks float at now (before untimed tasks); past events stay in the grid at 50% alpha
val pastTasks = allScheduled.filter { it.type == "task" && Instant.parse(it.start!!) < now }
val scheduledEvents = allScheduled.filter { it.type != "task" || Instant.parse(it.start!!) >= now }
- val floating = items.filter { it.start == null }
+ val floating = rest.filter { it.start == null }
val fragments = SlotPacker.pack(pastTasks + floating, scheduledEvents, now)
val gridStart = calcGridStart(scheduledEvents, nowZoned.hour)
val gridEnd = calcGridEnd(scheduledEvents, nowZoned.hour)
- val tomorrowStart = nowZoned.toLocalDate().plusDays(1).atStartOfDay(zone).toInstant()
- val tomorrowEnd = tomorrowStart.plus(1, ChronoUnit.DAYS)
val tomorrowItems = scheduledEvents
.filter { Instant.parse(it.start!!) >= tomorrowStart && Instant.parse(it.start!!) < tomorrowEnd }
val tomorrowFrags = fragments
@@ -96,17 +118,39 @@ fun WidgetRoot(items: List<WidgetItem>, now: Instant) {
)
}
+ todayAllDay.forEach { AllDayRow(it) }
+
for (hour in gridStart..gridEnd) {
HourRow(hour, nowZoned, scheduledEvents, fragments, zone)
}
- if (tomorrowItems.isNotEmpty() || tomorrowFrags.any { it.slots.isNotEmpty() }) {
- TomorrowSection(tomorrowItems, tomorrowFrags, zone)
+ if (tomorrowItems.isNotEmpty() || tomorrowFrags.any { it.slots.isNotEmpty() } || tomorrowAllDay.isNotEmpty()) {
+ TomorrowSection(tomorrowItems, tomorrowFrags, tomorrowAllDay, zone)
}
}
}
@Composable
+fun AllDayRow(event: WidgetItem) {
+ val color = sourceColor(event.source)
+ Row(
+ modifier = GlanceModifier
+ .fillMaxWidth()
+ .padding(vertical = 3.dp)
+ .clickable(actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(event.url.ifEmpty { "https://calendar.google.com" })))),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Box(modifier = GlanceModifier.width(3.dp).height(16.dp).background(color)) {}
+ Text(
+ text = event.title,
+ style = TextStyle(color = ColorProvider(Color.White.copy(alpha = 0.9f)), fontSize = 13.sp, fontWeight = FontWeight.Medium),
+ modifier = GlanceModifier.padding(start = 8.dp),
+ maxLines = 1
+ )
+ }
+}
+
+@Composable
fun HourRow(
hour: Int,
nowZoned: ZonedDateTime,
@@ -284,7 +328,7 @@ fun TaskRow(task: WidgetItem) {
}
@Composable
-fun TomorrowSection(items: List<WidgetItem>, fragments: List<TaskFragment>, zone: ZoneId) {
+fun TomorrowSection(items: List<WidgetItem>, fragments: List<TaskFragment>, allDayEvents: List<WidgetItem>, zone: ZoneId) {
Box(modifier = GlanceModifier.fillMaxWidth().height(1.dp).padding(vertical = 4.dp).background(Color(0x1AFFFFFF))) {}
Row(modifier = GlanceModifier.fillMaxWidth().padding(top = 6.dp, bottom = 2.dp)) {
@@ -298,6 +342,8 @@ fun TomorrowSection(items: List<WidgetItem>, fragments: List<TaskFragment>, zone
)
}
+ allDayEvents.forEach { AllDayRow(it) }
+
items.forEach { item ->
val isPast = false
if (item.type == "event") {