diff --git a/CHANGELOG b/CHANGELOG index cbae3acf..950e125d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * Settings import/export scripts work on release builds * Fixed an issue where the onboarding flow failed to detect the existing glasses firmware version * Update launcher, files, and game UIs to work better with watch input +* Calendar app shows the day-of-the-month in its icon ## 0.6 - 2026-08-29 - Start keeping a changelog and making signed binaries via GitHub Releases diff --git a/app/apps/calendar/calendar-app.ts b/app/apps/calendar/calendar-app.ts index 1d13337d..fddf39fd 100644 --- a/app/apps/calendar/calendar-app.ts +++ b/app/apps/calendar/calendar-app.ts @@ -1,6 +1,8 @@ import { ensureCalendarPermission, hasCalendarPermission } from "../../g2/android-permissions"; import { invalidateCalendarCache } from "../../native/calendar"; +import { makeImageWindowIcon, windowIcon } from "../../ui/shell/chrome-layer"; import { CalendarLayer } from "./calendar"; +import { renderCalendarDateIcon } from "./calendar-icon"; import { createInProcessWindow, YieldAtRootLayer, @@ -39,6 +41,7 @@ export function createCalendarAppWindow(options: InProcessAppOptions): InProcess title: "Calendar", iconLetter: "Ca", icon: "calendar", + drawIcon: makeImageWindowIcon(renderCalendarDateIcon, windowIcon("calendar", "Ca")), closeable: true, actions: options.actions, baseLayer: new YieldAtRootLayer(new CalendarLayer(requestPermission)), diff --git a/app/apps/calendar/calendar-icon.ts b/app/apps/calendar/calendar-icon.ts new file mode 100644 index 00000000..151784cf --- /dev/null +++ b/app/apps/calendar/calendar-icon.ts @@ -0,0 +1,55 @@ +import { type GrayImage } from "../../graphics/image"; +import { ICON_SVGS, renderSvgIcon } from "../../graphics/icons"; +import { ensurePreinstalledFonts, installedFontPath } from "../../graphics/installed-fonts"; +import { TtfFont } from "../../graphics/ttf-font"; + +// The calendar icon minus its divider line, freeing the whole box for the +// date digits. Derived from the shared SVG so the outline stays in sync. +const DIVIDER = ''; +const CALENDAR_BLANK_SVG = ICON_SVGS.calendar.replace(DIVIDER, ""); + +// One entry per requested size (launcher 44, sidebar 32/28); replaced when the +// day rolls over. A fresh image object per (size, day) keeps downstream +// per-object caches (texture cache, the sidebar's inverted-icon memo) correct. +const cache = new Map(); + +/** + * Digit font: bundled Roboto scaled to the icon (not the user-selected UI + * font, so the digits always fit the icon's box). Loaded once per icon size. + */ +const digitFonts = new Map(); +function loadDigitFont(size: number): TtfFont | null { + let font = digitFonts.get(size); + if (font === undefined) { + ensurePreinstalledFonts(); // the icon can render before any font picker use + font = TtfFont.load(installedFontPath("Roboto-Regular.ttf"), Math.round(size / 2)); + digitFonts.set(size, font); + } + return font; +} + +/** + * The calendar icon with today's day-of-month drawn in its body, like a phone + * calendar app icon. + */ +export function renderCalendarDateIcon(size: number): GrayImage | null { + const day = new Date().getDate(); + const cached = cache.get(size); + if (cached && cached.day === day) return cached.image; + const base = renderSvgIcon("calendar-blank", CALENDAR_BLANK_SVG, size); + if (!base) return null; + // Without the digits the divider-less icon reads as broken; a null return + // gets both call sites' stock-calendar fallback instead. + const font = loadDigitFont(size); + if (!font) return null; + const image = base.clone(); + const text = String(day); + // Center in the box interior (viewBox y 5..21 of 24, inside the stroke), + // nudged down so the digits sit clear of the top-edge hanging tabs. + const x = Math.round((size - font.measureText(text)) / 2); + const y = Math.round((size * 13.5) / 24 - font.lineHeight / 2); + image.drawText(font, x, y, text, 255); + image.bakeDeferredDrawsInPlace(); + cache.set(size, { day, image }); + return image; +} diff --git a/app/apps/calendar/index.ts b/app/apps/calendar/index.ts index 07b98e36..03cdb74d 100644 --- a/app/apps/calendar/index.ts +++ b/app/apps/calendar/index.ts @@ -1,10 +1,12 @@ import { type AppDefinition } from "../app-definition"; import { CALENDAR_SURFACE_ID, CALENDAR_WINDOW_ID, createCalendarAppWindow } from "./calendar-app"; +import { renderCalendarDateIcon } from "./calendar-icon"; const calendarApp: AppDefinition = { appId: "calendar", title: "Calendar", icon: "calendar", + renderIcon: renderCalendarDateIcon, launch: (ctx) => ctx.launchInProcessApp(CALENDAR_WINDOW_ID, CALENDAR_SURFACE_ID, createCalendarAppWindow), };