feat: v0.3.6.0 — AES-GCM field encryption, PIN/passphrase security, encryption verifier, backup codec
build / Assemble debug APK (push) Failing after 2s

This commit is contained in:
Incido Developer committed 2026-08-20 01:14:15 +12:00
1 parent 089926377c
commit 14d61c78d3
55 files changed
+2474 -715

No files matched your search

+125 -10
View File
@@ -16,13 +16,13 @@
## 1. Licensing
### 1.1 FOSS Flavor — License: AGPL-3.0
### 1.1 License: GPL-3.0
- Anyone may use, modify, and redistribute the code.
- Anyone who runs a modified version (even as a network service) **must publish their source code changes**.
- This enforces the "contribute back" requirement for downstream users while still allowing them to profit from their own derivative applications.
- Full license text: https://www.gnu.org/licenses/agpl-3.0.en.html
- A `LICENSE` file containing the full AGPL-3.0 text must be committed to the repository root.
- Modifications that are **distributed** (sold, published, or otherwise conveyed to others) must also be released under GPL-3.0 (copyleft).
- Internal / private modifications are not required to be published — only **distributed** versions trigger the source-sharing obligation.
- Full license text: https://www.gnu.org/licenses/gpl-3.0.en.html
- A `LICENSE` file containing the full GPL-3.0 text must be committed to the repository root.
- A `NOTICE` file should credit contributors and reference the license.
### 1.2 Commercial Flavor — Future Feature
@@ -40,7 +40,7 @@ A separate commercial build under a proprietary license, intended for users/orga
### 2.2 Package & Identity
- **Application ID:** `org.incido.app`
- **Display name:** Incido
- **License file:** `LICENSE` (AGPL-3.0)
- **License file:** `LICENSE` (GPL-3.0)
- **Notice file:** `NOTICE`
### 2.3 Local Toolchain Requirements
@@ -260,7 +260,6 @@ This list is the canonical backlog. Items can be promoted into future versions a
- Automated APK builds on commit
- Translation infrastructure (Weblate or Crowdin)
- Contribution guidelines (`CONTRIBUTING.md`)
- Code of conduct
- Issue and PR templates
- Documentation site (public)
- Release/signing infrastructure for Play Store distribution
@@ -285,7 +284,7 @@ v0.1 is considered complete when **all** of the following are true:
- Build instructions
- Install/run instructions
- License notice
5. `LICENSE` (AGPL-3.0) is committed
5. `LICENSE` (GPL-3.0) is committed
6. `NOTICE` is committed
### 7.2 Manual Smoke Test Script (run before tagging v0.1)
@@ -346,12 +345,12 @@ A short reference for AI assistants:
### 9.1 Known Risks
- **ObjectBox KMP setup is non-trivial** — first-time KMP+ObjectBox configuration may require debugging. Allow extra time for initial build configuration.
- **Compose Multiplatform is mature but Android-first** — minor adjustments may be needed when iOS/Desktop ports happen. Not a v0.1 concern.
- **AGPL-3.0 is strict** — some potential contributors or downstream users may prefer MIT/Apache. This is intentional per requirements; document clearly in README.
- **GPL-3.0 is strict** — some potential contributors or downstream users may prefer MIT/Apache (especially those who want to build a proprietary network service without publishing source). This is an intentional choice; document clearly in README.
### 9.2 Open Questions (to resolve during v0.1 development)
- App icon design — placeholder for v0.1; designed icon in v0.2.
- Splash screen design — Android 12+ splash API; minimal in v0.1.
- ObjectBox license — verify ObjectBox's own license terms are compatible with AGPL-3.0 distribution.
- ObjectBox license — verify ObjectBox's own license terms are compatible with GPL-3.0 distribution.
- Play Store distribution — not in v0.1; F-Droid distribution should be evaluated for FOSS flavor.
---
@@ -366,6 +365,12 @@ A short reference for AI assistants:
| Version | Date | Notes |
|---------|------|-------|
| 0.3.5.1 | 2026-08-17 | **Emergency hotfix** — two UX bugs in v0.3.5.0. **1. "Encrypted" badge silently failed to appear on the first enable.** Audit found `EncryptionVerifier.checkNow()` early-returned with `if (_checking.value) return` whenever a verify-all was in flight. The startup pass launched from `AppContainer.init` could still be running when the user toggled Encrypt-at-rest in Settings; the post-migration re-check then silently dropped, the startup pass eventually wrote its stale (pre-encryption, empty verified-id) result back to the StateFlow, and the cards never earned the badge until the second toggle or a relaunch let a fresh check actually run. Fix: drop the `_checking` skip-guard and replace it with a `kotlinx.coroutines.sync.Mutex` that serializes checks in invocation order. Every `checkNow()` call now takes its turn and the last call's result wins, so the post-migration check always produces the fresh verified-id set; the startup pass is cheap (no encrypted rows yet → all skips) so user-triggered checks after a real migration only wait milliseconds. **2. "Encrypted" badge UX on note cards.** v0.3.5.0 rendered the indicator as a centred `Row` with a lock icon + "Encrypted" label at the card's bottom edge. Replace with a bare 14 dp `Lock` `Icon` sitting immediately to the LEFT of the timestamp inside the card's existing bottom Row — the row already uses `Alignment.CenterVertically`, so the icon is vertically centred with the date/time and lives in the same left-anchored position on every card regardless of card content (tag row, body preview, checklist summary). The icon keeps the existing `contentDescription = "Encrypted"`. versionCode 25→26, versionName "0.3.5.0"→"0.3.5.1", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.5.0 | 2026-08-17 | **Maintenance release** — real at-rest encryption, verified "Encrypted" badge, and screenshot blocking. **1. Real field-level encryption ("Encrypt in place" now works).** Audit of the v0.3.2.0 toggle found it was cosmetic: `ObjectBoxStore.init()` ignored the key (`@Suppress("UNUSED_PARAMETER")`), `AppContainer` always passed `encryptionKey = null`, and the OSS ObjectBox 4.0.3 `BoxStoreBuilder` exposes no encryption API at all (verified against the local artifact — page-level encryption is ObjectBox Sync/Pro only). Fix: application-layer field encryption. `NoteEntity` gains `cipherVersion` (0=plain, 1=AES-256-GCM) + `contentBlob`; `NoteAttachmentEntity` gains the same pair for `bytesBlob` — additive schema, auto-migrated. New `FieldCipher` abstraction in `:core:data` with `AesGcmFieldCipher` in `:composeApp` (fresh random 12-byte nonce per blob; GCM tag = integrity proof), keyed by the existing Keystore-wrapped 32-byte key from `ObjectBoxKeyProvider`. The repository consults a shared `CipherHolder` on every read/write (encrypt-on-write, decrypt-on-read, in-memory content search while encrypted); `NoteCryptoService` sweeps all rows in place with progress. Toggling encryption ON installs the cipher and encrypts every plaintext note + attachment row live (no restart); toggling OFF decrypts everything first, then removes the cipher and deletes the key; disabling Security entirely also runs the decrypt sweep so no data is orphaned. AES-256-GCM is the correct PQ-era choice for data at rest (NIST: Grover halves effective security → ~128-bit residual; no public-key crypto in this path). **2. Verified "Encrypted" badge on cards.** New `EncryptionVerifier` runs on every app open (and after each migration): full trial-decrypt of every `cipherVersion = 1` note row; the GCM auth tag passing is the proof of integrity. Only notes in the resulting verified-id set get a bottom-centre "Encrypted" label (with lock icon) on their card — never derived from the settings flag alone; rows that fail verification are reported and excluded. **3. Block screenshots toggle (default ON).** New `UserSettings.blockScreenshots` (DataStore-backed, defaults true); `MainActivity` applies/clears `FLAG_SECURE` from a startup snapshot + live settings-flow collection, blocking screenshots, screen recording, and app-switcher previews; Settings → Security gains the "Block screenshots" switch. Settings copy for encryption updated (no longer claims a restart is required). versionCode 24→25, versionName "0.3.4.0"→"0.3.5.0", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.4.0 | 2026-08-17 | **Maintenance release** — three changes. **1. Attachment indicator on note cards** — a paperclip icon (`Icons.Filled.AttachFile`) now appears on the right edge of every card whose note carries at least one attachment (any type — image, PDF, audio…). It is a non-interactive `Icon` (24 dp, `contentDescription = "Has attachments"`) aligned `Alignment.CenterEnd` with `padding(end = 16.dp)` so its glyph centre sits at 28 dp from the right edge — the same vertical column as the ⋮ overflow `IconButton` (top) and the favourite star (bottom), exactly halfway between them (both neighbours centre their 24 dp glyphs at 28 dp: 4 dp padding + 24 dp inside a 48 dp `IconButton`). Bare `Icon` rather than `IconButton` so it never intercepts the whole-card tap that opens the editor. **2. Light-theme readability over image thumbnails** — the card's 0.45-alpha black scrim always renders the background dark, but the overlay content kept the theme-driven colours, so in Light mode dark text sat on a dark photo (all but invisible). Fix: when a thumbnail is present every overlay switches to a forced light palette regardless of theme — title pure white; body preview, checklist summary, timestamp, ⋮ icon, unfilled star, paperclip and "+N" tag overflow white @ 85 %; hashtag chips white; favourited star a light amber (`#FFD54F`) so "favourited" stays distinguishable; the Card's `contentColor` is also set to white. Plain (no-thumbnail) cards are untouched and keep their existing tinted/surface colours. `HashtagRow` now takes caller-supplied `tagColor` / `overflowColor` params. **3. Auto-Lock = Immediate + file-picker hotfix** — with Auto-Lock set to "Immediately", attaching a file (paperclip → SAF picker), taking a photo (camera), opening an attachment in the system viewer, or exporting/importing a backup locked the app the moment the external activity returned: the picker backgrounds the Activity (`ON_STOP`), the return fires `ON_RESUME`, and the 0 ms timeout always re-locks. The lock gate then tore down the `NavHost` from composition, destroying the editor's `NavBackStackEntry` ViewModelStore — so the unsaved note vanished and the picker result never landed. Fix: `SecurityManager` gains an in-flight flag (`externalActivityInFlight`, `@Volatile`) set by a new `beginExternalActivity()` and consumed exactly once by `onAppForegrounded()`, which skips the re-lock check and clears `backgroundedAt` when the flag is set. Call sites: `NoteEditorScreen` (file picker launch, camera launch after permission grant, system-viewer `ACTION_VIEW` — `securityManager` threaded through `AttachmentStrip`/`AttachmentThumbnail`), `SettingsScreen` (backup export + import SAF launchers), with `IncidoApp` threading `resolvedSecurity` to both screens. Genuine background/foreground cycles still lock as configured; cold launch is unaffected (fresh process ⇒ flag always false). versionCode 23→24, versionName "0.3.3.8"→"0.3.4.0", SettingsViewModel.APP_VERSION bumped in lockstep. || 0.3.3.8 | 2026-08-17 | **Emergency hotfix** — the designed `incido.png` artwork (glass shield + fountain-pen nib) replaces the v0.1 placeholder launcher icon. The 2048×2048 source is downscaled (LANCZOS) into density-correct raster buckets: `mipmap-{mdpi…xxxhdpi}/ic_launcher.png` (48/72/96/144/192 px square) plus anti-aliased circular `ic_launcher_round.png` in the same buckets, and `drawable-{mdpi…xxxhdpi}/ic_launcher_foreground.png` (108/162/216/324/432 px) feeding the `mipmap-anydpi-v26` adaptive icons (`ic_launcher.xml` / `ic_launcher_round.xml`), whose stale `<monochrome>` placeholder reference is dropped and whose `ic_launcher_background` colour is re-tinted from `#6650A4` to the artwork's edge navy `#010435` so parallax exposure is seamless. The obsolete placeholder vector `drawable/ic_launcher_foreground.xml` is deleted; manifest `android:icon` / `android:roundIcon` references are unchanged. versionCode 22→23, versionName "0.3.3.7"→"0.3.3.8", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.7 | 2026-08-17 | **Emergency hotfix** — when Biometric is the active lock method, the lock screen's "Authenticate" button required an extra tap before the fingerprint / face reader would start. Fix: `PinEntryScreen` now auto-launches the `BiometricPrompt` as soon as the lock screen composes in biometric-only mode (`settings.isBiometricLockActive`), via a one-shot `LaunchedEffect(biometricOnly)` guarded by an `autoLaunched` flag (so a cancelled prompt cannot re-trigger). Success → `onUnlocked()`; cancel/error → the lock screen stays with an error message and the "Authenticate" button remains as the manual-retry path. The failure message in biometric-only mode no longer mentions a PIN ("Authentication failed. Tap Authenticate to try again."). PIN mode is untouched — `biometricOnly` is false there, so the auto-launch effect never runs and the PIN field keeps its auto-focus. versionCode 21→22, versionName "0.3.3.6"→"0.3.3.7", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.6 | 2026-08-17 | **Emergency hotfix** — the fixed card height shipped in v0.3.3.5 (`168.dp`) proved too tall on real devices. Fix: `CARD_HEIGHT_DP` in `NoteListScreen.kt` reduced by ~15% to `143.dp` (~15% taller than the pre-0.3.3.5 wrap-content typical of ~124.dp). Everything else from v0.3.3.5 is unchanged — cards remain a single fixed height, the timestamp stays pinned to the card's bottom edge via the weighted spacer, the hashtag row is still hidden when empty, and the colour stripe still spans the full card height. versionCode 20→21, versionName "0.3.3.5"→"0.3.3.6", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.5 | 2026-08-17 | **Emergency hotfix** — the note cards on the main page used wrap-content height, so card heights varied depending on whether the note carried a body preview, hashtag row, or checklist summary (and untagged notes rendered visibly shorter than tagged ones). Fix: every `NoteCard` now has a fixed height of `168.dp` (~35% taller than the previous typical wrap-content height of ~124.dp for a title + 2-line body preview), applied via `Modifier.height(CARD_HEIGHT_DP)` on the Card. A `Spacer(Modifier.weight(1f))` inside the content column pins the timestamp row to the bottom of the fixed-height card so the layout stays consistent regardless of content; the hashtag row is still hidden entirely when the note has no tags. The left colour stripe now spans the full card height (`fillMaxHeight().width(14.dp)`) instead of the hardcoded `size(width = 14.dp, height = 110.dp)`. Thumbnail background + scrim, dog-ear, ⋮ overflow button, favourite-star overlay, and long-press menu are unaffected (all corner-anchored). versionCode 19→20, versionName "0.3.3.4"→"0.3.3.5", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.4 | 2026-08-17 | **Emergency hotfix** — the favourite star on note cards was rendered inside the title row and overlapped the ⋮ overflow `IconButton` anchored to the card's top-right corner. Fix: the star is removed from the title row (the title now spans the full width) and re-added as an overlay aligned to `Alignment.BottomEnd` with `padding(end = 4.dp, bottom = 4.dp)` — the same `end = 4.dp` offset the `TopEnd` overflow button uses — so the two controls sit in the same vertical column and no longer collide. The star keeps its existing toggle behaviour and tinting (filled + primary when favourited, outline + onSurfaceVariant otherwise). versionCode 18→19, versionName "0.3.3.3"→"0.3.3.4", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.3 | 2026-08-17 | **Emergency hotfix** — importing an encrypted backup crashed the app without any errors. Root cause: the passphrase `CharArray` was wiped immediately after the preview decrypt step (`EncryptedBackupCodec.decrypt` zeroes the array it consumes, and `SettingsScreen` then nulled its cached copy), so the confirm dialog's Import button called `viewModel.import(uri, null)`; `BackupManager.import()` threw `IllegalArgumentException("Encrypted backup requires a passphrase")` inside an unguarded `scope.launch { }` and the app crashed. Fix: the screen now retains a copy of the passphrase for the import step (`pendingImportPassphrase = chars.copyOf()` on dialog confirm), hands `import()` a fresh copy (`retained?.copyOf()`), and wipes the retained array in a `finally` block; the preview / import coroutines are wrapped in try/catch so any failure (wrong passphrase re-decrypt, truncated envelope, I/O error, malformed JSON) surfaces a snackbar ("Import failed. Check the file and passphrase." / "Could not read backup file.") instead of crashing; the confirm dialog's `onDismissRequest` now also wipes the retained passphrase. `BackupManager.preview()` additionally catches `IllegalArgumentException` (truncated envelope failing the `require(...)` size checks) and `GeneralSecurityException` so corrupt encrypted files return `null` cleanly. versionCode 17→18, versionName "0.3.3.2"→"0.3.3.3", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.3.2 | 2026-08-17 | **Emergency hotfix** for two lock-screen regressions in v0.3.3.x: **White-on-white lock screen in dark mode** — `PinEntryScreen` rendered a bare `Column` with no background of its own, so under the dark theme it was transparent and the permanently-light Activity window background showed through, making the heading and PIN field invisible. The screen is now wrapped in a themed `Surface(color = MaterialTheme.colorScheme.background)` (with matching `contentColor`) so it always paints its own theme-aware background in both light and dark modes. **Biometric unlock hangs** — `SecurityManager.authenticateWithBiometric` busy-waited on the main thread (`while (!done) {}`) while the BiometricPrompt callbacks were posted to the main executor; the callbacks could never run because the main thread never became free, so the app never unlocked (ANR-like hang). Authentication is now fully asynchronous: the method takes an `onResult(Boolean)` callback, the prompt's success/error callbacks run on the main executor and flip `onUnlocked()` or surface a failure via the existing error text. The prompt's `DEVICE_CREDENTIAL` authenticator remains as a fallback so biometric-only users can still unlock with the device PIN/pattern. versionCode 16→17, versionName "0.3.3.1"→"0.3.3.2", SettingsViewModel.APP_VERSION bumped in lockstep. |
@@ -388,6 +393,116 @@ A short reference for AI assistants:
---
## 11. Release Build Procedure (every release)
This is the canonical procedure for shipping a new Incido release. The
two deliverables are version-stamped APKs at the repository root:
- `incido-<versionName>-debug.apk` — for development / testing.
- `incido-<versionName>.apk` — signed with the dev keystore, for sharing.
A small Gradle task called `copyReleaseApks` (registered in
`app/build.gradle.kts`) does the stamping automatically — once
`versionName` is bumped, the filenames follow.
### 11.1 Bump the version (three places, in lockstep)
1. **`app/build.gradle.kts`** — in `android.defaultConfig`:
- `versionName = "<NEW_VERSION>"` (e.g. `0.3.6.0` — must match
`MAJOR.MINOR.MAINTENANCE.EMERGENCY`; the in-file regex validator
fails the build otherwise).
- `versionCode = <NEW_VERSION_CODE>` (monotonic int, +1 from the
previous release).
2. **`composeApp/src/main/kotlin/org/incido/compose/ui/settings/SettingsViewModel.kt`**
— `const val APP_VERSION = "<NEW_VERSION>"` so the About card in
Settings displays the new version and the in-app release-notes
dialog recognises it.
3. **`README.md`** — bump the intro paragraph and "Current release"
line, and add a new row at the top of the Changelog table (the table
is the user-facing changelog — §10 keeps the historical release
notes).
### 11.2 Build both APKs (and stamp them)
From the repository root:
```bash
./gradlew clean assembleDebug assembleRelease
```
This is a single command that does everything:
1. `clean` wipes the previous `app/build/`.
2. `assembleDebug` builds the debug APK at
`app/build/outputs/apk/debug/app-debug.apk`.
3. `assembleRelease` builds the signed release APK at
`app/build/outputs/apk/release/app-release.apk`.
4. `copyReleaseApks` (registered as a `finalizedBy` of `assembleRelease`)
copies both files to the repo root with the version-stamped names:
- `./incido-<versionName>-debug.apk`
- `./incido-<versionName>.apk`
The release APK is signed by `signingConfigs.release`, which points at
the dev keystore at `keystore/release.jks` (alias `incido`, store and
key password both `incido_dev_keystore`). **Never ship this keystore to
an external store** — see `keystore/README.md` for instructions on
generating a production keystore before Play Store / F-Droid
distribution.
#### Why a copy task and not `outputFileName` mutation?
We tried the obvious `applicationVariants.outputs.all { output ->
output.outputFileName = ... }` pattern first, but AGP 8.7.2's Kotlin
DSL trips over two quirks:
1. The legacy `applicationVariants.outputs.all { ... }` lambda
resolution clashes with Kotlin's `Iterable<T>.all(predicate: (T) ->
Boolean)` — Kotlin picks the predicate form and the assignment
fails to type-check (even with an explicit `Action<BaseVariantOutput>`
wrapper and `@Suppress("DEPRECATION")`).
2. The modern `androidComponents.onVariants { ... }` API doesn't
expose `outputFileName` as a settable property on its outputs.
A `tasks.register("copyReleaseApks") { ... }` is one Gradle idiomatic
way out: the APKs land where AGP's defaults want them, and the copy
task just renames-and-drops at the repo root with `versionName` baked
in. The `.gitignore` rule for `incido-*.apk` means these files never
accidentally land in a commit.
### 11.3 Verify
```bash
ls -la incido-<versionName>-debug.apk incido-<versionName>.apk
```
Expected:
- Both files exist at the repo root with the correct names.
- Debug APK is roughly 25–35 MB.
- Release APK is roughly 20–25 MB (smaller because R8 will eventually
minify once `isMinifyEnabled = true` is flipped on; for now both
builds are unminified).
Smoke-test the debug APK on a real device before sharing the release:
```bash
adb install -r incido-<versionName>-debug.apk
```
### 11.4 One-liner for the next release
```bash
# (after bumping versionName/versionCode/APP_VERSION/README per §11.1)
./gradlew clean assembleDebug assembleRelease && \
ls -la incido-$(grep '^versionName' app/build.gradle.kts | head -1 | awk -F'"' '{print $2}')-*.apk
```
(The `ls` extracts the version from `app/build.gradle.kts` so you don't
have to type it — `./gradlew assembleRelease` has already deposited
both stamped APKs at the repo root by the time you reach it.)
---
## Appendix A — Key Library Versions (for the version catalog)
These versions are current as of plan drafting. The AI assistant should verify and pin them in `gradle/libs.versions.toml` at project scaffold time: