./gradlew :app:assembleDebug # build
./fd deploy # build + install + launchThe three classes Android itself starts stay in the root package, so their component names never move; everything else is grouped by what it does.
app/src/main/java/id/zero/flipdash/
DashActivity.kt the activity on display 1: window flags, 1 s ticker, day/night schedule
DashService.kt foreground service, wakelock, watchdog, "released" state
BootReceiver.kt starts the service again after a reboot or an update
core/ the spine: config in, values out
Cfg.kt config load/save, hot reload, colour resolution
Store.kt last value per source + history for sparklines
Palettes.kt 12 palettes + 4 styles, served to the settings page
I18n.kt the ~30 strings the phone draws, in every language (see language.md)
Fmt.kt Log.kt Shell.kt
data/ where a value comes from, and when
Engine.kt the data-fetch scheduler
Sources.kt http / shell / device / sensor / static + time-aware URLs
Payload.kt json / prom / kv / lines / regex → a value tree
DeviceMetrics.kt battery, cpu, ram, network, storage, uptime, wifi, thermal
SensorHub.kt physical sensors (+ probing every sensor for the catalog)
render/ everything that puts pixels on the cover screen
DashView.kt the page: top bar, widget grid, page rotation, touch
Overlays.kt what covers the page: menu, ntfy popup, ringing alarm, night clock
Skin.kt drawing styles (modern/pixel/terminal/minimal) + theme fonts
Dc.kt draw context: fonts, box-fitted text sizes, shape helpers
widget/ one file per family, plus the frame around them all
Widgets.kt the entry point: title, timeframe corner, stale/error marks
WidgetData.kt value lookup, scaling, colour rules, templates, OHLC series
MeterWidgets.kt value, gauge, bar, spark
ChartWidgets.kt chart, candle
BoardWidgets.kt status, list, text, ntfy
TimeWidgets.kt clock, alarm, alarm list
system/ the phone around the app
Displays.kt phone screen modes + rotation
Screen.kt screen corner-radius detection
Ntfy.kt streaming subscription, sound/vibration, popup
Alarms.kt alarm schedule, ringing/snooze state, alarm-stream audio
web/ the settings page's server
ConfigServer.kt sockets, threads, the token gate
Http.kt request parsing and reply writing, nothing app-specific
Routes.kt every endpoint in one list
app/src/main/assets/
editor.html the settings page (~3,300 lines, no framework)
i18n.js the settings page's dictionaries, served at /i18n.js
default_config.json
icon.svg icon-180.png favicon and home-screen icon for the settings page
fonts/ Fira Sans/Code (settings page), Press Start 2P & VT323 (themes)
app/src/main/res/
mipmap-anydpi-v26/ adaptive launcher icon (minSdk 31, so no legacy PNGs)
drawable/ icon layers + the notification silhouette — all generated
tools-zeroserver.sh node_exporter metrics collector
tools-mockntfy.py a mock ntfy server for testing
tools-logo.py regenerates every icon from one pixel grid (see below)
fd the control script you run from your computer
docs/ this documentation (cover-*.png come from `./fd shot`)
Dependencies point one way: core imports nothing of its own, data builds on core, render and
system build on those, and web sits on top of everything — it exists to expose the rest. The only
upward references are to the three entry classes in the root package, which any layer may poke because
they are what is actually running. When something low in the stack starts needing a drawing class, the
logic is in the wrong package: Cfg.widgetSpec lives in core because the engine has to know where a
widget points, and that is config shape rather than drawing.
Important when changing how widgets look: the preview in
editor.htmlis a second implementation of the drawing engine (JavaScript, entirely separate from the Kotlin). Changerender/widget/*.ktorrender/Skin.ktand you must change its counterpart ineditor.htmltoo — otherwise the preview lies to you.
The settings page is tested by driving a real Chrome over the DevTools Protocol, not by calling its
functions directly. That matters: the "text fields only accept one character" bug (a re-render stealing
focus on every keystroke) is invisible to a test that just calls functions through Runtime.evaluate.
Three checks worth running whenever you touch editor.html:
- Smoke test — open every tab over CDP and catch
Runtime.exceptionThrown. - Horizontal overflow — at a 390 px viewport, no tab's
scrollWidthmay exceed itsclientWidth. This one has already caught a regression in the Data sources table. - Untranslated strings — load
?lang=en, walk every tab and dialog, then read[...FD_MISSING]. It lists keys that fell back to Indonesian; see Language for how to read the noise.
When you add UI text, write it in Indonesian and let it flow through
el()— that is where translation happens, so noT()call is needed at the call site. Only text assembled around a variable needsT('… {x} …', {x})written by hand. Then add the key toi18n.js.
- Cover-screen screenshots need the physical id
4630947232161729155;-d 1fails withStatus: -2. When the phone isn't folded the cover is off and you get a black image — run./fd cover onfirst, and don't forget./fd cover offafterwards or you'll leave the phone stuck in folded mode. - Android's regex engine (ICU) rejects unescaped
}and]even though a normal JVM accepts them.Regex("\\{([^}]+)}")crashes the app in<clinit>. Always write\\{…\\}and\\]. - Text must be fitted to ink height, not to the nominal font size — pixel fonts don't have the internal
leading that sans fonts do. Use
Dc.fitBox()/Dc.baselineFor(). - A 270° arc is
2rwide but only1.707rtall — deriving the radius from cell width alone gives you squashed gauges. - Android 12+'s phantom process killer is permanently disabled on this phone; without that, background services die within hours.
The logo is a folded Flip seen face-on: a 2:1 cover screen with a rising chart inside it, a hinge gap,
and the lower half below — the product's own silhouette, drawn on a 12 × 8 grid of whole pixels so it
stays crisp at 16 px and matches the pixel theme the dashboard already draws with.
That grid lives in exactly one place, at the top of tools-logo.py. Everything else is generated:
python3 tools-logo.py # needs Pillow for the PNGs; SVG + Android XML need nothing
| Output | Used by |
|---|---|
res/drawable/ic_launcher_{foreground,background,monochrome}.xml |
adaptive launcher icon, incl. Android 13+ themed icons |
res/drawable/ic_stat_flipdash.xml |
the foreground-service notification |
assets/icon.svg, assets/icon-180.png |
favicon and apple-touch-icon, served at /icon.svg and /icon-180.png |
docs/img/logo.{svg,png}, logo-mark.svg, logo-wordmark.png |
README and docs |
Edit the drawables by hand and the next run of the script overwrites you — change the grid instead. The
one copy that is not generated is the inline <svg> in the sidebar of editor.html, which uses the
page's own --primary / --accent tokens; keep it in step by eye.
Colours come from the settings page's design tokens: #3B82F6 bezel, #FBBF24 chart, #475569 lower
half, on a #16233F → #070D1C tile. The wordmark is set in Press Start 2P, the same font bundled for
the pixel theme.
Three constraints shaped the whole codebase:
- No dependencies. Just
Canvas,org.jsonandHttpURLConnection— no AndroidX, no Compose. The APK is ~2.9 MB and the process stays light, because it has to run 24 hours a day. - All configuration happens over the network. You cannot lay out a dashboard on a 1.9" screen, so the phone serves its own full settings page on port 8099.
- That screen is the only one. Anything essential — leaving the dashboard, changing pages, forcing a refresh — still has to be reachable by touching the small screen.