Root README for the new layout; legacy/README.md points back. Legacy Gitea and GitHub workflows run only by hand from legacy/ and the Gitea one does not publish unless asked. Fix compiler warnings. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
12 KiB
ultra launcher
An Android home screen, written in MoonBit. Home starts blank: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. Swipe down (or tap the search pill) for the drawer with every app and a search (Enter opens the first match); long-press an app there for its menu (add to home, app info, uninstall; system apps have no uninstall), and swipe up to close it. The Windows button in the panel at the top opens Recents. The layout is saved on the device, and the app updates itself from the latest release here.
| home | drawer | app menu | resize handles |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
(Screenshots are of the browser demo at phone size.)
Install
Get the APK from the latest release, which CI rebuilds on every push to main. Open it once, press Home, and pick ultra Home as the default. The package is dev.ultra.launcher and builds are signed with the committed android/debug.keystore, the same key every earlier build (WebView, Qt) used, so this installs over them. The activity keeps the Qt build's class name, so the default-home choice survives.
The Windows button uses an accessibility service (RecentsService, which only performs the Recents action). Enable it once under Settings → Accessibility; on Android 13+ a sideloaded APK may first need App info → ⋮ → Allow restricted settings.
On first start the old WebView build's home screen (its ultra.home.* localStorage) is imported. The Qt build's layout is not imported (see Not done below).
How it is built
MoonBit owns the logic and the UI; Java is only what Android itself requires.
┌──────────────── pure MoonBit (no platform deps; moon test on js and wasm-gc) ───────────────┐
pointer / touch / │ gesture ──► app.input ──► app.update(Model, Msg) ──► Effects (data) │
key events ───────►│ │ │
│ └──► app.view(Model) ──► vdom tree (data) │
└───────────────┬────────────────────────────────────────────────┬───────────────────────────┘
│ effects │ tree
┌───────────────▼─────────────────────────────────────────────────▼──────────────┐
│ web/ (js backend): runs effects against window.Android, patches the DOM, │
│ listens for events │
└───────────────┬─────────────────────────────────────────────────────────────────┘
│ window.Android.* / window.launcher.*
┌───────────────▼─────────────────────────────────────────────────────────────────┐
│ android/java (Java): HomeActivity + WebView + AppWidgetHostViews, Updater, │
│ RecentsService │
└─────────────────────────────────────────────────────────────────────────────────┘
| package | what | tested by |
|---|---|---|
grid/ |
the home grid: packing (dense, with pinned cells), cell/box math, pin, resize steps, widget columns | moon test |
gesture/ |
pointer state machine: tap, long press (500 ms, 10 px slop), drag, release, swipe | moon test |
updater/ |
release/version.json parsing, build-N tags, the install/skip decision, 6 h throttle |
moon test |
jsonx/ |
small Json accessors |
moon test |
vdom/ |
a virtual DOM as plain data, generic over the message type; renders to HTML text for snapshots | moon test |
app/ |
Model, Msg, update (returns Effects), view, JSON persistence and the import of the old localStorage layout, search, sheets/menus, drag and resize, the update flow |
60 headless tests that drive it through pointer input |
web/ |
the js-target program: keyed DOM patcher, event wiring, host bridge (window.Android, or stand-ins that show a toast in a desktop browser), icon loading |
tests/e2e.cjs, tests/android-sim.cjs (Playwright) |
android/ |
the Java shell, manifest, resources, signing key, build.sh |
builds; needs a device to run |
Why this shape: the launcher's hard parts are layout math, gestures and state, and all of them are pure functions here, so moon test covers them on desktop with no Android and no browser. The view is a data tree rather than direct DOM calls, so its output is snapshot-tested as text, and pointer input is aimed at tree nodes by the tests exactly as the page aims it. Rendering in the existing WebView keeps the design that already works for widgets (real AppWidgetHostViews laid over transparent slots in the page).
What stays Java, and why
About 1,100 lines in android/java/dev/ultra/launcher/; none of it decides anything, it carries out what the page asks:
HomeActivity: Android requires anActivityfor the HOME role; it hosts the WebView, servesapps.json/widgets.json/ icons fromLauncherApps,PackageManagerandAppWidgetManager, and hostsAppWidgetHostViews, which are JavaViews that can only be created and laid out by Java. Its widget touch interception (long press, drag) must decide synchronously whether to take a gesture from the widget, so it stays there and reports throughwindow.launcher.widget*.Updater:HttpURLConnection(the page cannotfetchthe Gitea API from the WebView's origin) andPackageInstaller.RecentsService: anAccessibilityServicemust be a Java class listed in the manifest; Android instantiates it by name.
A pure-MoonBit shell (native backend → C, NativeActivity + JNI, drawing through the NDK) was considered and rejected: it would still need the same Java classes (RecentsService, and something to host AppWidgetHostView), the rest would be hundreds of lines of hand-written JNI in C, and nothing of it could be run or tested here (no Android SDK/NDK on the dev machine, no device). The moon toolchain's Android support on mooncakes (e.g. Nanaloveyuki/ajni, wzzc-dev/moui) is young and was not evaluated further. Rabbita was also considered for the view layer; it would tie the view to its DOM Html type and closures, out of reach of plain-data tests, and the gesture/drag handling needs delegated pointer events and its own hit-testing anyway.
Build and test
Needs MoonBit (curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash), Node 22 for the browser tests, and for the APK a JDK 17+ plus the Android SDK's build-tools;35.0.0 and platforms/android-35/android.jar.
moon test # the pure core: grid, gestures, updater, the app (js backend)
moon test --target wasm-gc # the same tests on a second backend
scripts/build-web.sh --demo # the page -> dist/web (with the demo apps.json / widgets.json)
npm install && npx playwright install chromium
npm test # builds the page, then tests/e2e.cjs and tests/android-sim.cjs
android/build.sh # the page + Java shell -> build/ultra-launcher.apk, signed
android/build.sh runs moon build (via scripts/build-web.sh), then aapt2 compile/link, javac, d8, zip, zipalign and apksigner, with no Gradle. It reads versionName from moon.mod and takes VERSION_CODE from the environment (default: minutes since the epoch, which is above every earlier build's). ANDROID_SDK_ROOT points at the SDK (default ~/android-sdk).
To try the page in a desktop browser: scripts/build-web.sh --demo && python3 -m http.server -d dist/web 8000. It runs against web/apps.json and web/widgets.json, shows a toast instead of launching, and draws widgets as labelled placeholders. Click the search pill, or hold the empty home.
CI and releases
.gitea/workflows/launcher.yml: a test job (MoonBit installed like in identicons-web, inside node:22-bookworm; moon test on js and wasm-gc, then the Playwright tests) and, on push to main, an apk job running ci/gitea-apk.sh, which builds the APK and publishes a Gitea release build-<versionCode> holding ultra-launcher.apk and version.json (a draft first, published once both files are up). The installed app compares that versionCode with its own and installs the newer APK. No actions/setup-node, no docker, every job has a timeout-minutes.
Releases of the app's version are managed with sweet: .sweet.config.yml (feature → minor, fix/performance → patch, chore/refactor → none) and .sweet.yml (moon.mod's version line is annotated // sweet-version). The Android versionName is read from moon.mod by the build, so that is the one file that carries the version.
legacy/
The previous implementations, moved here with git mv so their history follows: the ultra (LPython → wasm) WebView build (web/, android/), the Qt Quick rewrite (qt/), and the experiments (wasi/, android-wasm/), with their tests and CI script. Their paths are fixed so they still build from legacy/ (see its README), but they are not maintained; their CI workflows run only by hand. The MoonBit launcher is a port of legacy/web/app.py (and the gesture code in its index.html), legacy/qt/qml/Layout.js and the Java shell.
Verified, and not
Verified here: moon test (60 tests, js and wasm-gc), the browser flows in tests/e2e.cjs (the legacy test's flows, ported), the page against a stub of the Java bridge (tests/android-sim.cjs: icons, widget placement, drawer cover, keyboard, Recents, update check and install request), and that android/build.sh produces a signed APK with package dev.ultra.launcher that aapt2 dump badging and apksigner verify accept.
Not verified: anything on a device. There is no Android runtime on the dev machine. The Java shell compiles and packages, and its logic was carried over from the legacy shell that ran on devices, but the combination (the MoonBit page in the WebView, real widget views over it, the installer, the accessibility service) has not been run.
Not done: importing the Qt build's saved layout (a QSettings INI file; the old WebView layout is imported), per-widget configuration beyond what the legacy shell did, and shrinking the page's JS (about 560 KB, mostly MoonBit's JSON and number-parsing runtime).



