From c9cc40ff6004387149a39905acfaea722604edf0 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Fri, 23 Oct 2026 18:51:49 +0200 Subject: [PATCH] Month and day widget: compact month grid beside the selected day's events (#441) --- app/src/main/AndroidManifest.xml | 12 + .../calendula/widget/WidgetKind.kt | 9 + .../widget/config/WidgetConfigScreen.kt | 9 + .../widget/config/WidgetConfigViewModel.kt | 8 + .../calendula/widget/split/MonthDayWidget.kt | 440 ++++++++++++++++++ .../res/layout/widget_preview_month_day.xml | 48 ++ app/src/main/res/values/strings.xml | 2 + .../main/res/xml/appwidget_info_month_day.xml | 16 + .../widget/split/MonthGridDaysTest.kt | 24 + 9 files changed, 568 insertions(+) create mode 100644 app/src/main/java/de/jeanlucmakiola/calendula/widget/split/MonthDayWidget.kt create mode 100644 app/src/main/res/layout/widget_preview_month_day.xml create mode 100644 app/src/main/res/xml/appwidget_info_month_day.xml create mode 100644 app/src/test/java/de/jeanlucmakiola/calendula/widget/split/MonthGridDaysTest.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2247f05..71929e5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -429,6 +429,18 @@ android:name=".widget.countdown.CountdownTickReceiver" android:exported="false" /> + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3072061..a9f1e0e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -492,6 +492,8 @@ Couldn\'t load your events. %1$s · repeats + Calendula month and day + No events Refresh New event Open Calendula to grant calendar access diff --git a/app/src/main/res/xml/appwidget_info_month_day.xml b/app/src/main/res/xml/appwidget_info_month_day.xml new file mode 100644 index 0000000..244dbc7 --- /dev/null +++ b/app/src/main/res/xml/appwidget_info_month_day.xml @@ -0,0 +1,16 @@ + + diff --git a/app/src/test/java/de/jeanlucmakiola/calendula/widget/split/MonthGridDaysTest.kt b/app/src/test/java/de/jeanlucmakiola/calendula/widget/split/MonthGridDaysTest.kt new file mode 100644 index 0000000..40578e6 --- /dev/null +++ b/app/src/test/java/de/jeanlucmakiola/calendula/widget/split/MonthGridDaysTest.kt @@ -0,0 +1,24 @@ +package de.jeanlucmakiola.calendula.widget.split + +import com.google.common.truth.Truth.assertThat +import kotlinx.datetime.DayOfWeek +import kotlinx.datetime.LocalDate +import org.junit.jupiter.api.Test + +class MonthGridDaysTest { + + @Test + fun `whole weeks from the week start cover the month and no more`() { + // October 2026 starts on a Thursday and has 31 days. + val october = 2026 * 12 + 9 + val monday = monthGridDays(october, DayOfWeek.MONDAY) + assertThat(monday.first()).isEqualTo(LocalDate(2026, 9, 28)) + assertThat(monday.last()).isEqualTo(LocalDate(2026, 11, 1)) + assertThat(monday).hasSize(35) + + // February 2027 starts on a Monday and fills exactly four weeks. + val february = 2027 * 12 + 1 + assertThat(monthGridDays(february, DayOfWeek.MONDAY)).hasSize(28) + assertThat(monthGridDays(february, DayOfWeek.SUNDAY)).hasSize(35) + } +}