7 Commits
Author SHA1 Message Date
Incido Developer f337e162f7 chore(release): v0.4.0.0
dev / Build debug APK (push) Successful in 1m58s
release / Build & attach release APK (push) Successful in 3m11s
Bump versionName 0.3.8.1 -> 0.4.0.0 (versionCode 34 -> 35) and mirror it in SettingsViewModel.APP_VERSION. Add the v0.4.0.0 'What's New' entry (drops v0.3.6.0 off the 5-recent tail) and a PREVIOUS_HISTORY.md section for the CI release description. Marks the in-app Carnet/QuickNote import as a minor feature release.
2026-09-18 16:09:24 +12:00
Incido Developer cbe015839b feat(import): import Carnet/QuickNote (.sqd) archives in-app
Adds an 'Import 3rd Party Notes' button to Settings > Backup & Restore that reads a Carnet/QuickNote .zip export (a single archive bundling one .sqd per note) and imports every note directly on-device, no pre-conversion step. Each .sqd is itself a zip (index.html + metadata.json + optional data/ attachments); the importer does a nested-zip read. Rich-text bodies are flattened to plain text, colours/keywords/links carry over, to-do lists become native checklists, and image attachments are imported (auto-generated preview thumbnails skipped). Additive import with per-note fault isolation.
2026-09-18 16:04:53 +12:00
Incido Developer 7e335d14ef docs(plan): add 11.5 - how to re-run a failed release
dev / Build debug APK (push) Successful in 19s
Records why re-running a red release run replays the tag's old workflow (and wipes assets on the way down), the dispatch-from-main retry path, and the task-id-vs-run-number / script-echo log gotchas.
2026-09-17 19:09:04 +12:00
Incido Developer c8c2c98c8e ci(release): add a workflow_dispatch retry path for releases
dev / Build debug APK (push) Successful in 21s
A tag push pins the workflow file to the tag's own commit, so re-running a red release run replays the OLD workflow even when main is already fixed - that is precisely why run 78 kept dying on the cp bug after the fix landed, and each retry deleted the changelog asset before failing to re-upload it.

Adds workflow_dispatch with a required 'tag' input plus a RELEASE_TAG env (input on dispatch, tag name on push) used by both checkouts and the release step, so a release can be re-published from main's current workflow against any existing tag. The checkout also gains a targeted shallow fetch of the tag, since a --depth=1 default-branch clone may not carry the tag's commit when dispatched from main.
2026-09-17 19:04:34 +12:00
Incido Developer cbebac3254 fix(release): stop copying the notes file onto itself before upload
dev / Build debug APK (push) Successful in 22s
release / Build & attach release APK (push) Successful in 26s
NOTES_FILE is already /tmp/Incido-<version>-changes.md, so 'cp $NOTES_FILE /tmp/$NOTES_ASSET' was a self-copy: cp exits 1 and set -e aborted the step AFTER both APKs had uploaded. That is what turned run 78 (tag v0.3.8.1) red - the LAN API change itself worked, the release and both APK assets landed first. Upload $NOTES_FILE directly instead.
2026-09-17 18:24:12 +12:00
Incido Developer ab26fe5f98 fix(release): v0.3.8.1 emergency rebuild, reinstall required
dev / Build debug APK (push) Successful in 46s
release / Build & attach release APK (push) Failing after 28s
Re-release v0.3.8.0 unchanged so the repaired pipeline can actually publish it: the v0.3.8.0 run was cancelled and never produced a release or APKs.

The build ran on a runner with an empty keystore cache, so CI minted a NEW signing key: installs cannot be upgraded in place (signature conflict), and with allowBackup=false an uninstall takes the user's notes. The release notes, README, and in-app What's New now all lead with export-a-backup-first.

Lockstep per Dev Plan 11.1: versionCode 33->34, versionName -> 0.3.8.1, APP_VERSION, README, PREVIOUS_HISTORY section, ReleaseNotes.RECENT (0.3.5.1 drops off the tail), Dev Plan 10 row.
2026-09-17 18:07:41 +12:00
Incido Developer dee20bf0f4 ci(release): point release API at LAN Gitea instance
dev / Build debug APK (push) Successful in 21s
Target http://192.168.8.17:3000 instead of https://git.trevena.info for the release create/asset-upload calls, so the release job talks to the instance over the LAN.
2026-09-17 17:35:47 +12:00
10 changed files with 612 additions and 56 deletions

No files matched your search

