6.1 KiB · text History 01e509e

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, sign-in, 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.

Signing in

The login page has the app’s name over “login”, a ? (help) in the corner, and three buttons that share the rest of the screen: stacked in portrait, side by side in landscape (the header becomes a left column). Each opens a bottom sheet; back or a swipe down closes it. ui/login/LoginScreen.kt, data/AppLogin.kt; the theme is the app’s own (Blueprint and the rest).

  • Scan: pairing, below.
  • Sign in with NEIAM: type the server once (remembered), and the app opens <server>/auth/oidc/neiam/login?app=1&challenge=… in a Custom Tab with a fresh PKCE pair. The server sends the browser back to recourse://auth?code=…; the app trades the code and its verifier at POST /api/v1/auth/oidc/exchange for a device token. The verifier waits in the encrypted prefs (ten minutes at most) in case Android kills the app while the browser is in front.
  • Username: server, username or email, password (autofill hints; Done submits) → POST /api/v1/auth/password.

On a server the app has talked to, GET /api/v1/auth/methods decides which buttons are on; a turned-off one is greyed out and says why. With no answer (no server yet, an older server) all three stay on and their errors explain. The server side: “App sign-in (no QR)” in ../README.md.

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 and point the camera at it (the viewfinder runs only while the Scan sheet is open). Or open the code from the phone’s own camera or browser — the app handles recourse:// and opens the Scan sheet 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 the login page.

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

The icon is ../ic_icon.toml, an icon-studio document. To change it, open it in icon-studio and export to the repo root (it resolves to android/app/src/main/res): that rewrites mipmap-*/ic_icon*.png and mipmap-anydpi-v26/ic_icon.xml. 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.