diff --git a/ACKNOWLEDGEMENTS.md b/ACKNOWLEDGEMENTS.md index fe2fac36..a054eae1 100644 --- a/ACKNOWLEDGEMENTS.md +++ b/ACKNOWLEDGEMENTS.md @@ -13,6 +13,13 @@ and others who contributed to documenting the G2's bluetooth protocol and firmwa G2 microphone LC3 decoding uses Google's liblc3: https://github.com/google/liblc3 +iPhone notification icons are Pebble's notification and timeline icons, from +https://github.com/pebble-dev/iconography: the original Pebble Technology icons +and Rebble community additions. They are licensed under the Apache License 2.0; +see app/graphics/pebble-icons.LICENSE. Faceclaw's table of the iPhone apps they +stand for builds on the one in the PebbleOS firmware, +https://github.com/coredevices/PebbleOS (also Apache License 2.0). + Weather data outside the US is by Open-Meteo.com: https://open-meteo.com/. It is licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). diff --git a/app/apps/glanceboard/widgets/system-card.ts b/app/apps/glanceboard/widgets/system-card.ts index e823cb5e..2ef3515a 100644 --- a/app/apps/glanceboard/widgets/system-card.ts +++ b/app/apps/glanceboard/widgets/system-card.ts @@ -9,6 +9,7 @@ import { import { type GrayImage, type UiFont } from "../../../graphics/image"; import { ensureLocationPermission, hasLocationPermission } from "../../../native/location-permissions"; import { onAndroidNotificationsChanged, readActiveNotificationIcons } from "../../../native/notification-icons"; +import { NOTIFICATION_ICON_SIZE } from "../../../native/notification-types"; import { readPhoneBatteryState } from "../../../native/phone-battery"; import { weatherBridge } from "../../../native/weather"; import { formatClockDate, formatClockTime } from "../../../ui/clock-format"; @@ -37,7 +38,6 @@ import { glanceFont } from "../glance-font"; import { type GlanceWidget } from "../widget"; const PAD = 8; -const NOTIFICATION_ICON_SIZE = 24; const NOTIFICATION_ICON_GAP = 4; const BATTERY_ITEM_GAP = 12; const BATTERY_LABEL_VALUE = 150; diff --git a/app/graphics/evenhub-font.ts b/app/graphics/evenhub-font.ts index 737715ed..d80ca2bd 100644 --- a/app/graphics/evenhub-font.ts +++ b/app/graphics/evenhub-font.ts @@ -25,6 +25,7 @@ import { EVENHUB_RUNTIME_FONT_FILENAME, isEvenHubFontAsset } from "../g2/firmwar import { lvglMetrics, lvglGlyph } from "../native/lvgl-font"; import { GrayImage, grayToNibble, type FwTextFont, type PlacedFwText, type PlacedFwTextGlyph } from "./image"; import { TtfFont } from "./ttf-font"; +import { decodeBase64 } from "../util/base64"; const CJK_ASSET_PATH = "fonts/source-han-sans/SourceHanSansSC-Light-20.lvgl.bin"; @@ -55,25 +56,6 @@ type CjkGlyph = { bitmap: Uint8Array; }; -const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -function base64Decode(text: string): Uint8Array { - const clean = text.replace(/[^A-Za-z0-9+/]/g, ""); - const out = new Uint8Array(Math.floor((clean.length * 3) / 4)); - let bits = 0; - let bitCount = 0; - let outIndex = 0; - for (let i = 0; i < clean.length; i++) { - bits = (bits << 6) | BASE64_ALPHABET.indexOf(clean[i]!); - bitCount += 6; - if (bitCount >= 8) { - bitCount -= 8; - out[outIndex++] = (bits >> bitCount) & 0xff; - } - } - return out.subarray(0, outIndex); -} - /** * Codepoint ranges whose glyphs the font asset merged from the flash CJK * font with a baseline-shifted ofsY (see scripts/build-evenhub-font.mjs). @@ -144,7 +126,7 @@ export class EvenHubFont implements FwTextFont { this.useTtfFallback = useTtfFallback; this.lineHeight = asset.lineHeight; this.baseline = asset.baseline; - this.bitmap = base64Decode(asset.bitmapBase64); + this.bitmap = decodeBase64(asset.bitmapBase64); this.glyphs = new Map(); for (const key of Object.keys(asset.glyphs)) { this.glyphs.set(Number(key), asset.glyphs[key]!); diff --git a/app/graphics/pebble-icons-data.ts b/app/graphics/pebble-icons-data.ts new file mode 100644 index 00000000..ae0188fd --- /dev/null +++ b/app/graphics/pebble-icons-data.ts @@ -0,0 +1,100 @@ +// Generated by scripts/generate-pebble-icons.cjs; do not edit by hand. +// +// Pebble notification icons from https://github.com/pebble-dev/iconography +// (commit 16a9ea42ea7ac079127af2ecc54f453dfbc314c8): the original Pebble Technology icons and +// Rebble community additions, licensed under the Apache License 2.0 (see +// app/graphics/pebble-icons.LICENSE). Modified: rasterized at 25x25 and +// inverted for a black display (Pebble draws them black on white). +// +// Each icon is SIZE x SIZE pixels at 2 bits each (0, 1, 2 = coverage 0, +// 128, 255), four pixels to a byte with the first in the high bits, +// row-major, base64-encoded. + +export const PEBBLE_ICON_SIZE = 25; + +export const PEBBLE_ICON_DATA = { + generic: "AAACgAAAAAAAoAAAAAAAKAAAAAACqqgAAAACqqqAAAACoACoAAACoAAKgAACoAAAqAAAoAAACgAAKAAAAoAACgAAAKAAAoAAACgAAKAAAAoAACgAAAKAACoAAACoACoAAAAKgCqqqAAAqAqqqgAACgKAAAAAAoCgAAAAAKAqqqqqqqgKqqqqqqoAAAAABkAAAAAAAKAAAAAAACgAAA==", // pebbleos/Pebble_25x25_Generic_notification.svg + activity: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAACkAGkAAAAqkKqQAAAKaqhqAAACgagqpAAAoAQaakAAKAABGqkACgAAClqkAoAAAUZqQKqpAAKBqSlWqqqgBooAFVWkAKKAAAAZACilVVValVpqqqqqqqqQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Activity.svg + alarmClock: "AAAAAAAAAAAAAAAAAAoAAACgAAqCqqgqAAqCqqqCoAqCoACoKgKCoAAKgoACoAoAqAACoAKACoACoACgAKgAoAAoAAoAKAAKAAKACgAKgACgAoAKgAAoAKAKgAAKACgKgAACgAqCgAACoACoAAACoAAKgAACoAACqAACqAABmoACpkAAZKqqoZAAKAqqoCgACgAAAAoAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Alarm_clock.svg + appStore: "AAAAAAAAAAACqoAAAAACqqgAAAACooqAAAACoKCoAAAAoCgKAAAAKAoCgAAACgKgoAAAAoAqKAAAAKgCqgAAAAqAKgAAAACqqgAAAAAKqgAABAAAAAAARpQAAAAFpGqqqqqqpAGqqqqqkAAoAAAAoAAKAAAAKAACgAAACgAAoAAAAoAAKAAAAKAACqqqqqgAAqqqqqoAAAAAAAAAAA==", // icons/25px_Appstore.svg + calendar: "AAKAAKAAAACgACgAAKqqqqqqgCqqqqqqoAoCgACgKAKAoAAoCgCiqoCqooAoqqAqqKAKAAAAACgCgAAAAAoAoAAAAAKAKAAACgCgCgAABoAoAoAABoAKAKAKBoACgCgCkpAAoAoAKpAAKAKABpAACgCgAKAAAoAoAAAAAKAKAAAAACgCgAAAAAoAqqqqqqqAKqqqqqqgAAAAAAAAAA==", // pebbleos/Pebble_25x25_Calendar.svg + car: "AAAAAAAAAAqqqqpAAAKqqqqgAAGQAAAoAACgAAAGQAAoAAAAoAAZAAAAKQAKAAAABkCqgAAAAKqqqqqqqqqgqqqqqqqAKAKACgCgCgCgAoAoAqqoAKqqAKqqACqqgCgAKqAAoAoACqgAKAKAAAAACgCqqqqqqoAqqqqqqqAAoKACgoAAKCgAoKAACgoAKCgCqqqqqqqqqqqqqqqqgA==", // pebbleos/Pebble_25x25_Car_rental.svg + contacts: "AAAAAAAAACqqqqqqAAqqqqqqgAKAAAAAoAqqAAAAKAKqgAAACgAKAAAAAoACgAAAAKAAoAApACgAKAAaQAoACgAGkAKAKqgAAACgCqoAGAAoACgAGoAKAAoAGqgCgAKACqpAoACgAAAAKAAoAAAACgCqoAAAAoAqqAAAAKAAoAAAACgAKAAAAAoACqqqqqqAAqqqqqqgAAAAAAAAAA==", // icons/25px_Contacts_book.svg + dinner: "AAAAAAAAAAAqqqAAAAAqqqoAAAKqAAKqAAKqAAAqoAKigAAKKgKgoAACgqCgKgACoCgoAqACoAoKACgAoAKCoAAAAAKgKgAAAAKgAqoAACqgACqAAAqgAACgAAKAAAAooCigAAAKKAooAAACigKKAAAAqqqqgAAAKqqqoAAACgAAKAAAAoAACgAAAKqqqoAAACqqqqAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Dinner_reservation.svg + email: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACqqqqqqqoqqqqqqqqKqAAAACqiioAAACoooKgAACoKKAqAACoCigCoACoAooAKgCoAKKAAqCoACigACqoAAooAoKoKAKKAqAoCoCigqAAAKgooqAAAAqKKqAAAACqiqAAAAAKoqqqqqqqqKqqqqqqqgAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Generic_e-mail.svg + flight: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAABqoAAAAAWpagqoABqkCqKqQGqQCqpkpalAAoKZGqQAAACmQpAAAAAooAAAqoAKKAAAKqAChkAUAGQCoZAKACgCoGQCgAoCoAqqoAaqoAKqqAKqoAAACgCgAAAAAoBkAAAAAKqoAAAAACqqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Scheduled_flight.svg + glucose: "AAAAAAAAAAAAAAAAAKqqqqqqgCqqqqqqoAoAAAAAKAKAAAAACgCgAAAAooAoAAAAqKAKAAAAqCgCgAoAqAoAoAqgqAKAKAqqqACgCgqCqAAoAoqAKAAKAKKAAAACgCgAAAAAoAoAAAAAKAKKqoAACgCiqqAAAoAoAAAAAKAKAAAAACgCqqqqqqoAqqqqqqqAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Glucose_monitor.svg + heart: "AAAAAAAAAAKAACgAAAKoACqAAAKqgCqoAAKgqCoKgAKgCqoAqAKgAKoACoCgAAoAAKAoAAAAACgKAAAAAAoCgAAAAAKAoAAAAACgKAAAAAAoCoAAAAAqAKgAAAAqAAqAAAAqAACoAAAqAAAKgAAqAAAAqAAqAAAACoAqAAAAAKgqAAAAAAqqAAAAAACqAAAAAAAKAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Heart.svg + incomingCall: "AAAACgAAAAAAAoAAAAAAqqqqqAAAKqqqqgAACgAAAoAAAoqqqKAAAKKqqigAACigAooAAAooAKKCgAKKACigqACigAooCoAoqqqKAKgKKqqigAqCgAAAoACgoqiqKAAAKKoqiqqgCgAAAqqoAoqiqKAAAKKoqigAKCgAAAoAKgoAAAKAKgKAAACgKgCgAAAoKgAqqqqqCgAKqqqqgA==", // pebbleos/Pebble_25x25_Incoming_call.svg + location: "AAACqqqoAAAAqqqqAAAAKAAqAAAACgAqAAAAAoAqAAAAAKAKgAAAACgAqAAAAAoACoAAAAKqqqgAAACqqqoAAAAoAAAAAAAKAAAAAAACgAAAAAAAoAAAAAAAKAAAAAAACgAAAAAAAoAAAAACqqqqAAACqqqqoAACoAoAKgACoAKAAqACoACgACoCoAAAAAKiqqqqqqqqqqqqqqqqgA==", // pebbleos/Pebble_25x25_Location.svg + microphone: "AAAqqoAAAAAqqqgAAAAqCgqAAAAKBpSgAAACqqqoAAAAqmmqAAAAKAoCgAAACqqqoAAAAqqqqAAAAKAoCgAAACgKAoAAAAqmmqAAAAKqqqgAAACgaQoAAAAqCgqAAAACqqqAAACgKqqAoAAqAAAAqAACoAAAqAAAKqqqqAAAAqqqqAAAAAAoAAAAAAAKAAAAAAAqqAAAAAAKqgAAAA==", // icons/25px_Microphone.svg + missedCall: "AAAACgAAAAAAAoAAAAAAqqqqqAAAKqqqqiqoCgAAAoqqAoqqqKKoAKKqqiiqgCigAoooqAooAKKKCoKKACigAKiigAooACooqqqKACoKKqqigCoCgAAAoCoAoqiqKCoAKKoqiioACgAAAqoAAoqiqKoAAKKoqigAACgAAAoAAAoqiqKAAAKKoqigAACgAAAoAAAqqqqqAAAKqqqqgA==", // pebbleos/Pebble_25x25_Missed_call.svg + movie: "AAAAAAAAAAAAAAAAAKqqqqqqACqqqqqqgAoqACoAoAKCoAKgKACgKgAqCgAoAqACooAKqqqqqqACqqqqqqgAoAqACooAKAqACoKACgqACoCgAoqACoAoAKqqqqqqACqqqqqqgAoAAAAAoAKAAAAAKACgAAAACgAoAAAAAoAKqqqqqqACqqqqqqgAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Movie_event.svg + music: "AAKQAAAAAACqkAAAAAApqpAAAAAKAaqQAAACgAGqkAAApAABqoAAKqQAAaAACmqkACgAAoBqpAoKqqAAaqaCqqgAAGqgoAoAAABoKAKAAAAKCgCgAAACgoAoAAAAoKAKAAKqqCqqgACqqgqqoAAoAoAAAAAKAKAAAAACgCgAAAAAoAoAAAAAKAKAAAAACqqgAAAAAqqoAAAAAAAAAA==", // icons/25px_Music_note.svg + news: "AAAAAAAAAAAAAAAAAAAAAAAAACqqqqqqoAqqqqqqqAKAAAAACgCgAAAAAoAoKqqqoKAKCqqqqCgCgAAAAAoAoKqqqgKAKCqqqoCgCgAAAAAoAoKqqqAKAKCqqqgCgCgAAAAAoAoKqqAAKAKCqqgACgCgAAAAAoAoAAAAAKAKqqqqqqgCqqqqqqoAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_News_event.svg + payBill: "AAAAAAAAAAAAAAAAAAAAAAAAApQAAAAAWqqlAABaqplqqAKqpZZAWgClAGSgAZBkACgoACgoAAoKqqqpAAZCqqqqQAGQoAACgAGgKAACkAaoCgACpBqqAoACqmqSgKACoqpAoCgAqCoAKAoACqoACgKAAKoAAoCgAAoAAKAoAAAAACgKqqqqqqoCqqqqqqqAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Pay_bill.svg + phone: "AAAACgAAAAAAAoAAAAAAqqqqqAAAKqqqqgAACgAAAoAAAoqqqKAAAKKqqigAACigAooAAAooAKKCgAKKACigqACigAooCoAoqqqKAKgKKqqigAqCgAAAoACgoqiqKAAAKKoqiqqgCgAAAqqoAoqiqKAAAKKoqigAKCgAAAoAKgoAAAKAKgKAAACgKgCgAAAoKgAqqqqqCgAKqqqqgA==", // pebbleos/Pebble_25x25_During_phone_call.svg + podcast: "ACgAAAAAAAoAAAAAAAZAAAAAAAGQAAAAAACgAAAAAAAoAAAAAAAZAAAAAAAGQAAAAAAqqqqqqqoKqqqqqqqCgAAAAACgoAAAAAAoKAqoAqqKCgqqgKqigoqAqAAAoKKACgAAKCigAoAACgooAKAAAoKKgKgAAKCgqqgAACgoCqgAAAoKAAAAAAKCgAAAAACgqqqqqqqoKqqqqqqqAA==", // pebbleos/Pebble_25x25_Radio_show.svg + reminder: "AAAACqoAAAAAAqqCgAAAAKCioAAAACgqoAAAAAoKoAAAAAKqoAAAAACqqAAqqqqoKoAKqqqqCqgCgoKCgoqAoKCgoKCgKCgoKCgACgoKqqqAAoKCqqqgAKqqoAAoACqqqAAKAAqACqoGgACoAqqGgAAKgAACkAAAoAACkAAAKAAAoAAACgAAKAAAAoAACgAAAKqqqoAAACqqqqAAAA==", // pebbleos/Pebble_25x25_Generic_reminder.svg + settings: "AAAKqqAAAAACqqgAAAAAoAoAAqqqqAKqqqqqqgCqqoAAAoAoAAAAAKqqAAAAACqqgAAAAAAAAAAAqqoAAAAAKqqAAAAACgCgAAAAqoAqqqqqqqAKqqqqoCgCgAAAAAqqoAAAAAKqqAAAAAAAAAAKqqAAAAACqqgAAAAAoAqqqqqqqAKqqqqqqgCgAAAAAoAoAAAAAKqqAAAAACqqgA==", // pebbleos/Pebble_25x25_Settings.svg + shopping: "AAAAaAAAAAABqoAAAAACqaAAAAAApCgAAAAAKAoAAAAACgKAAACqqqqqqoAqqqqqqqAGgAAAAGQApAAAACgAGgAAAAoAApAAAAZAAGgAAAKAAAoAAACgAAZAAABkAAKAAABoAACgAAGqQABkAAKpoAAoAACkKQAKAAAABoAGQAAAAKQCqqqqqqoAqqqqqqqAAAAAAAAAAAAAAAAAAA==", // icons/25px_Shopping_bag.svg + sms: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACqqqqqqqAqqqqqqqoCoAAAAAKgKgAAAAAoAoAAAAAKAKCqqqqCgCgqqqqgoAoAAAAAKAKAAAAACgCgqqgAAoAoKqoAAKAKAAAAACgCgAAAAAoAqAAAAAqACqqqqqqAAKqqqqqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // icons/25px_SMS.svg + stocks: "AAAAAAAACgAAAAAAAoAAAAAAAKAAAAAAACgAAAAAAAoAAAAoAAKAAAAqigCgAAAqqqAoAAAqCqoKAoAqCoKigqgqAqCooqqqACqoKqCqAAKoCqAKAAAoAqAAAAAKAKAAAAACgCgAAAAAoAoAAAAAKAKAAAAACgCgAAAAAoAoAAAAAKAKAAAAACgCqqqqqqoAqqqqqqqAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Stocks_event.svg + tv: "AAAAAAoAAAAAAAqAAAAKAAqAAAACoAqAAAAAKgqAAAAAAqqAAAKqqqqqqqCqqqqqqqgoAAAAAAoKKqqqqqKCiqqqqqigooAAAAooKKAAAAKKCigAAACigooAAAAooKKAAAAKKCiqqqqqigoqqqqqooKAAAAAAKCgACqgACgoAAqoAAoKAAAAAAKCqqqqqqqgqqqqqqqoAAAAAAAAAA==", // pebbleos/Pebble_25x25_TV_show.svg + voicemail: "AABAUAAAAABkaAAAAAAZKQAAAAAKKQAAAAKCigEAAACoABaQAABqgCqQAAApqApAAAAKCoAAAAAGQKgAAAACgAqAAAAAoBqgAAAAZCqQAAAAKQqAAAAACoBpAKAAAKgGkGoAAAaQaSqgAABpBqoqAAAGkCpCoAAAaQKAKgAABpAABqAAAGkAGqgAAAKhqpAAAAAqqQAAAAACkAAAAA==", // icons/25px_Phone.svg + warning: "AAAAAAAAAAAAoAAAAAAAaQAAAAAAKoAAAAAAGqQAAAAACgoAAAAABkGQAAAAAoooAAAAAZKGQAAAAaCgpAAAAKQoGgAAAGgKApAAACkCgGgAABoAoApAAApAKAGgAAZAAAAZAAKAAoACgAGQAKAAZACgACgACgCkAAoAAaBoAAAAACkqqqqqqqqKqqqqqqqgAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Generic_warning.svg + weather: "AAAAAAKAAAAAAACgAAAACgAoAAAAAqAKAAAAACoAAAAAAAKKqgAAAAAKqqAAAAAKgCoAAKqCgAKAAKqooACgAKgKqAAoKqgAqqqqKqoACqqqqgKgAAACqgAoAAAAKoAAAAAACqAAAAAAAqgAAAAAAKqAAAAAAKiqqqqqqqgKqqqqqqgAAAAAAAAAKCgoAAAACgoKAAAAAoKCgAAAAA==", // pebbleos/Pebble_25x25_Generic_weather.svg + airmail: "AAAAAAAAAAAAAAAAAAAqqqoAAAAqqqqgAAAqAAAqAAAqAAACoAAqAAAAKgAqAAAAAqAKkAAAAagCqkAABqoApqkAGqaAKBqkapCgCgBqqkAoAoABqQAKAKAAAAACgCgAAAAAoAoAAAAAKAKgAAAAKgAaQAAAKgABpAAAKgAAGkAAKgAAAKqqqgAAAAqqqgAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Airmail_25px.svg + amazon: "AACqqgAAAACqqqAAAACoACoAAACoAAKgAAAqqoAoAAAKqqgKAAAAAAqCgAAAAACgoAAAAqqoKAAAAqqqCgAAAqAAAoAAAqAAAKAAAKAqqCgAACgqqgoAAAoKAoKAAAKCgKCoAACgqqgKgAAoCqgAqAAKgAAoKgKAqAAqqgqoCqqqqgqKgKqqCgqAqAAAAAqACqqqqqqAAKqqqqqAAA==", // pebbleos/Pebble_25x25_Amazon.svg + appleShortcuts: "AAAKqAAAAAAKqoAAAAAKgKgAAAAKgAqAAAAKgACoAAAKgAAKgAAKgAAAqAAKgCqgCoACgCqqAKAAoCoCoCgAKgoAKioAAqAAAqoAACoAACoAACqgACqgACoqACoqAAoCoCoCgAKAKqoAoACoAqoAqAAKgAAAqAAAqAAAqAAACoAAqAAAAKgAqAAAAAqAqAAAAACqqAAAAAAKqAAAAA==", // brand-logos/Apple_Shortcuts_25px.svg + bbcNews: "qqqqqqqqoAAAAAAAKCqgqoCqCgqqKqiqooKCigooKKCqoqqKACgqqKqigAoKCigooKKCqoqqKqigqoKqAqgoAAAAAAAKAAAKqqACgAACqqgAoAAAoAoAKACqqAKACgAqqgCgAoAKAoAoAKACgKqqACgAoCqqgAoAKqoKAAKACqqCgACgAACqoAAoAAAqqAAKAAAAAAACqqqqqqqqgA==", // brand-logos/BBC_News_25px.svg + beeper: "AAqqqqAAAAqqqqoAAAqAAAKgAAqAAAAqAAqAAAACoAKAAAAAKACgAAAACgAoAAAAAoAKAAAAAKACoAAAAKgAKgAAAKgAAqAAAKgAAKqqoKgAACqqqKoAAAoAGaqgAAKACqgqAACgAqgCoAAoAagAKAAKAKgACgACgCgAAoAAoAAAAqAAKAAAAqAACgAAAqAAAqqqqqAAAKqqqqAAAA==", // brand-logos/Beeper_25px.svg + bluesky: "AAAAAAAAAGgAAAApAqqAAAAqqKWoAAAqWigKgAAqAooAqAAqAKKACoAqACigAKgqAAooAAqqAAKKAACqAACigAAKAAAopAAAAAAaGgAAAAAKQpAAAAAGgGqoAAKqkAqqAACqoAKpAAAGqACkAAAAGgAoAAAAAoAKAAKAAKACgAGkACgAqACqACoACoBqkCoAAKqpaqoAAAqqCqoAAA==", // brand-logos/Bluesky_25px.svg + discord: "AAAAAAAAAAAAAAAAAAAAAAAAAABoAACkAAKqqqqqoAClqqqpaABkAAAABkAoAAAAAKAKAAAAACgGQAAAAAZCgAAAAACgoCqgKqAoZAqoCqgGaAKKAooAqgCqgKqAKoAqoCqgCqAAAAAAAqkAAAAAAaqkCqqoBqhqmqqqmqQBqoAAqpAABoAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Discord_25px.svg + duolingo: "AAAAAAAAAAAAAAAAAAoAAAAoAKagAAAqaCqqAAAqqhqmoAAqappoKgAqCmqAAqAqAAUKqCgKCqgKqoAACqqKgKgACoCqgAoAAoAKoKKAAKKCqCigACigqgooAAooKoKKAAKKCqCiiqiigqoCqqqqAqKqqoCqqqAqoqqqKqAAAKqqgAAAAAoCgAAAAAKqoAAAAAAqoAAAAAAAAAAAAA==", // brand-logos/Duolingo_25px.svg + ebay: "AAAqqgAAAAAqqqAAAAAqACoAAAAqAAKgAAAKAAAoAAACgAAKAAKqqqqqqqCqqqqqqqgoAKACgAoKACgAoAKCgAoAKACgoAKACgAoKACgAoAKCgAoAKACgoAKACgAoKACgAoAKCgAoAKACgoAKACgAoKACgAoAKCgAoAKACgoAKACgAoKgCgAoAqAqAoAKAqACqqqqqqAAKqqqqqAAA==", // brand-logos/eBay_25px.svg + element: "AACqqoAAAAAqqqgAAAAKAAqAAAACgACoAAAAqqgKAACqqqqCgACqqqCgoACoACgoKACoAAoKCqqoCqqCgqqqCqqgqqgqgoAAKqoKoKAAAAKCqCqqAACgqgqqgqqoKqqgoKqoCqqoKCgACoAKCgoACoACgoKqqoAAoKqqqoAAKAqqgAAACoAAoAAAAKgAKAAAAAqqqgAAAACqqoAAAA==", // brand-logos/Element_25px.svg + facebook: "AAAAAAAAAAAAAAAAAAAAAAAAAAqqqqqqgAKqqqqqoACgAAAAKAAoAAAACgAKAAAKgoACgAAKoKAAoAAKgCgAKAACgAoACgAAoAKAAoACqqCgAKAAqqgoACgAAoAKAAoAAKACgAKAACgAoACgAAoAKAAoAAKACgAKAACgAoACqqqqqqAAqqqqqqgAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Facebook_notification.svg + facetime: "AAAoAAAAAAAKAAAAAoACgAKAAKgAoAKgAAqAKAKgAACoCgKgAAAKgoKgAAAAoACgAAAAAAAAAAAAAAAAAAAAKqqqoACgKqqqqgCoKgAAAqCqKgCqgCqqigCqqAKoooCoCoCoKKAoAKAoCigKACgKAooCgAoCgKKAqAqAqCigCqqAKooqAKqAKqqCoAAAKgqgKqqqqgCoAqqqqgAKAA==", // pebbleos/Pebble_25x25_Facetime_incoming.svg + gmail: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqqqqqqqiqqqqqqqooAqAAqAKKACoAqACigAKgqAAooKAqqAoKKCoCqAqCigqgKAqgooKqAAqoKKCioAqKCigoKgqCgooKCqqgoKKCiqqqKCigqoKCqgooKoAAKoKKCoAAAqCiqqqqqqqoqqqqqqqqAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Gmail_notification.svg + googleChat: "AAAAAAAAAAAAAAAAAKqqqqoAACqqqqqgAAoAAAAqAAKAAAACoACgAAAAKgAoCqqqgqAKAqqqoCgCgKAAKAoAoCgACgKAKAoAAoCgCgKAAKAoAoCqqqgKAKAqqqoCgCgKgAAAoAoCgAAAKAKAoAAACgCqqAqqqoAqqgqqqqAAAoqAAAAAAKqAAAAAACqAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Google_Chat_25px.svg + googleMaps: "AAAAAKqgAAAAAKqqAKqqqqgCoKqqqqgAKqgAACgAAqgKoAoAAKoKqAKAACqKgACgAAqigqgqAAqooKoCoAqKKgqAKgqCgqqAKoKgoCqAKmWoKAAAKgqqCgAAKgKqgoAAKgBpoKAAKqAKKCgAKioCigoAKgKgAoKAKgAqAKCgKgACoCgoKgAAKgoKqgAAAqqAqqqqqqqACqqqqqqAAA==", // pebbleos/Pebble_25x25_Google_Maps.svg + googlePhotos: "AAAAoAAAAAAAKgAAAAAACqAAAAAAAqoAAAAAAKKgAAAAqqgqAAAAqqoCoAAAqAKAKAAAqACgCgAAqACqAoAAqACqoKAAqqqoKqqqKqqqCqqqgAKCqoAKgACgKoAKgAAoAoAKgAAKAKAKgAACoCqqgAAAKgqqgAAAAqKAAAAAACqgAAAAAAKoAAAAAAAqAAAAAAACgAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Google_Photos.svg + googleTasks: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAqqqAqAAAqqqoqAAAqAAKqAAAqAAAqAAAqAAAqoAAKAAAqKAACgAAqCgAAooAqAoAAKKgqAKAACgqqACgAAoCqAAoAAKAKAAKAACoAAAKgAAKgAAKgAAAqAAKgAAACqqqgAAAAKqqgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Google_Tasks_25px.svg + homeAssistant: "AAAAAAAAAAAAKAAAAAAAKoAAAAAAKqgAAAAAKgqAAAAAKgCoAAAAKgAKgAAAKgAAqAAAKgqqCoAAKgKqgKgAKgCgoAqAKgAoKACoKgAKqgAKigACqoAAooAACgqqKKAAAoKqiiiqoKCgoooqqCgoKKKKCgoKqiiigoKKqoooqqCqgAKKKqoqgACigAKqgAAoqqqqqqqqKqqqqqqqgA==", // brand-logos/Home_Assistant_25px.svg + instagram: "AAAAAAAAAAAAAAAAAKqqqqqqgCqqqqqqoAoAAAAAKAKAAAAqqgCgAAAKqoAoAKqoAKAKAKqqgCgCgKgAqAoAqqgACqqAKqgAAKqgCgoAACgoAoKAAAoKAKCgAAKCgCgoAACgoAoKgACoKAKAqACoCgCgCqqoAoAoAKqoAKAKAAAAACgCqqqqqqoAqqqqqqqAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Instagram.svg + iosPhotos: "AAAKqAAAAAAKqoAAAAqqgKqoAAqqgAqqgAqBoAKQqAKAKACgCgCgBkBkAoApAKAoAaAKpBkZBqgKqpaKWqqKgGqqqkCqgAGqqQAKoAAKqAACqAAaqpAAqoBqqqpAqKqpaKWqqAqkGRkGqAKQCgKAGgCgBkBkAoAoAoAKAKAKgaACkKgAqqgAqqgACqqAqqgAAACqqAAAAAAKqAAAAA==", // pebbleos/Pebble_25x25_iOS_Photos.svg + kakaoTalk: "AAAAAAAAAAAAAAAAAAKqqqqAAAKqqqqoAAKgAAAKgAKgAAAAqAKgAAAACoCgCqqqAKAoAqqqgCgKAACgAAoCgAAoAAKAoAAKAACgKAACgAAoCgAAoAAKAoAAKAACgKAACgAAoCoAAAAAqAKgAAAAqAAqAAAAqAACgKqqqAAAoaqqqAAAKaQAAAAACqQAAAAAAqQAAAAAAKAAAAAAAA==", // pebbleos/Pebble_25x25_KakaoTalk.svg + kik: "AoAAAAAAAqgAAAAAAqqAAAAAAKCgAAAAACgoAAAAAAoKAKqAAAKCgKqgAACgoKgoAAAoKKgKAAAKCqgKgCgCgqgKgGqQoKgKgKlqKCgKgCgCigAKgAoAooAKgAKAKKACoACpaigAKgAGqQoKAqAAKAKCoCoAAACgqgKgAAAoKqAqAAAKCioCgAACqoKgoAAAKoAqqAAAAoACqgAAAA==", // pebbleos/Pebble_25x25_Kik.svg + line: "AKqqqqqAAKqqqqqoAKgAAAAKgKgAAAAAqKgAAAAACqgAAAAAAKoKAoqoqiqCgKKqKoqgoCiiigKoKAoooqiqCgKKKKoqgoCiiigKoKooooqiqCqKKKKoqoAAAAAAKKgAAAAAKgqAAAAAKgCoAAAAKgAKqqqAKgAAqqqgKgAAAAAZKgAAAAAGagAAAAABqgAAAAAAKgAAAAAACgAAAA==", // pebbleos/Pebble_25x25_Line.svg + linkedIn: "AAAAAAAAAAAAAAAAAKqqqqqqgCqqqqqqoAoAAAAAKAKAAAAACgCgKAAAAoAoCgAAAKAKAAAAACgCgKAAAAoAoCgqqAKAKAoKqoCgCgKCgKAoAoCgoCgKAKAoKAoCgCgKCgKAoAoCgoCgKAKAoKAoCgCgAAAAAoAoAAAAAKAKAAAAACgCqqqqqqoAqqqqqqqAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_LinkedIn.svg + messenger: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAABqAACgAACqAABqQAGqQAApqAKqgAAZCpamkAAaAGqRoAAKQAKAoAAGgAAApAACgKAAaAACkapAKQABpqWoGQAAqqAKmgAAapAAakAAKoAAAoAAKkAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Facebook_messenger_notification.svg + omniFocus: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKgAAAAAAKqAAAAAAKioAAAAAKgKAAAAAKgKgAAAAKgKgACoAKgKgACqgKgKgACoqKgKgAAoCqgKgAAKgKgKgAAAqAQKgAAACoAKgAAAAKgKgAAAAAqKgAAAAACqgAAAAAAKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/OmniFocus_25px.svg + outlook: "AAAAAAAAAAAAFAAAAAAAapAAAAABqqpAAAAGqQapAAAapAAapABqkAAAapCqQAAAAaopAAAAAAaKAAAAAACikAAAAABqqqqoAAGqqqqqAAaqqAACgBqkqiqooGqQKoqqKqpACqKCiqkAAqigopqkAKoqqKBqgCqKqigBoAqgAAoAKAKqqqqAKgKqqqqgKgKgCqqqqqqgAKqqqqqgAA==", // brand-logos/Outlook_25px.svg + reddit: "AAAAAAAAAAAAAAAAAAAAAAqgAAAAAAqqAAAAAAKCgAAAAACgoAAAAAKqqAAAAACmqAAAAABkAAAAAAAoAAAAqkaqpGqAqqqqqqqoqBpAAGkKqAAAAAAAqgAKACgAKqECgAoBKiqQoAKBqgKgAAAAKgAoAqqgCgAKQKqoBoACqQqoGqAAGqQAapAAAGqqqkAAAAGqqQAAAAAAAAAAAA==", // brand-logos/Reddit_25px.svg + signal: "AAqqCqgAAAqqgqqAAAKAAACoAAACqqoKAAoCqqqgAAqCoAAqAoqCoAACoKqCoAAAKgqioAAAAqKooAAAACigKAAAAAooCgAAAAKKooAAAACgKKAAAAAoCigAAAAKKooAAAACiqKAAAACoqigAAACoKBkAAACoKgoAAACoKgKBqqqoCgGqqqqoAACqkAAAKAApAqoKqgAAAKqCqgAAA==", // brand-logos/Signal_25px.svg + simplex: "AAAAAAAAAAAoAoAAAAAqgqgAAAAqqqqAAAAqCqCoAAAKgKAqAAAoqAAqKAAqipQqKoAqqqpKqqgqCqGQqgqKgKAoCgKgqAAqgAKgCoAqqAKgAqAKqgCoAqAAqgAKgqAoCgKAqKgqhkKoKgqqqpKqqgCqKlCoqgAKKgAKigAAKgKAqAAACoKoKgAAAKqqqgAAAAqgqgAAAACgCgAAAA==", // brand-logos/SimpleX_25px.svg + slack: "AAAAGgAAAAAAqoAAAAAAKWWgAAGgBkqoAAqoAaKWQAKWWqgBoABkqpAKqAAaKQGikACqgBqoZAApAKqWSgAGWikAooAAqoZAKGWgKWSgBkqoAAooAaKWQAKGWqgBoABkqpAKqAAaKQGikACqgBqoZAApAKqWWgAGWikAqoAAqoZAKQAAKWWgAAAAAAqoAAAAAAKQAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Slack.svg + snapchat: "AACqqgAAAACqqqAAAACoACoAAACoAAKgAAAoKCgoAAAKCgoKAAKqgoKCqoCqoKCgqqAoACgoACgKQAAAABoCqQAAAGqAGqAAAKpAAGgAACkAAAoAAAoAAAqAAAKgAAqAAAAqAAqAAAACoAqAAAAAKgqAAAAAAqKAAAAAACikAAAAABoqlAAAAWqAapAABqkAAWqqqpQAAAGqqkAAAA==", // pebbleos/Pebble_25x25_Snapchat.svg + steam: "AAAAAAAAAAAAAAAAAAAAACqqAAAAACqqoAAAACoAKgAAACoqoqAAAAoqqigAAAKKAooAAACigKKAAAAooCigAAAaKqooAAAKAqoqAAKqQAAqKQKqgCqqCqqgAGqqABqpAKkAAAAqqCgAAAAKGgoAAAACgAKAAAAAqAKgAAAACqqgAAAAAKqgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Steam_25px.svg + substack: "AAAAAAAAAAAAAAAAACqqqqqqAAqqqqqqgAKAAAAAoACgAAAAKAAoAAAACgAKqqqqqoACqqqqqqAAoAAAACgAKAAAAAoACqqqqqqAAqqqqqqgAKAAAAAoACgAAAAKAAoAAAACgAKAAAAAoACgAAAAKAAoAGpACgAKAaqpAoAChqkapKAAqqQAaqgAKpAAAaoACkAAAAaAAAAAAAAAAA==", // brand-logos/Substack_25px.svg + swarm: "AAAAAKQAAAAAAKqAACkAAKmgACqpACgoACpaqAoKACoAGkKGgApAAaCmkAGgACkqoAApAAaKkAAGqqqgAAAAqqpABqkAAAAAaqqkAAACqqBqgAABpCgBoAAAqQoAKAAAakKACgAAKpBkAoAAGmgKAKAACkoCoCgABoKQKioAApApAqoAAKpGgGoAAAaqqqoAAAAaqqQAAAAAAAAAAA==", // brand-logos/Swarm_25px.svg + tapo: "AAABkAAAAAACqgAAAAACoqAAAAACoCoAAAACoCqgAAACoCoqAAACoAoCoAACoAKAKgACoACgAqACoAAoACoCoAAqAAKhoAAqoAApoAAqKgACqAAqAqAAqgAqACoAKoAKAAKACqACgACgAqgAoAAoAKoAKAAKACqACgACgAqgAoAAoAKoAKAAKACqACgACgAqqqoAAqqqqqqAAKqqgA==", // brand-logos/Tapo_25px.svg + teams: "AAKoAAAAAAKqgAAAAAKgqAAAAACgCgAAAAAoAoAqgAAKgqAqqAAAqqAKCgAACqACgoACqqqgqqACqqqqCqACoAACqqoCqqqoKqqgqqqqCgAqKAACgoACiiqooKAAooqqKCgAKKAoCgoACigKAoKAAooCgKCgAKKAoCgoACigAAoKAAoqqqqCoAKKqqqgKgKgCqqqqqqgAKqqqqqgAA==", // brand-logos/Teams_25px.svg + telegram: "AAAAAAAAAAAAAAAAAAAAAAAAaAAAAAABqgAAAAAWqkAAAABqkpAAAAGqQKAAAAapAGQAAGqQABkAAapAAAoABqkAGgKAWpQBaoGQqkAGqoCgKqRappAoAGqqUaAZAABpAKAGQAAGQKQCgAABkGqRoAAAKCmqpAAACikGqAAAAaoAGgAAAGoAAAAAAApAAAAAAAKAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Telegram_app.svg + threads: "AAKqqqgAAAKqqqqAAAKgAACoAAKgAAAKgAKgKqqAqAKgKqqoCoKgKgAKgqCgCoAAoqAoAKqoKqAKAKqqCqACgKgAACoAoKgAAAKgKCgqqAAoCgoKqgoKAoKCgoKCgKCgqqCgoCgoKqgoKAoKgAAqCgKAqAAqAoCoCqqqAqAKgKqqAqAAqAAAAqAACoAAAqAAAKqqqqAAAAqqqqAAAA==", // brand-logos/Threads_25px.svg + tiktok: "AAAAAAAAAAAAKqgAAAAACqpAAAAAAoGgAAAAAKAqAAAAACgCpQAAAAoAKoAAAAKAAKAACqigoCgACqooKkoACoKKCqqACoCigpqgCoGooKAAAoGqKCgAAKCkCgoAACgoAoKAAAoKAKCgAAKCkGgoAACgaqkKAAAqBqkKgAACoAAKgAAAKgAKgAAAAqqqgAAAACqqgAAAAAAAAAAAAA==", // brand-logos/TikTok_25px.svg + twitch: "AAqqqqqqAAqqqqqqgAqgAAAAoAqoAAAAKAqKAAAACgKCgCgKAoCgoAoCgKAoKAKAoCgKCgCgKAoCgoAoCgKAoKAKAoCgKCgAAAAoCgoAAAAqAoKAAAAqAKCgAAAqACgqqqqqAAoKqqqqAAKAAqAqAACgAKAqAAAqqgqqAAAKqoqqAAAAAKqAAAAAACqAAAAAAAqAAAAAAAKAAAAAAA==", // brand-logos/Twitch_25px.svg + twitter: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWgAKQAACqqFqqkAApSqqKqpAZAKaRpaqWQAGgKQGqgACkApABoAAoAGgAAAAKAAaAAAACgACkAAAAoAAaAAAAKAABoAAAGgABqAAAGgACpAAAGkAGoAAACkAKoAAAWkACqpQWqoAABaqqpQAAAAFpQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_Twitter_notification.svg + unifiProtect: "AAAAAAAAAAAaqkAAAAAqqqgAAAAqQBqAAAAaCqCkAAAKSqoaAAACgoKCgAAAoKCgoAAAKCqoKAAACgKoCgAAAoAAAoAAAKAAAKAAACgCgCgAAAoAoAoAAAKAKAKAAACgAACgAAAoAAAoAAAKAAAKAAACgAACgAAAoAAAoAAAKAAAKAAACoAAKgAAAKqqqgAAAAqqqgAAAAAAAAAAAA==", // brand-logos/Unifi_Protect_25px.svg + viber: "AAAAAAAAAAACqqgAAAAAqqqAAAAAAACoAAKAAAAKgAKoAKqAqAKqgCqoCoKgqAAKgKigCoAAqAooAKgoCoKKACoKgKCigCoAqCgooCoACgoKKAqAAAKCigCoAAAAoqAKgCgAACoAqCqAAAKgCqqoAAAqAKoKgAACoAoAqAAAKgAACoAAAqAAAqAAACoAAqAAAAKqqqAAAAAqqqAAAA==", // pebbleos/Pebble_25x25_Viber.svg + waze: "AAAAAAAAAAACqqoAAAACqqqgAAACoAAqAAACoAACoAACoAAAKgACoAFBQqAAoACgoCgAKAAoKAoACgAKCgKAAoABQUCgAKAAAAAoqqgCgCgKKqoAqqoCgqAACqoAoCoAAAAAqAKgAAAAqAAqqgAAqAACqqAAqAAAoCqqqAAAKAqqqgAACgKKAoAAAqqiqqAAACqgKqAAAAAAAAAAAA==", // brand-logos/Waze_25px.svg + weChat: "AAAAAAAAACqqqAAAACqqqoAAACoAAKgAACoAAAqAACoAAACoAAoKoKoKAAKCqCqCgACgAAAAoAAoAAAKqqgKAAAKqqqCgAAKgACoqAAKgAAKioACgAAAoKAAoqiqKCqqqKoqigqqqgAAAoKgAoAAAKCgAKgAAKgAAAqAACgAAACqqqoAAAAKqqqAAAAAAAKgAAAAAAAoAAAAAAAAAA==", // pebbleos/Pebble_25x25_WeChat.svg + whatsApp: "AAAAAAAAAAAAAAAAAAAKqqoAAAAKqqqgAAAKgAAqAAAKgAACoAAKigAAKgAKiqAAAqAKiqoAACoCgoKgAAKAoKCoAACgKCioAAAoCgoqAAAKAoKCoKACgKCoKqoAoCgKgqqgKAoAqCgqCgKgCoAKioBoAKqqioAZAAqqioAKAAAACoAGlqAACoACqqqqqoAAqVKqqoAAAAAAAAAAAA==", // pebbleos/Pebble_25x25_WhatsApp_notification.svg + whatsAppBusiness: "AAAAAKqgAAAAACqoAAAqqqoKAAAqqqqCqgAqACqgqoAqAAoAAKAqKAKAACgqKoCqgqoqKqgqoKqKCgqAKCoCgoKgCqqAoKKgAqqgKCioAAAoCgoKgoAKAoKgqqgCgKAqCqqAoCgCoKCoKAqAKgAqKgGgAqqqKgBkACqqKgAoAAAAKgAaWoAAKgAKqqqqqgACpUqqqgAAAAAAAAAAAA==", // brand-logos/WhatsApp_Business_25px.svg + yahooMail: "CqqqqqqgAqqqqqqoAKAAAAAKACgqoAACgAoKqKqAoAKAKiqgKACgAqqACgAoACqAAoAKAAKAAKACgAqqACgAoAKqgAoCqAAAAAKoqgACgACqKoACqAAqiqgCqoAqooqCoKgqKKCqoAqqCigKoACqAooCoAAKgKKCoAAAqCiioAAACooqoAAAAKqKqqqqqqqiqqqqqqqoAAAAAAAAAA==", // pebbleos/Pebble_25x25_Yahoo_mail.svg + youtube: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqqqqqoAKqqqqqqgKgAAAAAqCgAAAAACgoACkAAAoKAAqkAAKCgAKqkACgoAChqgAoKAAoBoAKCgAKGqACgoACqpAAoKAAqkAAKCgAKQAACgoAAAAAAoKgAAAAAqAqqqqqqqACqqqqqqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Youtube_25px.svg + zoom: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqqqqoABqqqqqqgGqoAAAAqaqqAAAACqkqgAAAAKQKoAAAAAACqAAAAAAAqgAAAAAAKoAAAAAACqAAAAAAAqgAAAAAAKoAAAAAACqgAAAApAoqAAAAKpKCoAAACqqgKqqqqoaoAqqqqqAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // brand-logos/Zoom_25px.svg +} as const; + +export type PebbleIconName = keyof typeof PEBBLE_ICON_DATA; diff --git a/app/graphics/pebble-icons.LICENSE b/app/graphics/pebble-icons.LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/app/graphics/pebble-icons.LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/app/graphics/pebble-icons.ts b/app/graphics/pebble-icons.ts new file mode 100644 index 00000000..8069d480 --- /dev/null +++ b/app/graphics/pebble-icons.ts @@ -0,0 +1,28 @@ +import { GrayImage } from "./image"; +import { decodeBase64 } from "../util/base64"; +import { PEBBLE_ICON_DATA, PEBBLE_ICON_SIZE, type PebbleIconName } from "./pebble-icons-data"; + +export { PEBBLE_ICON_SIZE, type PebbleIconName }; + +// 2-bit codes in pebble-icons-data.ts -> coverage. +const LEVELS = [0, 128, 255, 255]; + +const cache = new Map(); + +/** + * One of the bundled Pebble notification icons (see pebble-icons-data.ts and + * scripts/generate-pebble-icons.cjs), as a PEBBLE_ICON_SIZE square coverage + * bitmap. Decoded once and shared: clone it before drawing on it. + */ +export function pebbleIcon(name: PebbleIconName): GrayImage { + let icon = cache.get(name); + if (!icon) { + const bytes = decodeBase64(PEBBLE_ICON_DATA[name]); + icon = new GrayImage(PEBBLE_ICON_SIZE, PEBBLE_ICON_SIZE, 0); + for (let i = 0; i < icon.pixels.length; i++) { + icon.pixels[i] = LEVELS[(bytes[i >> 2]! >> (6 - 2 * (i & 3))) & 3]!; + } + cache.set(name, icon); + } + return icon; +} diff --git a/app/native/notification-app-icons.ts b/app/native/notification-app-icons.ts new file mode 100644 index 00000000..cdd5e365 --- /dev/null +++ b/app/native/notification-app-icons.ts @@ -0,0 +1,203 @@ +import type { PebbleIconName } from "../graphics/pebble-icons"; + +/** + * Icons for notification sources that arrive without one: iPhone + * notifications over ANCS carry the app's bundle ID, its display name + * (fetched separately) and an ANCS category, but no icon. The icons are + * Pebble's (see scripts/generate-pebble-icons.cjs). + * + * The bundle IDs start from the Pebble firmware's own ANCS table (PebbleOS + * include/pbl/services/notifications/ancs/ancs_known_apps.h, minus retired + * apps), plus Apple's built-in apps and popular apps mapped to a generic + * pictogram. Every App Store bundle ID here was checked against Apple's + * iTunes lookup when it was added; Apple's built-in apps follow + * github.com/joeblau/apple-bundle-identifiers. + * + * Display names are a fallback for apps whose bundle ID varies per build: + * self-built apps such as Loop sign with their builder's team ID. They match + * the whole name, ignoring case, so generic words (an app called "United" + * or "Voice") are left out. Bundle prefixes catch regional variants + * (com.abbott.librelink.us, .gb, ...). + * + * Apple's Phone app is deliberately absent: its notifications are calls, + * missed calls and voicemail, which the ANCS category tells apart. + */ +type AppIcon = { + icon: PebbleIconName; + bundleIds: readonly string[]; + bundlePrefixes?: readonly string[]; + names?: readonly string[]; +}; + +const APP_ICONS: readonly AppIcon[] = [ + // Apple's built-in apps. + { icon: "sms", bundleIds: ["com.apple.MobileSMS"] }, + { icon: "email", bundleIds: ["com.apple.mobilemail"] }, + { icon: "calendar", bundleIds: ["com.apple.mobilecal"] }, + { icon: "reminder", bundleIds: ["com.apple.reminders"] }, + { icon: "facetime", bundleIds: ["com.apple.facetime"] }, + { icon: "iosPhotos", bundleIds: ["com.apple.mobileslideshow"] }, + { icon: "alarmClock", bundleIds: ["com.apple.mobiletimer"] }, + { icon: "weather", bundleIds: ["com.apple.weather"] }, + { icon: "location", bundleIds: ["com.apple.findmy", "com.apple.Maps"] }, + { icon: "settings", bundleIds: ["com.apple.Preferences"] }, + { icon: "heart", bundleIds: ["com.apple.Health"] }, + { icon: "activity", bundleIds: ["com.apple.Fitness"] }, + { icon: "news", bundleIds: ["com.apple.news"] }, + { icon: "podcast", bundleIds: ["com.apple.podcasts"] }, + { icon: "music", bundleIds: ["com.apple.Music"] }, + { icon: "tv", bundleIds: ["com.apple.tv"] }, + { icon: "payBill", bundleIds: ["com.apple.Passbook"] }, + { icon: "stocks", bundleIds: ["com.apple.stocks"] }, + { icon: "appStore", bundleIds: ["com.apple.AppStore"] }, + { icon: "appleShortcuts", bundleIds: ["com.apple.shortcuts"] }, + { icon: "microphone", bundleIds: ["com.apple.VoiceMemos"] }, + { icon: "contacts", bundleIds: ["com.apple.MobileAddressBook"] }, + { icon: "shopping", bundleIds: ["com.apple.store.Jolly"] }, + + // Apps with an icon of their own. + { icon: "airmail", bundleIds: ["com.airmailapp.iphone"], names: ["Airmail"] }, + { icon: "amazon", bundleIds: ["com.amazon.Amazon"], names: ["Amazon"] }, + { icon: "bbcNews", bundleIds: ["uk.co.bbc.news"], names: ["BBC News"] }, + { icon: "beeper", bundleIds: ["com.automattic.beeper"], names: ["Beeper"] }, + { icon: "bluesky", bundleIds: ["xyz.blueskyweb.app"], names: ["Bluesky"] }, + { icon: "discord", bundleIds: ["com.hammerandchisel.discord"], names: ["Discord"] }, + { icon: "duolingo", bundleIds: ["com.duolingo.DuolingoMobile"], names: ["Duolingo"] }, + { icon: "ebay", bundleIds: ["com.ebay.iphone"], names: ["eBay"] }, + { icon: "element", bundleIds: ["im.vector.app", "io.element.elementx"], names: ["Element", "Element X", "Element Classic"] }, + { icon: "facebook", bundleIds: ["com.facebook.Facebook"], names: ["Facebook"] }, + { icon: "gmail", bundleIds: ["com.google.Gmail"], names: ["Gmail"] }, + { icon: "googleChat", bundleIds: ["com.google.Dynamite"], names: ["Google Chat"] }, + { icon: "googleMaps", bundleIds: ["com.google.Maps"], names: ["Google Maps"] }, + { icon: "googlePhotos", bundleIds: ["com.google.photos"], names: ["Google Photos"] }, + { icon: "googleTasks", bundleIds: ["com.google.tasks"], names: ["Google Tasks"] }, + { icon: "homeAssistant", bundleIds: ["io.robbie.HomeAssistant"], names: ["Home Assistant"] }, + { icon: "instagram", bundleIds: ["com.burbn.instagram"], names: ["Instagram"] }, + { icon: "kakaoTalk", bundleIds: ["com.iwilab.KakaoTalk"], names: ["KakaoTalk"] }, + { icon: "kik", bundleIds: ["com.kik.chat"], names: ["Kik"] }, + { icon: "line", bundleIds: ["jp.naver.line"], names: ["LINE"] }, + { icon: "linkedIn", bundleIds: ["com.linkedin.LinkedIn"], names: ["LinkedIn"] }, + { icon: "messenger", bundleIds: ["com.facebook.Messenger"], names: ["Messenger"] }, + { icon: "omniFocus", bundleIds: ["com.omnigroup.OmniFocus4", "com.omnigroup.OmniFocus3.iOS"], names: ["OmniFocus"] }, + { icon: "outlook", bundleIds: ["com.microsoft.Office.Outlook"], names: ["Outlook"] }, + { icon: "reddit", bundleIds: ["com.reddit.Reddit"], names: ["Reddit"] }, + { icon: "signal", bundleIds: ["org.whispersystems.signal"], names: ["Signal"] }, + { icon: "simplex", bundleIds: ["chat.simplex.app"], names: ["SimpleX"] }, + { icon: "slack", bundleIds: ["com.tinyspeck.chatlyio"], names: ["Slack"] }, + { icon: "snapchat", bundleIds: ["com.toyopagroup.picaboo"], names: ["Snapchat"] }, + { icon: "steam", bundleIds: ["com.valvesoftware.Steam"], names: ["Steam"] }, + { icon: "substack", bundleIds: ["com.substack.Substack"], names: ["Substack"] }, + { icon: "swarm", bundleIds: ["com.foursquare.robin"], names: ["Swarm"] }, + { icon: "tapo", bundleIds: ["com.tplink.tapo"], names: ["Tapo"] }, + { icon: "teams", bundleIds: ["com.microsoft.skype.teams"], names: ["Teams", "Microsoft Teams"] }, + { icon: "telegram", bundleIds: ["ph.telegra.Telegraph"], names: ["Telegram"] }, + { icon: "threads", bundleIds: ["com.burbn.barcelona"], names: ["Threads"] }, + { icon: "tiktok", bundleIds: ["com.zhiliaoapp.musically"], names: ["TikTok"] }, + { icon: "twitch", bundleIds: ["tv.twitch"], names: ["Twitch"] }, + // X, still under Twitter's bundle ID and drawn with its bird, as on Pebble. + { icon: "twitter", bundleIds: ["com.atebits.Tweetie2"], names: ["X", "Twitter"] }, + { icon: "unifiProtect", bundleIds: ["com.ubnt.protect"], names: ["UniFi Protect"] }, + { icon: "viber", bundleIds: ["com.viber"], names: ["Viber"] }, + { icon: "waze", bundleIds: ["com.waze.iphone"], names: ["Waze"] }, + { icon: "weChat", bundleIds: ["com.tencent.xin"], names: ["WeChat"] }, + { icon: "whatsApp", bundleIds: ["net.whatsapp.WhatsApp"], names: ["WhatsApp"] }, + { icon: "whatsAppBusiness", bundleIds: ["net.whatsapp.WhatsAppSMB"], names: ["WA Business", "WhatsApp Business"] }, + { icon: "yahooMail", bundleIds: ["com.yahoo.Aerogram"], names: ["Yahoo Mail"] }, + { icon: "youtube", bundleIds: ["com.google.ios.youtube"], names: ["YouTube"] }, + { icon: "zoom", bundleIds: ["us.zoom.videomeetings"], names: ["Zoom"] }, + + // Apps drawn with a generic pictogram. + { icon: "calendar", bundleIds: ["com.google.calendar", "com.flexibits.fantastical2.iphone"], names: ["Google Calendar", "Fantastical"] }, + { icon: "email", bundleIds: ["com.readdle.smartemail", "ch.protonmail.protonmail"], names: ["Proton Mail"] }, + { icon: "sms", bundleIds: ["com.google.GVDialer", "ch.threema.iapp", "com.groupme.iphone-app"], names: ["Threema", "GroupMe"] }, + { icon: "reminder", bundleIds: ["com.todoist.ios", "com.culturedcode.ThingsiPhone", "com.microsoft.to-do"], names: ["Todoist"] }, + { icon: "car", bundleIds: ["com.ubercab.UberClient", "com.zimride.instant"], names: ["Uber", "Lyft"] }, + { icon: "dinner", bundleIds: ["com.ubercab.UberEats", "doordash.DoorDashConsumer", "com.grubhub.search"], names: ["Uber Eats", "DoorDash", "Grubhub"] }, + { + icon: "glucose", + bundleIds: [ + "com.dexcom.G6", "com.dexcom.g7app", "com.dexcom.dexcomone", "com.dexcom.stelo", "com.dexcom.followglobal", + "org.nativescript.LibreLinkUp", + ], + bundlePrefixes: ["com.abbott.librelink.", "com.abbott.libre3."], + names: ["Dexcom G6", "Dexcom G7", "Dexcom ONE", "LibreLink", "LibreLinkUp", "Loop", "Trio", "LoopFollow", "xDrip4iOS"], + }, + { icon: "music", bundleIds: ["com.spotify.client", "com.google.ios.youtubemusic", "com.pandora"], names: ["Spotify", "YouTube Music", "Pandora"] }, + { icon: "podcast", bundleIds: ["fm.overcast.overcast", "au.com.shiftyjelly.podcasts"], names: ["Overcast", "Pocket Casts"] }, + { + icon: "tv", + bundleIds: ["com.netflix.Netflix", "com.hulu.plus", "com.disney.disneyplus", "com.amazon.aiv.AIVApp"], + names: ["Netflix", "Hulu", "Disney+", "Prime Video"], + }, + { + icon: "payBill", + bundleIds: [ + "net.kortina.labs.Venmo", "com.squareup.cash", "com.yourcompany.PPClient", "com.chase", "com.bankofamerica.BofA", + "com.wf.mobilebanking", "com.capitalone.enterprisemobilebanking", + "com.revolut.revolut", "com.transferwise.Transferwise", "de.no26.Number26", "com.bunq.ios", + ], + names: ["Venmo", "Cash App", "PayPal", "Revolut", "N26", "bunq"], + }, + { icon: "stocks", bundleIds: ["com.robinhood.release.Robinhood", "com.vilcsak.bitcoin2"], names: ["Robinhood", "Coinbase"] }, + { + icon: "flight", + bundleIds: [ + "com.united.UnitedCustomerFacingIPhone", "com.delta.iphone.ver1", "com.aa.AmericanAirlines", + "com.southwest.iphoneprod", "com.flightyapp.flighty", + ], + names: ["Fly Delta", "Flighty"], + }, + { icon: "weather", bundleIds: ["com.weather.TWC", "com.grailr.CARROTweather"] }, + { icon: "activity", bundleIds: ["com.strava.stravaride", "com.nike.nikeplus-gps", "com.fitbit.FitbitMobile"], names: ["Strava", "Fitbit"] }, + { icon: "heart", bundleIds: ["com.ouraring.oura"], names: ["Oura"] }, + { icon: "news", bundleIds: ["com.nytimes.NYTimes", "com.google.GoogleDigitalEditions"], names: ["Google News"] }, +]; + +/** + * Icons for the ANCS categories (CategoryID: Other, IncomingCall, + * MissedCall, Voicemail, Social, Schedule, Email, News, HealthAndFitness, + * BusinessAndFinance, Location, Entertainment), for apps not listed above. + */ +const CATEGORY_ICONS: readonly PebbleIconName[] = [ + "generic", "incomingCall", "missedCall", "voicemail", "sms", "calendar", + "email", "news", "heart", "stocks", "location", "tv", +]; + +type Index = { bundleIds: Map; prefixes: [string, PebbleIconName][]; names: Map }; +let index: Index | null = null; + +function buildIndex(): Index { + const built: Index = { bundleIds: new Map(), prefixes: [], names: new Map() }; + for (const app of APP_ICONS) { + for (const id of app.bundleIds) built.bundleIds.set(id.toLowerCase(), app.icon); + for (const prefix of app.bundlePrefixes ?? []) built.prefixes.push([prefix.toLowerCase(), app.icon]); + for (const name of app.names ?? []) built.names.set(name.toLowerCase(), app.icon); + } + return built; +} + +/** + * The icon for a notification's source app, by bundle ID (ignoring case; + * Apple treats bundle IDs case-insensitively), else by its display name; + * null when the app isn't known. + */ +export function notificationAppIcon(bundleId: string, appName: string): PebbleIconName | null { + index ??= buildIndex(); + const id = bundleId.trim().toLowerCase(); + if (id) { + const byId = index.bundleIds.get(id) ?? index.prefixes.find(([prefix]) => id.startsWith(prefix))?.[1]; + if (byId) return byId; + } + const name = appName.trim().toLowerCase(); + return (name && index.names.get(name)) || null; +} + +/** The icon for an ANCS category (a CategoryID as a string); the bell for anything unknown. */ +export function notificationCategoryIcon(category: string): PebbleIconName { + return CATEGORY_ICONS[Number(category)] ?? "generic"; +} + +/** Every icon the table refers to, for tests. */ +export function allNotificationAppIcons(): PebbleIconName[] { + return Array.from(new Set(APP_ICONS.map((app) => app.icon).concat(CATEGORY_ICONS))); +} diff --git a/app/native/notification-icons.ios.ts b/app/native/notification-icons.ios.ts index 2aa15f7c..940656dc 100644 --- a/app/native/notification-icons.ios.ts +++ b/app/native/notification-icons.ios.ts @@ -1,6 +1,7 @@ -import { GrayImage } from '../graphics/image' -import { renderIcon, type IconName } from '../graphics/icons' +import type { GrayImage } from '../graphics/image' +import { pebbleIcon } from '../graphics/pebble-icons' import { AncsClient, ANCS_CONNECT_MESSAGE, type AncsState } from '../g2/ancs-client' +import { notificationAppIcon, notificationCategoryIcon } from './notification-app-icons' import { rememberNotificationSources } from './notification-sources' import type { AndroidNotification } from './notification-types' export type { AndroidNotification, AndroidNotificationAction } from './notification-types' @@ -32,34 +33,24 @@ export function onAndroidNotificationPosted(listener: (key: string) => void): () // (they hear every change), and an open popup closes on the repaint that follows. export function onAndroidNotificationRemoved(_listener: (key: string) => void): () => void { return () => {} } export function onAndroidNotificationsChanged(listener: () => void): () => void { return onAndroidNotificationPosted(listener) } -// ANCS does not provide app icons, so show one for the notification's ANCS -// category; never fetch notification sources or content from a third-party -// icon service. Indexed by CategoryID: Other, IncomingCall, MissedCall, -// Voicemail, Social, Schedule, Email, News, HealthAndFitness, -// BusinessAndFinance, Location, Entertainment. -const CATEGORY_ICONS: readonly IconName[] = ['bell','phone-incoming','phone-missed','voicemail','message-circle', - 'calendar','mail','newspaper','heart-pulse','briefcase','map-pin','tv'] -function categoryIcon(category: string): GrayImage { - return renderIcon(CATEGORY_ICONS[Number(category)] ?? 'bell',24)?.clone() ?? bell() -} -// Drawn fallback for when the SVG rasterizer fails. -function bell(): GrayImage { - const image = new GrayImage(24,24,0) - image.fillRoundedRect(6,5,12,13,220,5) - image.fillRect(4,17,16,2,220) - image.fillRect(10,20,4,2,220) - return image +// ANCS does not provide app icons, so show a bundled Pebble icon for the +// source app (by bundle ID or display name), else for the notification's +// ANCS category. Never fetch notification sources or content from a +// third-party icon service. +function notificationIcon(notification: AndroidNotification): GrayImage { + const name = notificationAppIcon(notification.packageName, notification.appName) ?? notificationCategoryIcon(notification.category) + return pebbleIcon(name).clone() } export function readActiveNotificationIcons(maxIcons: number, _allowStale: boolean) { // One icon per source, standing for its first notification. const sources = new Map() for (const n of readActiveNotifications(ALL_NOTIFICATIONS)) if (!sources.has(n.packageName)) sources.set(n.packageName, n) const shown = Array.from(sources.values()).slice(0,Math.max(0,maxIcons)) - return {icons: shown.map(n => categoryIcon(n.category)),keys: shown.map(n => n.key),stale:false} + return {icons: shown.map(notificationIcon),keys: shown.map(n => n.key),stale:false} } export function readNotificationIconByKey(key: string, _allowStale: boolean) { const notification = readActiveNotifications(ALL_NOTIFICATIONS).find(n => n.key === key) - return {icon: notification ? categoryIcon(notification.category) : null,stale:false} + return {icon: notification ? notificationIcon(notification) : null,stale:false} } // ANCS carries no attachments, avatars or custom layouts. export function readNotificationPicture(_notification: AndroidNotification, _maxWidth: number, _maxHeight: number, _allowStale: boolean) { diff --git a/app/native/notification-icons.ts b/app/native/notification-icons.ts index 065e6747..822360b5 100644 --- a/app/native/notification-icons.ts +++ b/app/native/notification-icons.ts @@ -3,11 +3,12 @@ import { logCurrent, spanCurrent } from "./frame-timings"; import { toUint8Array } from "../util/array-util"; import { rememberNotificationSources } from "./notification-sources"; import { PHOTO_TONE, grayImageFromPacket } from "./image-files"; +import { NOTIFICATION_ICON_SIZE } from "./notification-types"; declare const com: any; declare const java: any; -const ICON_SIZE = 24; +const ICON_SIZE = NOTIFICATION_ICON_SIZE; /** Ask the native listener for every active source, including those below the list's display limit. */ export const ALL_NOTIFICATIONS = 0x7fffffff; // Backstop TTL only: the icon caches are invalidated eagerly whenever a diff --git a/app/native/notification-types.ts b/app/native/notification-types.ts index 0501a1a7..84f05419 100644 --- a/app/native/notification-types.ts +++ b/app/native/notification-types.ts @@ -1,4 +1,13 @@ /** Shared notification model; Android names are retained for existing callers. */ + +/** + * Side of a notification's (square) source icon wherever one is drawn: the + * status bar, notification cards and views, the Glanceboard. 25 is the size + * of the Pebble icons iPhone notifications use (app/graphics/pebble-icons.ts), + * which are drawn on that pixel grid; Android's icons render at any size. + */ +export const NOTIFICATION_ICON_SIZE = 25; + export type AndroidNotificationAction = { index: number; title: string; enabled: boolean }; export type AndroidNotification = { key: string; packageName: string; appName: string; title: string; text: string; diff --git a/app/ui/notifications.ts b/app/ui/notifications.ts index 905d5d1c..cf1fe2fc 100644 --- a/app/ui/notifications.ts +++ b/app/ui/notifications.ts @@ -18,6 +18,7 @@ import { type NotificationImageResult, } from "../native/notification-icons"; import { setNotificationSourceEnabled } from "../native/notification-sources"; +import { NOTIFICATION_ICON_SIZE } from "../native/notification-types"; import { notificationEmptyMessage } from "../native/notification-access"; import { noteStaleDataUsed, renderPassAllowsStaleData } from "../util/render-freshness"; import { type InputEvent } from "./gestures"; @@ -29,7 +30,7 @@ const TITLE_X = 18; const TITLE_Y = 10; const LIST_TOP = 38; const CARD_X = 20; -const ICON_SIZE = 24; +const ICON_SIZE = NOTIFICATION_ICON_SIZE; const ICON_TEXT_GAP = 8; const CARD_TEXT_X = 10 + ICON_SIZE + ICON_TEXT_GAP; const CARD_GAP = 6; diff --git a/app/ui/shell/chrome-layer.ts b/app/ui/shell/chrome-layer.ts index c908f10e..33c2c211 100644 --- a/app/ui/shell/chrome-layer.ts +++ b/app/ui/shell/chrome-layer.ts @@ -7,6 +7,7 @@ import { truncateText } from "../../graphics/textwrap"; import { activeAmbientCards } from "./ambient-cards"; import { BATTERY_ICON_WIDTH, DENSE_BATTERY_BLOCK_HEIGHT, drawBattery, drawDenseBatteries, type BatteryDevice } from "../../graphics/battery"; import { ALL_NOTIFICATIONS, readActiveNotificationIcons } from "../../native/notification-icons"; +import { NOTIFICATION_ICON_SIZE } from "../../native/notification-types"; import { readPhoneBatteryState } from "../../native/phone-battery"; import { noteStaleDataUsed, renderPassAllowsStaleData } from "../../util/render-freshness"; import { renderIcon, renderIconWithGlyph, type IconActivity, type IconName } from "../../graphics/icons"; @@ -430,7 +431,6 @@ function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null return { left, right, top, contentTop: atBottom ? top + 1 : top, divider }; } -const NOTIFICATION_ICON_SIZE = 24; const NOTIFICATION_ICON_STEP = NOTIFICATION_ICON_SIZE + 4; // Notification icons' top, in the top bar's layout (where any status icon's // selection box starts, a row above). diff --git a/app/util/base64.ts b/app/util/base64.ts new file mode 100644 index 00000000..720b149f --- /dev/null +++ b/app/util/base64.ts @@ -0,0 +1,19 @@ +const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +/** Decode standard base64 (padding and whitespace ignored), without relying on atob or Buffer. */ +export function decodeBase64(text: string): Uint8Array { + const clean = text.replace(/[^A-Za-z0-9+/]/g, ""); + const out = new Uint8Array(Math.floor((clean.length * 3) / 4)); + let bits = 0; + let bitCount = 0; + let outIndex = 0; + for (let i = 0; i < clean.length; i++) { + bits = (bits << 6) | BASE64_ALPHABET.indexOf(clean[i]!); + bitCount += 6; + if (bitCount >= 8) { + bitCount -= 8; + out[outIndex++] = (bits >> bitCount) & 0xff; + } + } + return out.subarray(0, outIndex); +} diff --git a/app/version.ts b/app/version.ts index a9d76032..41655119 100644 --- a/app/version.ts +++ b/app/version.ts @@ -1,2 +1,2 @@ -export const FACECLAW_VERSION = "0.8.5"; +export const FACECLAW_VERSION = "0.8.6-pre"; export const USER_AGENT = "Faceclaw/"+FACECLAW_VERSION; diff --git a/scripts/generate-pebble-icons.cjs b/scripts/generate-pebble-icons.cjs new file mode 100644 index 00000000..a074be6a --- /dev/null +++ b/scripts/generate-pebble-icons.cjs @@ -0,0 +1,528 @@ +#!/usr/bin/env node +/** + * Rasterizes Pebble notification/timeline icons from a checkout of + * https://github.com/pebble-dev/iconography (Apache-2.0) into + * app/graphics/pebble-icons-data.ts, for notification sources that come + * without an icon of their own (iPhone notifications over ANCS). + * + * git clone https://github.com/pebble-dev/iconography ~/src/pebble-iconography + * node scripts/generate-pebble-icons.cjs ~/src/pebble-iconography [--preview sheet.pgm] + * + * The 25px icons are drawn black-on-white for Pebble's light screen, on a + * 25x25 pixel grid. They are rendered here at 1:1 into 25x25 coverage + * bitmaps for a black display: what was ink is lit, and white fills are + * dark (painted in order, so a white fill still hides what is under it). + * Strokes get round caps and joins, as Pebble's own renderer drew them. + * Pixels are quantized to the 0 / 128 / 255 coverage levels the SVG icons + * use (SvgIconSource.quantizeCoverage). --preview writes a contact sheet + * (4x scale, ICONS order, 10 per row) to check the result by eye. + * + * Only the SVG subset these icons use is supported (path with + * M/L/H/V/C/S/Q/Z, line, polyline, polygon, rect, circle, ellipse; nested + * groups with translate/scale/matrix transforms); anything else fails + * loudly rather than drawing wrong. + */ +'use strict'; +const fs = require('node:fs'); +const path = require('node:path'); +const { execFileSync } = require('node:child_process'); + +const SIZE = 25; +const SUPERSAMPLE = 8; +const OUTPUT = path.join(__dirname, '..', 'app', 'graphics', 'pebble-icons-data.ts'); + +/** Icon name (as the app refers to it) -> source SVG within the iconography checkout. */ +const ICONS = { + // Generic pictograms, for notification categories and for apps without a brand icon. + generic: 'pebbleos/Pebble_25x25_Generic_notification.svg', + activity: 'pebbleos/Pebble_25x25_Activity.svg', + alarmClock: 'pebbleos/Pebble_25x25_Alarm_clock.svg', + appStore: 'icons/25px_Appstore.svg', + calendar: 'pebbleos/Pebble_25x25_Calendar.svg', + car: 'pebbleos/Pebble_25x25_Car_rental.svg', + contacts: 'icons/25px_Contacts_book.svg', + dinner: 'pebbleos/Pebble_25x25_Dinner_reservation.svg', + email: 'pebbleos/Pebble_25x25_Generic_e-mail.svg', + flight: 'pebbleos/Pebble_25x25_Scheduled_flight.svg', + glucose: 'pebbleos/Pebble_25x25_Glucose_monitor.svg', + heart: 'pebbleos/Pebble_25x25_Heart.svg', + incomingCall: 'pebbleos/Pebble_25x25_Incoming_call.svg', + location: 'pebbleos/Pebble_25x25_Location.svg', + microphone: 'icons/25px_Microphone.svg', + missedCall: 'pebbleos/Pebble_25x25_Missed_call.svg', + movie: 'pebbleos/Pebble_25x25_Movie_event.svg', + music: 'icons/25px_Music_note.svg', + news: 'pebbleos/Pebble_25x25_News_event.svg', + payBill: 'pebbleos/Pebble_25x25_Pay_bill.svg', + phone: 'pebbleos/Pebble_25x25_During_phone_call.svg', + podcast: 'pebbleos/Pebble_25x25_Radio_show.svg', + reminder: 'pebbleos/Pebble_25x25_Generic_reminder.svg', + settings: 'pebbleos/Pebble_25x25_Settings.svg', + shopping: 'icons/25px_Shopping_bag.svg', + sms: 'icons/25px_SMS.svg', + stocks: 'pebbleos/Pebble_25x25_Stocks_event.svg', + tv: 'pebbleos/Pebble_25x25_TV_show.svg', + voicemail: 'icons/25px_Phone.svg', + warning: 'pebbleos/Pebble_25x25_Generic_warning.svg', + weather: 'pebbleos/Pebble_25x25_Generic_weather.svg', + // Brands. + airmail: 'brand-logos/Airmail_25px.svg', + amazon: 'pebbleos/Pebble_25x25_Amazon.svg', + appleShortcuts: 'brand-logos/Apple_Shortcuts_25px.svg', + bbcNews: 'brand-logos/BBC_News_25px.svg', + beeper: 'brand-logos/Beeper_25px.svg', + bluesky: 'brand-logos/Bluesky_25px.svg', + discord: 'brand-logos/Discord_25px.svg', + duolingo: 'brand-logos/Duolingo_25px.svg', + ebay: 'brand-logos/eBay_25px.svg', + element: 'brand-logos/Element_25px.svg', + facebook: 'pebbleos/Pebble_25x25_Facebook_notification.svg', + facetime: 'pebbleos/Pebble_25x25_Facetime_incoming.svg', + gmail: 'pebbleos/Pebble_25x25_Gmail_notification.svg', + googleChat: 'brand-logos/Google_Chat_25px.svg', + googleMaps: 'pebbleos/Pebble_25x25_Google_Maps.svg', + googlePhotos: 'pebbleos/Pebble_25x25_Google_Photos.svg', + googleTasks: 'brand-logos/Google_Tasks_25px.svg', + homeAssistant: 'brand-logos/Home_Assistant_25px.svg', + instagram: 'pebbleos/Pebble_25x25_Instagram.svg', + iosPhotos: 'pebbleos/Pebble_25x25_iOS_Photos.svg', + kakaoTalk: 'pebbleos/Pebble_25x25_KakaoTalk.svg', + kik: 'pebbleos/Pebble_25x25_Kik.svg', + line: 'pebbleos/Pebble_25x25_Line.svg', + linkedIn: 'pebbleos/Pebble_25x25_LinkedIn.svg', + messenger: 'pebbleos/Pebble_25x25_Facebook_messenger_notification.svg', + omniFocus: 'brand-logos/OmniFocus_25px.svg', + outlook: 'brand-logos/Outlook_25px.svg', + reddit: 'brand-logos/Reddit_25px.svg', + signal: 'brand-logos/Signal_25px.svg', + simplex: 'brand-logos/SimpleX_25px.svg', + slack: 'pebbleos/Pebble_25x25_Slack.svg', + snapchat: 'pebbleos/Pebble_25x25_Snapchat.svg', + steam: 'brand-logos/Steam_25px.svg', + substack: 'brand-logos/Substack_25px.svg', + swarm: 'brand-logos/Swarm_25px.svg', + tapo: 'brand-logos/Tapo_25px.svg', + teams: 'brand-logos/Teams_25px.svg', + telegram: 'pebbleos/Pebble_25x25_Telegram_app.svg', + threads: 'brand-logos/Threads_25px.svg', + tiktok: 'brand-logos/TikTok_25px.svg', + twitch: 'brand-logos/Twitch_25px.svg', + twitter: 'pebbleos/Pebble_25x25_Twitter_notification.svg', + unifiProtect: 'brand-logos/Unifi_Protect_25px.svg', + viber: 'pebbleos/Pebble_25x25_Viber.svg', + waze: 'brand-logos/Waze_25px.svg', + weChat: 'pebbleos/Pebble_25x25_WeChat.svg', + whatsApp: 'pebbleos/Pebble_25x25_WhatsApp_notification.svg', + whatsAppBusiness: 'brand-logos/WhatsApp_Business_25px.svg', + yahooMail: 'pebbleos/Pebble_25x25_Yahoo_mail.svg', + youtube: 'brand-logos/Youtube_25px.svg', + zoom: 'brand-logos/Zoom_25px.svg', +}; + +// ----- XML ----------------------------------------------------------------- + +/** A minimal well-formed-XML reader: elements and attributes; text, comments and PIs are skipped. */ +function parseXml(text) { + const root = { tag: '#document', attrs: {}, children: [] }; + const stack = [root]; + const token = /|<\?[\s\S]*?\?>|||<\/([^\s>]+)\s*>|<([^\s/>!?]+)((?:\s+[^\s=/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>/g; + let match; + while ((match = token.exec(text))) { + if (match[1]) { + const open = stack.pop(); + if (!open || open.tag !== match[1]) throw new Error(`mismatched `); + } else if (match[2]) { + const attrs = {}; + for (const a of match[3].matchAll(/([^\s=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) attrs[a[1]] = a[2] ?? a[3]; + const element = { tag: match[2], attrs, children: [] }; + stack[stack.length - 1].children.push(element); + if (!match[4]) stack.push(element); + } + } + if (stack.length !== 1) throw new Error(`unclosed <${stack[stack.length - 1].tag}>`); + const svg = root.children.find((child) => child.tag === 'svg'); + if (!svg) throw new Error('no element'); + return svg; +} + +// ----- Styles and transforms ----------------------------------------------- + +const INHERITED = ['fill', 'stroke', 'stroke-width', 'fill-opacity', 'stroke-opacity', 'fill-rule']; + +/** Presentation attributes overlaid by the style attribute (which wins, as in CSS). */ +function ownStyle(element) { + const style = { ...element.attrs }; + for (const part of (element.attrs.style ?? '').split(';')) { + const colon = part.indexOf(':'); + if (colon > 0) style[part.slice(0, colon).trim()] = part.slice(colon + 1).trim(); + } + return style; +} + +const IDENTITY = [1, 0, 0, 1, 0, 0]; + +function multiply(m, n) { + return [ + m[0] * n[0] + m[2] * n[1], m[1] * n[0] + m[3] * n[1], + m[0] * n[2] + m[2] * n[3], m[1] * n[2] + m[3] * n[3], + m[0] * n[4] + m[2] * n[5] + m[4], m[1] * n[4] + m[3] * n[5] + m[5], + ]; +} + +function parseTransform(text) { + let m = IDENTITY; + if (!text) return m; + for (const [, name, args] of text.matchAll(/(\w+)\s*\(([^)]*)\)/g)) { + const v = args.split(/[\s,]+/).filter(Boolean).map(Number); + if (name === 'translate') m = multiply(m, [1, 0, 0, 1, v[0], v[1] ?? 0]); + else if (name === 'scale') m = multiply(m, [v[0], 0, 0, v[1] ?? v[0], 0, 0]); + else if (name === 'matrix' && v.length === 6) m = multiply(m, v); + else throw new Error(`unsupported transform ${name}(${args})`); + } + return m; +} + +/** 0 (white) .. 1 (black): how lit a color's ink is once the icon is inverted. */ +function inkOf(color) { + if (!color || color === 'none' || color === 'transparent') return null; + const named = { black: '#000000', white: '#ffffff', currentcolor: '#000000' }; + let hex = named[color.toLowerCase()] ?? color; + if (/^#[0-9a-f]{3}$/i.test(hex)) hex = '#' + [...hex.slice(1)].map((c) => c + c).join(''); + if (!/^#[0-9a-f]{6}$/i.test(hex)) throw new Error(`unsupported color ${color}`); + const n = parseInt(hex.slice(1), 16); + const luminance = (0.2126 * ((n >> 16) & 255) + 0.7152 * ((n >> 8) & 255) + 0.0722 * (n & 255)) / 255; + return 1 - luminance; +} + +// ----- Geometry ------------------------------------------------------------ + +const CURVE_STEPS = 16; +const ARC_STEPS = 48; + +/** Subpaths ({ points: [[x, y], ...], closed }) in the element's own coordinates. */ +function shapeOf(element) { + const a = element.attrs; + const num = (name, fallback = 0) => (a[name] === undefined ? fallback : parseFloat(a[name])); + switch (element.tag) { + case 'path': return pathSubpaths(a.d ?? ''); + case 'line': return [{ points: [[num('x1'), num('y1')], [num('x2'), num('y2')]], closed: false }]; + case 'polyline': + case 'polygon': { + const v = (a.points ?? '').trim().split(/[\s,]+/).filter(Boolean).map(Number); + const points = []; + for (let i = 0; i + 1 < v.length; i += 2) points.push([v[i], v[i + 1]]); + return points.length ? [{ points, closed: element.tag === 'polygon' }] : []; + } + case 'rect': { + const x = num('x'), y = num('y'), w = num('width'), h = num('height'); + let rx = a.rx === undefined ? num('ry') : num('rx'); + let ry = a.ry === undefined ? rx : num('ry'); + rx = Math.min(rx, w / 2); ry = Math.min(ry, h / 2); + if (w <= 0 || h <= 0) return []; + if (rx <= 0 || ry <= 0) return [{ points: [[x, y], [x + w, y], [x + w, y + h], [x, y + h]], closed: true }]; + const points = []; + const corners = [[x + w - rx, y + ry, -90], [x + w - rx, y + h - ry, 0], [x + rx, y + h - ry, 90], [x + rx, y + ry, 180]]; + for (const [cx, cy, start] of corners) { + for (let i = 0; i <= ARC_STEPS / 4; i++) { + const t = ((start + (90 * i) / (ARC_STEPS / 4)) * Math.PI) / 180; + points.push([cx + rx * Math.cos(t), cy + ry * Math.sin(t)]); + } + } + return [{ points, closed: true }]; + } + case 'circle': + case 'ellipse': { + const rx = element.tag === 'circle' ? num('r') : num('rx'); + const ry = element.tag === 'circle' ? num('r') : num('ry'); + if (rx <= 0 || ry <= 0) return []; + const points = []; + for (let i = 0; i < ARC_STEPS; i++) { + const t = (2 * Math.PI * i) / ARC_STEPS; + points.push([num('cx') + rx * Math.cos(t), num('cy') + ry * Math.sin(t)]); + } + return [{ points, closed: true }]; + } + default: + return null; + } +} + +function pathSubpaths(d) { + const tokens = d.match(/[A-Za-z]|[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g) ?? []; + const subpaths = []; + let current = null; + let x = 0, y = 0, startX = 0, startY = 0; + let lastControl = null; + let command = ''; + let i = 0; + const next = () => { + if (i >= tokens.length || /[A-Za-z]/.test(tokens[i])) throw new Error(`path data ends early: ${d}`); + return Number(tokens[i++]); + }; + const lineTo = (nx, ny) => { current.points.push([nx, ny]); x = nx; y = ny; }; + const cubic = (x1, y1, x2, y2, x3, y3) => { + const [x0, y0] = [x, y]; + for (let s = 1; s <= CURVE_STEPS; s++) { + const t = s / CURVE_STEPS, u = 1 - t; + current.points.push([ + u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * x3, + u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * y3, + ]); + } + x = x3; y = y3; lastControl = [x2, y2]; + }; + while (i < tokens.length) { + if (/[A-Za-z]/.test(tokens[i])) command = tokens[i++]; + else if (!command) throw new Error(`path data starts without a command: ${d}`); + const rel = command === command.toLowerCase(); + const ox = rel ? x : 0, oy = rel ? y : 0; + const upper = command.toUpperCase(); + if (upper !== 'C' && upper !== 'S') lastControl = null; + switch (upper) { + case 'M': { + const nx = ox + next(), ny = oy + next(); + current = { points: [[nx, ny]], closed: false }; + subpaths.push(current); + x = startX = nx; y = startY = ny; + command = rel ? 'l' : 'L'; // further pairs are implicit line-tos + break; + } + case 'L': lineTo(ox + next(), oy + next()); break; + case 'H': lineTo(ox + next(), y); break; + case 'V': lineTo(x, oy + next()); break; + case 'C': cubic(ox + next(), oy + next(), ox + next(), oy + next(), ox + next(), oy + next()); break; + case 'S': { + const [cx, cy] = lastControl ? [2 * x - lastControl[0], 2 * y - lastControl[1]] : [x, y]; + cubic(cx, cy, ox + next(), oy + next(), ox + next(), oy + next()); + break; + } + case 'Q': { + const qx = ox + next(), qy = oy + next(), ex = ox + next(), ey = oy + next(); + cubic(x + (2 / 3) * (qx - x), y + (2 / 3) * (qy - y), ex + (2 / 3) * (qx - ex), ey + (2 / 3) * (qy - ey), ex, ey); + lastControl = null; + break; + } + case 'Z': + if (current) current.closed = true; + x = startX; y = startY; + // A drawing command straight after Z starts a new subpath at the start point. + current = { points: [[x, y]], closed: false }; + subpaths.push(current); + command = ''; + break; + default: + throw new Error(`unsupported path command ${command} in ${d}`); + } + } + return subpaths.filter((subpath) => subpath.points.length > 1 || subpath.closed); +} + +// ----- Rasterization ------------------------------------------------------- + +const GRID = SIZE * SUPERSAMPLE; + +/** Mark the samples a shape's fill covers (scanline crossings, nonzero or evenodd). */ +function fillMask(subpaths, evenOdd) { + const mask = new Uint8Array(GRID * GRID); + const edges = []; + for (const { points } of subpaths) { + for (let k = 0; k < points.length; k++) { + const [x0, y0] = points[k], [x1, y1] = points[(k + 1) % points.length]; + if (y0 !== y1) edges.push([x0, y0, x1, y1]); + } + } + for (let row = 0; row < GRID; row++) { + const sy = (row + 0.5) / SUPERSAMPLE; + const crossings = []; + for (const [x0, y0, x1, y1] of edges) { + if ((sy >= y0 && sy < y1) || (sy >= y1 && sy < y0)) { + crossings.push([x0 + ((sy - y0) * (x1 - x0)) / (y1 - y0), y1 > y0 ? 1 : -1]); + } + } + crossings.sort((p, q) => p[0] - q[0]); + let winding = 0; + for (let k = 0; k + 1 < crossings.length; k++) { + winding += crossings[k][1]; + const inside = evenOdd ? (k + 1) % 2 === 1 : winding !== 0; + if (!inside) continue; + const from = Math.max(0, Math.ceil(crossings[k][0] * SUPERSAMPLE - 0.5)); + const to = Math.min(GRID - 1, Math.floor(crossings[k + 1][0] * SUPERSAMPLE - 0.5)); + for (let col = from; col <= to; col++) mask[row * GRID + col] = 1; + } + } + return mask; +} + +/** Mark the samples within half the stroke width of any segment: round caps and joins. */ +function strokeMask(subpaths, width) { + const mask = new Uint8Array(GRID * GRID); + const half = width / 2; + const segment = (x0, y0, x1, y1) => { + const minCol = Math.max(0, Math.floor((Math.min(x0, x1) - half) * SUPERSAMPLE)); + const maxCol = Math.min(GRID - 1, Math.ceil((Math.max(x0, x1) + half) * SUPERSAMPLE)); + const minRow = Math.max(0, Math.floor((Math.min(y0, y1) - half) * SUPERSAMPLE)); + const maxRow = Math.min(GRID - 1, Math.ceil((Math.max(y0, y1) + half) * SUPERSAMPLE)); + const dx = x1 - x0, dy = y1 - y0, length2 = dx * dx + dy * dy; + for (let row = minRow; row <= maxRow; row++) { + const sy = (row + 0.5) / SUPERSAMPLE; + for (let col = minCol; col <= maxCol; col++) { + const sx = (col + 0.5) / SUPERSAMPLE; + const t = length2 ? Math.max(0, Math.min(1, ((sx - x0) * dx + (sy - y0) * dy) / length2)) : 0; + const ex = sx - (x0 + t * dx), ey = sy - (y0 + t * dy); + if (ex * ex + ey * ey <= half * half) mask[row * GRID + col] = 1; + } + } + }; + for (const { points, closed } of subpaths) { + if (points.length === 1) segment(points[0][0], points[0][1], points[0][0], points[0][1]); + for (let k = 0; k + 1 < points.length; k++) segment(...points[k], ...points[k + 1]); + if (closed && points.length > 2) segment(...points[points.length - 1], ...points[0]); + } + return mask; +} + +function composite(ink, mask, value, alpha) { + for (let k = 0; k < ink.length; k++) if (mask[k]) ink[k] = ink[k] * (1 - alpha) + value * alpha; +} + +/** Render one SVG source to SIZE x SIZE coverage values (0..255, quantized). */ +function renderIcon(svgText) { + const svg = parseXml(svgText); + const viewBox = (svg.attrs.viewBox ?? `0 0 ${SIZE} ${SIZE}`).trim().split(/[\s,]+/).map(Number); + const [minX, minY, vw, vh] = viewBox; + // 1:1 keeps the icons' pixel-grid strokes crisp; larger art scales down. + const scale = Math.min(1, SIZE / vw, SIZE / vh); + const offsetX = scale === 1 ? Math.round((SIZE - vw) / 2) : (SIZE - vw * scale) / 2; + const offsetY = scale === 1 ? Math.round((SIZE - vh) / 2) : (SIZE - vh * scale) / 2; + const base = [scale, 0, 0, scale, offsetX - minX * scale, offsetY - minY * scale]; + const ink = new Float32Array(GRID * GRID); + + const walk = (element, inherited, matrix, opacity) => { + const own = ownStyle(element); + if (own.display === 'none' || own.visibility === 'hidden') return; + const style = { ...inherited }; + for (const key of INHERITED) if (own[key] !== undefined) style[key] = own[key]; + const m = multiply(matrix, parseTransform(element.attrs.transform)); + const alpha = opacity * (own.opacity === undefined ? 1 : parseFloat(own.opacity)); + if (element.tag === 'svg' || element.tag === 'g') { + for (const child of element.children) walk(child, style, m, alpha); + return; + } + const subpaths = shapeOf(element); + if (subpaths === null) { + // Not drawn: definitions, editor metadata, and the stray embedded + // reference bitmap in one export (Pebble's converter skips them too). + if (['defs', 'clipPath', 'mask', 'title', 'desc', 'metadata', 'image', 'style'].includes(element.tag) || element.tag.includes(':')) return; + throw new Error(`unsupported element <${element.tag}>`); + } + const placed = subpaths.map(({ points, closed }) => ({ + closed, + points: points.map(([px, py]) => [m[0] * px + m[2] * py + m[4], m[1] * px + m[3] * py + m[5]]), + })); + const fill = inkOf(style.fill ?? 'black'); + if (fill !== null) { + const fillAlpha = alpha * parseFloat(style['fill-opacity'] ?? '1'); + composite(ink, fillMask(placed, style['fill-rule'] === 'evenodd'), fill, fillAlpha); + } + const stroke = inkOf(style.stroke); + const width = parseFloat(style['stroke-width'] ?? '1') * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])); + if (stroke !== null && width > 0) { + const strokeAlpha = alpha * parseFloat(style['stroke-opacity'] ?? '1'); + composite(ink, strokeMask(placed, width), stroke, strokeAlpha); + } + }; + walk(svg, {}, base, 1); + + const pixels = new Uint8Array(SIZE * SIZE); + for (let py = 0; py < SIZE; py++) { + for (let px = 0; px < SIZE; px++) { + let sum = 0; + for (let sy = 0; sy < SUPERSAMPLE; sy++) { + for (let sx = 0; sx < SUPERSAMPLE; sx++) sum += ink[(py * SUPERSAMPLE + sy) * GRID + px * SUPERSAMPLE + sx]; + } + const coverage = (sum / (SUPERSAMPLE * SUPERSAMPLE)) * 255; + pixels[py * SIZE + px] = coverage < 64 ? 0 : coverage >= 192 ? 255 : 128; + } + } + return pixels; +} + +// ----- Output -------------------------------------------------------------- + +const LEVEL_CODES = { 0: 0, 128: 1, 255: 2 }; + +/** 2 bits per pixel (0 / 128 / 255), four pixels per byte, high bits first; base64. */ +function encode(pixels) { + const bytes = Buffer.alloc(Math.ceil(pixels.length / 4)); + for (let k = 0; k < pixels.length; k++) bytes[k >> 2] |= LEVEL_CODES[pixels[k]] << (6 - 2 * (k & 3)); + return bytes.toString('base64'); +} + +function writePreview(file, rendered) { + const SCALE = 4, CELL = (SIZE + 4) * SCALE, COLUMNS = 10; + const rows = Math.ceil(rendered.length / COLUMNS); + const width = COLUMNS * CELL, height = rows * CELL; + const image = Buffer.alloc(width * height, 40); + rendered.forEach(({ pixels }, index) => { + const left = (index % COLUMNS) * CELL + 2 * SCALE, top = Math.floor(index / COLUMNS) * CELL + 2 * SCALE; + for (let y = 0; y < SIZE * SCALE; y++) { + for (let x = 0; x < SIZE * SCALE; x++) { + image[(top + y) * width + left + x] = pixels[Math.floor(y / SCALE) * SIZE + Math.floor(x / SCALE)]; + } + } + }); + fs.writeFileSync(file, Buffer.concat([Buffer.from(`P5\n${width} ${height}\n255\n`), image])); +} + +function main() { + const args = process.argv.slice(2); + const previewAt = args.indexOf('--preview'); + const preview = previewAt >= 0 ? args.splice(previewAt, 2)[1] : null; + const checkout = args[0]; + if (!checkout) { + console.error('usage: generate-pebble-icons.cjs [--preview sheet.pgm]'); + process.exit(2); + } + const commit = execFileSync('git', ['-C', checkout, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(); + const rendered = Object.entries(ICONS).map(([name, source]) => { + try { + return { name, source, pixels: renderIcon(fs.readFileSync(path.join(checkout, source), 'utf8')) }; + } catch (error) { + throw new Error(`${source}: ${error.message}`); + } + }); + const lines = [ + '// Generated by scripts/generate-pebble-icons.cjs; do not edit by hand.', + '//', + '// Pebble notification icons from https://github.com/pebble-dev/iconography', + `// (commit ${commit}): the original Pebble Technology icons and`, + '// Rebble community additions, licensed under the Apache License 2.0 (see', + '// app/graphics/pebble-icons.LICENSE). Modified: rasterized at 25x25 and', + '// inverted for a black display (Pebble draws them black on white).', + '//', + '// Each icon is SIZE x SIZE pixels at 2 bits each (0, 1, 2 = coverage 0,', + '// 128, 255), four pixels to a byte with the first in the high bits,', + '// row-major, base64-encoded.', + '', + `export const PEBBLE_ICON_SIZE = ${SIZE};`, + '', + 'export const PEBBLE_ICON_DATA = {', + ...rendered.map(({ name, source, pixels }) => ` ${name}: "${encode(pixels)}", // ${source}`), + '} as const;', + '', + 'export type PebbleIconName = keyof typeof PEBBLE_ICON_DATA;', + '', + ]; + fs.writeFileSync(OUTPUT, lines.join('\n')); + console.log(`wrote ${rendered.length} icons to ${path.relative(process.cwd(), OUTPUT)}`); + if (preview) { + writePreview(preview, rendered); + console.log(`preview: ${preview}`); + rendered.forEach(({ name }, index) => process.stdout.write(`${index % 10 === 0 ? '\n' : ' '}${name}`)); + process.stdout.write('\n'); + } +} + +if (require.main === module) main(); + +module.exports = { renderIcon, encode, ICONS, SIZE }; diff --git a/tests/app-layout.test.cjs b/tests/app-layout.test.cjs index ab00d9d7..533ae0e8 100644 --- a/tests/app-layout.test.cjs +++ b/tests/app-layout.test.cjs @@ -349,11 +349,13 @@ test('the mirror\'s crop follows Preview scaling, the Glanceboard and the lock, // The real chrome layer over the given geometry, with platform pieces stubbed: // a 4px-per-character font that paints each character as a 2x6 block, up to -// `notifications` 24px notification icons (keyed n0, n1, ...), and a phone +// `notifications` notification icons (keyed n0, n1, ...), and a phone // battery at 80%. const graphics = require('../.test-build/app/graphics/image.js'); const shellScene = require('../.test-build/app/graphics/shell-scene.js'); const displayList = require('../.test-build/app/graphics/display-list.js'); +const notificationTypes = require('../.test-build/app/native/notification-types.js'); +const ICON = notificationTypes.NOTIFICATION_ICON_SIZE; function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, trayIcons = [] } = {}) { const font = { lineHeight: 12, ascent: 10, measureText: (text) => text.length * 4, drawText: (image, x, y, text, value) => { for (let i = 0; i < text.length; i++) image.fillRect(x + i * 4, y + 2, 2, 6, value); } }; @@ -369,9 +371,10 @@ function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, t '../../native/notification-icons': { ALL_NOTIFICATIONS: 0x7fffffff, readActiveNotificationIcons: (max) => { requested.push(max); const count = Math.min(max, notifications); - return { icons: Array.from({ length: count }, () => new graphics.GrayImage(24, 24, 200)), + return { icons: Array.from({ length: count }, () => new graphics.GrayImage(ICON, ICON, 200)), keys: Array.from({ length: count }, (_, index) => `n${index}`), stale: false }; } }, + '../../native/notification-types': notificationTypes, '../../native/phone-battery': { readPhoneBatteryState: () => ({ battery: phoneBattery, charging: false }) }, '../../util/render-freshness': { renderPassAllowsStaleData: () => false }, '../dashboard-settings': { batteryDisplayModeSetting: { get: () => 'icon' }, phoneBatteryVisibilitySetting: settings, @@ -536,9 +539,9 @@ test('the switcher row lays out windows, free space, notifications, widgets, bat // Right to left from the row's end (x=608), centred under its separator // line (y=366): "Thu Oct 2 9:41" (56px) flush with it; the battery block (label // 20 + gap 5 + gauge 21) 16px before it; the 30px widget 10px before that; - // then the two notification icons, 8px clear of the widget. The surface - // starts 2px before them, room for a selection box round the first. - const clockX = 608 - 56, batteryLeft = clockX - 16 - 46, trayLeft = batteryLeft - 40, iconsLeft = trayLeft - 8 - 56 + 4; + // then the two notification icons (4px apart), 8px clear of the widget. + // The surface starts 2px before them, room for a selection box round the first. + const clockX = 608 - 56, batteryLeft = clockX - 16 - 46, trayLeft = batteryLeft - 40, iconsLeft = trayLeft - 8 - 2 * (ICON + 4) + 4; assert.deepEqual([status.x, status.y, status.image.width, status.image.height], [iconsLeft - 2, 367, 608 - iconsLeft + 2, 35]); const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x]; // The clock's text runs 8 rows down the top bar's layout, which sits 5 rows into the row. @@ -567,19 +570,20 @@ test('past two rows of windows, they scroll, and notification icons give way to assert.equal(g.switcherRowHeight(), 72); assert.equal(heightChanges(), 1); assert.deepEqual([row.y, row.image.height], [366, 72]); - // Notification icons drop from the end until the two status rows leave - // three window slots a row (32 + 20 + 3 * 40 - 8, and the gap): 28 stay, - // 15 in the first row (416px) and 13 with the clock in the second (432px). - assert.equal(chrome.statusItems().length, 28); - assert.deepEqual([status.x, status.y, status.image.height], [608 - 432 - 2, 367, 71]); + // Notification icons (29px apart) drop from the end until the two status + // rows leave three window slots a row (32 + 20 + 3 * 40 - 8, and the gap): + // 27 stay, 15 in the first row (431px) and 12 with the clock in the second + // (416px). + assert.equal(chrome.statusItems().length, 27); + assert.deepEqual([status.x, status.y, status.image.height], [608 - 431 - 2, 367, 71]); const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x]; - assert.deepEqual([at(status, 608 - 416, 366 + 5 + 2), at(status, 608 - 432, 366 + 36 + 5 + 2)], [200, 200]); + assert.deepEqual([at(status, 608 - 431, 366 + 5 + 2), at(status, 608 - 416, 366 + 36 + 5 + 2)], [200, 200]); // Three windows a row; the rest scroll, with the chevron after the second // row's, at the end of the windows rather than of the row. assert.equal(chrome.windowIndexAt(32 + 10 + 2 * 40 + 4, 380, 12), 2); assert.equal(chrome.windowIndexAt(32 + 10 + 3 * 40 + 4, 380, 12), null); assert.equal(chrome.windowIndexAt(32 + 10 + 2 * 40 + 4, 420, 12), 5); - const windowsRight = 608 - 432 - 8; + const windowsRight = 608 - 431 - 8; const chevron = row.image.pixels.findIndex((v) => v === 140); assert.deepEqual([chevron % row.image.width + row.x, Math.floor(chevron / row.image.width) + row.y], [windowsRight - 6, 366 + 36 + 18 - 5]); }); @@ -655,11 +659,11 @@ test('the status bar takes a second row of its own before the windows do', () => chrome.paintParts(); assert.equal(heightChanges(), 1, 'reported once'); assert.deepEqual(g.rect('min'), before); - // Both rows right-aligned against the row's end: 8 icons (220px) over 6 - // and the clock (236px), a top bar's height apart. - assert.deepEqual([status.x, status.y, status.image.height], [608 - 236 - 2, 367, 63]); + // Both rows right-aligned against the row's end: 8 icons (228px) over 6 + // and the clock (242px), a top bar's height apart. + assert.deepEqual([status.x, status.y, status.image.height], [608 - 242 - 2, 367, 63]); const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x]; - assert.deepEqual([at(status, 608 - 220, 371 + 2), at(status, 608 - 236, 371 + 28 + 2), at(status, 608 - 56, 371 + 28 + 8 + 2)], + assert.deepEqual([at(status, 608 - 228, 371 + 2), at(status, 608 - 242, 371 + 28 + 2), at(status, 608 - 56, 371 + 28 + 8 + 2)], [200, 200, 210]); assert.deepEqual(keysOf(chrome.statusItems()), Array.from({ length: 14 }, (_, i) => `n${i}`)); // The windows keep one row, against the window. @@ -673,19 +677,20 @@ test('windows past one row take a second, where a selected one sits in a box', ( g.settings.appSwitcherPositionSetting.value = 'bottom'; g.settings.statusBarPositionSetting.value = 'bottom'; const { chrome, state } = chromeLayer(g, { notifications: 14, windows: 9 }); - state.selectedIndex = 8; + state.selectedIndex = 7; const [row, status] = chrome.paintParts(); assert.equal(g.switcherRowHeight(), 72); - // Eight slots a row (what the 236px status rows leave); the ninth window + // Seven slots a row (what the 242px status rows leave); the eighth window // starts the second row, under the first. - assert.deepEqual([chrome.windowIndexAt(31 + 7 * 40, 380, 9), chrome.windowIndexAt(31, 410, 9), chrome.windowIndexAt(71, 410, 9)], [7, 8, null]); + assert.deepEqual([chrome.windowIndexAt(31 + 6 * 40, 380, 9), chrome.windowIndexAt(31 + 7 * 40, 380, 9), chrome.windowIndexAt(31, 410, 9), + chrome.windowIndexAt(71, 410, 9), chrome.windowIndexAt(111, 410, 9)], [6, null, 7, 8, null]); const at = (p, x, y) => p.image.pixels[(y - p.y) * p.image.width + x - p.x]; // Its selection is a box (as for a sidebar overflow column), and the // separator runs unbroken over the first row. assert.deepEqual([at(row, 31, 402 + 18), at(row, 31 + 5, 402 + 7)], [150, 120]); assert.equal(at(row, 50, 366), 40); // The status rows line up with the window rows. - assert.equal(status.image.withDrawsBaked().pixels[(366 + 36 + 5 + 2 - status.y) * status.image.width + 608 - 236 - status.x], 200); + assert.equal(status.image.withDrawsBaked().pixels[(366 + 36 + 5 + 2 - status.y) * status.image.width + 608 - 242 - status.x], 200); }); test('a popup app switcher shows a box of window icons over the dimmed window while focused', () => { @@ -777,13 +782,13 @@ test('a notification the switcher selects sits in a box, filled with its icon in Object.assign(state, { selectedIndex: -1, selectedStatusItem: notification('n1'), focus: 'sidebar' }); let [row, status] = chrome.paintParts(); assert.deepEqual(keysOf(chrome.statusItems()), ['n0', 'n1', 'n2']); - // Clock only: the icons end 8px before its 8px lead-in, 28px apart, each - // 7 rows into the row (the top bar's layout, 5 rows down). - const iconsLeft = 608 - 56 - 8 - 8 - 3 * 28 + 4, iconY = 366 + 7, n1 = iconsLeft + 28; + // Clock only: the icons end 8px before its 8px lead-in, 4px apart, each + // centred in the top bar's 28 rows (its layout 5 rows down the row). + const step = ICON + 4, iconsLeft = 608 - 56 - 8 - 8 - 3 * step + 4, iconY = 366 + 5 + ((28 - ICON) >> 1), n1 = iconsLeft + step; const at = (p, x, y) => p.image.withDrawsBaked().pixels[(y - p.y) * p.image.width + x - p.x]; // The box: 2px either side of the icon, 1px above and below, white; the // icon inside it inverted (bright, so to black); its neighbours as ever. - assert.deepEqual([at(status, n1 - 2, iconY + 12), at(status, n1 + 25, iconY + 12), at(status, n1 + 12, iconY - 1)], [255, 255, 255]); + assert.deepEqual([at(status, n1 - 2, iconY + 12), at(status, n1 + ICON + 1, iconY + 12), at(status, n1 + 12, iconY - 1)], [255, 255, 255]); assert.equal(at(status, n1 + 12, iconY - 2), 1); assert.deepEqual([at(status, n1 + 5, iconY + 5), at(status, iconsLeft + 5, iconY + 5)], [1, 200]); // No window is selected: the separator runs unbroken over the windows. diff --git a/tests/ios-notification-icons.test.cjs b/tests/ios-notification-icons.test.cjs index e47e8146..009ed1cd 100644 --- a/tests/ios-notification-icons.test.cjs +++ b/tests/ios-notification-icons.test.cjs @@ -1,51 +1,108 @@ const test = require('node:test'); const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const os = require('node:os'); +const path = require('node:path'); const { loader } = require('./helpers/load-typescript.cjs'); +const generator = require('../scripts/generate-pebble-icons.cjs'); -class FakeImage { - constructor(name) { this.name = name; } - clone() { return new FakeImage(this.name); } - fillRoundedRect() {} - fillRect() {} -} - -function setup(notifications, render = name => new FakeImage(name)) { - const icons = loader({}, { - '../graphics/image': { GrayImage: class extends FakeImage { constructor() { super('drawn-bell'); } } }, - '../graphics/icons': { renderIcon: (name, size) => { assert.equal(size, 24); return render(name); } }, +function setup(notifications) { + const load = loader({}, { '../g2/ancs-client': { AncsClient: class {}, ANCS_CONNECT_MESSAGE: '' }, './notification-sources': { rememberNotificationSources() {} }, - })('app/native/notification-icons.ios.ts'); + }); + const icons = load('app/native/notification-icons.ios.ts'); icons.bindIosNotifications({ read: () => notifications }); - return icons; + return { icons, pebble: load('app/graphics/pebble-icons.ts') }; } -const notification = (key, packageName, category) => ({ key, packageName, category }); +const notification = (key, packageName, category, appName = '') => ({ key, packageName, category, appName }); -test('tray icons follow each source\'s first notification category', () => { - const icons = setup([ - notification('a', 'com.apple.mobilephone', '2'), - notification('b', 'com.apple.mobilephone', '1'), - notification('c', 'com.apple.mobilemail', '6'), - notification('d', 'com.example.tv', '11'), +/** Which bundled icon an image is (icons are compared by their pixels). */ +function iconName(pebble, image) { + const data = loader({}, {})('app/graphics/pebble-icons-data.ts').PEBBLE_ICON_DATA; + return Object.keys(data).find(name => Buffer.from(pebble.pebbleIcon(name).pixels).equals(Buffer.from(image.pixels))); +} + +test('tray icons come from the source app, else its notification category, one per source', () => { + const { icons, pebble } = setup([ + notification('a', 'net.whatsapp.WhatsApp', '4'), + notification('b', 'net.whatsapp.WhatsApp', '4'), + notification('c', 'com.apple.mobilephone', '2', 'Phone'), + notification('d', 'com.apple.MobileSMS', '4', 'Messages'), + notification('e', 'com.example.tv', '11', 'Some TV App'), ]); const result = icons.readActiveNotificationIcons(10, false); - assert.deepEqual([...result.keys], ['a', 'c', 'd']); - assert.deepEqual([...result.icons].map(icon => icon.name), ['phone-missed', 'mail', 'tv']); + assert.deepEqual([...result.keys], ['a', 'c', 'd', 'e']); + assert.deepEqual([...result.icons].map(icon => iconName(pebble, icon)), ['whatsApp', 'missedCall', 'sms', 'tv']); assert.equal(icons.readActiveNotificationIcons(1, false).icons.length, 1); }); -test('unknown categories use the bell; a failed rasterization uses the drawn bell', () => { - const icons = setup([notification('a', 'x', '0'), notification('b', 'y', '12'), notification('c', 'z', '')]); - assert.deepEqual([...icons.readActiveNotificationIcons(10, false).icons].map(icon => icon.name), ['bell', 'bell', 'bell']); - assert.equal(icons.readNotificationIconByKey('missing', false).icon, null); +test('apps match by bundle ID ignoring case, by regional prefix, then by display name', () => { + const { icons, pebble } = setup([ + notification('a', 'NET.WHATSAPP.WHATSAPP', '0'), + notification('b', 'com.abbott.librelink.de', '0', 'LibreLink'), + notification('c', 'com.ABCDE12345.loopkit.Loop', '0', 'Loop'), + notification('d', 'com.example.unknown', '0', 'loopfollow'), + notification('e', 'com.example.unknown2', '0', 'Some Loop App'), + ]); + const byKey = key => iconName(pebble, icons.readNotificationIconByKey(key, false).icon); + assert.deepEqual(['a', 'b', 'c', 'd', 'e'].map(byKey), ['whatsApp', 'glucose', 'glucose', 'glucose', 'generic']); +}); - const failing = setup([notification('a', 'x', '4')], () => null); - assert.equal(failing.readNotificationIconByKey('a', false).icon.name, 'drawn-bell'); +test('unknown categories use the generic bell; an unknown key has no icon', () => { + const { icons, pebble } = setup([notification('a', 'x', '0'), notification('b', 'y', '12'), notification('c', 'z', '')]); + assert.deepEqual([...icons.readActiveNotificationIcons(10, false).icons].map(icon => iconName(pebble, icon)), ['generic', 'generic', 'generic']); + assert.equal(icons.readNotificationIconByKey('missing', false).icon, null); }); test('icons are copies, so callers can draw on them', () => { - const shared = new FakeImage('message-circle'); - const icons = setup([notification('a', 'x', '4')], () => shared); - assert.notEqual(icons.readNotificationIconByKey('a', false).icon, shared); + const { icons, pebble } = setup([notification('a', 'net.whatsapp.WhatsApp', '4')]); + const first = icons.readNotificationIconByKey('a', false).icon; + first.pixels.fill(77); + assert.equal(iconName(pebble, icons.readNotificationIconByKey('a', false).icon), 'whatsApp'); +}); + +test('every icon the tables use is bundled, 25px square, quantized, and not blank', () => { + const load = loader({}, {}); + const table = load('app/native/notification-app-icons.ts'); + const { pebbleIcon, PEBBLE_ICON_SIZE } = load('app/graphics/pebble-icons.ts'); + const { PEBBLE_ICON_DATA } = load('app/graphics/pebble-icons-data.ts'); + assert.equal(PEBBLE_ICON_SIZE, load('app/native/notification-types.ts').NOTIFICATION_ICON_SIZE); + for (const name of table.allNotificationAppIcons()) assert.ok(name in PEBBLE_ICON_DATA, `${name} is not bundled`); + for (const name of Object.keys(PEBBLE_ICON_DATA)) { + const icon = pebbleIcon(name); + assert.deepEqual([icon.width, icon.height], [25, 25], name); + assert.ok(icon.pixels.every(value => value === 0 || value === 128 || value === 255), `${name} has unquantized pixels`); + assert.ok(icon.pixels.some(value => value === 255), `${name} is blank`); + } +}); + +test('the icon generator inverts Pebble art: black ink lights up, white fills hide what is under them', () => { + const svg = ` + + + + + + `; + const pixels = generator.renderIcon(svg); + const at = (x, y) => pixels[y * 25 + x]; + // A 2px stroke on a grid line covers exactly the two pixel rows either side of it. + assert.deepEqual([at(5, 2), at(5, 3), at(5, 4), at(5, 5)], [0, 255, 255, 0]); + // Round caps reach a pixel past each end. + assert.equal(at(1, 3), 255); + assert.equal(at(0, 3), 0); + // The white rect drawn later hides the second line where they overlap. + assert.deepEqual([at(8, 9), at(12, 9), at(17, 9)], [255, 0, 255]); + // Black fills light up, through a group's transform; hidden groups draw nothing. + assert.deepEqual([at(5, 17), at(5, 20)], [255, 0]); + assert.equal(at(24, 24), 0); + + // Its encoding round-trips through the app's decoder. + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pebble-icons-')); + const dataFile = path.join(dir, 'pebble-icons-data.ts'); + fs.writeFileSync(dataFile, `export const PEBBLE_ICON_SIZE = 25;\nexport const PEBBLE_ICON_DATA = { probe: "${generator.encode(pixels)}" } as const;\n`); + const decoded = loader({}, { './pebble-icons-data': loader({}, {})(dataFile) })('app/graphics/pebble-icons.ts').pebbleIcon('probe'); + assert.deepEqual([...decoded.pixels], [...pixels]); }); diff --git a/tests/menu-display-list.test.cjs b/tests/menu-display-list.test.cjs index 35984ee7..4cf41711 100644 --- a/tests/menu-display-list.test.cjs +++ b/tests/menu-display-list.test.cjs @@ -101,7 +101,7 @@ test('unselected sidebar icons retain -2 depth through shell cropping, including '../../graphics/shell-scene':shellScene,'../../graphics/image':graphics,'../../graphics/display-list':require('../.test-build/app/graphics/display-list.js'), '../../graphics/ui-fonts':{getDefaultSmallFont:()=>font,getDefaultMediumFont:()=>font}, '../../graphics/textwrap':{},'./ambient-cards':{},'../../graphics/battery':{}, - '../../native/notification-icons':{},'../../native/phone-battery':{},'../../util/render-freshness':{}, + '../../native/notification-icons':{},'../../native/notification-types':require('../.test-build/app/native/notification-types.js'),'../../native/phone-battery':{},'../../util/render-freshness':{}, '../../graphics/icons':{},'../dashboard-settings':{},'../clock-format':{},'../../graphics/bdffont':{}, '../layers':{LayerStack},'../menu':{scrollToKeepSelectionVisible:()=>0},'../metrics':{}, './geometry':{MIN_WINDOW_HEIGHT:280,minWindowTop:()=>0,windowTop:()=>0,SHELL_OPAQUE_BLACK:1,SIDEBAR_WIDTH:64,TOP_BAR_HEIGHT:24, diff --git a/tests/notification-filter.test.cjs b/tests/notification-filter.test.cjs index dbfccce3..40cda7c6 100644 --- a/tests/notification-filter.test.cjs +++ b/tests/notification-filter.test.cjs @@ -82,6 +82,7 @@ function ui(fontSize = 12) { '~/util/date-util': { formatRelativeTime: () => '' }, '../native/notification-icons': native, '../native/notification-sources': prefs, + '../native/notification-types': require('../.test-build/app/native/notification-types.js'), '../native/notification-access': { isNotificationListenerEnabled: () => true }, '../util/render-freshness': { renderPassAllowsStaleData: () => false }, './menu-highlight-motion': require('../.test-build/app/ui/menu-highlight-motion.js'), '../graphics/menu-scroll-list': require('../.test-build/app/graphics/menu-scroll-list.js'), './menu-scroll-motion': require('../.test-build/app/ui/menu-scroll-motion.js'), '../graphics/draw-expression': require('../.test-build/app/graphics/draw-expression.js'), diff --git a/tests/tsconfig.json b/tests/tsconfig.json index a403f3ee..374ebdf1 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -28,6 +28,7 @@ "../app/ui/menu-core.ts", "../app/phone-ui/phone-gestures.ts", "../app/native/java-direct-buffer.ts", + "../app/native/notification-types.ts", "../app/g2/firmware-compat.ts", "../app/g2/glasses-hardware-identity.ts", "../app/g2/ble-proximity.ts",