+27 -6
View File
@@ -4,19 +4,38 @@ on:
push:
tags:
- 'v*.*.*'
# Retry path: a tag push pins the workflow file to that tag's commit, so a
# re-run of a red release run replays the OLD workflow even after main is
# fixed (that is exactly how run 78 kept failing post-fix). Dispatching
# against main runs main's current workflow against any already-published
# tag, so a release can be re-published without moving a tag.
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to rebuild and re-publish, e.g. v0.3.8.1'
required: true
type: string
jobs:
build-release:
name: Build & attach release APK
runs-on: ubuntu-latest
timeout-minutes: 30
env:
# The tag this run publishes: the tag itself on a push, or the typed
# input on a manual retry (where github.ref_name is just the branch).
RELEASE_TAG: ${{ github.event.inputs.tag || github.ref_name }}
steps:
- name: Checkout
run: |
git clone --depth=1 https://git.trevena.info/nick/incido.git repo
cd repo
# Targeted shallow fetch of the exact tag: the clone above is shallow
# off the default branch, so --tags alone may not carry the tag's
# commit when the run is dispatched from main instead of pushed.
git fetch --depth=1 origin tag "$RELEASE_TAG" || true
git fetch --tags origin
git checkout ${{ github.ref_name }}
git checkout "$RELEASE_TAG"
- name: Set up JDK 17
run: |
@@ -57,7 +76,7 @@ jobs:
timeout-minutes: 25
run: |
cd repo
git checkout ${{ github.ref_name }}
git checkout "$RELEASE_TAG"
# Persistent signing keystore: minted ONCE in the runner's
# cache dir (which survives across runs, same place the JDK
# and SDK live) and copied into the checkout. Every release
@@ -101,9 +120,9 @@ jobs:
run: |
set -e
cd repo
TAG="${{ github.ref_name }}"
TAG="$RELEASE_TAG"
VERSION="${TAG#v}"
API="https://git.trevena.info/api/v1/repos/nick/incido"
API="http://192.168.8.17:3000/api/v1/repos/nick/incido"
APK_DEBUG="Incido-$VERSION-debug.apk"
APK_RELEASE="Incido-$VERSION-release.apk"
@@ -212,8 +231,10 @@ jobs:
NOTES_ASSET="Incido-$VERSION-changes.md"
echo "--- Deleting stale asset for $NOTES_ASSET ---"
python3 /tmp/delete_asset.py "$API" "$RELEASE_ID" "$NOTES_ASSET" "$GH_TOKEN"
cp "$NOTES_FILE" "/tmp/$NOTES_ASSET"
upload_asset "$NOTES_ASSET" "/tmp/$NOTES_ASSET" || exit 1
# Upload $NOTES_FILE directly: it already IS /tmp/<asset name>, so
# copying it onto itself made cp fail with exit 1 and killed the
# whole step (set -e) after the APKs had uploaded fine.
upload_asset "$NOTES_ASSET" "$NOTES_FILE" || exit 1
fi
echo "--- Final release state ---"
+34
View File
@@ -370,6 +370,7 @@ A short reference for AI assistants:
| Version | Date | Notes |
|---------|------|-------|
| 0.3.8.1 | 2026-09-17 | **Emergency hotfix — rebuild / re-release of v0.3.8.0. Zero app-code changes; release-pipeline fix only.** **1. Why.** The release job had been failing to publish reliably. `.gitea/workflows/release.yml` now addresses the Gitea API as `http://192.168.8.17:3000/api/v1/repos/nick/incido` (LAN, direct) instead of the Cloudflare-fronted `https://git.trevena.info/...`, which was the source of the mid-upload 524 origin timeouts that 4a28f4f could only retry around. **2. Signing key rotated — INSTALLED BUILDS CANNOT UPDATE IN PLACE.** The job ran on a runner whose `/var/lib/gitea-runner/work` cache held no `release.jks`, so the mint-if-absent branch (release.yml) generated a NEW certificate; Android rejects an APK whose signing cert differs from the installed one, so v0.3.8.1 must be uninstalled before it will install. Because `allowBackup="false"` (AndroidManifest) keeps notes out of Android's cloud/D2D restore, an uninstall DESTROYS the user's notes — so the release notes lead with "export a backup first" (Settings → Backup → Export, plus Settings → Security → Export encryption key when encryption is on), then uninstall → install → restore. **Follow-up worth doing:** copy the original `release.jks` onto the runner at `/var/lib/gitea-runner/work/release.jks` to restore in-place upgrades and stop the rotation; until then every release repeats this. **3. Lockstep (§11.1).** versionCode 33→34, versionName "0.3.8.0"→"0.3.8.1", SettingsViewModel.APP_VERSION bumped, README current-release line + reinstall warning, PREVIOUS_HISTORY.md section (feeds the release description + `Incido-0.3.8.1-changes.md` asset), and the in-app What's New dialog (ReleaseNotes.RECENT — v0.3.5.1 drops off the 5-entry tail). |
| 0.3.8.0 | 2026-09-16 | **Feature release — task lists, shopping lists, hashtag-autocomplete fix** (closes §6.1 "Checklists / to-do items within notes" + "Grocery list with running price total"). **1. Note types.** New `NoteType` enum in `:core/domain` (TEXT / TASK_LIST / SHOPPING_LIST) carried by `Note.type` and an additive `NoteEntity.typeKey` Short column (ObjectBox auto-migrates; old rows = TEXT). List bodies persist as GitHub-flavoured `- [ ] item` lines (`Note.splitListContent` / `serializeListContent`), so content stays the single source of truth: full-text search, AES-GCM field encryption, share-into, the v0.2 inline checklist card summaries, and Trash all keep working untouched. **2. Task-list editor.** Checklist button next to the # tag button in the editor's bottom action row converts the note into editable rows (Checkbox + item text + remove, "+ Add item", first non-checkbox line kept as the title field); tapping the active button reverts to plain text. Active mode tints primary. Cards already showed "- [ ]" open/done counts; shopping cards now show a basket icon instead of the checkbox glyph. **3. Shopping list + running total.** Same mechanism with two structured fields per row: a read-only **quantity picker (1–9)** (`ExposedDropdownMenuBox` — no keyboard ever opens) and a **POS-style price field** (`KeyboardType.Number`; every digit typed is a cent — the field stores the RAW digits verbatim (e.g. `199` = $1.99) so mid-field cursor placement behaves like a normal text field and can never scramble the amount, with a non-editable `$` prefix; the total bar renders dollars). A sticky `ShoppingTotalBar` stays pinned above the rows — always visible, updated live — summing `qty × price` of CHECKED (= in-basket) items in **integer cents** (no binary-float drift). Storage puts both values in an explicit end-of-line marker `- [x] Eggs {q12 p2.40}`, so the PRODUCT TEXT IS NEVER SCANNED FOR NUMBERS ("Battery AA 3", "Poster 50 x 60" stay pure product names); hand-typed §6.1 shapes (`Milk 3.50`, `Eggs 12 x 2.40`) still import once into the structured fields on conversion (decimals required on the legacy forms to avoid exactly that ambiguity). Converting to a task list folds values back into plain text tokens (`Eggs 12 x 2.40`) so nothing is lost across mode switches. **4. Add-tag suggestions repaired.** The autocomplete collector in `NoteEditorViewModel.init` was `tagInputFlow.collect { pool.collect { … } }` over infinite ObjectBox callbackFlows — the outer lambda suspended in the inner collect forever, keystrokes never re-queried, and `openAddTagSheet()` zeroed the list, so the sheet only ever offered "+ Create". Rebuilt on `flatMapLatest` over `tagInputFlow` (sheet opens showing every existing tag most-used-first, filters live per keystroke). **5. Backups** round-trip the new type via defaulted `BackupNote.noteType` ("TEXT") — pre-v0.3.8.0 files import unchanged, `ignoreUnknownKeys` covers older readers; encrypted backups reuse the same shape. ViewModel: `isDirty` gains the type axis; list edits keep `content` synchronised with the row serialisation so save/preview/canSave gates need no changes. versionCode 32→33, versionName "0.3.7.1"→"0.3.8.0", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.7.1 | 2026-08-30 | **Maintenance release — UI polish + one bug fix.** **1. Editor top bar decluttered.** The Add/Edit `TopAppBar` carried six right-side actions (camera, attach, tag, favourite, save, overflow), which crowded the title on narrow screens. Camera / Attach file / Add tag move to a Keep-style bottom action row (hairline `HorizontalDivider` above it; rides above the nav bar / keyboard via the existing IME insets). The top bar is now back + "New note" / "Edit note" title (`maxLines = 1`, ellipsis) + favourite + save + overflow (Move to Trash when editing) — always fits, and matches the §5.2 spec. **2. Image-viewer false failure fixed.** `ImageViewerScreen` checked `bitmap == null` in a `LaunchedEffect` before the async load finished, so a "Couldn't decode image attachment" toast fired on every persisted image open. Replaced with a `loadFailed` state set only after the byte load / decode genuinely fails; the placeholder switches from "Loading…" to "Couldn't load image" (toast removed). **3. Search QoL.** The list search field auto-focuses on open (`FocusRequester` + `LaunchedEffect(state.isSearchActive)`) and gains a trailing clear (✕) button while the query is non-empty. **4. Drawer tag-list overflow fixed.** The scrollable "Recent tags" column in `IncidoDrawer` had no height cap, so long tag lists could overflow the sheet bottom; it now takes `weight(1f)` and scrolls within the remaining height. Dead `_ignored` workaround val removed. **5. Add-tag sheet autofocus.** The sheet's input field is focused on open so the keyboard is already up. Also small hygiene: unused `persistedBytes` param dropped from `AttachmentStrip`; fully-qualified `Spacer` / `Image` / `Column` / `Dispatchers` references replaced with imports. **6. New flat app icon.** `incido_flat_icon.png` (1024×1024, squircle + shield + pen nib, transparent corners) replaces the v0.3.3.8 artwork: LANCZOS-downscaled into `drawable-{mdpi…xxxhdpi}/ic_launcher_foreground.png` (108/162/216/324/432 px, full 108dp canvas — the artwork's fill colour matches the background layer so the squircle edges blend seamlessly) and legacy `mipmap-{mdpi…xxxhdpi}/ic_launcher{,_round}.png` (48/72/96/144/192 px); `ic_launcher_background` re-tinted `#010435` → `#352999`. versionCode 31→32, versionName "0.3.7.0"→"0.3.7.1", SettingsViewModel.APP_VERSION bumped in lockstep. |
| 0.3.7.0 | 2026-08-20 | **Feature release — Trash / soft delete.** Deleting a note (long-press card → ⋮ menu → Delete, or the editor's delete action) now soft-deletes it instead of destroying it: the note is flagged as trashed and hidden from Home, Favorites, Untagged, tag views, and ordinary search. A new **Trash** entry in the nav drawer lists only soft-deleted notes; each Trash card's overflow menu exposes **Restore** (returns the note to its previous views) and **Delete permanently** (destroys the row + attachments for good). `NoteEntity` gains a `trashed` flag (additive schema, auto-migrated); `NoteFilter` gains a `Trash` case; the repository gains `moveToTrash` / `restoreFromTrash` / `deletePermanently`; the drawer, list, and editor ViewModels + screens wire the new actions. Backups round-trip the trashed state. No automatic purge window yet — permanent deletion is immediate (see §6.1 "Trash status" note). versionCode 30→31, versionName "0.3.6.3"→"0.3.7.0", SettingsViewModel.APP_VERSION bumped in lockstep. |
@@ -521,6 +522,39 @@ adb install -r incido-<versionName>-debug.apk
have to type it — `./gradlew assembleRelease` has already deposited
both stamped APKs at the repo root by the time you reach it.)
### 11.5 Re-running a failed release
**Never "Re-run" a red release run.** A tag push pins the workflow file to
that tag's own commit, so a re-run replays the workflow as it was when the
tag was cut — even after `main` has been fixed. It is also destructive: the
release step deletes each stale asset before re-uploading it, so a retry that
dies mid-step leaves the release with *fewer* assets than it started with.
(This is exactly what happened to v0.3.8.1 run 78, twice, over a `cp` bug
already patched on `main`.)
Instead, dispatch the workflow from `main`, which runs `main`'s current
workflow against an existing tag:
```bash
# Gitea: POST .../actions/workflows/release.yml/dispatches (expect 204)
curl -s -X POST \
-H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d '{"ref":"main","inputs":{"tag":"v0.3.8.1"}}' \
http://192.168.8.17:3000/api/v1/repos/nick/incido/actions/workflows/release.yml/dispatches
```
Equivalently: Actions → "release" → Run workflow → branch `main` → tag input.
The job reuses the existing release entry, refreshes its description, and
re-attaches both APKs and `Incido-<version>-changes.md`.
Two API gotchas found the hard way: a run's **task id is not its run number**
(`GET /actions/runs/<n>/logs` 404s; logs live at
`GET /actions/jobs/<task-id>/logs`), and job logs echo the whole script before
executing it, so grep below the last `::endgroup::` to see real output.
If CI cannot attach the changelog file at all, `scripts/ci/backfill-release-notes.sh <version>`
patches description + notes asset after the fact (idempotent, never touches the APKs).
---
## Appendix A — Key Library Versions (for the version catalog)
+34
View File
@@ -18,6 +18,40 @@ the release falls back to a plain "Release <tag>" description.
---
## v0.4.0.0 — 2026-09-18
New in this release: **Import 3rd Party Notes**. Settings → Backup & Restore
now has an "Import 3rd Party Notes" button that ingests a Carnet / QuickNote
`.zip` export — a single archive bundling one `.sqd` per note — straight
on-device, with no pre-conversion step. Rich-text bodies are flattened to plain
text; note colours, keywords (imported as tags) and links carry over; to-do
lists become native checklists; and image attachments are imported
(auto-generated preview thumbnails are skipped). Import is additive — existing
notes are preserved and imported notes get fresh IDs.
---
## v0.3.8.1 — 2026-09-17
> **⚠️ Reinstall required — please export a backup first.** This build is signed
> with a **new CI signing key** (the previous key lived in the old build runner's
> cache and was not carried over), so Android will refuse to install it over an
> existing Incido — it reports a signature conflict. Incido deliberately doesn't
> participate in Android's automatic backup/restore, so **uninstalling deletes
> your notes**. To update safely: **Settings → Backup → Export** (and
> **Settings → Security → Export encryption key** if you use encryption),
> then uninstall Incido, install this APK, and restore from your backup.
> If you'd rather keep using v0.3.8.0, that's fine — nothing in it is broken.
- **No app changes.** v0.3.8.1 is a re-release of v0.3.8.0: same task lists,
shopping lists with the running total, and add-tag suggestions fix. Only the
build number and the release pipeline changed.
- **Why the rebuild.** The release pipeline had been failing to publish builds
reliably. Release uploads now go to the Gitea API over the local network
instead of the proxied public address, which is where the upload timeouts were
coming from — so this is the first build in a while to ship with its APKs and
notes attached the way §11.1 intends.
## v0.3.8.0 — 2026-09-16
- **Task lists + shopping lists (Development Plan §6.1).** New checklist button in the editor's bottom action row (next to the `#` tag button) converts any note into an editable task list — real checkboxes, add / remove item rows; tap the button again to return to plain text (`NoteType`, additive `typeKey` column, auto-migrated). New shopping-basket button works the same way but gives every row a tap-to-pick **quantity (1–9) dropdown** and a supermarket-style price field where the number pad types cents — enter `199` and it counts as **$1.99** in the maths (the price box keeps exactly the digits you typed, so cursor placement can never scramble them, while the total bar speaks real dollars). An always-visible running total sits above the list, adding quantity × price for everything checked (= in the basket). The three values are strictly separate fields saved with an explicit end-of-line marker (`- [x] Eggs {q12 p2.40}`), so numbers inside a product name (like "Battery AA 3") can never leak into the money maths; hand-typed classic lines (`Milk 3.50`, `Eggs 12 x 2.40`) are still recognised when converting older notes. Lists persist as GitHub-flavoured `- [ ]` lines, so search, encryption, backups (new defaulted `noteType` field — old files still import), and card "N open · M done" summaries keep working; shopping cards show a basket icon.
+8 -2
View File
@@ -6,7 +6,7 @@ Incido is a privacy-first, on-device note-taking application for Android.
All data stays on your device by default — no accounts, no cloud, no
trackers.
This repository contains the **v0.3.8.0** release: a single-user, offline
This repository contains the **v0.3.8.1** release: a single-user, offline
note app with hashtags, favourites, task lists, shopping lists with a
running total, colour-coded notes, photo and file attachments,
share-into from other apps and the
@@ -17,9 +17,15 @@ device migrations. The architecture is multi-module Android today and
is structured so iOS / Desktop ports can happen later without UI
rewrites.
**Current release:** v0.3.8.0 — full release notes ship **on its entry on
**Current release:** v0.3.8.1 — full release notes ship **on its entry on
the [Releases page](https://git.trevena.info/nick/incido/releases)**.
> **v0.3.8.1 needs a clean reinstall** (a new CI signing key makes it conflict
> with any existing Incido install). **Export a backup from
> Settings → Backup first** — Incido doesn't use Android's automatic backup, so
> uninstalling deletes your notes. Otherwise this build is identical to
> v0.3.8.0.
> **Version scheme (from v0.3.0.0 onwards):** `MAJOR.MINOR.MAINTENANCE.EMERGENCY` —
> e.g. `0.3.0.0`. `MAJOR.MINOR.MAINTENANCE` are normal release numbers;
> `EMERGENCY` is non-zero only for hotfixes shipped out-of-band.
+14 -13
View File
@@ -28,19 +28,20 @@ android {
applicationId = "org.incido.app"
minSdk = 26
targetSdk = 35
// v0.3.8.0: feature release — task lists, shopping lists, hashtag fix.
// - Task-list note type: bottom-bar toggle converts the body into
// an editable checklist (checkbox + text rows, add / remove).
// - Shopping-list note type: like the task list plus a number-pad
// Cost field per item and a sticky running total of the checked
// (= in-basket) items (Development Plan §6.1).
// - Hashtag sheet now shows live-filtered suggestions again (the
// nested-collect autocomplete pipeline was stuck; flatMapLatest).
// - NoteEntity gains `typeKey` (additive, auto-migrated); backups
// round-trip `noteType` with a "TEXT" default for old files.
// - versionCode monotonic +1 from v0.3.7.1 (32).
versionCode = 33
versionName = "0.3.8.0"
// v0.4.0.0: MINOR feature release — in-app import of 3rd-party
// notes. Settings → Backup & Restore gains an "Import 3rd Party
// Notes" button that reads a Carnet / QuickNote `.zip` export (a
// single archive bundling one `.sqd` per note, where each `.sqd` is
// itself a zip of index.html + metadata.json + optional data/
// attachments) and imports every note directly on-device — no
// pre-conversion step. Rich-text bodies are flattened to plain text;
// colours, keywords (as tags) and links carry over; to-do lists
// become native checklists; image attachments are imported (auto-
// generated preview thumbnails are skipped). Import is additive with
// per-note fault isolation.
// - versionCode monotonic +1 from v0.3.8.1 (34).
versionCode = 35
versionName = "0.4.0.0"
}
// --- Signing ---
@@ -0,0 +1,405 @@
package org.incido.compose.data.backup
import android.content.Context
import android.net.Uri
import java.io.ByteArrayInputStream
import java.util.zip.ZipInputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import org.incido.domain.model.Hashtag
import org.incido.domain.model.Note
import org.incido.domain.model.NoteColor
import org.incido.domain.model.NoteType
import org.incido.domain.repository.NoteRepository
/**
* v0.3.9.0 — imports notes from a **Carnet / QuickNote** archive.
*
* The source is a `.zip` whose top-level entries are `*.sqd` files (plus
* some metadata dirs we ignore). Each `.sqd` is *itself* a zip containing:
* * `index.html` — the note body inside `<div class="edit-zone">…</div>`
* * `metadata.json` — `creation_date`, `last_modification_date`,
* `keywords[]`, `rating`, `color`, `urls{}`, `todolists[]`
* * `data/<file>` — optional attachments (images etc). A companion
* `data/preview_` thumbnail is skipped so we don't
* import a low-res duplicate.
*
* Incido stores note bodies as **plain text**, so the rich-text HTML is
* flattened to text (block tags → newlines, entities decoded, tags stripped).
* The `.sqd` filename becomes the note's title line, which also gives
* image-only notes (no HTML body) a readable title.
*
* Import is **additive** — matching the existing backup-import behaviour:
* existing notes are preserved, every imported note gets a fresh id, and
* attachments are stored via [NoteRepository.addAttachment] (which applies
* EXIF normalisation + at-rest encryption transparently).
*
* Both archive shapes are accepted: a bundle of `*.sqd` files, or a single
* `.sqd` file picked directly (its zip entries are the note's own
* `index.html` / `metadata.json` / files under `data/`).
*/
class CarnetImporter(
private val context: Context,
private val repository: NoteRepository,
) {
private val json = Json {
ignoreUnknownKeys = true
isLenient = true
}
/**
* Read the archive at [uri] and import every Carnet note it contains.
* Returns the number of notes imported.
*/
suspend fun import(
uri: Uri,
onProgress: (current: Int, total: Int) -> Unit = { _, _ -> },
): Int = withContext(Dispatchers.IO) {
val archiveBytes = context.contentResolver.openInputStream(uri)?.use { it.readBytes() }
?: throw java.io.IOException("Could not open input stream for $uri")
val topLevel = readZip(archiveBytes)
// The picked file is a single archive that bundles every note as a
// nested `.sqd` entry (each `.sqd` is itself a zip). Collect those.
val sqdNotes = topLevel.filter { (name, _) -> name.endsWith(".sqd", ignoreCase = true) }
.toList()
// Candidates as (title-file-name, raw-bytes). If no `.sqd` entries
// were found, the picked file is treated as a single `.sqd` (its own
// zip entries are index.html / metadata.json / data/…).
val candidates: List<Pair<String, ByteArray>> = if (sqdNotes.isNotEmpty()) {
sqdNotes
} else {
listOf((queryDisplayName(uri) ?: "Imported note.sqd") to archiveBytes)
}
// Parse phase — fault-isolated so one corrupt `.sqd` can't abort the
// rest of the archive.
val notes = candidates.mapNotNull { (name, bytes) ->
runCatching { parseSqd(name.substringAfterLast('/'), bytes) }.getOrNull()
}.filter { it.hasContent() }
// Persist phase — also per-note, so a single bad note doesn't lose the
// ones already written (the repository commits each note independently).
val total = notes.size
var imported = 0
notes.forEach { parsed ->
val ok = runCatching { persist(parsed) }.isSuccess
if (ok) imported++
onProgress(imported, total)
}
imported
}
// --- Persistence ---------------------------------------------------------
private suspend fun persist(parsed: ParsedSqd) {
val hashtags = parsed.keywords
.flatMap { raw ->
// Prefer the whole keyword as one tag; if it isn't a valid
// hashtag (Incido allows only [a-z0-9._-], 1–31 chars), split
// on whitespace/commas and keep the valid sub-tokens.
val one = Hashtag.normalise(raw)
if (Hashtag.parseOrNull(one) != null) {
listOf(one)
} else {
raw.split(Regex("[\\s,]+"))
.map { Hashtag.normalise(it) }
.filter { Hashtag.parseOrNull(it) != null }
}
}
.filter { it.isNotEmpty() }
.toSet()
val saved = repository.saveNoteWithHashtags(
note = Note(
id = 0L, // force a fresh id
content = parsed.content,
createdAt = parsed.createdAt,
updatedAt = parsed.updatedAt,
isFavorite = parsed.isFavorite,
color = parsed.color,
isTrashed = false,
type = parsed.type,
),
hashtagsToAdd = hashtags,
hashtagsToRemove = emptySet(),
)
for (att in parsed.attachments) {
repository.addAttachment(
noteId = saved.id,
bytes = att.bytes,
mimeType = sniffMimeType(att.bytes),
displayName = att.displayName,
)
}
}
// --- .sqd parsing --------------------------------------------------------
private fun parseSqd(fileName: String, sqdBytes: ByteArray): ParsedSqd {
val files = readZip(sqdBytes)
val title = fileName.substringBeforeLast('.')
.ifBlank { "Untitled" }
val html = files["index.html"]?.toString(Charsets.UTF_8).orEmpty()
val meta = files["metadata.json"]
?.let {
runCatching {
json.decodeFromString(CarnetMetadata.serializer(), it.toString(Charsets.UTF_8))
}.getOrNull()
}
?: CarnetMetadata()
val body = htmlToText(html)
// Attachments: anything under data/ that is a real file (not a dir
// entry) and not an auto-generated preview thumbnail.
val attachments = files
.filter { (name, bytes) ->
name.startsWith("data/") &&
!name.endsWith("/") &&
bytes.isNotEmpty() &&
!name.substringAfterLast('/').startsWith("preview_")
}
.map { (name, bytes) -> Attachment(name.substringAfterLast('/'), bytes) }
val type = if (meta.todolists.isNotEmpty()) NoteType.TASK_LIST else NoteType.TEXT
return ParsedSqd(
content = buildContent(title, body, meta),
createdAt = meta.creationDate.takeIf { it > 0 } ?: System.currentTimeMillis(),
updatedAt = meta.lastModificationDate.takeIf { it > 0 } ?: System.currentTimeMillis(),
isFavorite = meta.rating >= 5,
color = mapColor(meta.color),
type = type,
keywords = meta.keywords,
attachments = attachments,
)
}
/**
* Assemble the final plain-text body. The filename is used as the title
* (first non-blank line in Incido's title/body split); then the HTML
* body; then any URLs from the metadata; then any to-do lists rendered as
* GFM checkbox lines (`- [ ]` / `- [x]`) so [NoteType.TASK_LIST] renders.
*/
private fun buildContent(title: String, body: String, meta: CarnetMetadata): String {
val blocks = mutableListOf<String>()
blocks += title
if (body.isNotBlank()) blocks += body
if (meta.urls.isNotEmpty()) {
blocks += meta.urls.keys.filter { it.isNotBlank() }
}
for (todo in meta.todolists) {
val lines = buildList {
todo.done.forEach { if (it.isNotBlank()) add("- [x] ${it.trim()}") }
todo.todo.forEach { if (it.isNotBlank()) add("- [ ] ${it.trim()}") }
}
if (lines.isNotEmpty()) blocks += lines.joinToString("\n")
}
return blocks.filter { it.isNotBlank() }.joinToString("\n\n").trim()
}
// --- Helpers -------------------------------------------------------------
/** Read every file entry (name → bytes) from a zip, skipping dirs. */
private fun readZip(bytes: ByteArray): LinkedHashMap<String, ByteArray> {
val out = LinkedHashMap<String, ByteArray>()
ZipInputStream(ByteArrayInputStream(bytes)).use { zis ->
while (true) {
val entry = zis.nextEntry ?: break
if (entry.isDirectory) { zis.closeEntry(); continue }
val data = zis.readBytes()
out[entry.name] = data
zis.closeEntry()
}
}
return out
}
/** Query the user-visible name of a SAF [uri] (falls back to null). */
private fun queryDisplayName(uri: Uri): String? {
return try {
context.contentResolver.query(uri, null, null, null, null)?.use { cursor ->
val idx = cursor.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME)
if (idx >= 0 && cursor.moveToFirst()) cursor.getString(idx) else null
}
} catch (_: Exception) {
null
}
}
companion object {
/** MIME type detected from magic bytes, falling back to a default. */
fun sniffMimeType(bytes: ByteArray): String {
fun b(i: Int) = if (i < bytes.size) bytes[i].toInt() and 0xFF else -1
if (b(0) == 0xFF && b(1) == 0xD8 && b(2) == 0xFF) return "image/jpeg"
if (b(0) == 0x89 && b(1) == 0x50 && b(2) == 0x4E && b(3) == 0x47) return "image/png"
if (b(0) == 0x47 && b(1) == 0x49 && b(2) == 0x46 && b(3) == 0x38) return "image/gif"
if (b(0) == 0x52 && b(1) == 0x49 && b(2) == 0x46 && b(3) == 0x46 &&
b(8) == 0x57 && b(9) == 0x45 && b(10) == 0x42 && b(11) == 0x50
) return "image/webp"
if (b(0) == 0x42 && b(1) == 0x4D) return "image/bmp"
return "application/octet-stream"
}
/** Carnet color string → Incido [NoteColor]. Unknown values → NONE. */
fun mapColor(raw: String): NoteColor = when (raw.trim().lowercase()) {
"red" -> NoteColor.RED
"green" -> NoteColor.GREEN
"blue" -> NoteColor.BLUE
"yellow", "amber" -> NoteColor.AMBER
"purple" -> NoteColor.PURPLE
else -> NoteColor.NONE
}
/**
* Flatten a Carnet `index.html` note body to plain text:
* strip comments, isolate the `.edit-zone` content, turn block
* boundaries into newlines, decode entities (incl. `&nbsp;`), then
* drop the remaining tags.
*/
fun htmlToText(html: String): String {
var s = html.replace(Regex("<!--.*?-->", RegexOption.DOT_MATCHES_ALL), " ")
// Keep only the edit-zone body (everything after its opening tag,
// up to the sibling `<div id="floating">` that follows it).
val zoneMatch = Regex("class=\"edit-zone\"[^>]*>").find(s)
if (zoneMatch != null) {
s = s.substring(zoneMatch.range.last + 1)
val floatIdx = s.indexOf("<div id=\"floating\"")
if (floatIdx >= 0) s = s.substring(0, floatIdx)
}
s = s.replace(Regex("<br\\s*/?>", RegexOption.IGNORE_CASE), "\n")
s = s.replace(Regex("</(div|p|li|ul|ol|tr|h[1-6])>", RegexOption.IGNORE_CASE), "\n")
s = s.replace(Regex("<[^>]+>"), "")
s = decodeEntities(s)
// Normalise whitespace: drop trailing spaces per line, collapse
// runs of 2+ blank lines to a single blank line.
val lines = s.replace("\r", "").split('\n').map { it.trimEnd() }
val collapsed = StringBuilder()
var blanks = 0
for (line in lines) {
if (line.isEmpty()) {
blanks++
if (blanks <= 1) collapsed.append('\n')
} else {
blanks = 0
collapsed.append(line).append('\n')
}
}
return collapsed.toString().trim()
}
/** Decode the named + numeric HTML entities a Carnet body can contain. */
private fun decodeEntities(input: String): String {
if (!input.contains('&')) return input
val sb = StringBuilder(input.length)
var i = 0
while (i < input.length) {
val c = input[i]
if (c == '&') {
val semi = input.indexOf(';', i + 1)
if (semi in (i + 1)..(i + 12)) {
val entity = input.substring(i, semi + 1)
val decoded = NAMED_ENTITIES[entity] ?: numericEntity(entity)
if (decoded != null) {
sb.append(decoded)
i = semi + 1
continue
}
}
}
sb.append(c)
i++
}
return sb.toString()
}
private fun numericEntity(entity: String): String? {
if (!entity.startsWith("&#") || !entity.endsWith(";")) return null
val body = entity.substring(2, entity.length - 1)
return try {
val code = if (body.startsWith("x") || body.startsWith("X")) {
body.substring(1).toLong(16)
} else {
body.toLong()
}
if (code in 0..0x10FFFF) String(Character.toChars(code.toInt())) else null
} catch (_: NumberFormatException) {
null
}
}
private val NAMED_ENTITIES = mapOf(
"&nbsp;" to " ",
"&amp;" to "&",
"&lt;" to "<",
"&gt;" to ">",
"&quot;" to "\"",
"&#39;" to "'",
"&apos;" to "'",
"&copy;" to "\u00A9",
"&reg;" to "\u00AE",
"&trade;" to "\u2122",
"&hellip;" to "\u2026",
"&mdash;" to "\u2014",
"&ndash;" to "\u2013",
"&rsquo;" to "\u2019",
"&lsquo;" to "\u2018",
"&rdquo;" to "\u201D",
"&ldquo;" to "\u201C",
)
}
// --- Data ----------------------------------------------------------------
/** A parsed, ready-to-persist Carnet note. */
data class ParsedSqd(
val content: String,
val createdAt: Long,
val updatedAt: Long,
val isFavorite: Boolean,
val color: NoteColor,
val type: NoteType,
val keywords: List<String>,
val attachments: List<Attachment>,
) {
fun hasContent(): Boolean = content.isNotBlank() || attachments.isNotEmpty()
}
/** A single attachment (file name + raw bytes) inside a `.sqd`'s `data/`. */
data class Attachment(val displayName: String, val bytes: ByteArray)
@Serializable
private data class CarnetMetadata(
@SerialName("creation_date") val creationDate: Long = 0,
@SerialName("last_modification_date") val lastModificationDate: Long = 0,
val keywords: List<String> = emptyList(),
val rating: Int = -1,
val color: String = "none",
val urls: Map<String, JsonElement> = emptyMap(),
val todolists: List<CarnetTodo> = emptyList(),
)
@Serializable
private data class CarnetTodo(
val id: String = "",
val todo: List<String> = emptyList(),
val done: List<String> = emptyList(),
)
}
@@ -25,6 +25,48 @@ object ReleaseNotes {
* Append a new entry on top each release.
*/
val RECENT: List<ReleaseNote> = listOf(
ReleaseNote(
version = "0.4.0.0",
date = "2026-09-18",
bullets = listOf(
"Import 3rd-party notes: Settings \u2192 Backup & Restore now " +
"has an \u201cImport 3rd Party Notes\u201d button that reads a " +
"Carnet / QuickNote .zip export (a single archive bundling " +
"one .sqd per note) and brings every note in \u2014 directly " +
"on-device, with no pre-conversion step.",
"Formatting is preserved as plain text: rich-text bodies are " +
"flattened, and note colours, keywords (imported as tags) " +
"and links carry over. To-do lists become native " +
"checklists you can tick off.",
"Images come across too \u2014 photo attachments inside each " +
"note are imported; auto-generated preview thumbnails are " +
"skipped, so you get one clean image per photo.",
"Import is additive: your existing notes are untouched and " +
"imported notes get fresh IDs, so you can safely pull in " +
"an archive at any time.",
),
),
ReleaseNote(
version = "0.3.8.1",
date = "2026-09-17",
bullets = listOf(
"Read this first \u2014 reinstall required. This build is signed " +
"with a new CI key (the previous key lived in the old build " +
"runner's cache and wasn't carried over), so Android refuses " +
"to install it over an existing Incido: it reports a " +
"signature conflict.",
"Export a backup BEFORE uninstalling: Settings \u2192 Backup " +
"\u2192 Export, plus Settings \u2192 Security \u2192 Export " +
"encryption key if you use encryption. Incido doesn't use " +
"Android's automatic backup, so uninstalling deletes your " +
"notes. Then install this APK and restore from that backup.",
"Nothing else changed: v0.3.8.1 is a re-release of v0.3.8.0 " +
"with the same task lists, shopping lists with the running " +
"total, and add-tag suggestions fix. The rebuild exists " +
"because the release pipeline had been failing to publish " +
"builds reliably; staying on v0.3.8.0 is perfectly fine.",
),
),
ReleaseNote(
version = "0.3.8.0",
date = "2026-09-16",
@@ -84,39 +126,6 @@ object ReleaseNotes {
"good, including attachments).",
),
),
ReleaseNote(
version = "0.3.6.0",
date = "2026-08-19",
bullets = listOf(
"Sharing a webpage to Incido (browser \u2192 Share \u2192 Incido) now " +
"creates a note with the page title on the first line and " +
"the URL below it \u2014 ready to save as-is. Fully offline: " +
"the title comes from the browser's share data, so Incido " +
"still never touches the network.",
"New in Settings \u2192 Security: \"Export encryption key\" saves " +
"the AES-256 key that protects your encrypted notes to a " +
"passphrase-protected .inckey file \u2014 your backup for " +
"device migrations.",
"\"Import encryption key\" restores that key on a fresh " +
"install, with a clear warning before the current key is " +
"replaced.",
),
),
ReleaseNote(
version = "0.3.5.1",
date = "2026-08-17",
bullets = listOf(
"Cards now update their \"Encrypted\" indicator the moment " +
"you flip the Encrypt-at-rest switch on — no need to " +
"toggle off+on or restart the app to see the badge " +
"appear.",
"The \"Encrypted\" indicator on each note card is now " +
"just a small lock icon, sitting immediately to the " +
"left of the date/time on the bottom row (consistent " +
"position on every card, instead of a centred \"lock + " +
"label\" group at the bottom of the card).",
),
),
// v0.3.8.0 push drops v0.3.5.0 off the "5 most recent" tail.
// v0.4.0.0 push drops v0.3.6.0 off the "5 most recent" tail.
)
}
@@ -11,6 +11,7 @@ import org.incido.data.crypto.NoteCryptoService
import org.incido.data.repository.NoteRepositoryImpl
import org.incido.domain.repository.NoteRepository
import org.incido.compose.data.backup.BackupManager
import org.incido.compose.data.backup.CarnetImporter
import org.incido.compose.data.security.AesGcmFieldCipher
import org.incido.compose.data.security.EncryptionVerifier
import org.incido.compose.data.security.ObjectBoxKeyProvider
@@ -78,6 +79,10 @@ class AppContainer(context: Context) {
val backupManager: BackupManager = BackupManager(appContext, noteRepository)
/** v0.3.9.0 — Carnet / QuickNote `.sqd` archive importer. */
val carnetImporter: CarnetImporter = CarnetImporter(appContext, noteRepository)
/** Migration sweep + startup integrity checker for the note store. */
val noteCryptoService = NoteCryptoService(boxStore, cipherHolder)
@@ -122,6 +122,15 @@ fun SettingsScreen(
var showRecoveryImportWarning by remember { mutableStateOf(false) }
// SAF launchers
// v0.3.9.0 — Carnet / QuickNote archive importer. Picks a .zip (or a
// lone .sqd) and imports it directly; no passphrase, additive.
val carnetImportLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.OpenDocument(),
) { uri ->
if (uri == null) return@rememberLauncherForActivityResult
scope.launch { viewModel.importCarnet(uri) }
}
val exportLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.CreateDocument("application/json"),
) { uri ->
@@ -296,6 +305,12 @@ fun SettingsScreen(
securityManager?.beginExternalActivity()
importLauncher.launch(arrayOf("application/json", "*/*"))
},
onImportCarnet = {
securityManager?.beginExternalActivity()
carnetImportLauncher.launch(
arrayOf("application/zip", "application/x-zip-compressed", "application/octet-stream", "*/*"),
)
},
)
AboutSection(
version = SettingsViewModel.APP_VERSION,
@@ -825,6 +840,7 @@ private fun SecuritySection(
private fun BackupSection(
onExport: () -> Unit,
onImport: () -> Unit,
onImportCarnet: () -> Unit,
) {
SettingsSection(title = "Backup & Restore") {
Column(
@@ -846,6 +862,9 @@ private fun BackupSection(
OutlinedButton(onClick = onImport, modifier = Modifier.fillMaxWidth()) {
Text("Import from file…")
}
OutlinedButton(onClick = onImportCarnet, modifier = Modifier.fillMaxWidth()) {
Text("Import 3rd Party Notes")
}
}
}
}
@@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import org.incido.compose.IncidoApplication
import org.incido.compose.data.backup.BackupManager
import org.incido.compose.data.backup.CarnetImporter
import org.incido.compose.data.security.AesGcmFieldCipher
import org.incido.compose.data.security.EncryptionVerifier
import org.incido.compose.data.security.ObjectBoxKeyProvider
@@ -46,6 +47,7 @@ class SettingsViewModel(
private val security: SecurityManager,
private val objectBoxKeyProvider: ObjectBoxKeyProvider,
private val backupManager: BackupManager,
private val carnetImporter: CarnetImporter,
private val noteCryptoService: NoteCryptoService,
private val cipherHolder: CipherHolder,
private val encryptionVerifier: EncryptionVerifier,
@@ -245,6 +247,25 @@ class SettingsViewModel(
_snackbar.value = "Imported $count note(s)."
}
/**
* v0.3.9.0 — import a Carnet / QuickNote archive (`.zip` of `*.sqd`, or a
* single `.sqd`) picked via SAF. Additive — existing notes are kept.
* Failures are caught and surfaced via the snackbar so a bad file never
* crashes the app.
*/
suspend fun importCarnet(uri: android.net.Uri) {
try {
val count = carnetImporter.import(uri)
_snackbar.value = if (count > 0) {
"Imported $count Carnet note(s)."
} else {
"No Carnet notes found in that file."
}
} catch (e: Exception) {
_snackbar.value = "Carnet import failed: ${e.message ?: "unreadable file"}"
}
}
// --- v0.3.6.0 recovery key ---
/**
@@ -333,7 +354,7 @@ class SettingsViewModel(
/** The version string baked into backup payloads and shown on
* the About card. Mirrors `app/build.gradle.kts` `versionName`
* — if you bump one, bump both. */
const val APP_VERSION = "0.3.8.0"
const val APP_VERSION = "0.4.0.0"
val Factory: ViewModelProvider.Factory = viewModelFactory {
initializer {
@@ -344,6 +365,7 @@ class SettingsViewModel(
security = c.securityManager,
objectBoxKeyProvider = c.objectBoxKeyProvider,
backupManager = c.backupManager,
carnetImporter = c.carnetImporter,
noteCryptoService = c.noteCryptoService,
cipherHolder = c.cipherHolder,
encryptionVerifier = c.encryptionVerifier,