Add IMAP receive: background sync of inbox into Room

Increment 3 — receive.

- ImapClient.fetchRecentInbox pulls recent INBOX headers (ENVELOPE/FLAGS/UID)
  over IMAP (password or XOAUTH2) into FetchedMessage.
- MailSyncer orchestrates per-account fetch -> Room (replace-per-account),
  refreshing and re-persisting the Gmail OAuth token when needed.
- WorkManager background sync via a @HiltWorker (periodic 15-min + an expedited
  one-shot after adding an account); Application supplies the HiltWorkerFactory
  and the default WorkManager initializer is removed.
- Mailbox renders real cached mail with pull-to-refresh and proper empty states
  (welcome/add-account vs no-messages); the sample-data crutch is removed.
- Shared entity mappers; MessageDao.replaceAccountMessages transaction.
- Tests: GreenMail-backed fetchRecentInbox unit test (deliver via SMTP, read via
  IMAP, newest-first). Instrumented Keystore + Angus-provider tests stay green on
  the Android 17 emulator, where the SyncWorker also runs to SUCCESS.
- Add error_prone_annotations to the compile classpath (Hilt/Dagger codegen).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 18:25:54 -05:00
co-authored by Claude Opus 4.8
parent 9c74510832
commit 5386ae76d3
24 changed files with 535 additions and 197 deletions
+5 -5
View File
@@ -5,11 +5,11 @@ A free and open-source email client for Android, built with Kotlin, Jetpack
Compose and Material 3 (Material You). LibreMail aims for a friendly default
experience with power-user features tucked under an **Advanced Settings** group.
> Status: **in development.** The app builds and runs with a Material You shell,
> and **account setup is implemented** — Gmail OAuth (AppAuth, PKCE) and generic
> IMAP/SMTP, each with a live "test connection" that logs in and lists folders,
> and credentials encrypted via the Android Keystore. IMAP sync and sending land
> in upcoming increments.
> Status: **in development.** Material You shell; **account setup** (Gmail OAuth via
> AppAuth/PKCE and generic IMAP/SMTP, with a live connection test and Keystore-
> encrypted credentials); and **IMAP receive** — background sync (WorkManager) that
> fetches your inbox headers into a local Room cache, shown with pull-to-refresh.
> Reading message bodies and sending land in upcoming increments.
## Features (target MVP)