ABV Nexus home

>> Notes /

Luxel widgets: native, light and in agreement with the app

This note is about Luxel, the task app with a heatmap at its heart, and its Android home-screen widgets.

Three widgets

  • Heatmap (free): a mirror of the in-app heatmap, drawn as one bitmap at the screen's own resolution.
  • Today (Pro): today's list with real checkboxes that flip the instant you tap (on Android 12 and later), and an "Add task" bar. It can show all tasks or one tag.
  • Home (Pro): the heatmap, a tag filter, the task list and the add bar together.

Native, not JavaScript

The app is written in React Native, but the widgets are native Kotlin. When you tap a checkbox on a widget, no JavaScript starts. The tap goes to a small native handler that writes the completion directly into the app's database and redraws.

That is why widget taps respond instantly, and why ticking a task from the home screen does not start the whole app in the background. If the app happens to be open, it gets a signal to reload.

One read per redraw

Each redraw reads the database once and draws every Luxel widget from that single read. Redraws happen when something changes, when the app goes to the background, once just after midnight so Today rolls over to the new day, and on Android's standard half-hourly widget refresh. There is no other background work.

The app and the widgets share one database file. It runs in write-ahead logging mode with a short wait on locks, so the app and a widget can read and write at the same time without corrupting anything. Widgets never change the database structure; only the app migrates it.

The hard part: agreeing on "today"

Two implementations of the same rules will disagree eventually. If the widget thinks a repeating task is due and the app does not, people stop trusting both.

So the logic that decides what is due, how many points a day has and which colour a heatmap square gets is written twice, in TypeScript and in Kotlin, deliberately as plain integer calendar maths with no date libraries. Then:

  • the TypeScript side generates a fixture of expected answers: 7,980 "does this rule occur on this day" cases, plus heatmap colours and brightness scales;
  • the Kotlin unit tests run against that same fixture during every Android build;
  • a build where the two disagree fails.

The heatmap adds one more wrinkle: its brightness adapts to your own last 60 days, so the widget has to compute the same scale as the app, not just the same colours.

The trade-off

Every change to those rules has to be made in two languages, and the fixture regenerated. That is real extra work. It is also the only way I found to make a widget feel like part of the app rather than a rough copy of it.

Widgets for iOS are planned and will read the same shared database, but they are not built yet.