The mail client from android-client-spec.md on AGP 9.4 / Kotlin 2.4 / compileSdk 37: sign-in and first-run (account, then notifications), adaptive list-detail with a modal or permanent drawer, swipe to archive or delete, a locked-down WebView for HTML mail with remote images blocked per message, reply/reply-all/compose with drafts and an outbox, and Material You theming with the brand palette as fallback. Mail is cached in Room and kept current by delta sync over /api/events. UnifiedPush (connector only, no FCM) delivers the server's content-free wake-ups; a WorkManager job syncs and raises one MessagingStyle notification per thread with Archive and Mark read, and drops notifications for threads read elsewhere. Settings shows push state, picks a distributor and sends a test push. The session token is encrypted with a Keystore key, backups are off, release builds are HTTPS-only (trusting user-installed CAs). CI now pins platform 37 / build-tools 36 and runs unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
5.0 KiB
Markdown
62 lines
5.0 KiB
Markdown
# tern-android
|
||
|
||
Android client for [Tern](../). See [`docs/android-client-spec.md`](docs/android-client-spec.md) and [`docs/branding-spec.md`](docs/branding-spec.md).
|
||
|
||
It needs no Google services, so it runs on GrapheneOS as is: nothing from Play Services or Firebase is anywhere in the dependency tree, and CI checks that on every build (§7).
|
||
|
||
## What's in it
|
||
|
||
- **First run** (§6): connect to the Tern server, add a mail account if the server has none, then an optional notifications step. That step is the only place the notification permission is asked for.
|
||
- **Mail**, laid out list–detail (§4): one pane on phones, list and conversation side by side on tablets and unfolded foldables. The drawer is modal on narrow screens and permanent on wide ones. Views are Inbox, All mail, Sent, Junk, Trash, your folders and your tags, plus the Outbox.
|
||
- **Swipe actions** (§3): right to archive, left to delete, left to restore in Trash. The whole row is the swipe target, so swipes never collide with the system back gesture. Screen readers get the same actions as accessibility actions (§8).
|
||
- **Reading:**
|
||
- Plain-text mail renders as text.
|
||
- HTML mail goes in a locked-down WebView: no JavaScript, and no file, content or network access.
|
||
- Remote images and tracking pixels stay blocked until you allow them for that message.
|
||
- Links open in the browser.
|
||
- **Actions:** archive, delete/restore, mark unread, report spam/not spam, move to folder, tags. These are the same actions the server's rules and the webapp use.
|
||
- **Compose:** new mail, reply and reply-all (with the same recipient rules as the webapp), drafts, and an outbox showing queued and failed mail.
|
||
- **Notifications** (§5): details below.
|
||
- **Offline cache** (§7): a Room database in app-private storage. It opens instantly and stays readable offline. It's excluded from backups and device transfer, and the session token is encrypted with an Android Keystore key.
|
||
- **Theming** (§2): Material You dynamic colour, falling back to the brand palette. Light, dark, or follow system, set in Settings.
|
||
|
||
## Notifications
|
||
|
||
Delivery goes through [UnifiedPush](https://unifiedpush.org): a distributor app on the phone (e.g. **ntfy** from F-Droid) keeps one connection to its push server. When new mail should notify, the Tern server pushes to the endpoint the phone registered.
|
||
|
||
- **The push carries no content.** It's an encrypted "sync now". Tern then fetches the actual changes over its own authenticated connection. The server's rules decide which mail notifies (*notify* / *don't notify* actions).
|
||
- **One notification per conversation,** conversation-style (`MessagingStyle`). A busy thread updates in place instead of stacking up, and a summary groups several threads.
|
||
- **Archive and Mark read** work straight from the notification. They run as background work, so they survive a flaky connection.
|
||
- **Syncing** runs as WorkManager jobs (§9). While the app is open it also checks for changes every 30 seconds.
|
||
- **Settings → Notifications** shows the registration state and any error from the last push, lets you choose between distributors when more than one is installed, and can send a test push through the whole chain.
|
||
|
||
### Setting up with a self-hosted ntfy
|
||
|
||
1. Install ntfy from F-Droid. In its settings, set **Default server** to your ntfy server.
|
||
2. In Tern, turn notifications on (in first-run or in Settings). Tern registers with ntfy, and ntfy hands it an endpoint on your server.
|
||
3. The Tern server must be able to reach that endpoint. If it should reach ntfy by a different address than the phone uses, or ntfy sits behind a private CA, see `PUSH_URL_REWRITE`, `PUSH_CA_CERT` and `PUSH_TLS_INSECURE` in the server README.
|
||
|
||
## Connecting to your server
|
||
|
||
- **Release builds are HTTPS-only.** They trust system CAs and **user-installed** CAs. So a server behind a private CA works once that CA is installed on the phone (Settings → Security → Encryption & credentials → Install a certificate).
|
||
- **Debug builds also allow plain HTTP,** for a development server such as `http://10.0.2.2:8080` from the emulator.
|
||
|
||
## Not built yet
|
||
|
||
- **App lock** (§7): biometric or device credential. Agreed to come later.
|
||
- **Quick reply from the notification** (§10): an open item in the spec.
|
||
- **Configurable swipe directions** (§10).
|
||
- **Rules, tags and folders are managed in the webapp.** The app applies them but doesn't edit them.
|
||
- **Opening attachments.** Conversations show a paperclip when they have attachments. The server stores the files but has no download endpoint yet, so neither client can open them.
|
||
|
||
## Building
|
||
|
||
```bash
|
||
./gradlew assembleDebug
|
||
./gradlew testDebugUnitTest
|
||
```
|
||
|
||
- **Toolchain:** AGP 9.4 (built-in Kotlin), Kotlin 2.4, Gradle 9.7, JDK 17. compileSdk 37, targetSdk 36, minSdk 29.
|
||
- **SDK:** needs an Android SDK (`ANDROID_HOME` or `local.properties`). AGP downloads any missing platform packages itself. CI pins them explicitly.
|
||
- **Release signing** comes from environment variables. See the release section of the server repo's [`docs/release-process.md`](https://git.app.ygg/mtps/tern-server/src/branch/master/docs/release-process.md).
|