4 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
9 changed files with 556 additions and 39 deletions

No files matched your search

+22 -3
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,7 +120,7 @@ jobs:
run: |
set -e
cd repo
TAG="${{ github.ref_name }}"
TAG="$RELEASE_TAG"
VERSION="${TAG#v}"
API="http://192.168.8.17:3000/api/v1/repos/nick/incido"
APK_DEBUG="Incido-$VERSION-debug.apk"
+33
View File
@@ -522,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)
+13
View File
@@ -18,6 +18,19 @@ 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
+14 -16
View File
@@ -28,22 +28,20 @@ android {
applicationId = "org.incido.app"
minSdk = 26
targetSdk = 35
// v0.3.8.1: EMERGENCY hotfix — re-release of v0.3.8.0 with NO app-code
// changes (EMERGENCY slot non-zero = out-of-band hotfix).
// - Why: the release pipeline kept failing to publish builds. The
// release job now talks to the Gitea API over the LAN
// (http://192.168.8.17:3000) instead of the Cloudflare-fronted
// public address, which is where the upload timeouts came from.
// - The build ran on a runner whose toolchain/keystore cache was
// empty, so CI minted a NEW signing key (release.yml mints one
// when /var/lib/gitea-runner/work/release.jks is absent). Existing
// installs therefore CANNOT be upgraded in place — Android refuses
// the APK as a signature conflict, so users must export a backup,
// uninstall, and reinstall (allowBackup=false, so an uninstall
// takes their notes with it). Warning shipped in the release notes.
// - versionCode monotonic +1 from v0.3.8.0 (33).
versionCode = 34
versionName = "0.3.8.1"
// 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,27 @@ 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",
@@ -105,24 +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.",
),
),
// v0.3.8.1 push drops v0.3.5.1 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.1"
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,