diff --git a/Apps/Calendar/README.md b/Apps/Calendar/README.md index ed7fb95..5f9ff11 100644 --- a/Apps/Calendar/README.md +++ b/Apps/Calendar/README.md @@ -6,10 +6,13 @@ Read-only CalDAV calendar viewer for Tactility. - Syncs events from a CalDAV calendar collection using an authenticated `REPORT` request - Downloads calendar events and caches them locally for subsequent app opens +- Loads large calendars while they download; events that don't repeat and ended over a year ago are left out, and the number of events is limited by the memory of the device - Shows next 30 days from cached event times and recurring events - Lets you configure a calendar collection URL, username and password - Stores account settings using Tactility preferences -- Provides a navigable month page, a full-screen agenda for the selected day, and a separate agenda page for the next 30 days +- Lists the next 30 days of events, grouped by day, from today or from any selected date +- Small screens show the list, with a week strip on touch devices (swipe to change week) and a full-screen month view +- Larger screens show the month next to the list ## Setup diff --git a/Apps/Calendar/main/Source/CalendarApp.cpp b/Apps/Calendar/main/Source/CalendarApp.cpp index 724fde9..62e66dd 100644 --- a/Apps/Calendar/main/Source/CalendarApp.cpp +++ b/Apps/Calendar/main/Source/CalendarApp.cpp @@ -1,15 +1,17 @@ #include "CalendarApp.h" +#include "DayButton.h" +#include "EventList.h" +#include "WeekStrip.h" + #include #include #include #include +#include #include #include -#include -#include -#include #include #include #include @@ -18,9 +20,11 @@ #include #include +#include #include #include #include +#include #include namespace { @@ -29,6 +33,11 @@ constexpr const char* APP_ID = "tactility.calendar"; constexpr const char* SETTINGS_FILE = "settings.properties"; constexpr uint32_t REQUEST_SAVE = 1U; constexpr uint32_t REQUEST_SYNC = 2U; +// Screens of at least this size show the month next to the list. +constexpr int32_t SPLIT_MIN_LONG_SIDE = 480; +constexpr int32_t SPLIT_MIN_SHORT_SIDE = 270; +// Horizontal movement on the week strip that counts as a swipe. +constexpr int32_t SWIPE_DISTANCE = 40; bool getAppFilePath(const char* filename, char* path, size_t size) { return app_paths_get_user_data_path(APP_ID, filename, path, size) == ERROR_NONE; @@ -55,29 +64,88 @@ void signalRequest(CalendarContext* context, uint32_t request) { } void invalidateCalendarData(CalendarContext* context); +void refreshEventList(CalendarContext* context); -void showSettings(CalendarContext* context, bool visible) { - context->settingsVisible = visible; - if (context->agendaPanel == nullptr || context->monthPanel == nullptr || - context->selectedDayPanel == nullptr || context->settingsPanel == nullptr) return; - if (visible) { - lv_obj_set_hidden(context->agendaPanel, true); - lv_obj_set_hidden(context->monthPanel, true); - lv_obj_set_hidden(context->selectedDayPanel, true); - lv_obj_set_hidden(context->settingsPanel, false); - } else { - lv_obj_set_hidden(context->settingsPanel, true); - lv_obj_set_hidden(context->agendaPanel, context->page != CalendarPage::Agenda); - lv_obj_set_hidden(context->monthPanel, - context->page != CalendarPage::Month || context->dayAgendaVisible); - lv_obj_set_hidden(context->selectedDayPanel, - context->page != CalendarPage::Month || !context->dayAgendaVisible); +CalendarDate selectedDate(const CalendarContext* context) { + return context->followToday ? context->shownToday : context->selectedDate; +} + +bool hasFullCalendar(const CalendarContext* context) { + return context->fullCalendarAvailable && + context->fullCalendarGeneration == context->settingsGeneration.load(); +} + +bool listVisible(const CalendarContext* context) { + return !context->settingsVisible && (context->splitLayout || context->page == CalendarPage::Agenda); +} + +// The full calendar, or else the upcoming report, which has the 30 days from its sync. nullptr without either. +const std::vector* knownEvents(const CalendarContext* context) { + if (hasFullCalendar(context)) return &context->events; + if (context->upcomingEventsGeneration == context->settingsGeneration.load() && + context->upcomingWindowStart[0] != '\0') { + return &context->upcomingEvents; } - if (!visible) { - lv_obj_t* focus = context->page == CalendarPage::Agenda ? context->agendaPanel - : context->dayAgendaVisible ? context->selectedDayEvents : context->monthGrid; - if (focus != nullptr) lv_group_focus_obj(focus); + return nullptr; +} + +void setToolbarButton(lv_obj_t* button, bool visible) { + lv_obj_set_hidden(button, !visible); +} + +void refreshToolbar(CalendarContext* context) { + if (context->toolbar == nullptr) return; + const bool content = !context->settingsVisible; + const bool monthPage = !context->splitLayout && context->page == CalendarPage::Month; + const bool monthShown = context->splitLayout || monthPage; + const CalendarDate today = context->shownToday; + const bool away = !context->followToday || + (monthShown && (context->displayYear != today.year || context->displayMonth != today.month)); + + setToolbarButton(context->todayButton, content && away); + setToolbarButton(context->previousButton, content && monthShown); + setToolbarButton(context->nextButton, content && monthShown); + setToolbarButton(context->viewButton, content && !context->splitLayout); + lv_label_set_text(lv_obj_get_child(context->viewButton, 0), + monthPage ? LVGL_ICON_SHARED_LISTS : LVGL_ICON_SHARED_CALENDAR_MONTH); + + std::string title = tr("Calendar"); + if (content && monthShown) { + title = calendarMonthLabel(context->displayYear, context->displayMonth); + } else if (content && context->weekStrip != nullptr) { + const CalendarDate selected = selectedDate(context); + title = calendarMonthLabel(selected.year, selected.month); + } else if (content && !context->followToday) { + // Without a grid or a strip, only the title shows which day was picked. + title = calendarDayLabel(context->selectedDate, today); } + // After the buttons, because the title takes the room that they leave. + lvgl_toolbar_set_title(context->toolbar, title.c_str()); +} + +void refreshVisibility(CalendarContext* context) { + if (context->contentPanel == nullptr || context->settingsPanel == nullptr) return; + lv_obj_set_hidden(context->contentPanel, context->settingsVisible); + lv_obj_set_hidden(context->settingsPanel, !context->settingsVisible); + if (!context->splitLayout) { + const bool monthPage = context->page == CalendarPage::Month; + lv_obj_set_hidden(context->monthGrid.panel, !monthPage); + lv_obj_set_hidden(context->agendaPanel, monthPage); + if (context->weekStrip != nullptr) lv_obj_set_hidden(context->weekStrip, monthPage); + } + refreshToolbar(context); +} + +void focusContent(CalendarContext* context) { + lv_obj_t* focus = !context->splitLayout && context->page == CalendarPage::Month + ? context->monthGrid.days : context->agendaPanel; + if (focus != nullptr) lv_group_focus_obj(focus); +} + +void showSettings(CalendarContext* context, bool visible) { + context->settingsVisible = visible; + refreshVisibility(context); + if (!visible) focusContent(context); } void copySettingsFromWidgets(CalendarContext* context) { @@ -140,9 +208,80 @@ void onSaveSettings(lv_event_t* event) { signalRequest(context, REQUEST_SAVE); } -void refreshEventList(CalendarContext* context); -void refreshMonth(CalendarContext* context); -void refreshMonthAgenda(CalendarContext* context); +void onDayClicked(lv_event_t* event); + +void refreshMonth(CalendarContext* context) { + if (context->monthGrid.days == nullptr) return; + // A hidden grid has no size: it is filled when it is shown. + if (!context->splitLayout && context->page != CalendarPage::Month) return; + + std::vector monthEvents; + if (const auto* events = knownEvents(context)) { + calendarExpandEventsForMonth(*events, context->displayYear, + context->displayMonth, monthEvents); + } + monthGridFill(context->monthGrid, context->displayYear, context->displayMonth, monthEvents, + selectedDate(context), context->shownToday, onDayClicked, context); +} + +void refreshWeekStrip(CalendarContext* context) { + if (context->weekStrip == nullptr) return; + const CalendarDate selected = selectedDate(context); + const CalendarDate monday = calendarAddDays(selected, -calendarWeekday(selected)); + char start[11] {}; + char end[11] {}; + calendarDateKey(monday, start); + calendarDateKey(calendarAddDays(monday, 7), end); + std::vector weekEvents; + if (const auto* events = knownEvents(context)) { + calendarExpandEventsForDateRange(*events, start, end, weekEvents); + } + weekStripFill(context->weekStrip, weekEvents, selected, context->shownToday); +} + +void refreshAll(CalendarContext* context) { + refreshVisibility(context); + refreshMonth(context); + refreshWeekStrip(context); + refreshEventList(context); +} + +// Updates the date of "today", and what follows it. +bool updateToday(CalendarContext* context) { + const CalendarDate today = calendarToday(); + if (today == context->shownToday) return false; + // A month that the user browsed to stays. + const bool showsTodayMonth = context->shownToday.year == 0 || + (context->displayYear == context->shownToday.year && + context->displayMonth == context->shownToday.month); + context->shownToday = today; + if (context->followToday && showsTodayMonth) { + context->displayYear = today.year; + context->displayMonth = today.month; + } + return true; +} + +// Shows the selection without rebuilding the month grid, so that this can be called from a click on it. +void showSelection(CalendarContext* context) { + const CalendarDate date = selectedDate(context); + context->displayYear = date.year; + context->displayMonth = date.month; + if (context->monthGrid.days != nullptr) { + monthGridSelect(context->monthGrid, date, context->shownToday); + } + refreshWeekStrip(context); + refreshToolbar(context); + refreshEventList(context); + if (context->agendaPanel != nullptr) lv_obj_scroll_to_y(context->agendaPanel, 0, LV_ANIM_OFF); +} + +// A picked day is shown in full, also when it is today. +void selectDate(CalendarContext* context, const CalendarDate& date) { + context->followToday = false; + context->selectedDate = date; + showSelection(context); +} void invalidateCalendarData(CalendarContext* context) { if (context->statusTimer != nullptr) { @@ -163,38 +302,114 @@ void invalidateCalendarData(CalendarContext* context) { lv_obj_clear_flag(context->statusLabel, LV_OBJ_FLAG_HIDDEN); } refreshMonth(context); - refreshMonthAgenda(context); + refreshWeekStrip(context); refreshEventList(context); } void setCalendarPage(CalendarContext* context, CalendarPage page) { + const bool opensMonth = page == CalendarPage::Month && context->page != CalendarPage::Month; context->page = page; - context->dayAgendaVisible = false; - if (context->agendaPanel == nullptr || context->monthPanel == nullptr || - context->selectedDayPanel == nullptr || context->settingsPanel == nullptr) return; - if (context->settingsVisible) { - showSettings(context, false); - } - lv_obj_set_hidden(context->agendaPanel, page != CalendarPage::Agenda); - lv_obj_set_hidden(context->monthPanel, page != CalendarPage::Month); - lv_obj_set_hidden(context->selectedDayPanel, true); - lv_obj_set_hidden(context->settingsPanel, true); - if (page == CalendarPage::Month) { - refreshMonth(context); + context->settingsVisible = false; + if (opensMonth) { + const CalendarDate selected = selectedDate(context); + context->displayYear = selected.year; + context->displayMonth = selected.month; + } + refreshAll(context); + focusContent(context); +} + +void changeMonth(CalendarContext* context, int offset) { + const CalendarDate shown {context->displayYear, context->displayMonth, 1}; + const CalendarDate target = calendarAddMonths(shown, offset); + if (target.year < 1000 || target.year > 9999) return; + if (context->splitLayout) { + // The list is next to the grid, so the selection moves along. + selectDate(context, calendarAddMonths(selectedDate(context), offset)); } else { - refreshEventList(context); + context->displayYear = target.year; + context->displayMonth = target.month; + refreshToolbar(context); + } + refreshMonth(context); +} + +void onDayClicked(lv_event_t* event) { + auto* context = static_cast(lv_event_get_user_data(event)); + selectDate(context, dayButtonDate(lv_event_get_current_target_obj(event))); + if (!context->splitLayout && context->page == CalendarPage::Month) { + context->page = CalendarPage::Agenda; + refreshVisibility(context); + focusContent(context); + } +} + +void onStripPressed(lv_event_t* event) { + auto* context = static_cast(lv_event_get_user_data(event)); + lv_indev_t* indev = lv_indev_active(); + if (indev != nullptr) lv_indev_get_point(indev, &context->stripPressPoint); + context->stripPressDate = dayButtonDate(lv_event_get_current_target_obj(event)); +} + +// A day of the week strip was released: a horizontal swipe changes the week, anything else selects the day. +void onStripClicked(lv_event_t* event) { + auto* context = static_cast(lv_event_get_user_data(event)); + lv_indev_t* indev = lv_indev_active(); + if (indev != nullptr && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) { + lv_point_t point {}; + lv_indev_get_point(indev, &point); + const int32_t distance = point.x - context->stripPressPoint.x; + if (std::abs(distance) >= SWIPE_DISTANCE) { + selectDate(context, calendarAddDays(selectedDate(context), distance < 0 ? 7 : -7)); + return; + } + // The date under the finger when it came down: the strip moves along when the day changes. + selectDate(context, context->stripPressDate); + return; } - lv_group_focus_obj(page == CalendarPage::Month ? context->monthGrid : context->agendaPanel); + selectDate(context, dayButtonDate(lv_event_get_current_target_obj(event))); +} + +void onToday(lv_event_t* event) { + auto* context = static_cast(lv_event_get_user_data(event)); + context->followToday = true; + showSelection(context); + refreshMonth(context); + // The button hides itself. + focusContent(context); +} + +void onPreviousMonth(lv_event_t* event) { + changeMonth(static_cast(lv_event_get_user_data(event)), -1); +} + +void onNextMonth(lv_event_t* event) { + changeMonth(static_cast(lv_event_get_user_data(event)), 1); +} + +void onToggleView(lv_event_t* event) { + auto* context = static_cast(lv_event_get_user_data(event)); + setCalendarPage(context, context->page == CalendarPage::Month ? CalendarPage::Agenda : CalendarPage::Month); } void onPreviousPage(void* userData) { auto* context = static_cast(userData); - setCalendarPage(context, CalendarPage::Month); + if (context->splitLayout) { + if (context->settingsVisible) showSettings(context, false); + changeMonth(context, -1); + } else { + setCalendarPage(context, CalendarPage::Month); + } } void onNextPage(void* userData) { auto* context = static_cast(userData); - setCalendarPage(context, CalendarPage::Agenda); + if (context->splitLayout) { + if (context->settingsVisible) showSettings(context, false); + changeMonth(context, 1); + } else { + setCalendarPage(context, CalendarPage::Agenda); + } } void requestCalendarSync(CalendarContext* context) { @@ -235,26 +450,19 @@ void createButton(lv_obj_t* parent, const char* text, lv_event_cb_t callback, Ca lv_label_set_text(label, text); } -void makeArrowButtonCircular(lv_obj_t* button, lv_obj_t* label) { - lv_obj_update_layout(button); - const lv_coord_t diameter = std::max(lv_obj_get_width(button), lv_obj_get_height(button)); - lv_obj_set_size(button, diameter, diameter); - lv_obj_center(label); +lv_obj_t* addToolbarButton(lv_obj_t* toolbar, const char* icon, lv_event_cb_t callback, CalendarContext* context) { + lv_obj_t* button = lvgl_toolbar_add_text_button_action(toolbar, icon, callback, context); + lv_obj_set_style_text_font(button, lvgl_get_shared_icon_default_font(), 0); + return button; } -void refreshEventList(CalendarContext* context) { - if (context->agendaPanel == nullptr) return; - for (uint32_t count = lv_obj_get_child_count(context->agendaPanel); count > 0; --count) { - lv_obj_delete(lv_obj_get_child(context->agendaPanel, static_cast(count - 1))); - } - +// The list from today: from the full calendar, or else from the cached upcoming report. +void addUpcomingEvents(CalendarContext* context) { const bool covered = context->upcomingEventsGeneration == context->settingsGeneration.load() && calendarUpcomingWindowCoversNow(context->upcomingWindowStart, context->upcomingWindowEnd); - context->agendaUsesLocalCalendar = - context->fullCalendarAvailable && - context->fullCalendarGeneration == context->settingsGeneration.load(); + context->agendaUsesLocalCalendar = hasFullCalendar(context); context->agendaCoverageExpired = !covered; context->agendaWindowStart = 0; context->agendaNextRefresh = 0; @@ -263,10 +471,7 @@ void refreshEventList(CalendarContext* context) { if (context->agendaUsesLocalCalendar) { const int64_t now = static_cast(time(nullptr)); if (now < 1735689600) { - lv_obj_t* unavailable = lv_label_create(context->agendaPanel); - lv_label_set_text(unavailable, tr("Set the device clock to view the Agenda.")); - lv_obj_set_width(unavailable, LV_PCT(100)); - lv_label_set_long_mode(unavailable, LV_LABEL_LONG_MODE_WRAP); + eventListAddMessage(context->agendaPanel, tr("Set the device clock to view the Agenda.")); return; } context->agendaWindowStart = now; @@ -277,58 +482,92 @@ void refreshEventList(CalendarContext* context) { if (!complete && covered) { context->agendaUsesLocalCalendar = false; } else if (!complete) { - lv_obj_t* warning = lv_label_create(context->agendaPanel); - lv_label_set_text(warning, + eventListAddMessage(context->agendaPanel, tr("Some cached events cannot be calculated. Sync may be needed.")); - lv_obj_set_width(warning, LV_PCT(100)); - lv_label_set_long_mode(warning, LV_LABEL_LONG_MODE_WRAP); } if (context->agendaUsesLocalCalendar) shownEvents = &localEvents; } else if (!covered) { - lv_obj_t* unavailable = lv_label_create(context->agendaPanel); - lv_obj_set_width(unavailable, LV_PCT(100)); - lv_label_set_long_mode(unavailable, LV_LABEL_LONG_MODE_WRAP); - lv_label_set_text(unavailable, + eventListAddMessage(context->agendaPanel, tr("Cached Agenda does not cover the current 30-day window. Sync to refresh.")); return; } if (shownEvents->empty()) { - lv_obj_t* empty = lv_label_create(context->agendaPanel); - lv_label_set_text(empty, tr("No events found in the next 30 days.")); - lv_obj_set_width(empty, LV_PCT(100)); - lv_label_set_long_mode(empty, LV_LABEL_LONG_MODE_WRAP); + eventListAddMessage(context->agendaPanel, tr("No events found in the next 30 days.")); + return; + } + eventListAddEvents(context->agendaPanel, *shownEvents, context->shownToday, context->shownToday); +} + +// The list from a picked day. +void addEventsFrom(CalendarContext* context, const CalendarDate& date) { + const std::vector* source = knownEvents(context); + // The upcoming report only has the days of its window. + CalendarDate syncedUntil {}; + if (source != nullptr && !hasFullCalendar(context)) { + CalendarDate first {}; + char key[11] {}; + char firstKey[11] {}; + char lastKey[11] {}; + calendarDateKey(date, key); + if (sscanf(context->upcomingWindowStart, "%4d%2d%2d", &first.year, &first.month, &first.day) != 3 || + sscanf(context->upcomingWindowEnd, "%4d%2d%2d", &syncedUntil.year, &syncedUntil.month, + &syncedUntil.day) != 3) { + source = nullptr; + } else { + calendarDateKey(first, firstKey); + calendarDateKey(syncedUntil, lastKey); + if (strcmp(key, firstKey) < 0 || strcmp(key, lastKey) > 0) source = nullptr; + } + } + if (source == nullptr) { + eventListAddMessage(context->agendaPanel, tr("Sync to view other dates.")); return; } + char start[11] {}; + char end[11] {}; + calendarDateKey(date, start); + calendarDateKey(calendarAddDays(date, 30), end); + std::vector events; + const bool complete = calendarExpandEventsForDateRange(*source, start, end, events); + if (!complete) { + eventListAddMessage(context->agendaPanel, tr("Some recurring events could not be expanded.")); + } + if (!events.empty()) { + eventListAddEvents(context->agendaPanel, events, date, context->shownToday); + } else if (hasFullCalendar(context)) { + eventListAddMessage(context->agendaPanel, tr("No events in the 30 days from this date.")); + } + if (!hasFullCalendar(context)) { + std::string message = tr("Events are synced up to {date}."); + const size_t position = message.find("{date}"); + if (position != std::string::npos) { + message.replace(position, 6, calendarDayLabel(syncedUntil, context->shownToday)); + } + eventListAddMessage(context->agendaPanel, message.c_str()); + } +} - for (const CalendarEvent& event : *shownEvents) { - lv_obj_t* card = lvgl_card_create(context->agendaPanel); - lv_obj_set_width(card, LV_PCT(100)); - lv_obj_set_height(card, LV_SIZE_CONTENT); - lv_obj_set_flex_flow(card, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_gap(card, 4, 0); - lv_obj_set_scrollable(card, false); - lv_obj_set_clickable(card, false); - - lv_obj_t* date = lv_label_create(card); - lv_label_set_text(date, event.start); - lv_obj_set_width(date, LV_PCT(100)); - lv_label_set_long_mode(date, LV_LABEL_LONG_MODE_WRAP); - lv_obj_set_style_text_font(date, lvgl_get_text_font(FONT_SIZE_SMALL), 0); - - lv_obj_t* summary = lv_label_create(card); - lv_label_set_text(summary, event.summary); - lv_obj_set_width(summary, LV_PCT(100)); - lv_label_set_long_mode(summary, LV_LABEL_LONG_MODE_WRAP); +void refreshEventList(CalendarContext* context) { + if (context->agendaPanel == nullptr) return; + lv_obj_clean(context->agendaPanel); + // Without the full calendar, the upcoming report is all there is for today. + if (context->followToday || + (context->selectedDate == context->shownToday && !hasFullCalendar(context))) { + addUpcomingEvents(context); + } else { + addEventsFrom(context, context->selectedDate); } } void onAgendaCoverageTimer(lv_timer_t* timer) { auto* context = static_cast(lv_timer_get_user_data(timer)); - if (context->agendaPanel == nullptr || context->page != CalendarPage::Agenda || - context->dayAgendaVisible || context->settingsVisible) { + if (context->agendaPanel == nullptr) return; + if (updateToday(context)) { + refreshAll(context); return; } + if (!listVisible(context) || !context->followToday) return; const int64_t now = static_cast(time(nullptr)); if (context->agendaUsesLocalCalendar) { @@ -349,239 +588,6 @@ void onAgendaCoverageTimer(lv_timer_t* timer) { } } -void onDayClicked(lv_event_t* event); - -void setDaySelectedStyle(lv_obj_t* day, bool selected) { - lv_obj_set_style_border_width(day, selected ? 2 : 0, LV_PART_MAIN); - lv_obj_set_style_border_color(day, lvgl_theme_is_mono() - ? lv_obj_get_style_text_color(lv_obj_get_parent(day), LV_PART_MAIN) - : lv_theme_get_color_secondary(day), LV_PART_MAIN); -} - -void refreshMonth(CalendarContext* context) { - if (context->monthTitle == nullptr || context->monthGrid == nullptr) return; - - tm monthStart {}; - monthStart.tm_year = context->displayYear - 1900; - monthStart.tm_mon = context->displayMonth - 1; - monthStart.tm_mday = 1; - monthStart.tm_hour = 12; - monthStart.tm_isdst = -1; - mktime(&monthStart); - - const time_t monthStartTime = mktime(&monthStart); - tm first = *localtime(&monthStartTime); - const int offset = (first.tm_wday + 6) % 7; - tm lastDay = monthStart; - lastDay.tm_mon = context->displayMonth; - lastDay.tm_mday = 0; - mktime(&lastDay); - const int daysInMonth = lastDay.tm_mday; - - char title[32] {}; - strftime(title, sizeof(title), "%B %Y", &monthStart); - lv_label_set_text(context->monthTitle, title); - - std::vector monthEvents; - if (context->fullCalendarAvailable && - context->fullCalendarGeneration == context->settingsGeneration.load()) { - calendarExpandEventsForMonth(context->events, context->displayYear, - context->displayMonth, monthEvents); - } - - lv_obj_clean(context->monthGrid); - lv_obj_set_flex_flow(context->monthGrid, LV_FLEX_FLOW_ROW_WRAP); - lv_obj_set_style_pad_all(context->monthGrid, 4, LV_PART_MAIN); - lv_obj_set_style_pad_gap(context->monthGrid, 2, LV_PART_MAIN); - - for (int cell = 0; cell < 42; ++cell) { - const int dayNumber = cell - offset + 1; - if (dayNumber < 1 || dayNumber > daysInMonth) { - lv_obj_t* blank = lv_obj_create(context->monthGrid); - lv_obj_set_size(blank, LV_PCT(13), LV_PCT(15)); - lv_obj_set_style_border_width(blank, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(blank, LV_OPA_TRANSP, LV_PART_MAIN); - continue; - } - - lv_obj_t* day = lv_button_create(context->monthGrid); - lv_obj_set_size(day, LV_PCT(13), LV_PCT(15)); - lv_obj_set_flex_flow(day, LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(day, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_set_style_pad_gap(day, 2, LV_PART_MAIN); - lv_obj_set_style_pad_all(day, 2, LV_PART_MAIN); - lv_obj_set_style_border_width(day, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(day, LV_OPA_TRANSP, LV_PART_MAIN); - lv_obj_set_scroll_on_focus(day, true); - lv_obj_set_user_data(day, reinterpret_cast(static_cast(dayNumber))); - lv_obj_add_event_cb(day, onDayClicked, LV_EVENT_CLICKED, context); - - lv_obj_t* number = lv_label_create(day); - char numberText[3] {}; - snprintf(numberText, sizeof(numberText), "%d", dayNumber); - lv_label_set_text(number, numberText); - lv_obj_set_style_text_align(number, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN); - const lv_color_t textColor = lv_obj_get_style_text_color(context->monthGrid, LV_PART_MAIN); - lv_obj_set_style_text_color(number, textColor, LV_PART_MAIN); - - char dateText[11] {}; - calendarFormatDateKey(dateText, sizeof(dateText), - context->displayYear, context->displayMonth, dayNumber); - bool hasEvent = false; - for (size_t i = 0; i < monthEvents.size() && !hasEvent; ++i) { - hasEvent = calendarEventOverlapsDay(monthEvents[i], dateText); - } - if (hasEvent) { - lv_obj_t* marker = lv_obj_create(day); - lv_obj_set_size(marker, 6, 6); - lv_obj_set_style_radius(marker, LV_RADIUS_CIRCLE, LV_PART_MAIN); - lv_obj_set_style_border_width(marker, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(marker, LV_OPA_COVER, LV_PART_MAIN); - lv_obj_set_style_bg_color(marker, lvgl_theme_is_mono() - ? textColor : lv_theme_get_color_secondary(marker), LV_PART_MAIN); - } - const bool selected = context->selectedYear == context->displayYear && - context->selectedMonth == context->displayMonth && - context->selectedDay == dayNumber; - setDaySelectedStyle(day, selected); - } -} - -void refreshMonthAgenda(CalendarContext* context) { - if (context->selectedDayTitle == nullptr || context->selectedDayEvents == nullptr) return; - - char dateText[11] {}; - if (!calendarFormatDateKey(dateText, sizeof(dateText), - context->selectedYear, context->selectedMonth, context->selectedDay)) { - lv_label_set_text(context->selectedDayTitle, tr("Selected day")); - return; - } - lv_label_set_text(context->selectedDayTitle, dateText); - - lv_obj_clean(context->selectedDayEvents); - if (!context->fullCalendarAvailable || - context->fullCalendarGeneration != context->settingsGeneration.load()) { - lv_obj_t* unavailable = lv_label_create(context->selectedDayEvents); - lv_label_set_text(unavailable, tr("Calendar data unavailable. Sync to download the calendar.")); - lv_obj_set_width(unavailable, LV_PCT(100)); - lv_label_set_long_mode(unavailable, LV_LABEL_LONG_MODE_WRAP); - return; - } - - std::vector monthEvents; - const bool expansionComplete = calendarExpandEventsForMonth( - context->events, context->selectedYear, context->selectedMonth, monthEvents); - size_t shownCount = 0; - for (size_t i = 0; i < monthEvents.size(); ++i) { - if (calendarEventOverlapsDay(monthEvents[i], dateText)) { - ++shownCount; - } - } - if (shownCount == 0) { - lv_obj_t* empty = lv_label_create(context->selectedDayEvents); - lv_label_set_text(empty, expansionComplete - ? tr("No events scheduled for this day.") - : tr("No events found; some recurring events could not be expanded.")); - lv_obj_set_width(empty, LV_PCT(100)); - lv_label_set_long_mode(empty, LV_LABEL_LONG_MODE_WRAP); - return; - } - - for (size_t i = 0; i < monthEvents.size(); ++i) { - const CalendarEvent& event = monthEvents[i]; - if (!calendarEventOverlapsDay(event, dateText)) continue; - - lv_obj_t* card = lvgl_card_create(context->selectedDayEvents); - lv_obj_set_width(card, LV_PCT(100)); - lv_obj_set_height(card, LV_SIZE_CONTENT); - lv_obj_set_flex_flow(card, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_gap(card, 2, LV_PART_MAIN); - lv_obj_set_scrollable(card, false); - lv_obj_set_clickable(card, false); - - lv_obj_t* time = lv_label_create(card); - lv_label_set_text(time, event.start + 11); - lv_obj_set_width(time, LV_PCT(100)); - lv_obj_set_style_text_font(time, lvgl_get_text_font(FONT_SIZE_SMALL), LV_PART_MAIN); - - lv_obj_t* summary = lv_label_create(card); - lv_label_set_text(summary, event.summary); - lv_obj_set_width(summary, LV_PCT(100)); - lv_label_set_long_mode(summary, LV_LABEL_LONG_MODE_WRAP); - } - if (!expansionComplete) { - lv_obj_t* warning = lv_label_create(context->selectedDayEvents); - lv_label_set_text(warning, tr("Some recurring events could not be expanded.")); - lv_obj_set_width(warning, LV_PCT(100)); - lv_label_set_long_mode(warning, LV_LABEL_LONG_MODE_WRAP); - } -} - -void onDayClicked(lv_event_t* event) { - auto* context = static_cast(lv_event_get_user_data(event)); - lv_obj_t* target = lv_event_get_current_target_obj(event); - const int day = static_cast(reinterpret_cast(lv_obj_get_user_data(target))); - context->selectedYear = context->displayYear; - context->selectedMonth = context->displayMonth; - context->selectedDay = day; - context->dayAgendaVisible = true; - lv_obj_set_hidden(context->monthPanel, true); - lv_obj_set_hidden(context->selectedDayPanel, false); - const uint32_t childCount = lv_obj_get_child_count(context->monthGrid); - for (uint32_t i = 0; i < childCount; ++i) { - lv_obj_t* dayButton = lv_obj_get_child(context->monthGrid, static_cast(i)); - const int dayNumber = static_cast(reinterpret_cast(lv_obj_get_user_data(dayButton))); - if (dayNumber > 0) { - setDaySelectedStyle(dayButton, dayNumber == day); - } - } - refreshMonthAgenda(context); - lv_group_focus_obj(context->selectedDayEvents); -} - -void onBackToMonth(lv_event_t* event) { - auto* context = static_cast(lv_event_get_user_data(event)); - context->dayAgendaVisible = false; - lv_obj_set_hidden(context->selectedDayPanel, true); - lv_obj_set_hidden(context->monthPanel, false); - lv_group_focus_obj(context->monthGrid); -} - -void changeDisplayedMonth(CalendarContext* context, int offset) { - tm targetMonth {}; - targetMonth.tm_year = context->displayYear - 1900; - targetMonth.tm_mon = context->displayMonth - 1 + offset; - targetMonth.tm_mday = 1; - targetMonth.tm_hour = 12; - targetMonth.tm_isdst = -1; - mktime(&targetMonth); - - const int year = targetMonth.tm_year + 1900; - if (year < 1000 || year > 9999) return; - - tm lastDay = targetMonth; - lastDay.tm_mon += 1; - lastDay.tm_mday = 0; - mktime(&lastDay); - - context->displayYear = year; - context->displayMonth = targetMonth.tm_mon + 1; - context->selectedYear = context->displayYear; - context->selectedMonth = context->displayMonth; - context->selectedDay = std::max(1, std::min(context->selectedDay, lastDay.tm_mday)); - refreshMonth(context); -} - -void onPreviousMonth(lv_event_t* event) { - auto* context = static_cast(lv_event_get_user_data(event)); - changeDisplayedMonth(context, -1); -} - -void onNextMonth(lv_event_t* event) { - auto* context = static_cast(lv_event_get_user_data(event)); - changeDisplayedMonth(context, 1); -} - void onStatusTimeout(lv_timer_t* timer) { auto* context = static_cast(lv_timer_get_user_data(timer)); if (context->statusTimer != timer) return; @@ -667,7 +673,7 @@ bool updateCalendarData(CalendarContext* context, uint32_t expectedGeneration, context->fullCalendarHasTiming = true; context->fullCalendarGeneration = expectedGeneration; refreshMonth(context); - refreshMonthAgenda(context); + refreshWeekStrip(context); } if (updateUpcoming) { context->upcomingEvents = std::move(upcomingEvents); @@ -676,6 +682,8 @@ bool updateCalendarData(CalendarContext* context, uint32_t expectedGeneration, upcomingWindowStart); copyText(context->upcomingWindowEnd, sizeof(context->upcomingWindowEnd), upcomingWindowEnd); + refreshMonth(context); + refreshWeekStrip(context); refreshEventList(context); } if (updateFullCalendar && !updateUpcoming) refreshEventList(context); @@ -790,151 +798,74 @@ void calendarLoadCachedEvents(CalendarContext* context) { void calendarCreateWidgets(lv_obj_t* parent, void* userData) { auto* context = static_cast(userData); const CalendarSyncSettings settingsSnapshot = getCalendarSyncSettings(context); - if (context->displayYear == 0) { - const time_t now = time(nullptr); - tm local {}; - if (localtime_r(&now, &local) != nullptr) { - context->displayYear = local.tm_year + 1900; - context->displayMonth = local.tm_mon + 1; - context->selectedYear = context->displayYear; - context->selectedMonth = context->displayMonth; - context->selectedDay = local.tm_mday; - } - } + updateToday(context); + + const int32_t width = lv_display_get_horizontal_resolution(nullptr); + const int32_t height = lv_display_get_vertical_resolution(nullptr); + context->splitLayout = std::max(width, height) >= SPLIT_MIN_LONG_SIDE && + std::min(width, height) >= SPLIT_MIN_SHORT_SIDE; + const bool landscape = width > height; + lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); + lv_obj_set_style_pad_gap(parent, 0, LV_PART_MAIN); lv_obj_set_scrollable(parent, false); lv_obj_set_style_border_width(parent, 0, LV_PART_MAIN); - lv_obj_t* toolbar = lvgl_toolbar_create(parent, tr("Calendar")); - lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); - lvgl_toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, onClose, context); + context->toolbar = lvgl_toolbar_create(parent, tr("Calendar")); + lv_obj_align(context->toolbar, LV_ALIGN_TOP_MID, 0, 0); + lvgl_toolbar_set_nav_action(context->toolbar, LV_SYMBOL_CLOSE, onClose, context); + context->todayButton = addToolbarButton(context->toolbar, LVGL_ICON_SHARED_CIRCLE, onToday, context); + context->previousButton = addToolbarButton(context->toolbar, LVGL_ICON_SHARED_KEYBOARD_ARROW_LEFT, onPreviousMonth, context); + context->nextButton = addToolbarButton(context->toolbar, LVGL_ICON_SHARED_KEYBOARD_ARROW_RIGHT, onNextMonth, context); + context->viewButton = addToolbarButton(context->toolbar, LVGL_ICON_SHARED_CALENDAR_MONTH, onToggleView, context); + addToolbarButton(context->toolbar, LVGL_ICON_SHARED_SETTINGS, onOpenSettings, context); context->statusLabel = lv_label_create(parent); lv_obj_set_width(context->statusLabel, LV_PCT(100)); lv_label_set_long_mode(context->statusLabel, LV_LABEL_LONG_MODE_WRAP); lv_obj_set_style_text_font(context->statusLabel, lvgl_get_text_font(FONT_SIZE_SMALL), 0); + lv_obj_set_style_pad_hor(context->statusLabel, 6, 0); lv_label_set_text(context->statusLabel, context->status); if (context->status[0] == '\0') { lv_obj_add_flag(context->statusLabel, LV_OBJ_FLAG_HIDDEN); } if (context->statusShouldExpire) scheduleStatusTimeout(context); - lv_obj_t* settings = lvgl_toolbar_add_text_button_action(toolbar, LVGL_ICON_SHARED_SETTINGS, onOpenSettings, context); - lv_obj_set_style_text_font(settings, lvgl_get_shared_icon_default_font(), 0); system_bars_set_main_action(LVGL_ICON_SHARED_REFRESH, onSyncMainAction, context); system_bars_set_page_button_callbacks(onPreviousPage, onNextPage, context); system_bars_set_page_buttons_visible(true); - context->monthPanel = lv_obj_create(parent); - lv_obj_set_width(context->monthPanel, LV_PCT(100)); - lv_obj_set_flex_grow(context->monthPanel, 1); - lv_obj_set_flex_flow(context->monthPanel, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_all(context->monthPanel, 8, LV_PART_MAIN); - lv_obj_set_style_pad_gap(context->monthPanel, 4, LV_PART_MAIN); - lv_obj_set_style_border_width(context->monthPanel, 0, LV_PART_MAIN); - - lv_obj_t* monthNavigation = lv_obj_create(context->monthPanel); - lv_obj_set_width(monthNavigation, LV_PCT(100)); - lv_obj_set_height(monthNavigation, LV_SIZE_CONTENT); - lv_obj_set_flex_flow(monthNavigation, LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(monthNavigation, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_set_style_pad_all(monthNavigation, 0, LV_PART_MAIN); - lv_obj_set_style_pad_gap(monthNavigation, 0, LV_PART_MAIN); - lv_obj_set_style_border_width(monthNavigation, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(monthNavigation, LV_OPA_TRANSP, LV_PART_MAIN); - - lv_obj_t* previousSlot = lv_obj_create(monthNavigation); - lv_obj_set_size(previousSlot, LV_PCT(25), LV_SIZE_CONTENT); - lv_obj_set_flex_flow(previousSlot, LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(previousSlot, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_set_style_pad_all(previousSlot, 0, LV_PART_MAIN); - lv_obj_set_style_border_width(previousSlot, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(previousSlot, LV_OPA_TRANSP, LV_PART_MAIN); - lv_obj_set_scrollable(previousSlot, false); - - lv_obj_t* previousMonth = lv_button_create(previousSlot); - lv_obj_set_size(previousMonth, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_radius(previousMonth, LV_RADIUS_CIRCLE, LV_PART_MAIN); - lv_obj_add_event_cb(previousMonth, onPreviousMonth, LV_EVENT_CLICKED, context); - lv_obj_t* previousLabel = lv_label_create(previousMonth); - lv_label_set_text(previousLabel, "<"); - makeArrowButtonCircular(previousMonth, previousLabel); - - context->monthTitle = lv_label_create(monthNavigation); - lv_obj_set_width(context->monthTitle, LV_PCT(50)); - lv_obj_set_style_text_align(context->monthTitle, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN); - lv_obj_set_style_text_font(context->monthTitle, lvgl_get_text_font(FONT_SIZE_LARGE), LV_PART_MAIN); - - lv_obj_t* nextSlot = lv_obj_create(monthNavigation); - lv_obj_set_size(nextSlot, LV_PCT(25), LV_SIZE_CONTENT); - lv_obj_set_flex_flow(nextSlot, LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(nextSlot, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_set_style_pad_all(nextSlot, 0, LV_PART_MAIN); - lv_obj_set_style_border_width(nextSlot, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(nextSlot, LV_OPA_TRANSP, LV_PART_MAIN); - lv_obj_set_scrollable(nextSlot, false); - - lv_obj_t* nextMonth = lv_button_create(nextSlot); - lv_obj_set_size(nextMonth, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_radius(nextMonth, LV_RADIUS_CIRCLE, LV_PART_MAIN); - lv_obj_add_event_cb(nextMonth, onNextMonth, LV_EVENT_CLICKED, context); - lv_obj_t* nextLabel = lv_label_create(nextMonth); - lv_label_set_text(nextLabel, ">"); - makeArrowButtonCircular(nextMonth, nextLabel); - - context->monthGrid = lv_obj_create(context->monthPanel); - lv_obj_set_width(context->monthGrid, LV_PCT(100)); - lv_obj_set_flex_grow(context->monthGrid, 1); - lv_obj_set_style_border_width(context->monthGrid, 0, LV_PART_MAIN); - lv_obj_set_style_bg_opa(context->monthGrid, LV_OPA_TRANSP, LV_PART_MAIN); - lv_obj_set_scrollbar_mode(context->monthGrid, LV_SCROLLBAR_MODE_OFF); - lvgl_grid_navigation_add(context->monthGrid); - - lv_obj_set_hidden(context->monthPanel, true); - refreshMonth(context); - - context->selectedDayPanel = lv_obj_create(parent); - lv_obj_set_width(context->selectedDayPanel, LV_PCT(100)); - lv_obj_set_flex_grow(context->selectedDayPanel, 1); - lv_obj_set_flex_flow(context->selectedDayPanel, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_all(context->selectedDayPanel, 8, LV_PART_MAIN); - lv_obj_set_style_pad_gap(context->selectedDayPanel, 8, LV_PART_MAIN); - lv_obj_set_style_border_width(context->selectedDayPanel, 0, LV_PART_MAIN); - createButton(context->selectedDayPanel, tr("Back to month"), onBackToMonth, context); - - context->selectedDayTitle = lv_label_create(context->selectedDayPanel); - lv_obj_set_width(context->selectedDayTitle, LV_PCT(100)); - lv_obj_set_style_text_font(context->selectedDayTitle, lvgl_get_text_font(FONT_SIZE_LARGE), LV_PART_MAIN); - - context->selectedDayEvents = lv_obj_create(context->selectedDayPanel); - lv_obj_set_width(context->selectedDayEvents, LV_PCT(100)); - lv_obj_set_flex_grow(context->selectedDayEvents, 1); - lv_obj_set_flex_flow(context->selectedDayEvents, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_all(context->selectedDayEvents, 4, LV_PART_MAIN); - lv_obj_set_style_pad_gap(context->selectedDayEvents, 4, LV_PART_MAIN); - lv_obj_set_style_border_width(context->selectedDayEvents, 0, LV_PART_MAIN); - lv_obj_set_scroll_dir(context->selectedDayEvents, LV_DIR_VER); - lv_obj_set_scrollbar_mode(context->selectedDayEvents, LV_SCROLLBAR_MODE_AUTO); - if (lv_group_t* group = lv_group_get_default()) { - lv_group_add_obj(group, context->selectedDayEvents); - } - lv_obj_set_hidden(context->selectedDayPanel, true); - refreshMonthAgenda(context); - - context->agendaPanel = lv_obj_create(parent); - lv_obj_set_width(context->agendaPanel, LV_PCT(100)); - lv_obj_set_flex_grow(context->agendaPanel, 1); - lv_obj_set_flex_flow(context->agendaPanel, LV_FLEX_FLOW_COLUMN); - lv_obj_set_style_pad_all(context->agendaPanel, 8, 0); - lv_obj_set_style_pad_gap(context->agendaPanel, 8, 0); - lv_obj_set_style_border_width(context->agendaPanel, 0, LV_PART_MAIN); - lv_obj_set_scroll_dir(context->agendaPanel, LV_DIR_VER); - lv_obj_set_scrollbar_mode(context->agendaPanel, LV_SCROLLBAR_MODE_AUTO); - if (lv_group_t* group = lv_group_get_default()) { - lv_group_add_obj(group, context->agendaPanel); + context->contentPanel = lv_obj_create(parent); + lv_obj_remove_style_all(context->contentPanel); + lv_obj_set_width(context->contentPanel, LV_PCT(100)); + lv_obj_set_flex_grow(context->contentPanel, 1); + lv_obj_set_flex_flow(context->contentPanel, + context->splitLayout && landscape ? LV_FLEX_FLOW_ROW : LV_FLEX_FLOW_COLUMN); + lv_obj_set_scrollable(context->contentPanel, false); + + if (context->splitLayout) { + context->monthGrid = monthGridCreate(context->contentPanel); + context->agendaPanel = eventListCreate(context->contentPanel); + if (landscape) { + lv_obj_set_size(context->monthGrid.panel, LV_PCT(55), LV_PCT(100)); + lv_obj_set_height(context->agendaPanel, LV_PCT(100)); + } else { + lv_obj_set_size(context->monthGrid.panel, LV_PCT(100), LV_PCT(45)); + lv_obj_set_width(context->agendaPanel, LV_PCT(100)); + } + lv_obj_set_flex_grow(context->agendaPanel, 1); + } else { + if (lvgl_indev_exists(LV_INDEV_TYPE_POINTER)) { + context->weekStrip = weekStripCreate(context->contentPanel, onStripPressed, onStripClicked, context); + } + context->agendaPanel = eventListCreate(context->contentPanel); + lv_obj_set_width(context->agendaPanel, LV_PCT(100)); + lv_obj_set_flex_grow(context->agendaPanel, 1); + context->monthGrid = monthGridCreate(context->contentPanel); + lv_obj_set_width(context->monthGrid.panel, LV_PCT(100)); + lv_obj_set_flex_grow(context->monthGrid.panel, 1); } - refreshEventList(context); context->agendaCoverageTimer = lv_timer_create(onAgendaCoverageTimer, 60000, context); if (context->agendaCoverageTimer == nullptr) { setStatus(context, tr("Could not start the Agenda coverage timer.")); @@ -963,8 +894,8 @@ void calendarCreateWidgets(lv_obj_t* parent, void* userData) { createButton(context->settingsPanel, tr("Save"), onSaveSettings, context); createButton(context->settingsPanel, tr("Cancel"), onCancelSettings, context); - showSettings(context, context->settingsVisible); - setCalendarPage(context, context->page); + refreshAll(context); + if (!context->settingsVisible) focusContent(context); } void calendarDestroyWidgets(void* userData) { @@ -981,13 +912,15 @@ void calendarDestroyWidgets(void* userData) { system_bars_set_main_action(nullptr, nullptr, nullptr); system_bars_set_page_button_callbacks(nullptr, nullptr, nullptr); system_bars_set_page_buttons_visible(false); + context->toolbar = nullptr; + context->todayButton = nullptr; + context->previousButton = nullptr; + context->nextButton = nullptr; + context->viewButton = nullptr; + context->contentPanel = nullptr; context->agendaPanel = nullptr; - context->monthPanel = nullptr; - context->monthTitle = nullptr; - context->monthGrid = nullptr; - context->selectedDayPanel = nullptr; - context->selectedDayTitle = nullptr; - context->selectedDayEvents = nullptr; + context->weekStrip = nullptr; + context->monthGrid = {}; context->settingsPanel = nullptr; context->statusLabel = nullptr; context->urlInput = nullptr; diff --git a/Apps/Calendar/main/Source/CalendarApp.h b/Apps/Calendar/main/Source/CalendarApp.h index c4bb1d7..7520a7f 100644 --- a/Apps/Calendar/main/Source/CalendarApp.h +++ b/Apps/Calendar/main/Source/CalendarApp.h @@ -3,7 +3,9 @@ #include #include +#include "CalendarDate.h" #include "CalendarSync.h" +#include "MonthGrid.h" #include #include #include @@ -44,20 +46,27 @@ struct CalendarContext { bool statusShouldExpire = false; bool settingsVisible = false; - bool dayAgendaVisible = false; + bool splitLayout = false; + // Ignored by the split layout, which shows both. CalendarPage page = CalendarPage::Agenda; - int selectedYear = 0; - int selectedMonth = 0; - int selectedDay = 0; + // While true, the list runs from now and the selection is today, also after midnight. + // After picking a day it is false, and selectedDate is used. + bool followToday = true; + CalendarDate selectedDate {}; + CalendarDate shownToday {}; int displayYear = 0; int displayMonth = 0; + lv_obj_t* toolbar = nullptr; + lv_obj_t* todayButton = nullptr; + lv_obj_t* previousButton = nullptr; + lv_obj_t* nextButton = nullptr; + lv_obj_t* viewButton = nullptr; + lv_obj_t* contentPanel = nullptr; lv_obj_t* agendaPanel = nullptr; - lv_obj_t* monthPanel = nullptr; - lv_obj_t* monthTitle = nullptr; - lv_obj_t* monthGrid = nullptr; - lv_obj_t* selectedDayPanel = nullptr; - lv_obj_t* selectedDayTitle = nullptr; - lv_obj_t* selectedDayEvents = nullptr; + lv_obj_t* weekStrip = nullptr; + MonthGrid monthGrid {}; + lv_point_t stripPressPoint {}; + CalendarDate stripPressDate {}; lv_obj_t* settingsPanel = nullptr; lv_obj_t* statusLabel = nullptr; lv_timer_t* statusTimer = nullptr; diff --git a/Apps/Calendar/main/Source/CalendarData.h b/Apps/Calendar/main/Source/CalendarData.h index 384d877..7fa99dc 100644 --- a/Apps/Calendar/main/Source/CalendarData.h +++ b/Apps/Calendar/main/Source/CalendarData.h @@ -47,6 +47,41 @@ struct CalendarEvent { bool calendarFormatDateKey(char* output, std::size_t size, int year, int month, int day); bool calendarEventOverlapsDay(const CalendarEvent& event, const char* date); +// Parses a CalDAV multistatus reply while it arrives. Only the entry that is being received is +// buffered, so the size of the reply doesn't matter: the number of events does. +class CalendarResponseParser { +public: + enum class Error { None, Invalid, EntryTooLarge, OutOfMemory }; + // Returns false when there is no memory to grow the event list to this many bytes. + using MemoryCheck = bool (*)(std::size_t bytes); + + // keepFrom ("YYYY-MM-DD") drops events that don't repeat and ended before that day. + explicit CalendarResponseParser(std::vector& events, const char* keepFrom = nullptr, + MemoryCheck hasMemory = nullptr); + // Returns false after an error: later data is ignored. + bool feed(const char* data, std::size_t length); + // Returns whether the reply was complete and all of it was loaded. + bool finish(); + Error error() const { return failure; } + +private: + enum class State { BeforeRoot, InRoot, Done }; + + void process(); + bool append(const std::vector& parsed); + + std::vector& events; + char keepFrom[11] {}; + MemoryCheck hasMemory; + std::string buffer; + std::string rootName; + std::size_t searchFrom = 0; + std::size_t loaded = 0; + std::size_t collections = 0; + State state = State::BeforeRoot; + Error failure = Error::None; +}; + bool calendarParseResponse(const std::string& xml, std::vector& events); bool calendarExpandEventsForMonth(const std::vector& events, int year, int month, diff --git a/Apps/Calendar/main/Source/CalendarDate.cpp b/Apps/Calendar/main/Source/CalendarDate.cpp new file mode 100644 index 0000000..9bbcab4 --- /dev/null +++ b/Apps/Calendar/main/Source/CalendarDate.cpp @@ -0,0 +1,98 @@ +#include "CalendarDate.h" + +#include "CalendarData.h" + +#include + +#include +#include + +namespace { + +constexpr const char* WEEKDAYS[] = { + tr_noop("Mon"), tr_noop("Tue"), tr_noop("Wed"), tr_noop("Thu"), + tr_noop("Fri"), tr_noop("Sat"), tr_noop("Sun") +}; + +constexpr const char* MONTHS[] = { + tr_noop("Jan"), tr_noop("Feb"), tr_noop("Mar"), tr_noop("Apr"), tr_noop("May"), tr_noop("Jun"), + tr_noop("Jul"), tr_noop("Aug"), tr_noop("Sep"), tr_noop("Oct"), tr_noop("Nov"), tr_noop("Dec") +}; + +// Noon avoids day changes caused by daylight saving time. +tm toTm(int year, int month, int day) { + tm value {}; + value.tm_year = year - 1900; + value.tm_mon = month - 1; + value.tm_mday = day; + value.tm_hour = 12; + value.tm_isdst = -1; + mktime(&value); + return value; +} + +CalendarDate fromTm(const tm& value) { + return {value.tm_year + 1900, value.tm_mon + 1, value.tm_mday}; +} + +// Translations choose the order, so the placeholders are named instead of printf arguments. +void replace(std::string& text, const char* placeholder, const std::string& value) { + const size_t position = text.find(placeholder); + if (position != std::string::npos) { + text.replace(position, std::char_traits::length(placeholder), value); + } +} + +} // namespace + +CalendarDate calendarToday() { + const time_t now = time(nullptr); + tm local {}; + localtime_r(&now, &local); + return fromTm(local); +} + +CalendarDate calendarAddDays(const CalendarDate& date, int days) { + return fromTm(toTm(date.year, date.month, date.day + days)); +} + +CalendarDate calendarAddMonths(const CalendarDate& date, int months) { + const CalendarDate first = fromTm(toTm(date.year, date.month + months, 1)); + return {first.year, first.month, std::min(date.day, calendarDaysInMonth(first.year, first.month))}; +} + +int calendarWeekday(const CalendarDate& date) { + return (toTm(date.year, date.month, date.day).tm_wday + 6) % 7; +} + +int calendarDaysInMonth(int year, int month) { + return toTm(year, month + 1, 0).tm_mday; +} + +void calendarDateKey(const CalendarDate& date, char (&key)[11]) { + if (!calendarFormatDateKey(key, sizeof(key), date.year, date.month, date.day)) key[0] = '\0'; +} + +const char* calendarWeekdayName(int weekday) { + return tr(WEEKDAYS[weekday]); +} + +std::string calendarDayLabel(const CalendarDate& date, const CalendarDate& today) { + std::string text = tr("{weekday} {day} {month}"); + replace(text, "{weekday}", calendarWeekdayName(calendarWeekday(date))); + replace(text, "{day}", std::to_string(date.day)); + replace(text, "{month}", tr(MONTHS[date.month - 1])); + const char* prefix = date == today ? tr("Today, {date}") + : date == calendarAddDays(today, 1) ? tr("Tomorrow, {date}") : nullptr; + if (prefix == nullptr) return text; + std::string prefixed = prefix; + replace(prefixed, "{date}", text); + return prefixed; +} + +std::string calendarMonthLabel(int year, int month) { + std::string text = tr("{month} {year}"); + replace(text, "{month}", tr(MONTHS[month - 1])); + replace(text, "{year}", std::to_string(year)); + return text; +} diff --git a/Apps/Calendar/main/Source/CalendarDate.h b/Apps/Calendar/main/Source/CalendarDate.h new file mode 100644 index 0000000..56b5b2b --- /dev/null +++ b/Apps/Calendar/main/Source/CalendarDate.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +struct CalendarDate { + int year = 0; + int month = 0; + int day = 0; + + bool operator==(const CalendarDate& other) const { + return year == other.year && month == other.month && day == other.day; + } + bool operator!=(const CalendarDate& other) const { return !(*this == other); } +}; + +CalendarDate calendarToday(); +CalendarDate calendarAddDays(const CalendarDate& date, int days); +// Keeps the day of the month where the target month has it. +CalendarDate calendarAddMonths(const CalendarDate& date, int months); +// 0 is Monday. +int calendarWeekday(const CalendarDate& date); +int calendarDaysInMonth(int year, int month); +// "YYYY-MM-DD" +void calendarDateKey(const CalendarDate& date, char (&key)[11]); + +const char* calendarWeekdayName(int weekday); +// "Mon 30 Nov", prefixed with "Today" or "Tomorrow" where that applies. +std::string calendarDayLabel(const CalendarDate& date, const CalendarDate& today); +// "Nov 2026" +std::string calendarMonthLabel(int year, int month); diff --git a/Apps/Calendar/main/Source/CalendarIcs.cpp b/Apps/Calendar/main/Source/CalendarIcs.cpp index 74b8c04..1f61359 100644 --- a/Apps/Calendar/main/Source/CalendarIcs.cpp +++ b/Apps/Calendar/main/Source/CalendarIcs.cpp @@ -1234,154 +1234,228 @@ bool findDirectChild(const std::string& xml, size_t begin, size_t end, return true; } -bool isSuccessfulHttpStatus(const std::string& xml, const XmlElement& status) { - if (status.selfClosing) return false; +// Returns the code of a "HTTP/1.1 200 OK" status element, or -1. +int httpStatusCode(const std::string& xml, const XmlElement& status) { + if (status.selfClosing) return -1; size_t begin = status.contentStart; size_t end = status.contentEnd; while (begin < end && isspace(static_cast(xml[begin]))) ++begin; while (end > begin && isspace(static_cast(xml[end - 1]))) --end; const std::string value = xml.substr(begin, end - begin); - if (!startsWithIgnoreCase(value, "HTTP/")) return false; + if (!startsWithIgnoreCase(value, "HTTP/")) return -1; const size_t codeStart = value.find_first_of(" \t"); - if (codeStart == std::string::npos) return false; + if (codeStart == std::string::npos) return -1; size_t codePosition = value.find_first_not_of(" \t", codeStart); - if (codePosition == std::string::npos || codePosition + 3 > value.size()) return false; + if (codePosition == std::string::npos || codePosition + 3 > value.size()) return -1; if (!isdigit(static_cast(value[codePosition])) || !isdigit(static_cast(value[codePosition + 1])) || !isdigit(static_cast(value[codePosition + 2])) || (codePosition + 3 < value.size() && !isspace(static_cast(value[codePosition + 3])))) { - return false; + return -1; } - const int code = (value[codePosition] - '0') * 100 + + return (value[codePosition] - '0') * 100 + (value[codePosition + 1] - '0') * 10 + value[codePosition + 2] - '0'; +} + +bool isSuccessCode(int code) { return code >= 200 && code < 300; } -bool validatePropstat(const std::string& xml, const XmlElement& propstat, - bool& containsCalendarData) { - containsCalendarData = false; - XmlElement calendarData; +// A resource or property that does not exist: there is nothing to load, and nothing is lost. +bool isMissingCode(int code) { + return code == 404 || code == 410; +} + +enum class ResponseResult { + Loaded, + // The resource was removed. + Missing, + // The entry of a collection, which has no calendar data. + Collection, + // The server failed to return it (or truncated the results): the report is incomplete. + Failed, +}; + +// Collection URLs end with a slash (RFC 4918 section 5.2), those of events don't. +bool isCollectionResponse(const std::string& xml, const XmlElement& response) { + XmlElement href; bool found = false; - if (!findNextElement(xml, propstat.contentStart, propstat.contentEnd, - "calendar-data", calendarData, found)) { + if (!findDirectChild(xml, response.contentStart, response.contentEnd, "href", href, found) || + !found) { return false; } - containsCalendarData = found; - if (!containsCalendarData) return true; + size_t end = href.contentEnd; + while (end > href.contentStart && isspace(static_cast(xml[end - 1]))) --end; + return end > href.contentStart && xml[end - 1] == '/'; +} - bool foundStatus = false; - size_t position = propstat.contentStart; - while (position < propstat.contentEnd) { +ResponseResult parseResponseElement(const std::string& xml, const XmlElement& response, + std::vector& events) { + bool found = false; + size_t position = response.contentStart; + while (position < response.contentEnd) { XmlElement status; - if (!findDirectChild(xml, position, propstat.contentEnd, "status", status, found)) { - return false; + if (!findDirectChild(xml, position, response.contentEnd, "status", status, found)) { + return ResponseResult::Failed; } if (!found) break; - foundStatus = true; - if (!isSuccessfulHttpStatus(xml, status)) return false; + const int code = httpStatusCode(xml, status); + if (isMissingCode(code)) return ResponseResult::Missing; + if (!isSuccessCode(code)) return ResponseResult::Failed; position = status.end; } - return foundStatus; -} -bool validateResponse(const std::string& xml, const XmlElement& response) { - bool hasSuccessfulCalendarData = false; - size_t position = response.contentStart; + bool loaded = false; + position = response.contentStart; while (position < response.contentEnd) { XmlElement propstat; - bool found = false; - if (!findDirectChild(xml, position, response.contentEnd, "propstat", - propstat, found)) { - return false; + if (!findDirectChild(xml, position, response.contentEnd, "propstat", propstat, found)) { + return ResponseResult::Failed; } if (!found) break; - bool containsCalendarData = false; - if (!validatePropstat(xml, propstat, containsCalendarData)) return false; - hasSuccessfulCalendarData = hasSuccessfulCalendarData || containsCalendarData; position = propstat.end; - } - position = response.contentStart; - while (position < response.contentEnd) { + XmlElement calendarData; + if (!findNextElement(xml, propstat.contentStart, propstat.contentEnd, + "calendar-data", calendarData, found)) { + return ResponseResult::Failed; + } + if (!found) continue; XmlElement status; - bool found = false; - if (!findDirectChild(xml, position, response.contentEnd, "status", status, found)) { - return false; + if (!findDirectChild(xml, propstat.contentStart, propstat.contentEnd, "status", status, found) || + !found) { + return ResponseResult::Failed; + } + const int code = httpStatusCode(xml, status); + // Servers list the properties that they don't have as empty elements in a 404 propstat. + if (isMissingCode(code)) continue; + if (!isSuccessCode(code)) return ResponseResult::Failed; + if (!calendarData.selfClosing) { + parseVEvents(decodeXml(xml.substr( + calendarData.contentStart, + calendarData.contentEnd - calendarData.contentStart)), events); } - if (!found) break; - if (!isSuccessfulHttpStatus(xml, status)) return false; - position = status.end; + loaded = true; } - return hasSuccessfulCalendarData; + if (loaded) return ResponseResult::Loaded; + return isCollectionResponse(xml, response) ? ResponseResult::Collection : ResponseResult::Failed; } -bool validateCalendarResponseStatuses(const std::string& xml) { - XmlElement multistatus; - size_t position = 0; - XmlTag root; - bool found = false; - if (!nextXmlTag(xml, position, root, found) || !found || root.closing || - root.localName != "multistatus") { - return false; - } - if (root.selfClosing) return true; - multistatus.name = root.name; - multistatus.start = root.start; - multistatus.contentStart = root.end; - if (!findElementEnd(xml, root, multistatus.contentEnd, multistatus.end)) return false; - - position = multistatus.contentStart; - while (position < multistatus.contentEnd) { - XmlElement response; - if (!findDirectChild(xml, position, multistatus.contentEnd, "response", - response, found)) { - return false; - } - if (!found) break; - if (!validateResponse(xml, response)) return false; - position = response.end; - } - return true; -} +} // namespace + +namespace { + +// A single calendar object, with its overrides, is far smaller than this. +constexpr size_t MAX_ENTRY_BYTES = 512 * 1024; } // namespace -bool calendarParseResponse(const std::string& xml, - std::vector& events) { - if (!validateCalendarResponseStatuses(xml)) return false; - size_t position = 0; - XmlTag root; - bool found = false; - if (!nextXmlTag(xml, position, root, found) || !found || root.closing || - root.localName != "multistatus") { - return false; +CalendarResponseParser::CalendarResponseParser(std::vector& events, const char* keepFrom, + MemoryCheck hasMemory) + : events(events), hasMemory(hasMemory) { + if (keepFrom != nullptr) copyText(this->keepFrom, sizeof(this->keepFrom), keepFrom); +} + +bool CalendarResponseParser::feed(const char* data, size_t length) { + // In slices, so that a large chunk doesn't have to be buffered as a whole. + constexpr size_t SLICE = 4096; + for (size_t offset = 0; offset < length && failure == Error::None && state != State::Done; offset += SLICE) { + buffer.append(data + offset, std::min(SLICE, length - offset)); + process(); + if (failure == Error::None && buffer.size() > MAX_ENTRY_BYTES) failure = Error::EntryTooLarge; } - if (root.selfClosing) return true; + return failure == Error::None; +} - size_t rootContentEnd = 0; - size_t rootEnd = 0; - if (!findElementEnd(xml, root, rootContentEnd, rootEnd)) return false; - (void)rootEnd; - position = root.end; - while (position < rootContentEnd) { - XmlElement calendarData; - if (!findNextElement(xml, position, rootContentEnd, "calendar-data", - calendarData, found)) { - return false; +bool CalendarResponseParser::finish() { + if (failure != Error::None) return false; + // A reply with only collections (a wrong URL) must not replace the cached events with nothing. + if (state != State::Done || (loaded == 0 && collections > 0)) failure = Error::Invalid; + return failure == Error::None; +} + +// Consumes what is complete in the buffer. An incomplete tag or element is left for the next data. +void CalendarResponseParser::process() { + while (failure == Error::None && state != State::Done) { + size_t position = 0; + XmlTag tag; + bool found = false; + if (!nextXmlTag(buffer, position, tag, found) || !found) return; + + if (state == State::BeforeRoot) { + if (tag.closing || tag.localName != "multistatus") { + failure = Error::Invalid; + return; + } + rootName = tag.name; + state = tag.selfClosing ? State::Done : State::InRoot; + buffer.erase(0, tag.end); + continue; } - if (!found) break; - if (!calendarData.selfClosing) { - parseVEvents(decodeXml(xml.substr( - calendarData.contentStart, - calendarData.contentEnd - calendarData.contentStart)), events); + + if (tag.closing) { + if (tag.name == rootName) state = State::Done; + else failure = Error::Invalid; + return; } - position = calendarData.end; + if (tag.selfClosing) { + buffer.erase(0, tag.end); + continue; + } + + // Scanning the whole element for every chunk is slow: wait until its end can be there. + const std::string closing = " closing.size() ? buffer.size() - closing.size() : 0; + return; + } + searchFrom = 0; + + if (tag.localName == "response") { + std::vector parsed; + switch (parseResponseElement(buffer, element, parsed)) { + case ResponseResult::Loaded: + ++loaded; + if (!append(parsed)) failure = Error::OutOfMemory; + break; + case ResponseResult::Collection: ++collections; break; + case ResponseResult::Missing: break; + case ResponseResult::Failed: failure = Error::Invalid; break; + } + } + buffer.erase(0, element.end); + } +} + +bool CalendarResponseParser::append(const std::vector& parsed) { + for (const CalendarEvent& event : parsed) { + // Overrides and cancellations stay: they change the occurrences of a repeating event. + const bool old = keepFrom[0] != '\0' && event.recurrenceRule[0] == '\0' && !event.recurrenceOverride && + !event.cancelled && strcmp(event.endDateExclusive, keepFrom) <= 0; + if (old) continue; + if (events.size() == events.capacity()) { + const size_t capacity = events.capacity() + std::max(16, events.capacity() / 2); + if (hasMemory != nullptr && !hasMemory(capacity * sizeof(CalendarEvent))) return false; + events.reserve(capacity); + } + events.push_back(event); } return true; } +bool calendarParseResponse(const std::string& xml, + std::vector& events) { + CalendarResponseParser parser(events); + parser.feed(xml.data(), xml.size()); + return parser.finish(); +} + namespace { struct RecurrenceDay { diff --git a/Apps/Calendar/main/Source/CalendarSync.cpp b/Apps/Calendar/main/Source/CalendarSync.cpp index 636171c..a2b60e9 100644 --- a/Apps/Calendar/main/Source/CalendarSync.cpp +++ b/Apps/Calendar/main/Source/CalendarSync.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace { @@ -29,13 +30,18 @@ constexpr char PREVIOUS_TIMING_CACHE_MAGIC[] = "TACTILITY_CALENDAR_CACHE_V7\n"; constexpr char TIMING_LEGACY_CACHE_MAGIC[] = "TACTILITY_CALENDAR_CACHE_V6\n"; constexpr char PREVIOUS_CACHE_MAGIC[] = "TACTILITY_CALENDAR_CACHE_V5\n"; constexpr char LEGACY_CACHE_MAGIC[] = "TACTILITY_CALENDAR_CACHE_V4\n"; -constexpr size_t MAX_RESPONSE_BYTES = 512 * 1024; +// Events that don't repeat and ended longer ago than this are not kept. +constexpr time_t HISTORY_SECONDS = 365 * 24 * 60 * 60; +// Left free for the rest of the system while the event list grows. +constexpr size_t MEMORY_RESERVE_BYTES = 64 * 1024; constexpr int HTTP_TIMEOUT_MS = 20000; -struct HttpResponse { - std::string body; - bool tooLarge = false; -}; +// Room for the new list and for the copy of it that is made to write the cache. +bool hasMemoryForEvents(size_t bytes) { + const size_t largest = std::max(memory_external_largest_block(), memory_heap_largest_block()); + // 0 on platforms without heap tracking. + return largest == 0 || largest >= 2 * bytes + MEMORY_RESERVE_BYTES; +} bool getAppFilePath(const char* filename, char* path, size_t size) { return app_paths_get_user_data_path(APP_ID, filename, path, size) == ERROR_NONE; @@ -55,14 +61,13 @@ bool isValidWindowTimestamp(const char* value) { } esp_err_t onHttpEvent(esp_http_client_event_t* event) { - auto* response = static_cast(event->user_data); - if (event->event_id == HTTP_EVENT_ON_DATA && response != nullptr && event->data_len > 0) { - const size_t incoming = static_cast(event->data_len); - if (response->body.size() + incoming > MAX_RESPONSE_BYTES) { - response->tooLarge = true; + auto* parser = static_cast(event->user_data); + if (event->event_id == HTTP_EVENT_ON_DATA && parser != nullptr && event->data_len > 0) { + // The bodies of redirects and authentication challenges are not part of the report. + if (esp_http_client_get_status_code(event->client) >= 300) return ESP_OK; + if (!parser->feed(static_cast(event->data), static_cast(event->data_len))) { return ESP_FAIL; } - response->body.append(static_cast(event->data), incoming); } return ESP_OK; } @@ -130,8 +135,8 @@ bool makeUpcomingReport(char* report, size_t size, } bool performReport(const CalendarSyncSettings& settings, const char* report, - HttpResponse& response, char* message, size_t messageSize) { - response.body.reserve(4096); + CalendarResponseParser& parser, const char* invalidMessage, + char* message, size_t messageSize) { esp_http_client_config_t config {}; config.url = settings.calendarUrl; config.username = settings.username; @@ -140,7 +145,7 @@ bool performReport(const CalendarSyncSettings& settings, const char* report, config.timeout_ms = HTTP_TIMEOUT_MS; config.buffer_size = 2048; config.event_handler = onHttpEvent; - config.user_data = &response; + config.user_data = &parser; #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE config.crt_bundle_attach = esp_crt_bundle_attach; #else @@ -163,8 +168,17 @@ bool performReport(const CalendarSyncSettings& settings, const char* report, const int statusCode = esp_http_client_get_status_code(client); esp_http_client_cleanup(client); - if (response.tooLarge) { - copyText(message, messageSize, tr("Calendar response exceeds the 512 KB limit.")); + if (parser.error() == CalendarResponseParser::Error::OutOfMemory) { + copyText(message, messageSize, tr("The calendar has too many events for the memory of this device.")); + return false; + } + if (parser.error() == CalendarResponseParser::Error::EntryTooLarge) { + copyText(message, messageSize, tr("A calendar entry is too large to load.")); + return false; + } + // Checked before the result: the client reports an error for a challenge that it can't answer. + if (statusCode == 401 || statusCode == 403) { + copyText(message, messageSize, tr("CalDAV authentication failed or access was denied.")); return false; } if (result != ESP_OK) { @@ -172,11 +186,11 @@ bool performReport(const CalendarSyncSettings& settings, const char* report, return false; } if (statusCode < 200 || statusCode >= 300) { - if (statusCode == 401 || statusCode == 403) { - copyText(message, messageSize, tr("CalDAV authentication failed or access was denied.")); - } else { - snprintf(message, messageSize, tr("CalDAV server returned HTTP %d."), statusCode); - } + snprintf(message, messageSize, tr("CalDAV server returned HTTP %d."), statusCode); + return false; + } + if (!parser.finish()) { + copyText(message, messageSize, invalidMessage); return false; } return true; @@ -193,34 +207,35 @@ bool syncCalendar(const CalendarSyncSettings& settings, CalendarSyncResult& sync char fullReport[768] {}; char upcomingReport[768] {}; - HttpResponse response; + char keepFrom[11] {}; + const time_t now = time(nullptr); + tm oldest {}; + const time_t oldestTime = now - HISTORY_SECONDS; + if (now >= 1735689600 && gmtime_r(&oldestTime, &oldest) != nullptr) { + strftime(keepFrom, sizeof(keepFrom), "%Y-%m-%d", &oldest); + } + if (makeFullCalendarReport(fullReport, sizeof(fullReport), - sync.fullError, sizeof(sync.fullError)) && - performReport(settings, fullReport, response, - sync.fullError, sizeof(sync.fullError))) { - sync.fullSucceeded = calendarParseResponse(response.body, sync.events); - if (!sync.fullSucceeded) { - copyText(sync.fullError, sizeof(sync.fullError), - tr("The full-calendar response is incomplete or invalid.")); - sync.events.clear(); - } + sync.fullError, sizeof(sync.fullError))) { + CalendarResponseParser parser(sync.events, keepFrom[0] != '\0' ? keepFrom : nullptr, + hasMemoryForEvents); + sync.fullSucceeded = performReport(settings, fullReport, parser, + tr("The full-calendar response is incomplete or invalid."), + sync.fullError, sizeof(sync.fullError)); } - std::string().swap(response.body); - response.tooLarge = false; + // Frees the memory too: the next report needs it. + if (!sync.fullSucceeded) std::vector().swap(sync.events); if (makeUpcomingReport(upcomingReport, sizeof(upcomingReport), sync.upcomingWindowStart, sizeof(sync.upcomingWindowStart), sync.upcomingWindowEnd, sizeof(sync.upcomingWindowEnd), - sync.upcomingError, sizeof(sync.upcomingError)) && - performReport(settings, upcomingReport, response, - sync.upcomingError, sizeof(sync.upcomingError))) { - sync.upcomingSucceeded = calendarParseResponse(response.body, sync.upcomingEvents); - if (!sync.upcomingSucceeded) { - copyText(sync.upcomingError, sizeof(sync.upcomingError), - tr("The upcoming-events response is incomplete or invalid.")); - sync.upcomingEvents.clear(); - } + sync.upcomingError, sizeof(sync.upcomingError))) { + CalendarResponseParser parser(sync.upcomingEvents, nullptr, hasMemoryForEvents); + sync.upcomingSucceeded = performReport(settings, upcomingReport, parser, + tr("The upcoming-events response is incomplete or invalid."), + sync.upcomingError, sizeof(sync.upcomingError)); } + if (!sync.upcomingSucceeded) std::vector().swap(sync.upcomingEvents); const auto eventLess = [](const CalendarEvent& left, const CalendarEvent& right) { const int startCompare = strcmp(left.start, right.start); if (startCompare != 0) return startCompare < 0; diff --git a/Apps/Calendar/main/Source/DayButton.cpp b/Apps/Calendar/main/Source/DayButton.cpp new file mode 100644 index 0000000..34df401 --- /dev/null +++ b/Apps/Calendar/main/Source/DayButton.cpp @@ -0,0 +1,78 @@ +#include "DayButton.h" + +#include + +#include + +namespace { + +constexpr int DOT_SIZE = 4; + +} // namespace + +lv_obj_t* dayButtonCreate(lv_obj_t* parent, lv_event_cb_t onClicked, void* userData) { + lv_obj_t* button = lv_button_create(parent); + lv_obj_set_style_pad_all(button, 0, LV_PART_MAIN); + // The theme's minimum button size does not fit seven days in a row. + lv_obj_set_style_min_width(button, 0, LV_PART_MAIN); + lv_obj_set_style_min_height(button, 0, LV_PART_MAIN); + // The theme's margin for the focus outline would widen the cells. + lv_obj_set_style_margin_all(button, 0, LV_PART_MAIN); + lv_obj_set_style_pad_gap(button, 1, LV_PART_MAIN); + lv_obj_set_style_shadow_width(button, 0, LV_PART_MAIN); + lv_obj_set_style_bg_opa(button, LV_OPA_TRANSP, LV_PART_MAIN); + lv_obj_set_style_border_width(button, 0, LV_PART_MAIN); + lv_obj_add_event_cb(button, onClicked, LV_EVENT_CLICKED, userData); + lv_label_create(button); + lv_obj_t* dot = lv_obj_create(button); + lv_obj_remove_style_all(dot); + lv_obj_set_size(dot, DOT_SIZE, DOT_SIZE); + lv_obj_set_style_radius(dot, LV_RADIUS_CIRCLE, LV_PART_MAIN); + lv_obj_set_style_bg_opa(dot, LV_OPA_COVER, LV_PART_MAIN); + lv_obj_set_clickable(dot, false); + return button; +} + +void dayButtonSet(lv_obj_t* button, const CalendarDate& date, const char* text, + const std::vector& events, bool compact) { + const intptr_t packed = date.year * 10000 + date.month * 100 + date.day; + lv_obj_set_user_data(button, reinterpret_cast(packed)); + lv_obj_set_flex_flow(button, compact ? LV_FLEX_FLOW_ROW : LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(button, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + lv_obj_t* label = lv_obj_get_child(button, 0); + lv_label_set_text(label, text); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN); + + char key[11] {}; + calendarDateKey(date, key); + bool hasEvent = false; + for (size_t i = 0; i < events.size() && !hasEvent; ++i) { + hasEvent = calendarEventOverlapsDay(events[i], key); + } + // Transparent rather than hidden, so that numbers don't move between days. + lv_obj_set_style_bg_opa(lv_obj_get_child(button, 1), hasEvent ? LV_OPA_COVER : LV_OPA_TRANSP, LV_PART_MAIN); +} + +void dayButtonSetState(lv_obj_t* button, const CalendarDate& selected, const CalendarDate& today) { + const CalendarDate date = dayButtonDate(button); + const bool isSelected = date == selected; + const lv_color_t text = lv_obj_get_style_text_color(lv_obj_get_parent(button), LV_PART_MAIN); + const bool mono = lvgl_theme_is_mono(); + const lv_color_t accent = mono ? text : lv_theme_get_color_primary(button); + // Dark text on all but dark accents: black reads better than white from about this brightness on. + const bool darkText = (accent.red * 299 + accent.green * 587 + accent.blue * 114) / 1000 > 100; + const lv_color_t foreground = isSelected ? (darkText ? lv_color_black() : lv_color_white()) : text; + + lv_obj_set_style_bg_color(button, accent, LV_PART_MAIN); + lv_obj_set_style_bg_opa(button, isSelected ? LV_OPA_COVER : LV_OPA_TRANSP, LV_PART_MAIN); + lv_obj_set_style_border_color(button, accent, LV_PART_MAIN); + lv_obj_set_style_border_width(button, date == today && !isSelected ? 1 : 0, LV_PART_MAIN); + lv_obj_set_style_text_color(lv_obj_get_child(button, 0), foreground, LV_PART_MAIN); + lv_obj_set_style_bg_color(lv_obj_get_child(button, 1), foreground, LV_PART_MAIN); +} + +CalendarDate dayButtonDate(lv_obj_t* button) { + const int packed = static_cast(reinterpret_cast(lv_obj_get_user_data(button))); + return {packed / 10000, packed / 100 % 100, packed % 100}; +} diff --git a/Apps/Calendar/main/Source/DayButton.h b/Apps/Calendar/main/Source/DayButton.h new file mode 100644 index 0000000..bac1cd2 --- /dev/null +++ b/Apps/Calendar/main/Source/DayButton.h @@ -0,0 +1,16 @@ +#pragma once + +#include "CalendarData.h" +#include "CalendarDate.h" + +#include + +#include + +// A day of the month grid or the week strip. The button holds its date. +lv_obj_t* dayButtonCreate(lv_obj_t* parent, lv_event_cb_t onClicked, void* userData); +// Sets the date, the number and the event dot. The dot is placed under the number, or beside it when compact. +void dayButtonSet(lv_obj_t* button, const CalendarDate& date, const char* text, + const std::vector& events, bool compact); +void dayButtonSetState(lv_obj_t* button, const CalendarDate& selected, const CalendarDate& today); +CalendarDate dayButtonDate(lv_obj_t* button); diff --git a/Apps/Calendar/main/Source/EventList.cpp b/Apps/Calendar/main/Source/EventList.cpp new file mode 100644 index 0000000..43a8d03 --- /dev/null +++ b/Apps/Calendar/main/Source/EventList.cpp @@ -0,0 +1,139 @@ +#include "EventList.h" + +#include + +#include + +#include +#include +#include +#include + +namespace { + +struct Entry { + char day[11]; + const CalendarEvent* event; +}; + +lv_obj_t* addLabel(lv_obj_t* parent, const char* text, LvglFontSize font) { + lv_obj_t* label = lv_label_create(parent); + lv_label_set_text(label, text); + lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_WRAP); + lv_obj_set_style_text_font(label, lvgl_get_text_font(font), LV_PART_MAIN); + return label; +} + +lv_obj_t* addBox(lv_obj_t* parent, lv_flex_flow_t flow) { + lv_obj_t* box = lv_obj_create(parent); + lv_obj_remove_style_all(box); + lv_obj_set_height(box, LV_SIZE_CONTENT); + lv_obj_set_flex_flow(box, flow); + lv_obj_set_scrollable(box, false); + lv_obj_set_clickable(box, false); + return box; +} + +bool parseDayKey(const char* key, CalendarDate& date) { + return sscanf(key, "%d-%d-%d", &date.year, &date.month, &date.day) == 3 && + date.month >= 1 && date.month <= 12; +} + +void addHeader(lv_obj_t* list, const char* dayKey, const CalendarDate& today) { + CalendarDate date; + if (!parseDayKey(dayKey, date)) return; + lv_obj_t* header = addLabel(list, calendarDayLabel(date, today).c_str(), FONT_SIZE_SMALL); + lv_obj_set_width(header, LV_PCT(100)); + lv_obj_set_style_pad_top(header, 6, LV_PART_MAIN); + lv_obj_set_style_text_color(header, lv_theme_get_color_primary(list), LV_PART_MAIN); +} + +// CalendarEvent::start is "YYYY-MM-DD HH:MM[ zone]" or "YYYY-MM-DD (all day)". +void addRow(lv_obj_t* list, const CalendarEvent& event, const char* listedDay, const CalendarDate& today) { + const size_t length = strlen(event.start); + char time[6] {}; + const char* zone = nullptr; + if (length >= 16 && event.start[10] == ' ' && event.start[13] == ':') { + memcpy(time, event.start + 11, 5); + if (length > 17) zone = event.start + 17; + } + const bool allDay = strstr(event.start, "(all day)") != nullptr; + + lv_obj_t* row = addBox(list, LV_FLEX_FLOW_ROW); + lv_obj_set_width(row, LV_PCT(100)); + lv_obj_set_style_pad_ver(row, 3, LV_PART_MAIN); + lv_obj_set_style_pad_column(row, 6, LV_PART_MAIN); + lv_obj_set_style_border_side(row, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN); + lv_obj_set_style_border_width(row, 1, LV_PART_MAIN); + lv_obj_set_style_border_color(row, lv_obj_get_style_text_color(list, LV_PART_MAIN), LV_PART_MAIN); + lv_obj_set_style_border_opa(row, LV_OPA_20, LV_PART_MAIN); + + lv_obj_t* timeLabel = addLabel(row, allDay ? tr("all day") : time, FONT_SIZE_SMALL); + // Wide enough for "00:00" and "all day", so that the titles line up. + lv_obj_set_width(timeLabel, static_cast(lvgl_get_text_font_height(FONT_SIZE_SMALL)) * 7 / 2); + + lv_obj_t* texts = addBox(row, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_grow(texts, 1); + lv_obj_set_width(addLabel(texts, event.summary, FONT_SIZE_DEFAULT), LV_PCT(100)); + // An event that is listed under a later day than it started on names its own date. + std::string details; + CalendarDate startDate; + if (strcmp(event.startDate, listedDay) != 0 && parseDayKey(event.startDate, startDate)) { + details = calendarDayLabel(startDate, today); + } + if (zone != nullptr) { + if (!details.empty()) details += ", "; + details += zone; + } + if (!details.empty()) { + lv_obj_set_width(addLabel(texts, details.c_str(), FONT_SIZE_SMALL), LV_PCT(100)); + } +} + +} // namespace + +lv_obj_t* eventListCreate(lv_obj_t* parent) { + lv_obj_t* list = lv_obj_create(parent); + lv_obj_set_flex_flow(list, LV_FLEX_FLOW_COLUMN); + lv_obj_set_style_pad_all(list, 6, LV_PART_MAIN); + lv_obj_set_style_pad_gap(list, 0, LV_PART_MAIN); + lv_obj_set_style_border_width(list, 0, LV_PART_MAIN); + lv_obj_set_scroll_dir(list, LV_DIR_VER); + lv_obj_set_scrollbar_mode(list, LV_SCROLLBAR_MODE_AUTO); + if (lv_group_t* group = lv_group_get_default()) { + lv_group_add_obj(group, list); + } + return list; +} + +void eventListAddMessage(lv_obj_t* list, const char* message) { + lv_obj_set_width(addLabel(list, message, FONT_SIZE_DEFAULT), LV_PCT(100)); +} + +void eventListAddEvents(lv_obj_t* list, const std::vector& events, + const CalendarDate& firstDay, const CalendarDate& today) { + char firstKey[11] {}; + calendarDateKey(firstDay, firstKey); + + std::vector entries; + entries.reserve(events.size()); + for (const CalendarEvent& event : events) { + Entry entry {{}, &event}; + const bool startsLater = strcmp(event.startDate, firstKey) > 0; + memcpy(entry.day, startsLater ? event.startDate : firstKey, sizeof(entry.day) - 1); + entries.push_back(entry); + } + // Events arrive ordered by instant, which with time zones is not always ordered by date. + std::stable_sort(entries.begin(), entries.end(), [](const Entry& left, const Entry& right) { + return strcmp(left.day, right.day) < 0; + }); + + const char* shownDay = ""; + for (const Entry& entry : entries) { + if (strcmp(entry.day, shownDay) != 0) { + addHeader(list, entry.day, today); + shownDay = entry.day; + } + addRow(list, *entry.event, entry.day, today); + } +} diff --git a/Apps/Calendar/main/Source/EventList.h b/Apps/Calendar/main/Source/EventList.h new file mode 100644 index 0000000..d694bb2 --- /dev/null +++ b/Apps/Calendar/main/Source/EventList.h @@ -0,0 +1,14 @@ +#pragma once + +#include "CalendarData.h" +#include "CalendarDate.h" + +#include + +#include + +lv_obj_t* eventListCreate(lv_obj_t* parent); +void eventListAddMessage(lv_obj_t* list, const char* message); +// Appends the events grouped by day. Events that started before firstDay are listed under it. +void eventListAddEvents(lv_obj_t* list, const std::vector& events, + const CalendarDate& firstDay, const CalendarDate& today); diff --git a/Apps/Calendar/main/Source/MonthGrid.cpp b/Apps/Calendar/main/Source/MonthGrid.cpp new file mode 100644 index 0000000..937df3b --- /dev/null +++ b/Apps/Calendar/main/Source/MonthGrid.cpp @@ -0,0 +1,94 @@ +#include "MonthGrid.h" + +#include "DayButton.h" + +#include +#include + +#include + +namespace { + +// 7 columns of 13% and 6 gaps fit in the width. +constexpr int CELL_WIDTH_PERCENT = 13; +constexpr int CELL_HEIGHT_PERCENT = 15; + +lv_obj_t* createRow(lv_obj_t* parent) { + lv_obj_t* row = lv_obj_create(parent); + lv_obj_remove_style_all(row); + lv_obj_set_width(row, LV_PCT(100)); + lv_obj_set_flex_flow(row, LV_FLEX_FLOW_ROW_WRAP); + lv_obj_set_style_pad_hor(row, 2, LV_PART_MAIN); + lv_obj_set_style_pad_column(row, 1, LV_PART_MAIN); + lv_obj_set_style_pad_row(row, 1, LV_PART_MAIN); + lv_obj_set_scrollable(row, false); + return row; +} + +} // namespace + +MonthGrid monthGridCreate(lv_obj_t* parent) { + MonthGrid grid; + grid.panel = lv_obj_create(parent); + lv_obj_remove_style_all(grid.panel); + lv_obj_set_flex_flow(grid.panel, LV_FLEX_FLOW_COLUMN); + lv_obj_set_scrollable(grid.panel, false); + + lv_obj_t* header = createRow(grid.panel); + lv_obj_set_height(header, LV_SIZE_CONTENT); + for (int weekday = 0; weekday < 7; ++weekday) { + lv_obj_t* label = lv_label_create(header); + lv_label_set_text(label, calendarWeekdayName(weekday)); + lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_CLIP); + lv_obj_set_width(label, LV_PCT(CELL_WIDTH_PERCENT)); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN); + lv_obj_set_style_text_font(label, lvgl_get_text_font(FONT_SIZE_SMALL), LV_PART_MAIN); + } + + grid.days = createRow(grid.panel); + lv_obj_set_flex_grow(grid.days, 1); + // The focus outline of the group is on the day buttons. + lvgl_grid_navigation_add(grid.days); + return grid; +} + +void monthGridFill(const MonthGrid& grid, int year, int month, const std::vector& events, + const CalendarDate& selected, const CalendarDate& today, + lv_event_cb_t onDayClicked, void* userData) { + lv_obj_clean(grid.days); + lv_obj_update_layout(grid.panel); + const int32_t cellHeight = lv_obj_get_content_height(grid.days) * CELL_HEIGHT_PERCENT / 100; + const bool compact = cellHeight < static_cast(lvgl_get_text_font_height(FONT_SIZE_DEFAULT)) + 8; + + const int offset = calendarWeekday({year, month, 1}); + const int dayCount = calendarDaysInMonth(year, month); + lv_obj_t* focus = nullptr; + for (int cell = 0; cell < offset + dayCount; ++cell) { + const int day = cell - offset + 1; + if (day < 1) { + lv_obj_t* blank = lv_obj_create(grid.days); + lv_obj_remove_style_all(blank); + lv_obj_set_size(blank, LV_PCT(CELL_WIDTH_PERCENT), LV_PCT(CELL_HEIGHT_PERCENT)); + lv_obj_set_clickable(blank, false); + continue; + } + lv_obj_t* button = dayButtonCreate(grid.days, onDayClicked, userData); + lv_obj_set_size(button, LV_PCT(CELL_WIDTH_PERCENT), LV_PCT(CELL_HEIGHT_PERCENT)); + char text[12] {}; + snprintf(text, sizeof(text), "%d", day); + const CalendarDate date {year, month, day}; + dayButtonSet(button, date, text, events, compact); + dayButtonSetState(button, selected, today); + if (date == selected || focus == nullptr) focus = button; + } + if (focus != nullptr) lvgl_grid_navigation_focus_without_touch(grid.days, focus); +} + +void monthGridSelect(const MonthGrid& grid, const CalendarDate& selected, const CalendarDate& today) { + const uint32_t count = lv_obj_get_child_count(grid.days); + for (uint32_t i = 0; i < count; ++i) { + lv_obj_t* child = lv_obj_get_child(grid.days, static_cast(i)); + // Blank cells have no children. + if (lv_obj_get_child_count(child) > 0) dayButtonSetState(child, selected, today); + } +} diff --git a/Apps/Calendar/main/Source/MonthGrid.h b/Apps/Calendar/main/Source/MonthGrid.h new file mode 100644 index 0000000..290c1c8 --- /dev/null +++ b/Apps/Calendar/main/Source/MonthGrid.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CalendarData.h" +#include "CalendarDate.h" + +#include + +#include + +struct MonthGrid { + lv_obj_t* panel = nullptr; + lv_obj_t* days = nullptr; +}; + +MonthGrid monthGridCreate(lv_obj_t* parent); +// Rebuilds the day buttons: don't call this from a click on one of them. +// onDayClicked receives the day button as the current target: see dayButtonDate(). +void monthGridFill(const MonthGrid& grid, int year, int month, const std::vector& events, + const CalendarDate& selected, const CalendarDate& today, + lv_event_cb_t onDayClicked, void* userData); +void monthGridSelect(const MonthGrid& grid, const CalendarDate& selected, const CalendarDate& today); diff --git a/Apps/Calendar/main/Source/WeekStrip.cpp b/Apps/Calendar/main/Source/WeekStrip.cpp new file mode 100644 index 0000000..dfcd0b9 --- /dev/null +++ b/Apps/Calendar/main/Source/WeekStrip.cpp @@ -0,0 +1,45 @@ +#include "WeekStrip.h" + +#include "DayButton.h" + +#include +#include + +#include + +lv_obj_t* weekStripCreate(lv_obj_t* parent, lv_event_cb_t onDayPressed, lv_event_cb_t onDayClicked, void* userData) { + lv_obj_t* strip = lv_obj_create(parent); + lv_obj_remove_style_all(strip); + lv_obj_set_width(strip, LV_PCT(100)); + // Weekday, number and dot. + lv_obj_set_height(strip, static_cast(lvgl_get_text_font_height(FONT_SIZE_SMALL)) * 2 + 20); + lv_obj_set_flex_flow(strip, LV_FLEX_FLOW_ROW); + lv_obj_set_style_pad_all(strip, 2, LV_PART_MAIN); + lv_obj_set_style_pad_column(strip, 2, LV_PART_MAIN); + lv_obj_set_scrollable(strip, false); + + // The buttons are updated in place, so that a swipe doesn't delete the object that it started on. + for (int weekday = 0; weekday < 7; ++weekday) { + lv_obj_t* button = dayButtonCreate(strip, onDayClicked, userData); + lv_obj_add_event_cb(button, onDayPressed, LV_EVENT_PRESSED, userData); + lv_obj_set_width(button, 0); + lv_obj_set_flex_grow(button, 1); + lv_obj_set_height(button, LV_PCT(100)); + lv_obj_set_style_text_font(button, lvgl_get_text_font(FONT_SIZE_SMALL), LV_PART_MAIN); + } + lvgl_grid_navigation_add(strip); + return strip; +} + +void weekStripFill(lv_obj_t* strip, const std::vector& events, + const CalendarDate& selected, const CalendarDate& today) { + const CalendarDate monday = calendarAddDays(selected, -calendarWeekday(selected)); + for (int weekday = 0; weekday < 7; ++weekday) { + lv_obj_t* button = lv_obj_get_child(strip, weekday); + const CalendarDate date = calendarAddDays(monday, weekday); + char text[32] {}; + snprintf(text, sizeof(text), "%s\n%d", calendarWeekdayName(weekday), date.day); + dayButtonSet(button, date, text, events, false); + dayButtonSetState(button, selected, today); + } +} diff --git a/Apps/Calendar/main/Source/WeekStrip.h b/Apps/Calendar/main/Source/WeekStrip.h new file mode 100644 index 0000000..19725a6 --- /dev/null +++ b/Apps/Calendar/main/Source/WeekStrip.h @@ -0,0 +1,15 @@ +#pragma once + +#include "CalendarData.h" +#include "CalendarDate.h" + +#include + +#include + +// The callbacks receive the day button as the current target: see dayButtonDate(). +// A swipe ends in a click too: compare the position with that of the press. +lv_obj_t* weekStripCreate(lv_obj_t* parent, lv_event_cb_t onDayPressed, lv_event_cb_t onDayClicked, void* userData); +// Shows the Monday to Sunday week of the selected day. +void weekStripFill(lv_obj_t* strip, const std::vector& events, + const CalendarDate& selected, const CalendarDate& today); diff --git a/Apps/Calendar/manifest.properties b/Apps/Calendar/manifest.properties index 6a87309..8b00873 100644 --- a/Apps/Calendar/manifest.properties +++ b/Apps/Calendar/manifest.properties @@ -2,8 +2,8 @@ manifest.version=0.3 target.sdk=0.8.0-dev target.platforms=esp32,esp32s3,esp32c6,esp32p4,esp32s31 id=tactility.calendar -version.name=0.5.0 -version.code=7 +version.name=0.6.0 +version.code=8 name=Calendar description.short=Read-only CalDAV calendar description=View your CalDAV calendar in a month view, selected-day agenda, and upcoming agenda. Sync downloads and caches events for later viewing. diff --git a/Apps/Calendar/translations/de-DE.po b/Apps/Calendar/translations/de-DE.po index c6ae8fb..9b9fed5 100644 --- a/Apps/Calendar/translations/de-DE.po +++ b/Apps/Calendar/translations/de-DE.po @@ -8,6 +8,9 @@ msgstr "%s; Abfrage kommender Termine fehlgeschlagen: %s%s" msgid "; cache not saved." msgstr "; Cache nicht gespeichert." +msgid "A calendar entry is too large to load." +msgstr "Ein Kalendereintrag ist zu groß zum Laden." + msgid "Agenda incomplete" msgstr "Agenda unvollständig" @@ -26,8 +29,11 @@ msgstr "Agenda nutzt früheren Stand" msgid "App storage is unavailable; settings cannot be saved." msgstr "Kein App-Speicher; Speichern nicht möglich." -msgid "Back to month" -msgstr "Zurück zum Monat" +msgid "Apr" +msgstr "Apr" + +msgid "Aug" +msgstr "Aug" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "Gespeicherte Agenda deckt die nächsten 30 Tage nicht ab. Bitte synchronisieren." @@ -53,15 +59,9 @@ msgstr "Kalender" msgid "Calendar changed. Sync to load its events." msgstr "Kalender geändert. Synchronisieren, um Termine zu laden." -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "Keine Kalenderdaten. Synchronisieren zum Laden." - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "Kalender geladen, Cache nicht gespeichert." -msgid "Calendar response exceeds the 512 KB limit." -msgstr "Kalenderantwort überschreitet 512 KB." - msgid "Calendar settings could not be loaded completely." msgstr "Einstellungen nur teilweise geladen." @@ -101,26 +101,59 @@ msgstr "Geräteuhr nicht lesbar." msgid "Could not start the Agenda coverage timer." msgstr "Agenda-Timer nicht startbar." +msgid "Dec" +msgstr "Dez" + msgid "Downloaded %zu calendar events." msgstr "%zu Termine heruntergeladen." msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "Gib in den Einstellungen eine gültige HTTPS-Kalender-URL ein." +msgid "Events are synced up to {date}." +msgstr "Termine sind bis {date} synchronisiert." + +msgid "Feb" +msgstr "Feb" + +msgid "Fri" +msgstr "Fr" + msgid "HTTPS calendar URL" msgstr "HTTPS-Kalender-URL" +msgid "Jan" +msgstr "Jan" + +msgid "Jul" +msgstr "Juli" + +msgid "Jun" +msgstr "Juni" + msgid "Loaded %zu cached events. Sync to update." msgstr "%zu gespeicherte Termine geladen. Zum Aktualisieren synchronisieren." +msgid "Mar" +msgstr "März" + +msgid "May" +msgstr "Mai" + +msgid "Mon" +msgstr "Mo" + msgid "No events found in the next 30 days." msgstr "Keine Termine in den nächsten 30 Tagen." -msgid "No events found; some recurring events could not be expanded." -msgstr "Keine Termine; einige Serientermine nicht auflösbar." +msgid "No events in the 30 days from this date." +msgstr "Keine Termine in den 30 Tagen ab diesem Datum." -msgid "No events scheduled for this day." -msgstr "Keine Termine an diesem Tag." +msgid "Nov" +msgstr "Nov" + +msgid "Oct" +msgstr "Okt" msgid "Password" msgstr "Passwort" @@ -128,14 +161,17 @@ msgstr "Passwort" msgid "Ready to sync the full calendar." msgstr "Bereit zum Synchronisieren." +msgid "Sat" +msgstr "Sa" + msgid "Save" msgstr "Speichern" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "Kalender-Cache ungültig; bitte synchronisieren." -msgid "Selected day" -msgstr "Gewählter Tag" +msgid "Sep" +msgstr "Sep" msgid "Set the device clock before syncing." msgstr "Vor dem Synchronisieren die Geräteuhr stellen." @@ -149,15 +185,24 @@ msgstr "Einige Termine sind nicht berechenbar. Evtl. synchronisieren." msgid "Some recurring events could not be expanded." msgstr "Einige Serientermine nicht auflösbar." +msgid "Sun" +msgstr "So" + msgid "Sync discarded because calendar settings changed." msgstr "Sync verworfen, da Einstellungen geändert wurden." msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "Sync fehlgeschlagen. WLAN, URL und Zertifikat prüfen." +msgid "Sync to view other dates." +msgstr "Synchronisieren für andere Tage." + msgid "Syncing CalDAV calendar..." msgstr "Kalender wird synchronisiert..." +msgid "The calendar has too many events for the memory of this device." +msgstr "Der Kalender hat zu viele Termine für den Speicher dieses Geräts." + msgid "The full-calendar response is incomplete or invalid." msgstr "Antwort für den ganzen Kalender unvollständig oder ungültig." @@ -167,8 +212,32 @@ msgstr "Antwort für kommende Termine unvollständig oder ungültig." msgid "This firmware has no HTTPS certificate bundle." msgstr "Diese Firmware hat keine HTTPS-Zertifikate." +msgid "Thu" +msgstr "Do" + +msgid "Today, {date}" +msgstr "Heute, {date}" + +msgid "Tomorrow, {date}" +msgstr "Morgen, {date}" + +msgid "Tue" +msgstr "Di" + msgid "Use your CalDAV calendar collection URL." msgstr "Verwende die URL deines CalDAV-Kalenders." msgid "Username" msgstr "Benutzername" + +msgid "Wed" +msgstr "Mi" + +msgid "all day" +msgstr "ganzt." + +msgid "{month} {year}" +msgstr "{month} {year}" + +msgid "{weekday} {day} {month}" +msgstr "{weekday} {day}. {month}" diff --git a/Apps/Calendar/translations/es-ES.po b/Apps/Calendar/translations/es-ES.po index e73151e..1dd0f39 100644 --- a/Apps/Calendar/translations/es-ES.po +++ b/Apps/Calendar/translations/es-ES.po @@ -8,6 +8,9 @@ msgstr "%s; falló el informe de próximos eventos: %s%s" msgid "; cache not saved." msgstr "; caché no guardada." +msgid "A calendar entry is too large to load." +msgstr "Una entrada del calendario es demasiado grande." + msgid "Agenda incomplete" msgstr "Agenda incompleta" @@ -26,8 +29,11 @@ msgstr "La agenda usa el informe anterior" msgid "App storage is unavailable; settings cannot be saved." msgstr "Sin almacenamiento; no se pueden guardar ajustes." -msgid "Back to month" -msgstr "Volver al mes" +msgid "Apr" +msgstr "abr" + +msgid "Aug" +msgstr "ago" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "La agenda guardada no cubre los próximos 30 días. Sincroniza." @@ -53,15 +59,9 @@ msgstr "Calendario" msgid "Calendar changed. Sync to load its events." msgstr "Calendario cambiado. Sincroniza para cargar los eventos." -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "Sin datos. Sincroniza para descargar el calendario." - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "Calendario descargado, pero no se guardó la caché." -msgid "Calendar response exceeds the 512 KB limit." -msgstr "La respuesta supera el límite de 512 KB." - msgid "Calendar settings could not be loaded completely." msgstr "Los ajustes no se cargaron por completo." @@ -101,26 +101,59 @@ msgstr "No se pudo leer el reloj." msgid "Could not start the Agenda coverage timer." msgstr "No se pudo iniciar el temporizador de agenda." +msgid "Dec" +msgstr "dic" + msgid "Downloaded %zu calendar events." msgstr "%zu eventos descargados." msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "Introduce en Ajustes una URL HTTPS de calendario válida." +msgid "Events are synced up to {date}." +msgstr "Eventos sincronizados hasta: {date}." + +msgid "Feb" +msgstr "feb" + +msgid "Fri" +msgstr "vie" + msgid "HTTPS calendar URL" msgstr "URL HTTPS del calendario" +msgid "Jan" +msgstr "ene" + +msgid "Jul" +msgstr "jul" + +msgid "Jun" +msgstr "jun" + msgid "Loaded %zu cached events. Sync to update." msgstr "%zu eventos en caché. Sincroniza para actualizar." +msgid "Mar" +msgstr "mar" + +msgid "May" +msgstr "may" + +msgid "Mon" +msgstr "lun" + msgid "No events found in the next 30 days." msgstr "No hay eventos en los próximos 30 días." -msgid "No events found; some recurring events could not be expanded." -msgstr "Sin eventos; no se pudieron expandir algunos recurrentes." +msgid "No events in the 30 days from this date." +msgstr "No hay eventos en los 30 días desde esta fecha." -msgid "No events scheduled for this day." -msgstr "No hay eventos este día." +msgid "Nov" +msgstr "nov" + +msgid "Oct" +msgstr "oct" msgid "Password" msgstr "Contraseña" @@ -128,14 +161,17 @@ msgstr "Contraseña" msgid "Ready to sync the full calendar." msgstr "Listo para sincronizar el calendario." +msgid "Sat" +msgstr "sáb" + msgid "Save" msgstr "Guardar" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "La caché no es válida; sincroniza." -msgid "Selected day" -msgstr "Día seleccionado" +msgid "Sep" +msgstr "sep" msgid "Set the device clock before syncing." msgstr "Ajusta el reloj antes de sincronizar." @@ -149,15 +185,24 @@ msgstr "Algunos eventos no se pueden calcular. Quizá haya que sincronizar." msgid "Some recurring events could not be expanded." msgstr "No se pudieron expandir algunos eventos recurrentes." +msgid "Sun" +msgstr "dom" + msgid "Sync discarded because calendar settings changed." msgstr "Sincronización descartada: cambiaron los ajustes." msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "Error al sincronizar. Revisa Wi-Fi, URL y certificado." +msgid "Sync to view other dates." +msgstr "Sincroniza para ver otras fechas." + msgid "Syncing CalDAV calendar..." msgstr "Sincronizando calendario..." +msgid "The calendar has too many events for the memory of this device." +msgstr "El calendario tiene demasiados eventos para la memoria de este dispositivo." + msgid "The full-calendar response is incomplete or invalid." msgstr "La respuesta completa está incompleta o no es válida." @@ -167,8 +212,32 @@ msgstr "La respuesta de próximos eventos no es válida." msgid "This firmware has no HTTPS certificate bundle." msgstr "Este firmware no incluye certificados HTTPS." +msgid "Thu" +msgstr "jue" + +msgid "Today, {date}" +msgstr "Hoy, {date}" + +msgid "Tomorrow, {date}" +msgstr "Mañana, {date}" + +msgid "Tue" +msgstr "mar" + msgid "Use your CalDAV calendar collection URL." msgstr "Usa la URL de tu calendario CalDAV." msgid "Username" msgstr "Usuario" + +msgid "Wed" +msgstr "mié" + +msgid "all day" +msgstr "todo el día" + +msgid "{month} {year}" +msgstr "{month} {year}" + +msgid "{weekday} {day} {month}" +msgstr "{weekday} {day} {month}" diff --git a/Apps/Calendar/translations/fr-FR.po b/Apps/Calendar/translations/fr-FR.po index ddc1a87..52ebee8 100644 --- a/Apps/Calendar/translations/fr-FR.po +++ b/Apps/Calendar/translations/fr-FR.po @@ -8,6 +8,9 @@ msgstr "%s ; requête des événements à venir échouée : %s%s" msgid "; cache not saved." msgstr " ; cache non enregistré." +msgid "A calendar entry is too large to load." +msgstr "Une entrée du calendrier est trop volumineuse." + msgid "Agenda incomplete" msgstr "Agenda incomplet" @@ -26,8 +29,11 @@ msgstr "Agenda basé sur le rapport précédent" msgid "App storage is unavailable; settings cannot be saved." msgstr "Stockage indisponible ; impossible d'enregistrer." -msgid "Back to month" -msgstr "Retour au mois" +msgid "Apr" +msgstr "avr" + +msgid "Aug" +msgstr "août" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "L'agenda en cache ne couvre pas les 30 prochains jours. Synchronisez." @@ -53,15 +59,9 @@ msgstr "Calendrier" msgid "Calendar changed. Sync to load its events." msgstr "Calendrier modifié. Synchronisez pour charger ses événements." -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "Données indisponibles. Synchronisez pour les télécharger." - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "Calendrier téléchargé, mais cache non enregistré." -msgid "Calendar response exceeds the 512 KB limit." -msgstr "La réponse dépasse la limite de 512 Ko." - msgid "Calendar settings could not be loaded completely." msgstr "Réglages chargés partiellement." @@ -101,26 +101,59 @@ msgstr "Impossible de lire l'horloge." msgid "Could not start the Agenda coverage timer." msgstr "Impossible de démarrer le minuteur d'agenda." +msgid "Dec" +msgstr "déc" + msgid "Downloaded %zu calendar events." msgstr "%zu événements téléchargés." msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "Saisissez une URL HTTPS de calendrier valide dans les réglages." +msgid "Events are synced up to {date}." +msgstr "Événements synchronisés jusqu’au {date}." + +msgid "Feb" +msgstr "févr" + +msgid "Fri" +msgstr "ven" + msgid "HTTPS calendar URL" msgstr "URL HTTPS du calendrier" +msgid "Jan" +msgstr "janv" + +msgid "Jul" +msgstr "juil" + +msgid "Jun" +msgstr "juin" + msgid "Loaded %zu cached events. Sync to update." msgstr "%zu événements en cache. Synchronisez pour actualiser." +msgid "Mar" +msgstr "mars" + +msgid "May" +msgstr "mai" + +msgid "Mon" +msgstr "lun" + msgid "No events found in the next 30 days." msgstr "Aucun événement dans les 30 prochains jours." -msgid "No events found; some recurring events could not be expanded." -msgstr "Aucun événement ; certaines récurrences non développées." +msgid "No events in the 30 days from this date." +msgstr "Aucun événement dans les 30 jours à partir de cette date." -msgid "No events scheduled for this day." -msgstr "Aucun événement ce jour-là." +msgid "Nov" +msgstr "nov" + +msgid "Oct" +msgstr "oct" msgid "Password" msgstr "Mot de passe" @@ -128,14 +161,17 @@ msgstr "Mot de passe" msgid "Ready to sync the full calendar." msgstr "Prêt à synchroniser le calendrier." +msgid "Sat" +msgstr "sam" + msgid "Save" msgstr "Enregistrer" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "Cache non valide ; synchronisez." -msgid "Selected day" -msgstr "Jour sélectionné" +msgid "Sep" +msgstr "sept" msgid "Set the device clock before syncing." msgstr "Réglez l'horloge avant de synchroniser." @@ -149,15 +185,24 @@ msgstr "Certains événements ne peuvent être calculés. Synchronisez." msgid "Some recurring events could not be expanded." msgstr "Certaines récurrences n'ont pas pu être développées." +msgid "Sun" +msgstr "dim" + msgid "Sync discarded because calendar settings changed." msgstr "Synchronisation annulée : réglages modifiés." msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "Échec. Vérifiez le Wi-Fi, l'URL et le certificat." +msgid "Sync to view other dates." +msgstr "Synchronisez pour voir d’autres dates." + msgid "Syncing CalDAV calendar..." msgstr "Synchronisation du calendrier..." +msgid "The calendar has too many events for the memory of this device." +msgstr "Le calendrier a trop d’événements pour la mémoire de cet appareil." + msgid "The full-calendar response is incomplete or invalid." msgstr "La réponse complète est incomplète ou non valide." @@ -167,8 +212,32 @@ msgstr "La réponse des événements à venir est non valide." msgid "This firmware has no HTTPS certificate bundle." msgstr "Ce micrologiciel n'a pas de certificats HTTPS." +msgid "Thu" +msgstr "jeu" + +msgid "Today, {date}" +msgstr "Aujourd'hui, {date}" + +msgid "Tomorrow, {date}" +msgstr "Demain, {date}" + +msgid "Tue" +msgstr "mar" + msgid "Use your CalDAV calendar collection URL." msgstr "Utilisez l'URL de votre calendrier CalDAV." msgid "Username" msgstr "Nom d'utilisateur" + +msgid "Wed" +msgstr "mer" + +msgid "all day" +msgstr "journée" + +msgid "{month} {year}" +msgstr "{month} {year}" + +msgid "{weekday} {day} {month}" +msgstr "{weekday} {day} {month}" diff --git a/Apps/Calendar/translations/ja-JP.po b/Apps/Calendar/translations/ja-JP.po index d68171b..25597d7 100644 --- a/Apps/Calendar/translations/ja-JP.po +++ b/Apps/Calendar/translations/ja-JP.po @@ -8,6 +8,9 @@ msgstr "%s。今後の予定の取得に失敗: %s%s" msgid "; cache not saved." msgstr "(キャッシュは未保存)" +msgid "A calendar entry is too large to load." +msgstr "カレンダーの項目が大きすぎて読み込めません。" + msgid "Agenda incomplete" msgstr "予定は不完全です" @@ -26,8 +29,11 @@ msgstr "予定は前回の結果を使用" msgid "App storage is unavailable; settings cannot be saved." msgstr "保存先がないため設定を保存できません。" -msgid "Back to month" -msgstr "月表示に戻る" +msgid "Apr" +msgstr "4月" + +msgid "Aug" +msgstr "8月" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "保存した予定は今後30日をカバーしていません。同期してください。" @@ -53,15 +59,9 @@ msgstr "カレンダー" msgid "Calendar changed. Sync to load its events." msgstr "カレンダーが変わりました。同期して予定を読み込んでください。" -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "データがありません。同期してダウンロードしてください。" - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "ダウンロードしましたが、保存できませんでした。" -msgid "Calendar response exceeds the 512 KB limit." -msgstr "カレンダーの応答が512 KBを超えています。" - msgid "Calendar settings could not be loaded completely." msgstr "設定を完全には読み込めませんでした。" @@ -101,26 +101,59 @@ msgstr "時計を読み取れません。" msgid "Could not start the Agenda coverage timer." msgstr "予定のタイマーを開始できません。" +msgid "Dec" +msgstr "12月" + msgid "Downloaded %zu calendar events." msgstr "%zu件の予定をダウンロードしました。" msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "設定で有効なHTTPSカレンダーURLを入力してください。" +msgid "Events are synced up to {date}." +msgstr "予定は{date}まで同期されています。" + +msgid "Feb" +msgstr "2月" + +msgid "Fri" +msgstr "金" + msgid "HTTPS calendar URL" msgstr "HTTPSカレンダーURL" +msgid "Jan" +msgstr "1月" + +msgid "Jul" +msgstr "7月" + +msgid "Jun" +msgstr "6月" + msgid "Loaded %zu cached events. Sync to update." msgstr "保存済みの予定%zu件を読み込みました。同期で更新します。" +msgid "Mar" +msgstr "3月" + +msgid "May" +msgstr "5月" + +msgid "Mon" +msgstr "月" + msgid "No events found in the next 30 days." msgstr "今後30日間の予定はありません。" -msgid "No events found; some recurring events could not be expanded." -msgstr "予定なし。一部の繰り返し予定は展開できませんでした。" +msgid "No events in the 30 days from this date." +msgstr "この日から30日間の予定はありません。" -msgid "No events scheduled for this day." -msgstr "この日の予定はありません。" +msgid "Nov" +msgstr "11月" + +msgid "Oct" +msgstr "10月" msgid "Password" msgstr "パスワード" @@ -128,14 +161,17 @@ msgstr "パスワード" msgid "Ready to sync the full calendar." msgstr "カレンダー全体を同期できます。" +msgid "Sat" +msgstr "土" + msgid "Save" msgstr "保存" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "保存データが無効です。同期してください。" -msgid "Selected day" -msgstr "選択した日" +msgid "Sep" +msgstr "9月" msgid "Set the device clock before syncing." msgstr "同期の前に時計を設定してください。" @@ -149,15 +185,24 @@ msgstr "一部の予定を計算できません。同期が必要かもしれま msgid "Some recurring events could not be expanded." msgstr "一部の繰り返し予定を展開できませんでした。" +msgid "Sun" +msgstr "日" + msgid "Sync discarded because calendar settings changed." msgstr "設定が変更されたため同期を破棄しました。" msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "同期失敗。Wi-Fi、URL、証明書を確認してください。" +msgid "Sync to view other dates." +msgstr "他の日付を見るには同期してください。" + msgid "Syncing CalDAV calendar..." msgstr "カレンダーを同期中..." +msgid "The calendar has too many events for the memory of this device." +msgstr "予定が多すぎて、この端末のメモリに収まりません。" + msgid "The full-calendar response is incomplete or invalid." msgstr "カレンダー全体の応答が不完全か無効です。" @@ -167,8 +212,32 @@ msgstr "今後の予定の応答が不完全か無効です。" msgid "This firmware has no HTTPS certificate bundle." msgstr "このファームウェアにはHTTPS証明書がありません。" +msgid "Thu" +msgstr "木" + +msgid "Today, {date}" +msgstr "今日 {date}" + +msgid "Tomorrow, {date}" +msgstr "明日 {date}" + +msgid "Tue" +msgstr "火" + msgid "Use your CalDAV calendar collection URL." msgstr "CalDAVカレンダーのURLを入力してください。" msgid "Username" msgstr "ユーザー名" + +msgid "Wed" +msgstr "水" + +msgid "all day" +msgstr "終日" + +msgid "{month} {year}" +msgstr "{year}年{month}" + +msgid "{weekday} {day} {month}" +msgstr "{month}{day}日({weekday})" diff --git a/Apps/Calendar/translations/ko-KR.po b/Apps/Calendar/translations/ko-KR.po index 4174144..0829d5e 100644 --- a/Apps/Calendar/translations/ko-KR.po +++ b/Apps/Calendar/translations/ko-KR.po @@ -8,6 +8,9 @@ msgstr "%s. 예정 일정 조회 실패: %s%s" msgid "; cache not saved." msgstr " (캐시 저장 안 됨)" +msgid "A calendar entry is too large to load." +msgstr "캘린더 항목이 너무 커서 불러올 수 없습니다." + msgid "Agenda incomplete" msgstr "일정이 불완전함" @@ -26,8 +29,11 @@ msgstr "이전 결과를 사용하는 일정" msgid "App storage is unavailable; settings cannot be saved." msgstr "앱 저장소가 없어 설정을 저장할 수 없습니다." -msgid "Back to month" -msgstr "월 보기로" +msgid "Apr" +msgstr "4월" + +msgid "Aug" +msgstr "8월" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "저장된 일정이 현재 30일 범위를 포함하지 않습니다. 동기화하세요." @@ -53,15 +59,9 @@ msgstr "캘린더" msgid "Calendar changed. Sync to load its events." msgstr "캘린더가 변경되었습니다. 동기화해 일정을 불러오세요." -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "캘린더 데이터가 없습니다. 동기화해 내려받으세요." - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "캘린더를 받았지만 캐시를 저장하지 못했습니다." -msgid "Calendar response exceeds the 512 KB limit." -msgstr "캘린더 응답이 512 KB 제한을 초과합니다." - msgid "Calendar settings could not be loaded completely." msgstr "설정을 완전히 불러오지 못했습니다." @@ -101,26 +101,59 @@ msgstr "기기 시계를 읽을 수 없습니다." msgid "Could not start the Agenda coverage timer." msgstr "일정 타이머를 시작할 수 없습니다." +msgid "Dec" +msgstr "12월" + msgid "Downloaded %zu calendar events." msgstr "일정 %zu개를 내려받았습니다." msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "설정에서 올바른 HTTPS 캘린더 URL을 입력하세요." +msgid "Events are synced up to {date}." +msgstr "{date}까지의 일정이 동기화되었습니다." + +msgid "Feb" +msgstr "2월" + +msgid "Fri" +msgstr "금" + msgid "HTTPS calendar URL" msgstr "HTTPS 캘린더 URL" +msgid "Jan" +msgstr "1월" + +msgid "Jul" +msgstr "7월" + +msgid "Jun" +msgstr "6월" + msgid "Loaded %zu cached events. Sync to update." msgstr "저장된 일정 %zu개를 불러왔습니다. 동기화해 갱신하세요." +msgid "Mar" +msgstr "3월" + +msgid "May" +msgstr "5월" + +msgid "Mon" +msgstr "월" + msgid "No events found in the next 30 days." msgstr "앞으로 30일 동안 일정이 없습니다." -msgid "No events found; some recurring events could not be expanded." -msgstr "일정 없음. 일부 반복 일정을 펼칠 수 없었습니다." +msgid "No events in the 30 days from this date." +msgstr "이 날짜부터 30일 동안 일정이 없습니다." -msgid "No events scheduled for this day." -msgstr "이 날짜에는 일정이 없습니다." +msgid "Nov" +msgstr "11월" + +msgid "Oct" +msgstr "10월" msgid "Password" msgstr "비밀번호" @@ -128,14 +161,17 @@ msgstr "비밀번호" msgid "Ready to sync the full calendar." msgstr "전체 캘린더를 동기화할 준비가 되었습니다." +msgid "Sat" +msgstr "토" + msgid "Save" msgstr "저장" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "저장된 캐시가 잘못되었습니다. 동기화하세요." -msgid "Selected day" -msgstr "선택한 날짜" +msgid "Sep" +msgstr "9월" msgid "Set the device clock before syncing." msgstr "동기화 전에 기기 시계를 설정하세요." @@ -149,15 +185,24 @@ msgstr "일부 일정을 계산할 수 없습니다. 동기화가 필요할 수 msgid "Some recurring events could not be expanded." msgstr "일부 반복 일정을 펼칠 수 없었습니다." +msgid "Sun" +msgstr "일" + msgid "Sync discarded because calendar settings changed." msgstr "설정이 변경되어 동기화를 버렸습니다." msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "동기화 실패. Wi-Fi, URL, 인증서를 확인하세요." +msgid "Sync to view other dates." +msgstr "다른 날짜를 보려면 동기화하세요." + msgid "Syncing CalDAV calendar..." msgstr "캘린더 동기화 중..." +msgid "The calendar has too many events for the memory of this device." +msgstr "일정이 너무 많아 이 기기의 메모리에 담을 수 없습니다." + msgid "The full-calendar response is incomplete or invalid." msgstr "전체 캘린더 응답이 불완전하거나 잘못되었습니다." @@ -167,8 +212,32 @@ msgstr "예정된 일정 응답이 불완전하거나 잘못되었습니다." msgid "This firmware has no HTTPS certificate bundle." msgstr "이 펌웨어에는 HTTPS 인증서 묶음이 없습니다." +msgid "Thu" +msgstr "목" + +msgid "Today, {date}" +msgstr "오늘, {date}" + +msgid "Tomorrow, {date}" +msgstr "내일, {date}" + +msgid "Tue" +msgstr "화" + msgid "Use your CalDAV calendar collection URL." msgstr "CalDAV 캘린더 URL을 사용하세요." msgid "Username" msgstr "사용자 이름" + +msgid "Wed" +msgstr "수" + +msgid "all day" +msgstr "종일" + +msgid "{month} {year}" +msgstr "{year}년 {month}" + +msgid "{weekday} {day} {month}" +msgstr "{month} {day}일 ({weekday})" diff --git a/Apps/Calendar/translations/zh-CN.po b/Apps/Calendar/translations/zh-CN.po index dec90d6..aff0db8 100644 --- a/Apps/Calendar/translations/zh-CN.po +++ b/Apps/Calendar/translations/zh-CN.po @@ -8,6 +8,9 @@ msgstr "%s;近期日程查询失败:%s%s" msgid "; cache not saved." msgstr ";缓存未保存。" +msgid "A calendar entry is too large to load." +msgstr "日历条目过大,无法加载。" + msgid "Agenda incomplete" msgstr "日程不完整" @@ -26,8 +29,11 @@ msgstr "日程沿用上次结果" msgid "App storage is unavailable; settings cannot be saved." msgstr "应用存储不可用;无法保存设置。" -msgid "Back to month" -msgstr "返回月视图" +msgid "Apr" +msgstr "4月" + +msgid "Aug" +msgstr "8月" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "缓存的日程未覆盖当前 30 天。请同步刷新。" @@ -53,15 +59,9 @@ msgstr "日历" msgid "Calendar changed. Sync to load its events." msgstr "日历已更改。请同步以载入日程。" -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "没有日历数据。请同步下载。" - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "日历已下载,但无法保存本地缓存。" -msgid "Calendar response exceeds the 512 KB limit." -msgstr "日历响应超过 512 KB 限制。" - msgid "Calendar settings could not be loaded completely." msgstr "日历设置未能完整载入。" @@ -101,26 +101,59 @@ msgstr "无法读取设备时钟。" msgid "Could not start the Agenda coverage timer." msgstr "无法启动日程计时器。" +msgid "Dec" +msgstr "12月" + msgid "Downloaded %zu calendar events." msgstr "已下载 %zu 个日程。" msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "请在设置中输入有效的 HTTPS 日历网址。" +msgid "Events are synced up to {date}." +msgstr "日程已同步至{date}。" + +msgid "Feb" +msgstr "2月" + +msgid "Fri" +msgstr "五" + msgid "HTTPS calendar URL" msgstr "HTTPS 日历网址" +msgid "Jan" +msgstr "1月" + +msgid "Jul" +msgstr "7月" + +msgid "Jun" +msgstr "6月" + msgid "Loaded %zu cached events. Sync to update." msgstr "已载入 %zu 个缓存日程。同步以更新。" +msgid "Mar" +msgstr "3月" + +msgid "May" +msgstr "5月" + +msgid "Mon" +msgstr "一" + msgid "No events found in the next 30 days." msgstr "未来 30 天没有日程。" -msgid "No events found; some recurring events could not be expanded." -msgstr "未找到日程;部分重复日程无法展开。" +msgid "No events in the 30 days from this date." +msgstr "自该日期起的30天内没有日程。" -msgid "No events scheduled for this day." -msgstr "当天没有日程。" +msgid "Nov" +msgstr "11月" + +msgid "Oct" +msgstr "10月" msgid "Password" msgstr "密码" @@ -128,14 +161,17 @@ msgstr "密码" msgid "Ready to sync the full calendar." msgstr "可以同步完整日历。" +msgid "Sat" +msgstr "六" + msgid "Save" msgstr "保存" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "已保存的缓存无效;请同步刷新。" -msgid "Selected day" -msgstr "所选日期" +msgid "Sep" +msgstr "9月" msgid "Set the device clock before syncing." msgstr "同步前请设置设备时钟。" @@ -149,15 +185,24 @@ msgstr "部分缓存日程无法计算,可能需要同步。" msgid "Some recurring events could not be expanded." msgstr "部分重复日程无法展开。" +msgid "Sun" +msgstr "日" + msgid "Sync discarded because calendar settings changed." msgstr "日历设置已更改,本次同步已丢弃。" msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "同步失败。请检查 Wi-Fi、网址和 HTTPS 证书。" +msgid "Sync to view other dates." +msgstr "同步后可查看其他日期。" + msgid "Syncing CalDAV calendar..." msgstr "正在同步日历..." +msgid "The calendar has too many events for the memory of this device." +msgstr "日程过多,超出本设备内存。" + msgid "The full-calendar response is incomplete or invalid." msgstr "完整日历响应不完整或无效。" @@ -167,8 +212,32 @@ msgstr "近期日程响应不完整或无效。" msgid "This firmware has no HTTPS certificate bundle." msgstr "此固件不含 HTTPS 证书包。" +msgid "Thu" +msgstr "四" + +msgid "Today, {date}" +msgstr "今天,{date}" + +msgid "Tomorrow, {date}" +msgstr "明天,{date}" + +msgid "Tue" +msgstr "二" + msgid "Use your CalDAV calendar collection URL." msgstr "请使用 CalDAV 日历集合网址。" msgid "Username" msgstr "用户名" + +msgid "Wed" +msgstr "三" + +msgid "all day" +msgstr "全天" + +msgid "{month} {year}" +msgstr "{year}年{month}" + +msgid "{weekday} {day} {month}" +msgstr "{month}{day}日 周{weekday}" diff --git a/Apps/Calendar/translations/zh-TW.po b/Apps/Calendar/translations/zh-TW.po index 3628f31..d64528e 100644 --- a/Apps/Calendar/translations/zh-TW.po +++ b/Apps/Calendar/translations/zh-TW.po @@ -8,6 +8,9 @@ msgstr "%s;近期行程查詢失敗:%s%s" msgid "; cache not saved." msgstr ";快取未儲存。" +msgid "A calendar entry is too large to load." +msgstr "行事曆項目過大,無法載入。" + msgid "Agenda incomplete" msgstr "行程不完整" @@ -26,8 +29,11 @@ msgstr "行程沿用上次結果" msgid "App storage is unavailable; settings cannot be saved." msgstr "應用程式儲存空間無法使用;無法儲存設定。" -msgid "Back to month" -msgstr "返回月檢視" +msgid "Apr" +msgstr "4月" + +msgid "Aug" +msgstr "8月" msgid "Cached Agenda does not cover the current 30-day window. Sync to refresh." msgstr "快取的行程未涵蓋目前 30 天。請同步更新。" @@ -53,15 +59,9 @@ msgstr "行事曆" msgid "Calendar changed. Sync to load its events." msgstr "行事曆已變更。請同步以載入行程。" -msgid "Calendar data unavailable. Sync to download the calendar." -msgstr "沒有行事曆資料。請同步下載。" - msgid "Calendar downloaded, but its local cache could not be saved." msgstr "行事曆已下載,但無法儲存本機快取。" -msgid "Calendar response exceeds the 512 KB limit." -msgstr "行事曆回應超過 512 KB 上限。" - msgid "Calendar settings could not be loaded completely." msgstr "行事曆設定未能完整載入。" @@ -101,26 +101,59 @@ msgstr "無法讀取裝置時鐘。" msgid "Could not start the Agenda coverage timer." msgstr "無法啟動行程計時器。" +msgid "Dec" +msgstr "12月" + msgid "Downloaded %zu calendar events." msgstr "已下載 %zu 個行程。" msgid "Enter a valid HTTPS calendar collection URL in Settings." msgstr "請在設定中輸入有效的 HTTPS 行事曆網址。" +msgid "Events are synced up to {date}." +msgstr "行程已同步至{date}。" + +msgid "Feb" +msgstr "2月" + +msgid "Fri" +msgstr "五" + msgid "HTTPS calendar URL" msgstr "HTTPS 行事曆網址" +msgid "Jan" +msgstr "1月" + +msgid "Jul" +msgstr "7月" + +msgid "Jun" +msgstr "6月" + msgid "Loaded %zu cached events. Sync to update." msgstr "已載入 %zu 個快取行程。同步以更新。" +msgid "Mar" +msgstr "3月" + +msgid "May" +msgstr "5月" + +msgid "Mon" +msgstr "一" + msgid "No events found in the next 30 days." msgstr "未來 30 天沒有行程。" -msgid "No events found; some recurring events could not be expanded." -msgstr "找不到行程;部分重複行程無法展開。" +msgid "No events in the 30 days from this date." +msgstr "自該日期起的30天內沒有行程。" -msgid "No events scheduled for this day." -msgstr "當天沒有行程。" +msgid "Nov" +msgstr "11月" + +msgid "Oct" +msgstr "10月" msgid "Password" msgstr "密碼" @@ -128,14 +161,17 @@ msgstr "密碼" msgid "Ready to sync the full calendar." msgstr "可以同步完整行事曆。" +msgid "Sat" +msgstr "六" + msgid "Save" msgstr "儲存" msgid "Saved calendar cache is invalid; sync to refresh." msgstr "已儲存的快取無效;請同步更新。" -msgid "Selected day" -msgstr "所選日期" +msgid "Sep" +msgstr "9月" msgid "Set the device clock before syncing." msgstr "同步前請設定裝置時鐘。" @@ -149,15 +185,24 @@ msgstr "部分快取行程無法計算,可能需要同步。" msgid "Some recurring events could not be expanded." msgstr "部分重複行程無法展開。" +msgid "Sun" +msgstr "日" + msgid "Sync discarded because calendar settings changed." msgstr "行事曆設定已變更,本次同步已捨棄。" msgid "Sync failed. Check Wi-Fi, URL and HTTPS certificate." msgstr "同步失敗。請檢查 Wi-Fi、網址和 HTTPS 憑證。" +msgid "Sync to view other dates." +msgstr "同步後即可檢視其他日期。" + msgid "Syncing CalDAV calendar..." msgstr "正在同步行事曆..." +msgid "The calendar has too many events for the memory of this device." +msgstr "行程過多,超出本裝置記憶體。" + msgid "The full-calendar response is incomplete or invalid." msgstr "完整行事曆回應不完整或無效。" @@ -167,8 +212,32 @@ msgstr "近期行程回應不完整或無效。" msgid "This firmware has no HTTPS certificate bundle." msgstr "此韌體不含 HTTPS 憑證包。" +msgid "Thu" +msgstr "四" + +msgid "Today, {date}" +msgstr "今天,{date}" + +msgid "Tomorrow, {date}" +msgstr "明天,{date}" + +msgid "Tue" +msgstr "二" + msgid "Use your CalDAV calendar collection URL." msgstr "請使用 CalDAV 行事曆集合網址。" msgid "Username" msgstr "使用者名稱" + +msgid "Wed" +msgstr "三" + +msgid "all day" +msgstr "全天" + +msgid "{month} {year}" +msgstr "{year}年{month}" + +msgid "{weekday} {day} {month}" +msgstr "{month}{day}日 週{weekday}"