4.8 KiB · text History 4d8ef0a

recourse Android

The phone client for recourse: the same forum, the same rules, on a phone. Plan and the reasoning behind it: ../docs/android.md; the API it talks to: ../docs/api.md.

Build

Needs a JDK 17–21 and an Android SDK (compileSdk 34, minSdk 26). Android Studio ships both.

# From the repo root:
just apk            # -> android/app/build/outputs/apk/debug/app-debug.apk
just apk-test       # JVM unit tests: the pairing link, the API contract
just adb-devices    # is there anything to install onto?
just apk-install    # onto a connected device / running emulator

just apk finds the JDK itself (movie_monster’s recipe): an already-usable JAVA_HOME, else Android Studio’s bundled jbr/, else a JDK 21/17 from the usual places. A system java that is 25, or a JRE with no compiler, fails as “does not provide the required capabilities: [JAVA_COMPILER]”, which reads like a project problem rather than a toolchain one. The SDK is android/local.properties (gitignored) or ANDROID_HOME, else ~/Android/Sdk.

Pairing

  1. On the web, sign in → account menu → Devices → Pair a device. The page shows a QR of recourse://pair?base=<origin>&token=<token>, once.
  2. In the app, tap Scan QR. Or open the code from the phone’s own camera or browser — the app handles recourse:// and opens with both fields filled in. Or type the two fields.
  3. The app calls GET /api/v1/me and stores the pair (in EncryptedSharedPreferences, excluded from backups) only once that answers, so a stale code fails here rather than as an empty forum later.

The origin in the code is what the browser was talking to (or PUBLIC_URL when set). A phone can only dial what it can reach: pair from localhost on a laptop and you’ll need to type the LAN address instead.

Unpair: Me → Unpair this device (revokes this device’s token on the server too). Revoke from elsewhere: Devices on the web, or Me → Devices in the app. A token unused for 90 days expires. Any 401 sends the app back to pairing.

What’s here

  • Forum — in the account’s Layout, the same setting as the web profile (the toolbar button switches it, for the web too):
    • Classic: the category tree, then a category’s topics as rows, with sort chips (saved as the account’s sort, as ?sort= is on the web), watch, and New topic.
    • Focus: a rail of categories over the chosen one’s topics as tiles — posters, reactions, new/unread. Opening a tile reads it full screen, and a sideways swipe steps to the neighbouring topic in tile order.
  • Topic — the posts as the server renders them (its own sanitized HTML of the markdown), reactions (one per post; tapping yours clears it), bookmarks, tags (editable by the author or staff), Reply. Reading counts the view and marks it read by the web’s rules. Editing a post opens the web.
  • Search, Tags and Bookmarks, in the same layout.
  • Inbox — notifications (new topics in watched categories, reactions to your posts), with the unread count on the tab.
  • Me — avatar, Layout, default sort, reaction notifications, email verification (resend), theme, devices, unpair.
  • Unverified accounts read everything they may see; write controls are hidden and a banner offers to resend the link, as on the web.
  • Themes — recourse’s daisyUI themes from assets/tailwind.config.js, under the same names, with System following the OS between light and dark as the web’s picker does. B612 matches the web’s typography.

Not here: admin (categories, reactions, invites, users), editing or deleting posts, sign-up, push notifications (docs/android.md §2e).

Launcher icon

res/mipmap-anydpi-v26/ic_icon.xml and res/drawable/ic_icon_placeholder_* are a placeholder. The icon is ../ic_icon.toml, an icon-studio document: open it in icon-studio and export to the repo root (it resolves to android/app/src/main/res), which writes mipmap-*/ic_icon*.png and overwrites mipmap-anydpi-v26/ic_icon.xml. Then delete the two placeholder drawables. The manifest already names @mipmap/ic_icon.

Release builds

CI (.forgejo/workflows/android.yml) runs the unit tests and, on master, builds, signs and publishes the release APK to the forge’s F-Droid repository, all inside android/Dockerfile. Locally:

docker buildx build --target android-test --progress=plain --file android/Dockerfile android

docker buildx build --target android-export \
  --secret id=keystore,src=./release.jks \
  --secret id=keystore_password,src=./keystore.pass \
  --output type=local,dest=./apk --progress=plain \
  --file android/Dockerfile android

Publishing needs ANDROID_KEYSTORE (base64 of the .jks) and ANDROID_KEYSTORE_PASS as repository secrets and skips cleanly without them. Keep the keystore: losing it means every install has to be uninstalled and redone by hand.