Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f87ca17ded | ||
|
|
1d97376aef | ||
|
|
d9043db857 | ||
|
|
d45cb7c31e | ||
|
|
3d234f307e | ||
|
|
ffa821bf28 |
No files matched your search
@@ -38,3 +38,4 @@ Thumbs.db
|
||||
# Built APKs at the repo root (stamped with version — see Incido
|
||||
# Development Plan §11 for the release build procedure).
|
||||
incido-*.apk
|
||||
Incido-*.apk
|
||||
+11
-2
@@ -66,7 +66,16 @@ or your feature's manual verification steps.
|
||||
We use [Conventional Commits](https://www.conventionalcommits.org/).
|
||||
Per-version user-facing notes live in `PREVIOUS_HISTORY.md`
|
||||
(Development Plan §11.1) — the release CI attaches the matching section
|
||||
to each Gitea release automatically:
|
||||
to each Gitea release automatically. Write each note (paragraph or bullet)
|
||||
as **one complete line — do not hard-wrap it**: the CI copies the section
|
||||
verbatim, so manual line breaks ship as premature returns, and the release
|
||||
UI reflows the text for you. **From v0.4.2.0 on, every new release section
|
||||
must open with the standard backup-warning callout** — ask users to make
|
||||
certain they have a current backup (Settings → Backup & Restore → Export,
|
||||
plus the encryption-key export under Settings → Security) before
|
||||
installing the new version. This reminder ships with every release.
|
||||
|
||||
Commit types:
|
||||
|
||||
| Type | Use for |
|
||||
|------|---------|
|
||||
@@ -144,7 +153,7 @@ under GPL-3.0 before opening the PR.
|
||||
> fails immediately — there's a validator in `app/build.gradle.kts`.
|
||||
|
||||
1. Bump `versionCode` (+1) and `versionName` in `app/build.gradle.kts`.
|
||||
2. Update the Development Plan §10 history table with the new dot-name.
|
||||
2. Update the Development Plan §10 history table with the new dot-name, and give the release its `PREVIOUS_HISTORY.md` section — opening, as every release does from v0.4.2.0 on, with the standard backup-warning callout (users must back up before installing).
|
||||
3. Tag the commit: `git tag -s vX.Y.Z.W -m "vX.Y.Z.W — short summary"`.
|
||||
4. `./gradlew assembleDebug assembleRelease` — confirm both green.
|
||||
5. Upload `app/build/outputs/apk/release/app-release.apk` to Gitea Releases.
|
||||
|
||||
@@ -370,6 +370,10 @@ A short reference for AI assistants:
|
||||
|
||||
| Version | Date | Notes |
|
||||
|---------|------|-------|
|
||||
| 0.4.2.0 | 2026-09-23 | **Feature release — voice notes, with a maintenance pass folded in (Opus recording format + editor toolbar reorder).** **1. Voice notes.** New `NoteType.VOICE_NOTE` toggled by a mic button on the editor's bottom toolbar (`RECORD_AUDIO` requested on first tap into voice mode): `VoiceRecorder` (framework `MediaRecorder`) writes the take via `cacheDir/voice_rec/`; `VoiceNoteSection` pins a record/re-record card plus a `MediaPlayer`-backed player bar (play/pause, seek, elapsed/total) at the top of the body, with a Download action (MediaStore Downloads on API 29+, FileProvider share-sheet fallback on API 26–28). Takes ride the ordinary attachment pipeline (`PendingAttachment` → `NoteAttachment`) — encrypted at rest, included in backups, survive type changes; one take per note, re-recording replaces the old one. `Note.firstAudioAttachment` convenience; mic badge on cards; zero new dependencies. **2. Opus audio format (maintenance).** Takes record as Opus-in-Ogg (`.opus` — 32 kbps, single channel, 48 kHz) via `OutputFormat.OGG` + `AudioEncoder.OPUS` on API 29+ (the public-API floor for OGG output), keeping the previous AAC/MPEG-4 (`.m4a`, 96 kbps) path for API 26–28; `VoiceRecorder.recordedMimeType` propagates the actual container to the attachment mime (`audio/ogg`), display name (`Voice_*.opus`), playback cache file, MediaStore download mime and share-intent type. Opus frame size / encoder complexity are platform defaults — `MediaRecorder` exposes no knob (120 ms frames + complexity 10 would require bundled native libopus; deferred). Existing `.m4a` takes still play; no migration. **3. Editor toolbar reorder (maintenance).** Bottom action row is now Photo · Voice · Attach · Tasks · Shopping list, with the hashtag button justified flush right via a weighted `Spacer`, separated from the cluster; handlers, permission flows and tints unchanged. **4. Backup-warning convention.** From this version every release section opens with a ⚠️ back-up-before-installing callout (PREVIOUS_HISTORY.md header, §11.1, CONTRIBUTING release process, README upgrade callout). **Lockstep (§11.1).** versionCode 37→38, versionName 0.4.1.1→0.4.2.0, `SettingsViewModel.APP_VERSION` bumped, README intro + current-release line + smoke-test step, PREVIOUS_HISTORY.md section (backup callout first; feeds the release description + `Incido-0.4.2.0-changes.md` asset), `ReleaseNotes.RECENT` (v0.3.8.0 drops off the 5-entry tail). |
|
||||
| 0.4.1.1 | 2026-09-23 | **Emergency hotfix — two v0.4.1.0 editor regressions.** **1. Saved notes landed in Drafts.** `NoteEditorViewModel.save()` published the note but left `UiState.existing.isDraft = true`, so the editor's dispose-time `flushDraft()` immediately re-persisted the just-saved note as a draft — every confirmed note ended up in Drafts. The save path now adopts the published row into state (`isDraft = false`, current hashtags kept), letting `persistDraftNow()`'s already-published guard turn that flush into a no-op. **2. Enter on a shopping-list Price field wrapped the cursor to the Title.** A bare `ImeAction.Next` with no handler fell through to system focus traversal — price being the row's last field inside the LazyColumn wrapped focus all the way back to the Title; the field now passes `KeyboardActions(onNext = { onAddAfter() })`, matching Enter on the Product field (fresh row, cursor in its Product box). **Lockstep (§11.1).** versionCode 36→37, versionName "0.4.1.0"→"0.4.1.1", SettingsViewModel.APP_VERSION bumped, README current-release line + two smoke-test regression steps, PREVIOUS_HISTORY.md section (feeds the release description + `Incido-0.4.1.1-changes.md` asset), ReleaseNotes.RECENT (v0.3.8.1 drops off the 5-entry tail). |
|
||||
| 0.4.1.0 | 2026-09-23 | **Feature release — colour filters + auto-saved drafts, plus Trash & editor polish.** **1. Colour filters.** The drawer gains a horizontal five-swatch strip (Blue / Green / Amber / Red / Purple) between Favorites and Drafts — no labels, the colours are self-explanatory; selecting a swatch shows ONLY **active** notes of that colour (tagged and untagged eligible, trashed never — same rules as Favorites / Untagged), search narrows within the colour, re-tapping the selected swatch returns to Home. `NoteFilter` gains `ByColor` (+ `color:<NAME>` route parsing in `App.kt`); the repository gains `observeByColor` / `searchByColor` reusing the shared `decorate()` / `matchingNoteIds()` trash-exclusion path. **2. Auto-saved drafts.** New notes persist as drafts while being written: `Note.isDraft` (indexed ObjectBox property; mirrored in `BackupNote`, defaulted false for older backups), `NoteFilter.Drafts` (+ `drafts` route + drawer row) with repository `observeDrafts` / `searchDrafts`; `NoteEditorViewModel` runs a debounced signature-driven autosave with `flushDraft()` on back-navigation / dispose; drafts appear ONLY in the Drafts view until saved (then Home) or trashed (then Trash); an untitled draft is labelled by kind — "Task List — (draft)", "Shopping List — (draft)" — on cards and the editor bar via `NoteType.displayName` + `Note.UNTITLED` (display-only; stored content untouched). **3. Empty Trash.** Trash view shows a `DeleteForever` top-bar action whenever it holds notes, gated by a confirmation `AlertDialog`; `deleteAllTrashed()` cascades note rows + hashtag xrefs + attachment rows exactly like `delete()`. **4. Editor row rebuild.** `EditorLineField` unified on one `BasicTextField` with a hand-drawn 2 dp underline — the old two-branch design mixed M3 `TextField`'s 56 dp min container with compact fields, producing double-height rows; `ChecklistItemRow` moved `Alignment.Top`→`Alignment.CenterVertically` so checkbox / delete / +/- controls ride centred beside wrapping labels. versionCode 35→36, versionName "0.4.0.0"→"0.4.1.0", SettingsViewModel.APP_VERSION bumped in lockstep, README current-release line, PREVIOUS_HISTORY.md section, and the in-app What's New dialog (ReleaseNotes.RECENT — v0.3.7.0 drops off the 5-entry tail). |
|
||||
| 0.4.0.0 | 2026-09-18 | **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 (imported 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, and imported notes get fresh IDs. New `CarnetImporter` in `composeApp/data/backup` + entry point in the Settings screen/view model. versionCode 34→35, versionName "0.3.8.1"→"0.4.0.0", SettingsViewModel.APP_VERSION bumped in lockstep, README current-release line, PREVIOUS_HISTORY.md section, and the in-app What's New dialog (ReleaseNotes.RECENT — v0.3.6.0 drops off the 5-entry tail). |
|
||||
| 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. |
|
||||
@@ -435,7 +439,18 @@ A small Gradle task called `copyReleaseApks` (registered in
|
||||
line. **`PREVIOUS_HISTORY.md`** — append a new
|
||||
`## v<NEW_VERSION> — <DATE>` section at the top: friendly user-facing
|
||||
bullets, newest first (this file replaced the old README Changelog
|
||||
table). On tag push the release workflow runs
|
||||
table). **Write each note (paragraph or bullet) as one complete line —
|
||||
do not hard-wrap it:** the CI copies the section verbatim into the release
|
||||
description and the `Incido-<version>-changes.md` asset, so a manual line
|
||||
break ships as a premature return; the release UI reflows the text for you. **From v0.4.2.0 on, every new section
|
||||
must open with the standard backup-warning callout** (blockquote
|
||||
`> ⚠️ **Before installing:** ...`): ask users to make certain they
|
||||
have a current backup — Settings → Backup & Restore → Export, plus
|
||||
the encryption key export under Settings → Security — before
|
||||
installing the new version. The same reminder leads the matching
|
||||
ReleaseNotes.kt entry and repeats on the README front page; it ships
|
||||
with EVERY release from now on.
|
||||
On tag push the release workflow runs
|
||||
`scripts/ci/release-notes.py` and attaches that section to the Gitea
|
||||
release as its description **and** as an `Incido-<version>-changes.md`
|
||||
asset beside the APKs — so keep one section per released version and
|
||||
|
||||
+51
-54
@@ -1,61 +1,58 @@
|
||||
# Incido — Previous Release History
|
||||
|
||||
Reference archive of Incido's user-facing release history (formerly the
|
||||
README changelog table).
|
||||
Reference archive of Incido's user-facing release history (formerly the README changelog table).
|
||||
|
||||
Current downloads ship **with their own notes**: every release on the
|
||||
[Releases page](https://git.trevena.info/nick/incido/releases) carries its
|
||||
version's changelog — rendered in the release description and also
|
||||
attached beside the APKs as `Incido-<version>-changes.md`. The CI generates
|
||||
both from the matching section below via `scripts/ci/release-notes.py`
|
||||
at tag-build time.
|
||||
Current downloads ship **with their own notes**: every release on the [Releases page](https://git.trevena.info/nick/incido/releases) carries its version's changelog — rendered in the release description and also attached beside the APKs as `Incido-<version>-changes.md`. The CI generates both from the matching section below via `scripts/ci/release-notes.py` at tag-build time.
|
||||
|
||||
**Adding a release:** append a `## v<VERSION> — <DATE>` section at the
|
||||
top of this file (see Development Plan §11.1). Newest first; never delete
|
||||
or reorder older sections — the CI must find a section for whatever tag it
|
||||
builds, and hotfix retags can target any version. If a tag has no section,
|
||||
the release falls back to a plain "Release <tag>" description.
|
||||
**Adding a release:** append a `## v<VERSION> — <DATE>` section at the top of this file (see Development Plan §11.1). Newest first; never delete or reorder older sections — the CI must find a section for whatever tag it builds, and hotfix retags can target any version. If a tag has no section, the release falls back to a plain "Release <tag>" description. **Every new section must open with the standard backup-warning callout** (from v0.4.2.0 onwards): ask users to back up their data — Settings → Backup & Restore, plus their encryption key under Settings → Security — before installing the new version.
|
||||
|
||||
---
|
||||
|
||||
## v0.4.2.0 — 2026-09-23
|
||||
|
||||
> ⚠️ **Before installing:** please make certain you have a current backup of your data — Settings → Backup & Restore → Export, plus your encryption key from Settings → Security if encryption is on — then install the new version and restore if you need to. Every Incido release from now on will carry this same reminder.
|
||||
|
||||
New in this release: **voice notes**.
|
||||
|
||||
- **Record right inside a note.** The editor's bottom toolbar gained a mic button — first in the row, right after the camera. The whole toolbar is now laid out Photo · Voice · Attach · Tasks · Shopping list, with the hashtag button moved to the far right, separated from the others. Tap the mic (Incido asks for microphone access the first time) and the note grows a recording card at the top of its body, right above the text. Tap to record, tap stop — your take gets a proper media player: play / pause, a seek bar, elapsed and total time.
|
||||
- **Small, crisp recordings.** Takes are captured as Opus audio (`.opus` — 32 kbps, single channel): tiny files with clear speech. Devices on Android 8.x / 9 fall back to the previous AAC format automatically; playback and downloading work identically either way.
|
||||
- **The recording is part of the note.** Takes are stored with the note like any other attachment — encrypted at rest when encryption is on, and included in backups — and a download button on the player copies the file out to your device's Downloads folder when you need it (older devices get the share sheet, which saves to the same places).
|
||||
- **Still a normal note.** Voice notes keep the title, the text body, colours, tags, favourites, drafts and search; re-recording replaces the old take, tapping 🗑 removes it, and converting the note back to a plain text note leaves the recording in place as an ordinary attachment. Voice-note cards carry a small mic badge so you can spot them at a glance.
|
||||
- **No new engines on board.** Recording and playback use the Android framework's own media APIs — no new libraries, no network access: recordings never leave your device.
|
||||
|
||||
## v0.4.1.1 — 2026-09-23
|
||||
|
||||
Hotfix over v0.4.1.0 — two editor fixes, nothing else changed. Installing it over v0.4.1.0 is a normal in-place update.
|
||||
|
||||
- **Saved notes stay put.** In v0.4.1.0 every note you saved ended up in Drafts instead of Home — the editor still believed the note was a draft and quietly re-saved it as one when you left the screen. Saving now publishes the note properly: it goes to Home and leaves Drafts for good.
|
||||
- **Enter behaves in the price box.** In a shopping list, pressing Enter in a row's Price field jumped the cursor all the way back to the note title. It now works exactly like Enter in the product field: a fresh item row appears below, with the cursor ready in its Product box.
|
||||
|
||||
## v0.4.1.0 — 2026-09-23
|
||||
|
||||
New in this release: **colour filters**, **auto-saved drafts** and an **Empty Trash** button — plus a steadier editor.
|
||||
|
||||
- **Colour filters in the drawer.** A horizontal strip of five swatches — Blue, Green, Amber, Red and Purple — sits right under Favorites. Tap a swatch and the list shows ONLY your notes in that colour: untagged colour notes appear, tagged ones appear too, and a trashed note of that colour is never shown — the filter follows the same rules as Favorites and Untagged. Tap the selected swatch again to return to Home.
|
||||
- Search works inside colour views as well: whatever you type narrows the selected colour's notes, exactly like search does on Favorites.
|
||||
- **Auto-saved drafts.** A brand-new note now saves itself as a draft while you type — no save button needed, no lost work. If you back out or close the app before finishing, the note waits in the new Drafts row in the navigation drawer; open it again and you are exactly where you left off.
|
||||
- A draft never gets in your way: it stays out of Home, Favorites, tag views and search until you save the note, and an untitled draft introduces itself by its kind — "Task List — (draft)", "Shopping List — (draft)" — on its card and in the editor's title bar. Drafts ride along in encrypted backups, so a restore brings them back too.
|
||||
- **Empty Trash.** The Trash view gains an Empty Trash button whenever it holds notes. One tap — confirmed by a dialog first — permanently deletes every trashed note, attachments included.
|
||||
- **Steadier editor rows.** The to-do and shopping-list editors now render title, item and quantity fields at one even, underlined row height, so rows sit evenly instead of the tall/short mix before. Long task labels wrap inside their row instead of stretching it, and the checkbox, delete and +/- controls stay centred alongside however many lines the label takes.
|
||||
|
||||
## 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.
|
||||
|
||||
---
|
||||
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.
|
||||
> **⚠️ 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.
|
||||
- **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.
|
||||
- **Add-tag sheet suggestions fixed** — the nested-collect autocomplete pipeline never resumed past the first keystroke, so only "+ Create…" ever showed; rebuilt on `flatMapLatest`, existing tags now list immediately when the sheet opens and filter live per keystroke.
|
||||
- **Add-tag sheet suggestions fixed.** The nested-collect autocomplete pipeline never resumed past the first keystroke, so only "+ Create…" ever showed; rebuilt on `flatMapLatest`, existing tags now list immediately when the sheet opens and filter live per keystroke.
|
||||
|
||||
## v0.3.7.1 — 2026-08-30
|
||||
|
||||
@@ -71,7 +68,7 @@ notes are preserved and imported notes get fresh IDs.
|
||||
|
||||
## v0.3.6.2 — 2026-08-19
|
||||
|
||||
- **CI / release-pipeline tag.** — re-tag of v0.3.6.1 used to exercise the Gitea Actions release workflow (keystore minted on the release runner; debug + release APKs attached to the Gitea release). No app changes.
|
||||
- **CI / release-pipeline tag.** Re-tag of v0.3.6.1 used to exercise the Gitea Actions release workflow (keystore minted on the release runner; debug + release APKs attached to the Gitea release). No app changes.
|
||||
|
||||
## v0.3.6.1 — 2026-08-19
|
||||
|
||||
@@ -87,7 +84,7 @@ notes are preserved and imported notes get fresh IDs.
|
||||
## v0.3.5.1 — 2026-08-17
|
||||
|
||||
- **"Encrypted" badge now appears the moment you flip the switch.** A race in `EncryptionVerifier.checkNow()` could silently drop the post-migration verification, leaving cards without the badge until a second toggle; replaced with a serializing Mutex so every check runs in invocation order.
|
||||
- **"Encrypted" indicator is now a single lock icon next to the date** — consistent position on every card instead of a centred "lock + label" group at the bottom.
|
||||
- **"Encrypted" indicator is now a single lock icon next to the date.** Consistent position on every card instead of a centred "lock + label" group at the bottom.
|
||||
|
||||
## v0.3.5.0 — 2026-08-17
|
||||
|
||||
@@ -97,9 +94,9 @@ notes are preserved and imported notes get fresh IDs.
|
||||
|
||||
## v0.3.4.0 — 2026-08-17
|
||||
|
||||
- **Attachment indicator on note cards.** — a paperclip icon now appears on the right edge of every card that carries an attachment.
|
||||
- **Light-theme readability over image thumbnails.** — cards with a dark photo background now force light text/icon colours over the image so notes stay readable in Light mode.
|
||||
- **Auto-Lock "Immediately" no longer locks during file pickers.** — attaching a file, taking a photo, viewing an attachment, or exporting/importing a backup no longer destroys your in-progress note.
|
||||
- **Attachment indicator on note cards.** A paperclip icon now appears on the right edge of every card that carries an attachment.
|
||||
- **Light-theme readability over image thumbnails.** Cards with a dark photo background now force light text/icon colours over the image so notes stay readable in Light mode.
|
||||
- **Auto-Lock "Immediately" no longer locks during file pickers.** Attaching a file, taking a photo, viewing an attachment, or exporting/importing a backup no longer destroys your in-progress note.
|
||||
|
||||
## v0.3.3.8 — 2026-08-17
|
||||
|
||||
@@ -148,13 +145,13 @@ notes are preserved and imported notes get fresh IDs.
|
||||
- **At-rest encryption.** ObjectBox store is opened with a 32-byte AES-256 key wrapped by the Android Keystore; toggling the switch generates / deletes the key and surfaces a "Re-encrypting notes…" dialog.
|
||||
- **PIN lock + biometric.** 4–6 digit PIN (PBKDF2-hashed, 100k iters, constant-time compare) with optional fingerprint / face unlock; cold launch + auto-lock timeout gate.
|
||||
- **Backup / Import / Export.** JSON codec with Base64 attachment bytes; encrypted variant uses AES-256-GCM + PBKDF2(passphrase, 200k iters) with a Generate button + Copy to clipboard. Passphrase policy: 12–32 chars, ≥1 digit, ≥1 special.
|
||||
- **Release notes dialog.** — tap the version number on the About card. Adds `USE_BIOMETRIC` + `USE_FINGERPRINT` permissions (still no INTERNET).
|
||||
- **Release notes dialog.** Tap the version number on the About card. Adds `USE_BIOMETRIC` + `USE_FINGERPRINT` permissions (still no INTERNET).
|
||||
|
||||
## v0.3.1.2 — 2026-08-15
|
||||
|
||||
- **Three v0.3.1.1 issues fixed.** **card thumbnails are actually visible now** — the v0.3.1.1 layout had the thumbnail Image as a sibling of the Card, so the Card's opaque `containerColor` was drawn on top and the image was completely hidden; the architecture is restructured so the Image + dark scrim live INSIDE the Card, and `containerColor = Color.Transparent` when a thumbnail is present (plain notes still get the existing tinted/surface background).
|
||||
- **Camera photos honour EXIF orientation** — `NoteRepositoryImpl.normalizeImageOrientation(bytes)` runs at storage time inside `addAttachment` (guarded `if (mimeType.startsWith("image/"))`); reads EXIF `Orientation`, rotates the bitmap, re-encodes as JPEG quality 92, and stores the corrected bytes so every render path (editor thumbnail, card thumbnail, full-screen viewer) sees the photo the right way up.
|
||||
- **Non-image attachments open in the system viewer** — `AttachmentThumbnail.onClick` now branches on `isImage`: image taps still go to the in-app full-screen viewer; non-image taps write the bytes to a `cacheDir` temp file, get a `FileProvider` URI, and launch `Intent.ACTION_VIEW` with `FLAG_GRANT_READ_URI_PERMISSION` (the previous unconditional viewer path silently failed for PDFs/MP3s/etc. with a stuck "Loading…"). `file_paths.xml` already exposes `cacheDir` via `<cache-path>`, so no manifest change was needed. Attaching arbitrary file types from the paperclip icon was already shipped in v0.3.1.1 (the `*/*` intent filters) — no code change here, just called out so it's clear what was already in place.
|
||||
- **Three v0.3.1.1 issues fixed.** **card thumbnails are actually visible now.** The v0.3.1.1 layout had the thumbnail Image as a sibling of the Card, so the Card's opaque `containerColor` was drawn on top and the image was completely hidden; the architecture is restructured so the Image + dark scrim live INSIDE the Card, and `containerColor = Color.Transparent` when a thumbnail is present (plain notes still get the existing tinted/surface background).
|
||||
- **Camera photos honour EXIF orientation.** `NoteRepositoryImpl.normalizeImageOrientation(bytes)` runs at storage time inside `addAttachment` (guarded `if (mimeType.startsWith("image/"))`); reads EXIF `Orientation`, rotates the bitmap, re-encodes as JPEG quality 92, and stores the corrected bytes so every render path (editor thumbnail, card thumbnail, full-screen viewer) sees the photo the right way up.
|
||||
- **Non-image attachments open in the system viewer.** `AttachmentThumbnail.onClick` now branches on `isImage`: image taps still go to the in-app full-screen viewer; non-image taps write the bytes to a `cacheDir` temp file, get a `FileProvider` URI, and launch `Intent.ACTION_VIEW` with `FLAG_GRANT_READ_URI_PERMISSION` (the previous unconditional viewer path silently failed for PDFs/MP3s/etc. with a stuck "Loading…"). `file_paths.xml` already exposes `cacheDir` via `<cache-path>`, so no manifest change was needed. Attaching arbitrary file types from the paperclip icon was already shipped in v0.3.1.1 (the `*/*` intent filters) — no code change here, just called out so it's clear what was already in place.
|
||||
|
||||
## v0.3.1.1 — 2026-08-15
|
||||
|
||||
@@ -162,10 +159,10 @@ notes are preserved and imported notes get fresh IDs.
|
||||
|
||||
## v0.3.1.0 — 2026-08-15
|
||||
|
||||
- **Context-aware search.** — on the Favorites and Untagged pages, the search icon is now visible and a typed query intersects with the active filter (search only favourites on Favorites, only untagged notes on Untagged). On Home, search spans everything.
|
||||
- **Photo / File attachments.** — the editor now has Camera (camera icon) and Attach File (paperclip icon) buttons. Photos are captured via `MediaStore.ACTION_IMAGE_CAPTURE` (with a transient `FileProvider` outbox; bytes live in the database, the temp file is deleted) and files via `ACTION_OPEN_DOCUMENT`. Attachments are stored as `ByteArray` columns inside ObjectBox — no filesystem paths to manage. Each note's attachments show up as a thumbnail strip in the editor with a ✕ in the top-right corner to remove. Tapping a thumbnail opens a full-screen viewer with pinch-to-zoom + pan (`Modifier.transformable`) and a close button.
|
||||
- **Card thumbnails.** — notes with image attachments show the first image as a (alpha-blended, scrimmed) background on the list card.
|
||||
- **Share-into.** — the app accepts `ACTION_SEND` (text + image) and `ACTION_SEND_MULTIPLE` (multiple images) from other apps. Inbound bytes are copied into a process-singleton `SharedIntentBuffer` and pre-filled into a new-note editor. Adds the `CAMERA` permission — still no `INTERNET`, still fully offline.
|
||||
- **Context-aware search.** On the Favorites and Untagged pages, the search icon is now visible and a typed query intersects with the active filter (search only favourites on Favorites, only untagged notes on Untagged). On Home, search spans everything.
|
||||
- **Photo / File attachments.** The editor now has Camera (camera icon) and Attach File (paperclip icon) buttons. Photos are captured via `MediaStore.ACTION_IMAGE_CAPTURE` (with a transient `FileProvider` outbox; bytes live in the database, the temp file is deleted) and files via `ACTION_OPEN_DOCUMENT`. Attachments are stored as `ByteArray` columns inside ObjectBox — no filesystem paths to manage. Each note's attachments show up as a thumbnail strip in the editor with a ✕ in the top-right corner to remove. Tapping a thumbnail opens a full-screen viewer with pinch-to-zoom + pan (`Modifier.transformable`) and a close button.
|
||||
- **Card thumbnails.** Notes with image attachments show the first image as a (alpha-blended, scrimmed) background on the list card.
|
||||
- **Share-into.** The app accepts `ACTION_SEND` (text + image) and `ACTION_SEND_MULTIPLE` (multiple images) from other apps. Inbound bytes are copied into a process-singleton `SharedIntentBuffer` and pre-filled into a new-note editor. Adds the `CAMERA` permission — still no `INTERNET`, still fully offline.
|
||||
|
||||
## v0.3.0.5 — 2026-08-15
|
||||
|
||||
|
||||
@@ -6,25 +6,41 @@ 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.1** release: a single-user, offline
|
||||
This repository contains the **v0.4.2.0** 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
|
||||
web, Trash (soft delete with Restore / permanent delete), at-rest
|
||||
running total, voice notes with an in-app media player and downloadable
|
||||
recordings, colour-coded notes with per-colour swatch filters,
|
||||
auto-saved drafts, photo and file attachments, share-into from other
|
||||
apps and the web, importing notes from third-party apps (Carnet /
|
||||
QuickNote `.zip` exports) directly on-device, Trash (soft delete with
|
||||
Restore / permanent delete / one-tap Empty Trash), at-rest
|
||||
AES-256-GCM encryption with screenshot blocking, PIN / biometric lock,
|
||||
encrypted backup and restore, and an exportable encryption key for
|
||||
device migrations. The architecture is multi-module Android today and
|
||||
is structured so iOS / Desktop ports can happen later without UI
|
||||
rewrites.
|
||||
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.1 — full release notes ship **on its entry on
|
||||
the [Releases page](https://git.trevena.info/nick/incido/releases)**.
|
||||
**Current release:** v0.4.2.0 (voice notes — a mic button turns any note
|
||||
into a recordable voice note with a built-in media player; recordings are
|
||||
compact Opus files (32 kbps, mono) stored with the note and downloadable
|
||||
to the device; the editor toolbar is reordered Photo · Voice · Attach ·
|
||||
Tasks · Shopping list with the hashtag button flush right) —
|
||||
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.
|
||||
> **Back up before every update:** from v0.4.2.0 onwards, every release
|
||||
> asks the same of you — **export a backup first** (Settings → Backup &
|
||||
> Restore → Export, plus your encryption key from Settings → Security if
|
||||
> you use encryption) before installing a new version. Incido is offline
|
||||
> by design and doesn't use Android's automatic backup, so a current
|
||||
> backup is your only safety net for any update.
|
||||
|
||||
> **Upgrading from v0.3.8.0 or earlier?** Releases are signed with a **new CI
|
||||
> key introduced in v0.3.8.1**, so Android won't update an old install in place
|
||||
> — it reports a signature conflict. **Export a backup from Settings → Backup
|
||||
> first** (and your encryption key from Settings → Security if you use
|
||||
> encryption), then uninstall and install fresh — Incido doesn't use Android's
|
||||
> automatic backup, so uninstalling deletes your notes. **Upgrading from
|
||||
> v0.3.8.1 onwards is a normal in-place update.**
|
||||
|
||||
> **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;
|
||||
@@ -172,13 +188,20 @@ After the first push:
|
||||
|
||||
```
|
||||
[ ] Launch app — "Incido" title centred, hamburger top-left
|
||||
[ ] Tap hamburger → drawer slides in with Home / Favorites / Untagged + divider + Recent tags
|
||||
[ ] Tap hamburger → drawer slides in with Home / Favorites / colour-swatch strip (Blue·Green·Amber·Red·Purple) / Drafts / Untagged / Trash / Settings + divider + Recent tags
|
||||
[ ] Tap "Favorites" → list shows only starred notes
|
||||
[ ] Tap "Untagged" → list shows only notes with zero hashtags
|
||||
[ ] Tap a colour swatch (e.g. Blue) → list shows only ACTIVE notes of that colour; untagged ones appear, trashed ones never; search narrows within the colour; tapping the selected swatch again returns to Home
|
||||
[ ] Start a new note, type, then back out without saving → it lands under "Drafts"; an untitled draft is titled "Task List — (draft)" / "Shopping List — (draft)"; reopening it restores the content; saving it moves it to Home
|
||||
[ ] Save a note (new or draft) → it appears on Home and NOT in Drafts — saving exits draft mode for good (v0.4.1.1 regression)
|
||||
[ ] Shopping list: press Enter in a row's Price field → a fresh row appears below with the cursor in its Product field, not back in the Title (v0.4.1.1 fix)
|
||||
[ ] Tap the mic button in a note's bottom toolbar → grant microphone access → a recording card appears above the text field; tap it, record, stop → a media player shows with play/pause, seek and elapsed/total time (v0.4.2.0)
|
||||
[ ] Voice note: tap the download button on the player → the recording lands in the system Downloads folder; the card also appears in the attachment strip; converting the note back to text keeps the recording (v0.4.2.0)
|
||||
[ ] Tap a recent hashtag → list filters to that tag
|
||||
[ ] Tap "Trash" → list shows only soft-deleted notes
|
||||
[ ] Delete a note → it disappears from Home/search/tag/Favorites and appears in Trash
|
||||
[ ] Trash card overflow → "Restore" returns the note; "Delete permanently" destroys it
|
||||
[ ] Trash holds notes → "Empty Trash" (∞-forever icon) appears in the top bar → confirm dialog → everything in Trash is permanently deleted
|
||||
[ ] Tap "Home" → back to all active notes
|
||||
[ ] Open a note → chip row above text field shows current tags (empty placeholder if none)
|
||||
[ ] Tap "#" icon → sheet opens, type "wo" → suggestions filter
|
||||
|
||||
+30
-14
@@ -28,20 +28,36 @@ android {
|
||||
applicationId = "org.incido.app"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
// 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"
|
||||
// v0.4.1.1: EMERGENCY hotfix — two editor regressions shipped
|
||||
// in v0.4.1.0. (1) Saving a note landed it in Drafts: the save
|
||||
// path published the note but left UiState.existing.isDraft =
|
||||
// true, so the editor's dispose-time flushDraft() immediately
|
||||
// re-persisted it as a draft; the state now adopts the
|
||||
// published row (isDraft = false), letting persistDraftNow()'s
|
||||
// already-published guard make the flush a no-op. (2) Enter on
|
||||
// a shopping-list Price field fell through to system focus
|
||||
// traversal and wrapped the cursor back to the Title; it now
|
||||
// wires KeyboardActions(onNext = onAddAfter) like the Product
|
||||
// field — Enter adds a fresh row with the cursor in its
|
||||
// Product box.
|
||||
// - versionCode monotonic +1 from v0.4.1.0 (36).
|
||||
// v0.4.2.0: FEATURE release — voice notes. New note type (mic
|
||||
// button on the editor's bottom toolbar toggles it; the toolbar
|
||||
// is reordered Photo · Voice · Attach · Tasks · Shopping list
|
||||
// with the hashtag button pushed flush right): a record /
|
||||
// re-record card plus a MediaPlayer-backed player bar (play/
|
||||
// pause, seek, elapsed/total) pinned at the top of the body,
|
||||
// with a Download action copying the take to the system
|
||||
// Downloads folder (share-sheet fallback on API 26–28). Takes
|
||||
// record as Opus in Ogg (.opus, 32 kbps, mono, 48 kHz) on
|
||||
// API 29+; API 26–28 keeps the AAC/MP4 fallback. Audio
|
||||
// rides the ordinary attachment pipeline — encrypted at rest,
|
||||
// in backups, survives type changes. RECORD_AUDIO permission
|
||||
// added; zero new dependencies (framework MediaRecorder /
|
||||
// MediaPlayer only).
|
||||
// - versionCode monotonic +1 from v0.4.1.1 (37).
|
||||
versionCode = 38
|
||||
versionName = "0.4.2.0"
|
||||
}
|
||||
|
||||
// --- Signing ---
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
database and are never uploaded anywhere.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<!-- v0.4.2.0: RECORD_AUDIO for voice notes. Recordings are stored
|
||||
as ordinary audio attachments inside the ObjectBox database
|
||||
(at-rest encryption applies) and never leave the device —
|
||||
still no INTERNET, no analytics, no cloud. -->
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<!-- v0.3.2.0: biometric (fingerprint / face) unlock for the
|
||||
app-lock PIN alternative. USE_BIOMETRIC is the modern
|
||||
permission; USE_FINGERPRINT is the pre-Android-10 alias and
|
||||
@@ -21,6 +26,12 @@
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
<!-- v0.4.2.0: voice notes need a mic; devices without one simply
|
||||
never see the recorder UI light up (the permission request
|
||||
fails gracefully). -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.microphone"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.fingerprint"
|
||||
android:required="false" />
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.incido.compose.ui.settings.auth.PinChangeScreen
|
||||
import org.incido.compose.ui.settings.auth.PinEntryScreen
|
||||
import org.incido.compose.ui.settings.auth.PinSetupScreen
|
||||
import org.incido.compose.ui.theme.IncidoTheme
|
||||
import org.incido.domain.model.NoteColor
|
||||
import org.incido.domain.model.NoteFilter
|
||||
import org.incido.domain.repository.NoteRepository
|
||||
|
||||
@@ -61,8 +62,13 @@ private fun String.toNoteFilter(): NoteFilter = when {
|
||||
this == "home" -> NoteFilter.Home
|
||||
this == "favorites" -> NoteFilter.Favorites
|
||||
this == "untagged" -> NoteFilter.Untagged
|
||||
this == "drafts" -> NoteFilter.Drafts
|
||||
this == "trash" -> NoteFilter.Trash
|
||||
startsWith("tag:") -> NoteFilter.ByTag(this.removePrefix("tag:"))
|
||||
startsWith("color:") -> NoteColor.values()
|
||||
.firstOrNull { it.name == this.removePrefix("color:") }
|
||||
?.let { NoteFilter.ByColor(it) }
|
||||
?: NoteFilter.Home
|
||||
else -> NoteFilter.Home
|
||||
}
|
||||
|
||||
|
||||
@@ -126,10 +126,12 @@ data class BackupNote(
|
||||
val attachments: List<BackupAttachment> = emptyList(),
|
||||
/** Preserve soft-delete state; defaults to false for older backups. */
|
||||
val isTrashed: Boolean = false,
|
||||
/** Preserve draft state; defaults to false for older backups. */
|
||||
val isDraft: Boolean = false,
|
||||
/**
|
||||
* v0.3.8.0 — serialised as the [org.incido.domain.model.NoteType]
|
||||
* enum name ("TEXT" / "TASK_LIST" / "SHOPPING_LIST"). Defaulted so
|
||||
* pre-v0.3.8.0 backup files import as plain-text notes.
|
||||
* enum name ("TEXT" / "TASK_LIST" / "SHOPPING_LIST" / "VOICE_NOTE").
|
||||
* Defaulted so pre-v0.3.8.0 backup files import as plain-text notes.
|
||||
*/
|
||||
val noteType: String = "TEXT",
|
||||
)
|
||||
@@ -163,6 +165,7 @@ private suspend fun Note.toBackup(repository: NoteRepository): BackupNote {
|
||||
isFavorite = isFavorite,
|
||||
color = color.name,
|
||||
isTrashed = isTrashed,
|
||||
isDraft = isDraft,
|
||||
noteType = type.name,
|
||||
hashtags = hashtags,
|
||||
attachments = backups,
|
||||
@@ -180,6 +183,7 @@ private fun Note.toBackup(): BackupNote = BackupNote(
|
||||
isFavorite = isFavorite,
|
||||
color = color.name,
|
||||
isTrashed = isTrashed,
|
||||
isDraft = isDraft,
|
||||
noteType = type.name,
|
||||
hashtags = hashtags,
|
||||
attachments = emptyList(),
|
||||
@@ -193,6 +197,7 @@ private fun BackupNote.toDomain(): Note = Note(
|
||||
isFavorite = isFavorite,
|
||||
color = runCatching { NoteColor.valueOf(color) }.getOrDefault(NoteColor.NONE),
|
||||
isTrashed = isTrashed,
|
||||
isDraft = isDraft,
|
||||
type = runCatching { NoteType.valueOf(noteType) }.getOrDefault(NoteType.TEXT),
|
||||
hashtags = hashtags,
|
||||
// Attachments are inserted separately by importSnapshot so they
|
||||
|
||||
@@ -25,6 +25,89 @@ object ReleaseNotes {
|
||||
* Append a new entry on top each release.
|
||||
*/
|
||||
val RECENT: List<ReleaseNote> = listOf(
|
||||
ReleaseNote(
|
||||
version = "0.4.2.0",
|
||||
date = "2026-09-23",
|
||||
bullets = listOf(
|
||||
"Before you update: please make certain you have a " +
|
||||
"current backup — Settings → Backup & Restore → " +
|
||||
"Export (plus your encryption key under Settings → " +
|
||||
"Security if encryption is on) — before installing " +
|
||||
"this version. Every future release will remind " +
|
||||
"you the same way.",
|
||||
"Voice notes: the editor's bottom toolbar gained a mic " +
|
||||
"button, right after the camera — the row is now " +
|
||||
"Photo · Voice · Attach · Tasks · Shopping list, " +
|
||||
"with the hashtag button moved to the far right. " +
|
||||
"Tap it and the note grows a recording card " +
|
||||
"at the top of its body — tap record, stop when " +
|
||||
"you're done, and your take gets a media player with " +
|
||||
"play / pause, a seek bar, and elapsed / total time.",
|
||||
"Recordings are captured as compact Opus audio " +
|
||||
"(.opus files \u2014 32 kbps, single channel): tiny " +
|
||||
"files, clear speech. Phones on Android 8.x / 9 " +
|
||||
"fall back to the old AAC format automatically.",
|
||||
"Your recording is saved with the note like any other " +
|
||||
"attachment — encrypted at rest when encryption " +
|
||||
"is on, riding along in backups — and a download " +
|
||||
"button copies it out to the system Downloads folder " +
|
||||
"when you need the file itself.",
|
||||
"Voice notes are still normal notes: title, text body, " +
|
||||
"colours, tags, favourites, drafts, and search all " +
|
||||
"work as before. Re-recording replaces the old take; " +
|
||||
"converting back to a text note keeps the recording " +
|
||||
"as an ordinary attachment.",
|
||||
"Voice note cards carry a mic badge, and the microphone " +
|
||||
"permission is only asked for on the first tap into " +
|
||||
"voice mode — recordings never leave the device.",
|
||||
),
|
||||
),
|
||||
ReleaseNote(
|
||||
version = "0.4.1.1",
|
||||
date = "2026-09-23",
|
||||
bullets = listOf(
|
||||
"Saved notes stay put: in v0.4.1.0 every note you " +
|
||||
"saved ended up in Drafts instead of Home \u2014 " +
|
||||
"the editor still believed it was a draft and " +
|
||||
"quietly re-saved it as one when you left the " +
|
||||
"screen. Saving now publishes properly: the note " +
|
||||
"goes to Home and leaves Drafts for good.",
|
||||
"Enter behaves in the price box: in a shopping list, " +
|
||||
"Enter in a row's Price field used to jump the " +
|
||||
"cursor back to the note title \u2014 it now works " +
|
||||
"like Enter in the product field: a fresh row " +
|
||||
"appears below, cursor ready in its Product box.",
|
||||
),
|
||||
),
|
||||
ReleaseNote(
|
||||
version = "0.4.1.0",
|
||||
date = "2026-09-23",
|
||||
bullets = listOf(
|
||||
"Colour filters in the drawer: a strip of five swatches " +
|
||||
"\u2014 Blue, Green, Amber, Red, Purple \u2014 sits " +
|
||||
"right under Favorites. Tap one and the list shows " +
|
||||
"ONLY notes of that colour; tap it again for Home.",
|
||||
"Colour views follow the Favorites / Untagged rules: " +
|
||||
"trashed notes never show, untagged ones do, and " +
|
||||
"search narrows within the selected colour.",
|
||||
"Auto-saved drafts: a new note saves itself while you " +
|
||||
"type, so nothing is ever lost \u2014 an unfinished " +
|
||||
"note waits in the new Drafts drawer row, and opening " +
|
||||
"it again picks up exactly where you stopped.",
|
||||
"An untitled draft names itself after its kind \u2014 " +
|
||||
"\"Task List \u2014 (draft)\", \"Shopping List \u2014 " +
|
||||
"(draft)\" \u2014 on its card and in the editor bar. " +
|
||||
"Drafts survive encrypted backup and restore too.",
|
||||
"Empty Trash: a one-tap button appears whenever the " +
|
||||
"Trash holds notes \u2014 a confirmation dialog " +
|
||||
"stands between that tap and permanently deleting " +
|
||||
"every trashed note, attachments included.",
|
||||
"Editor rows rebuilt: title, item and quantity fields " +
|
||||
"share one even underlined height, long checklist " +
|
||||
"labels wrap instead of stretching the row, and " +
|
||||
"checkbox / +/- controls stay centred alongside.",
|
||||
),
|
||||
),
|
||||
ReleaseNote(
|
||||
version = "0.4.0.0",
|
||||
date = "2026-09-18",
|
||||
@@ -46,27 +129,6 @@ object ReleaseNotes {
|
||||
"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",
|
||||
@@ -94,38 +156,6 @@ object ReleaseNotes {
|
||||
"only \"+ Create\\u2026\" ever showed).",
|
||||
),
|
||||
),
|
||||
ReleaseNote(
|
||||
version = "0.3.7.1",
|
||||
date = "2026-08-30",
|
||||
bullets = listOf(
|
||||
"Cleaner Add / Edit screen: camera, attach-file, and " +
|
||||
"add-tag moved out of the crowded title bar into a " +
|
||||
"bottom action row — the title and remaining buttons " +
|
||||
"now fit comfortably on every screen.",
|
||||
"Fixed a false error message that flashed whenever you " +
|
||||
"opened a saved image in the full-screen viewer.",
|
||||
"Search now focuses automatically when opened and shows " +
|
||||
"a clear (✕) button while you type.",
|
||||
"Long tag lists in the navigation drawer now scroll " +
|
||||
"instead of being cut off at the bottom.",
|
||||
"The add-tag sheet opens with the keyboard already up.",
|
||||
"New app icon: a flatter, cleaner take on the shield " +
|
||||
"and pen-nib artwork.",
|
||||
),
|
||||
),
|
||||
ReleaseNote(
|
||||
version = "0.3.7.0",
|
||||
date = "2026-08-20",
|
||||
bullets = listOf(
|
||||
"Trash / soft delete. Deleting a note now moves it to a new " +
|
||||
"Trash section in the navigation drawer instead of " +
|
||||
"destroying it immediately \u2014 it disappears from Home, " +
|
||||
"Favorites, Untagged, tag views, and ordinary search.",
|
||||
"Inside Trash, each note's menu offers Restore (puts it back " +
|
||||
"where it was) or Delete permanently (destroys it for " +
|
||||
"good, including attachments).",
|
||||
),
|
||||
),
|
||||
// v0.4.0.0 push drops v0.3.6.0 off the "5 most recent" tail.
|
||||
// v0.4.2.0 push drops v0.3.7.1 off the "5 most recent" tail.
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
package org.incido.compose.ui.drawer
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@@ -11,7 +18,9 @@ import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.icons.filled.LabelOff
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Drafts
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.filled.Tag
|
||||
@@ -25,17 +34,24 @@ import androidx.compose.material3.NavigationDrawerItemDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import org.incido.compose.ui.theme.AllNoteColors
|
||||
import org.incido.compose.ui.theme.toComposeColor
|
||||
import org.incido.domain.model.HashtagUsage
|
||||
import org.incido.domain.model.NoteColor
|
||||
import org.incido.domain.model.NoteFilter
|
||||
|
||||
/**
|
||||
* Left-side navigation drawer. Top section has five fixed entries
|
||||
* (Home / Favorites / Untagged / Trash / Settings); a `HorizontalDivider`; then
|
||||
* Left-side navigation drawer. Top section has the fixed entries
|
||||
* (Home / Favorites / the colour-swatch strip / Drafts / Untagged /
|
||||
* Trash / Settings); a `HorizontalDivider`; then
|
||||
* a live scrollable list of the user's most-recently-used hashtags.
|
||||
*
|
||||
* Tapping a filter entry calls [onSelectFilter]; tapping Settings
|
||||
@@ -44,6 +60,16 @@ import org.incido.domain.model.NoteFilter
|
||||
*
|
||||
* v0.3.2.0 — Settings is a new entry directly underneath "Untagged"
|
||||
* with its own divider for visual separation.
|
||||
*
|
||||
* Colour filters sit between "Favorites" and "Drafts" as one
|
||||
* horizontal strip of swatches — the colours are self-explanatory, so
|
||||
* there are no labels. Selecting one shows ONLY active notes of that
|
||||
* colour — trashed notes never appear, untagged ones do (see
|
||||
* NoteFilter.ByColor); tapping the selected swatch again returns to
|
||||
* Home.
|
||||
*
|
||||
* "Drafts" lists auto-saved new notes (see Note.isDraft) — a new note
|
||||
* is persisted automatically while it is being written.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -82,6 +108,64 @@ fun IncidoDrawer(
|
||||
onClick = { onSelectFilter(NoteFilter.Favorites) },
|
||||
icon = { Icon(Icons.Filled.Star, contentDescription = null) },
|
||||
)
|
||||
// Colour filters: one horizontal strip of swatches under
|
||||
// Favorites (NONE is not offered; the colours are
|
||||
// self-explanatory, so there are no labels). Each shows
|
||||
// ONLY active notes of that colour — trashed notes never
|
||||
// appear, untagged ones do. Tapping the selected swatch
|
||||
// again returns to Home.
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 6.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(
|
||||
space = 14.dp,
|
||||
alignment = Alignment.CenterHorizontally,
|
||||
),
|
||||
) {
|
||||
AllNoteColors.filter { it != NoteColor.NONE }.forEach { color ->
|
||||
val selected = currentFilter == NoteFilter.ByColor(color)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(30.dp)
|
||||
.clip(CircleShape)
|
||||
.background(color.toComposeColor())
|
||||
.then(
|
||||
if (selected) {
|
||||
Modifier.border(
|
||||
width = 3.dp,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
shape = CircleShape,
|
||||
)
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
)
|
||||
.clickable {
|
||||
onSelectFilter(
|
||||
if (selected) NoteFilter.Home
|
||||
else NoteFilter.ByColor(color),
|
||||
)
|
||||
},
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
if (selected) {
|
||||
Icon(
|
||||
Icons.Filled.Check,
|
||||
contentDescription = "${color.label} filter selected",
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = Color.White,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NavigationDrawerItem(
|
||||
label = { Text("Drafts") },
|
||||
selected = currentFilter == NoteFilter.Drafts,
|
||||
onClick = { onSelectFilter(NoteFilter.Drafts) },
|
||||
icon = { Icon(Icons.Filled.Drafts, contentDescription = null) },
|
||||
)
|
||||
NavigationDrawerItem(
|
||||
label = { Text("Untagged") },
|
||||
selected = currentFilter == NoteFilter.Untagged,
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.incido.compose.ui.editor
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
@@ -24,7 +25,6 @@ import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.ime
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -37,6 +37,8 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
@@ -49,6 +51,7 @@ import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Description
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.Mic
|
||||
import androidx.compose.material.icons.filled.ShoppingBasket
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.filled.Tag
|
||||
@@ -71,12 +74,11 @@ import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SuggestionChip
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -88,10 +90,14 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.onFocusEvent
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.painter.BitmapPainter
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
@@ -103,6 +109,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
@@ -232,6 +239,39 @@ fun NoteEditorScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// v0.4.2.0 — voice notes. RECORD_AUDIO is requested the first time
|
||||
// the user toggles the mic mode; on grant the note converts. The
|
||||
// grant state is checked LIVE on every tap (a revoke from Settings
|
||||
// mid-session must not slip through a cached flag).
|
||||
val micPermissionLauncher = rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.RequestPermission()
|
||||
) { granted ->
|
||||
if (granted) {
|
||||
viewModel.convertTo(NoteType.VOICE_NOTE)
|
||||
} else {
|
||||
Toast.makeText(ctx, "Microphone permission denied", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
fun micPermissionGranted(): Boolean =
|
||||
ContextCompat.checkSelfPermission(
|
||||
ctx,
|
||||
Manifest.permission.RECORD_AUDIO,
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
fun toggleVoiceMode() {
|
||||
if (state.type == NoteType.VOICE_NOTE) {
|
||||
// Toggling back needs no mic at all — the take survives as
|
||||
// an ordinary attachment.
|
||||
viewModel.convertTo(NoteType.VOICE_NOTE)
|
||||
return
|
||||
}
|
||||
if (micPermissionGranted()) {
|
||||
viewModel.convertTo(NoteType.VOICE_NOTE)
|
||||
} else {
|
||||
micPermissionLauncher.launch(Manifest.permission.RECORD_AUDIO)
|
||||
}
|
||||
}
|
||||
|
||||
fun launchCamera() {
|
||||
val (uri, _) = createTempCameraUri(ctx)
|
||||
if (uri == null) {
|
||||
@@ -271,11 +311,25 @@ fun NoteEditorScreen(
|
||||
}
|
||||
|
||||
fun tryClose() {
|
||||
// Drafts (new notes and draft editing) autosave every edit, so
|
||||
// leaving is always lossless: flush any in-flight change and pop
|
||||
// — no "Discard changes?" prompt.
|
||||
if (viewModel.isDraftFlow) {
|
||||
viewModel.flushDraft()
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
if (isDirty()) showDiscardDialog = true else onClose()
|
||||
}
|
||||
|
||||
BackHandler(enabled = true) { tryClose() }
|
||||
|
||||
// Any other exit path (rotation, nav teardown) also flushes pending
|
||||
// draft edits immediately.
|
||||
DisposableEffect(viewModel) {
|
||||
onDispose { viewModel.flushDraft() }
|
||||
}
|
||||
|
||||
if (showDiscardDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showDiscardDialog = false },
|
||||
@@ -308,7 +362,11 @@ fun NoteEditorScreen(
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = if (state.isEditing) "Edit note" else "New note",
|
||||
text = when {
|
||||
state.isDraft -> draftBarTitle(state)
|
||||
state.isEditing -> "Edit note"
|
||||
else -> "New note"
|
||||
},
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
@@ -392,7 +450,35 @@ fun NoteEditorScreen(
|
||||
// field whenever the note is a task / shopping list; the
|
||||
// rows live in NoteEditorUiState.items and the view-model
|
||||
// keeps `content` synchronised with their serialisation.
|
||||
if (state.type == NoteType.TEXT) {
|
||||
// v0.4.2.0 — voice recorder / media-player card pinned at
|
||||
// the very top of the note body, directly above the text
|
||||
// field (which keeps working exactly like the plain-text
|
||||
// editor: title = first line).
|
||||
if (state.type == NoteType.VOICE_NOTE) {
|
||||
val voicePending = state.pendingAttachments
|
||||
.lastOrNull { it.mimeType.startsWith("audio/") }
|
||||
val voicePersisted = state.attachments.lastOrNull { it.isAudio }
|
||||
VoiceNoteSection(
|
||||
voicePending = voicePending,
|
||||
voicePendingBytes = voicePending?.let {
|
||||
state.pendingAttachmentBytes[it.tempId]
|
||||
},
|
||||
voicePersisted = voicePersisted,
|
||||
repository = repository,
|
||||
hasMicPermission = { micPermissionGranted() },
|
||||
onRequestPermission = {
|
||||
micPermissionLauncher.launch(Manifest.permission.RECORD_AUDIO)
|
||||
},
|
||||
onTakeRecorded = viewModel::setVoiceRecording,
|
||||
onDeleteTake = {
|
||||
voicePending?.let { viewModel.removePendingAttachment(it.tempId) }
|
||||
?: voicePersisted?.let { viewModel.deletePersistedAttachment(it.id) }
|
||||
},
|
||||
securityManager = securityManager,
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
)
|
||||
}
|
||||
if (state.type == NoteType.TEXT || state.type == NoteType.VOICE_NOTE) {
|
||||
OutlinedTextField(
|
||||
value = state.content,
|
||||
onValueChange = viewModel::onContentChange,
|
||||
@@ -428,6 +514,7 @@ fun NoteEditorScreen(
|
||||
onItemCostChange = viewModel::setItemCost,
|
||||
onRemoveItem = viewModel::removeListItem,
|
||||
onAddItem = viewModel::addListItem,
|
||||
onAddItemAfter = viewModel::addListItemAfter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -465,7 +552,9 @@ fun NoteEditorScreen(
|
||||
// into this bottom action row so the top bar always fits
|
||||
// (the six-action cluster used to crowd the title on narrow
|
||||
// screens). Keep-style placement, above the nav bar /
|
||||
// keyboard.
|
||||
// keyboard. Order: Photo · Voice · Attach · Tasks · Shopping
|
||||
// list, then the hashtag button sits flush right — a
|
||||
// weighted spacer separates it from the action cluster.
|
||||
HorizontalDivider()
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@@ -480,6 +569,18 @@ fun NoteEditorScreen(
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
// v0.4.2.0 — voice-note toggle, first after Photo:
|
||||
// converts the note to / from voice mode (mic permission
|
||||
// is requested on the first tap into the mode).
|
||||
IconButton(onClick = { toggleVoiceMode() }) {
|
||||
Icon(
|
||||
Icons.Filled.Mic,
|
||||
contentDescription = "Voice note",
|
||||
tint = if (state.type == NoteType.VOICE_NOTE)
|
||||
MaterialTheme.colorScheme.primary
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = {
|
||||
// v0.3.4.0 hotfix: the SAF picker backgrounds
|
||||
// the app; with Auto-Lock = Immediate the return
|
||||
@@ -493,21 +594,9 @@ fun NoteEditorScreen(
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { viewModel.openAddTagSheet() },
|
||||
enabled = state.canAddMoreTags,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Tag,
|
||||
contentDescription = "Add tag",
|
||||
tint = if (state.canAddMoreTags)
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else MaterialTheme.colorScheme.outlineVariant,
|
||||
)
|
||||
}
|
||||
// v0.3.8.0 — task-list toggle next to the # button.
|
||||
// Converts the body into editable checklist rows (and
|
||||
// back); the active mode tints with the primary colour.
|
||||
// v0.3.8.0 — task-list toggle: converts the body into
|
||||
// editable checklist rows (and back); the active mode
|
||||
// tints with the primary colour.
|
||||
IconButton(onClick = { viewModel.convertTo(NoteType.TASK_LIST) }) {
|
||||
Icon(
|
||||
Icons.Filled.Checklist,
|
||||
@@ -529,6 +618,21 @@ fun NoteEditorScreen(
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
// Push the hashtag button to the far right, visually
|
||||
// separated from the action cluster above.
|
||||
Spacer(Modifier.weight(1f))
|
||||
IconButton(
|
||||
onClick = { viewModel.openAddTagSheet() },
|
||||
enabled = state.canAddMoreTags,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Tag,
|
||||
contentDescription = "Add tag",
|
||||
tint = if (state.canAddMoreTags)
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else MaterialTheme.colorScheme.outlineVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -996,7 +1100,12 @@ private fun ChecklistEditorBody(
|
||||
onItemCostChange: (Int, String) -> Unit,
|
||||
onRemoveItem: (Int) -> Unit,
|
||||
onAddItem: () -> Unit,
|
||||
onAddItemAfter: (Int) -> Unit,
|
||||
) {
|
||||
// Enter/Return in a task/product row inserts the next row and moves
|
||||
// the cursor into it. The nonce re-fires the new row's focus effect
|
||||
// even when the same index is targeted repeatedly.
|
||||
var focusTarget by remember { mutableStateOf(-1 to 0L) }
|
||||
LazyColumn(modifier = modifier.fillMaxWidth()) {
|
||||
item {
|
||||
// Title / preamble. Kept as plain lines above the checkbox
|
||||
@@ -1015,10 +1124,19 @@ private fun ChecklistEditorBody(
|
||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||
)
|
||||
}
|
||||
if (isShopping) {
|
||||
item { ShoppingColumnHeader() }
|
||||
}
|
||||
itemsIndexed(items) { index, item ->
|
||||
ChecklistItemRow(
|
||||
item = item,
|
||||
isShopping = isShopping,
|
||||
focusOnCompose = focusTarget.first == index,
|
||||
focusNonce = focusTarget.second,
|
||||
onAddAfter = {
|
||||
onAddItemAfter(index)
|
||||
focusTarget = (index + 1) to focusTarget.second + 1
|
||||
},
|
||||
onToggle = { checked -> onToggleItem(index, checked) },
|
||||
onTextChange = { text -> onItemTextChange(index, text) },
|
||||
onQuantityChange = { qty -> onItemQuantityChange(index, qty) },
|
||||
@@ -1040,21 +1158,80 @@ private fun ChecklistEditorBody(
|
||||
}
|
||||
}
|
||||
|
||||
/** One row: `[ ]` · Product · Qty picker · per-item price · remove. */
|
||||
/**
|
||||
* Small "Product / Amnt. / Price" label line above the shopping rows.
|
||||
* Mirrors [ChecklistItemRow]'s column geometry (checkbox spacer +
|
||||
* weighted product + fixed qty/price widths) so the labels sit over
|
||||
* their columns and the fields themselves stay uncluttered.
|
||||
*/
|
||||
@Composable
|
||||
private fun ShoppingColumnHeader() {
|
||||
val labelStyle = MaterialTheme.typography.labelSmall
|
||||
val labelColor = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp),
|
||||
) {
|
||||
Spacer(Modifier.size(48.dp)) // checkbox column
|
||||
Text(
|
||||
"Product",
|
||||
style = labelStyle,
|
||||
color = labelColor,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(start = 16.dp, top = 16.dp),
|
||||
)
|
||||
Spacer(Modifier.size(6.dp))
|
||||
Text(
|
||||
"Amnt.",
|
||||
style = labelStyle,
|
||||
color = labelColor,
|
||||
modifier = Modifier
|
||||
.width(44.dp)
|
||||
.padding(start = 4.dp, top = 16.dp),
|
||||
)
|
||||
Spacer(Modifier.size(6.dp))
|
||||
Text(
|
||||
"Price",
|
||||
style = labelStyle,
|
||||
color = labelColor,
|
||||
modifier = Modifier
|
||||
.width(56.dp)
|
||||
.padding(start = 4.dp, top = 16.dp),
|
||||
)
|
||||
Spacer(Modifier.size(48.dp)) // remove-button column
|
||||
}
|
||||
}
|
||||
|
||||
/** One row: `[ ]` · Product (grows multi-line) · Qty · price · remove. */
|
||||
@Composable
|
||||
private fun ChecklistItemRow(
|
||||
item: ChecklistItem,
|
||||
isShopping: Boolean,
|
||||
focusOnCompose: Boolean,
|
||||
focusNonce: Long,
|
||||
onAddAfter: () -> Unit,
|
||||
onToggle: (Boolean) -> Unit,
|
||||
onTextChange: (String) -> Unit,
|
||||
onQuantityChange: (String) -> Unit,
|
||||
onCostChange: (String) -> Unit,
|
||||
onRemove: () -> Unit,
|
||||
) {
|
||||
// Enter on the row above lands the cursor here (see [focusOnCompose]
|
||||
// in ChecklistEditorBody — the target is always a freshly inserted
|
||||
// row, so focusing on first composition is enough).
|
||||
val textFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(focusNonce) {
|
||||
if (focusOnCompose) textFocus.requestFocus()
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp),
|
||||
// Controls hug the field's vertical centre, so the checkbox,
|
||||
// quantity / price columns and the remove ✕ travel with the
|
||||
// row as a long entry wraps onto extra lines.
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Checkbox(checked = item.checked, onCheckedChange = onToggle)
|
||||
@@ -1065,24 +1242,32 @@ private fun ChecklistItemRow(
|
||||
EditorLineField(
|
||||
value = item.text,
|
||||
onValueChange = onTextChange,
|
||||
placeholder = if (isShopping) "Product" else "Task",
|
||||
// Shopping rows are labelled by the ShoppingColumnHeader
|
||||
// above, so the fields stay empty-clean; plain task rows keep
|
||||
// their single "Task" hint.
|
||||
placeholder = if (isShopping) "" else "Task",
|
||||
keyboardOptions = KeyboardOptions(
|
||||
capitalization = KeyboardCapitalization.Sentences,
|
||||
imeAction = ImeAction.Next,
|
||||
),
|
||||
// Enter/Return (IME "Next") creates the following row and
|
||||
// moves the cursor there instead of tabbing sideways.
|
||||
keyboardActions = KeyboardActions(onNext = { onAddAfter() }),
|
||||
// Long text wraps onto more lines (field grows downward)
|
||||
// instead of scrolling sideways out of view.
|
||||
singleLine = false,
|
||||
maxLines = 6,
|
||||
fieldModifier = Modifier.focusRequester(textFocus),
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
if (isShopping) {
|
||||
Spacer(Modifier.size(6.dp))
|
||||
// Free-text quantity line (replaced the 1–9 dropdown, whose
|
||||
// digit never fit its box). Blank means quantity 1: while
|
||||
// focused an empty line shows the "Quan." hint; on focus
|
||||
// Free-text quantity line. Blank means quantity 1: on focus
|
||||
// loss it settles on "1" — display-only, storage keeps the
|
||||
// blank default so {q1} never enters the saved text.
|
||||
EditorLineField(
|
||||
value = item.quantity,
|
||||
onValueChange = onQuantityChange,
|
||||
placeholder = "Quan.",
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number,
|
||||
imeAction = ImeAction.Next,
|
||||
@@ -1090,7 +1275,8 @@ private fun ChecklistItemRow(
|
||||
formatUnfocused = { digits ->
|
||||
if (digits.isEmpty()) "1" else digits
|
||||
},
|
||||
modifier = Modifier.width(72.dp),
|
||||
compact = true,
|
||||
modifier = Modifier.width(44.dp),
|
||||
)
|
||||
Spacer(Modifier.size(6.dp))
|
||||
// Supermarket-style cents entry: while focused the line shows
|
||||
@@ -1100,15 +1286,23 @@ private fun ChecklistItemRow(
|
||||
EditorLineField(
|
||||
value = item.cost,
|
||||
onValueChange = onCostChange,
|
||||
placeholder = "Price",
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number,
|
||||
imeAction = ImeAction.Next,
|
||||
),
|
||||
// v0.4.x FIX: Enter/Return on Price now behaves exactly
|
||||
// like Enter on the product field — a fresh row appears
|
||||
// below and the cursor lands directly in its Product
|
||||
// field. (A bare ImeAction.Next with no handler fell
|
||||
// through to system focus traversal, which — the price
|
||||
// being the row's last field inside a LazyColumn —
|
||||
// wrapped the cursor all the way back to the Title.)
|
||||
keyboardActions = KeyboardActions(onNext = { onAddAfter() }),
|
||||
formatUnfocused = { digits ->
|
||||
if (digits.isEmpty()) "" else "$" + Note.amountFromPriceDigits(digits)
|
||||
},
|
||||
modifier = Modifier.width(110.dp),
|
||||
compact = true,
|
||||
modifier = Modifier.width(56.dp),
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onRemove) {
|
||||
@@ -1130,6 +1324,24 @@ private fun ChecklistItemRow(
|
||||
private fun editorFieldStyle(): TextStyle =
|
||||
MaterialTheme.typography.bodyMedium.copy(fontSize = 13.sp, lineHeight = 18.sp)
|
||||
|
||||
/**
|
||||
* Top-bar label while a draft session is live. A draft that already
|
||||
* carries a title just says "Draft"; one with NO title names itself
|
||||
* after its kind — "Task List - (draft)", "Shopping List - (draft)" —
|
||||
* mirroring the Drafts card title so both surfaces agree. (TEXT drafts
|
||||
* take their title from the first content line, so they always land in
|
||||
* the "Draft" branch.)
|
||||
*/
|
||||
private fun draftBarTitle(state: NoteEditorUiState): String {
|
||||
// v0.4.2.0: voice notes keep the plain content field (title = first
|
||||
// line), so they read their title from `content` like TEXT does.
|
||||
val titleSource =
|
||||
if (state.type == NoteType.TEXT || state.type == NoteType.VOICE_NOTE) state.content
|
||||
else state.listHeader
|
||||
val hasTitle = titleSource.lineSequence().any { it.isNotBlank() }
|
||||
return if (hasTitle) "Draft" else "${state.type.displayName} - (draft)"
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.8.0 — one plain underlined editing line, shared by every editable
|
||||
* field in the editor (title, task/product, quantity, price). Replaces
|
||||
@@ -1147,7 +1359,11 @@ private fun EditorLineField(
|
||||
onValueChange: (String) -> Unit,
|
||||
placeholder: String = "",
|
||||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
formatUnfocused: ((String) -> String)? = null,
|
||||
singleLine: Boolean = true,
|
||||
maxLines: Int = 1,
|
||||
compact: Boolean = false,
|
||||
fieldModifier: Modifier = Modifier,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -1156,43 +1372,65 @@ private fun EditorLineField(
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
val displayed =
|
||||
if (focused || formatUnfocused == null) value else formatUnfocused(value)
|
||||
Row(
|
||||
modifier = modifier.heightIn(min = 44.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// Material 3 filled TextField with fully transparent containers:
|
||||
// what remains visible is just the text line and the 2 dp bottom
|
||||
// indicator — exactly the "one line per field" look, for free.
|
||||
TextField(
|
||||
value = displayed,
|
||||
onValueChange = onValueChange,
|
||||
singleLine = true,
|
||||
placeholder = {
|
||||
Text(
|
||||
text = placeholder,
|
||||
style = fieldStyle,
|
||||
color = hintColor,
|
||||
maxLines = 1,
|
||||
)
|
||||
},
|
||||
textStyle = fieldStyle.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
),
|
||||
keyboardOptions = keyboardOptions,
|
||||
colors = TextFieldDefaults.colors(
|
||||
focusedContainerColor = Color.Transparent,
|
||||
unfocusedContainerColor = Color.Transparent,
|
||||
disabledContainerColor = Color.Transparent,
|
||||
errorContainerColor = Color.Transparent,
|
||||
focusedIndicatorColor = MaterialTheme.colorScheme.primary,
|
||||
unfocusedIndicatorColor = MaterialTheme.colorScheme.outlineVariant,
|
||||
cursorColor = MaterialTheme.colorScheme.primary,
|
||||
),
|
||||
modifier = fieldModifier
|
||||
.weight(1f)
|
||||
.onFocusEvent { focused = it.isFocused },
|
||||
)
|
||||
// v0.4.x: EVERY field — product/task text, quantity, price, header —
|
||||
// is one content-hugging BasicTextField with a hand-drawn 2 dp
|
||||
// bottom rule (the [compact] flag no longer changes rendering). The
|
||||
// Material 3 TextField's baked-in 56 dp minimum container made even
|
||||
// an empty field look double-height and pinned the row's checkbox /
|
||||
// price controls to the top edge; now a single line of text is a
|
||||
// single line of field, and singleLine = false fields grow
|
||||
// line-by-line up to [maxLines] as the entry wraps.
|
||||
val indicatorColor = if (focused) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.outlineVariant
|
||||
}
|
||||
BasicTextField(
|
||||
value = displayed,
|
||||
onValueChange = onValueChange,
|
||||
singleLine = singleLine,
|
||||
maxLines = maxLines,
|
||||
textStyle = fieldStyle.copy(color = MaterialTheme.colorScheme.onSurface),
|
||||
keyboardOptions = keyboardOptions,
|
||||
keyboardActions = keyboardActions,
|
||||
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
|
||||
decorationBox = { innerTextField ->
|
||||
// The 10 / 4 dp block gives a slim underlined line a comfy
|
||||
// tap target; the rule below lands on the block's bottom
|
||||
// edge, so it always sits 4 dp under the LAST text line —
|
||||
// one line or six.
|
||||
Box(
|
||||
modifier = Modifier.padding(top = 10.dp, bottom = 4.dp),
|
||||
contentAlignment = Alignment.CenterStart,
|
||||
) {
|
||||
if (displayed.isEmpty() && placeholder.isNotEmpty()) {
|
||||
Text(
|
||||
text = placeholder,
|
||||
style = fieldStyle,
|
||||
color = hintColor,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
innerTextField()
|
||||
}
|
||||
},
|
||||
// NOTE: the caller's [modifier] (weight(1f) for the product
|
||||
// column, fixed 44/56.dp for quantity/price) MUST stay in the
|
||||
// chain — dropping it lets fillMaxWidth() win the Row and
|
||||
// swallow the neighbouring columns.
|
||||
modifier = fieldModifier
|
||||
.then(modifier)
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 2.dp)
|
||||
.drawBehind {
|
||||
drawRect(
|
||||
color = indicatorColor,
|
||||
topLeft = Offset(0f, size.height - 2.dp.toPx()),
|
||||
size = Size(size.width, 2.dp.toPx()),
|
||||
)
|
||||
}
|
||||
.onFocusEvent { focused = it.isFocused },
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -8,11 +8,15 @@ import androidx.lifecycle.viewmodel.initializer
|
||||
import androidx.lifecycle.viewmodel.viewModelFactory
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -89,12 +93,29 @@ data class NoteEditorUiState(
|
||||
*/
|
||||
val fullScreenAttachmentId: ViewerAttachmentId? = null,
|
||||
) {
|
||||
/** `true` while content is non-blank and not in the middle of saving. */
|
||||
val canSave: Boolean get() = content.isNotBlank() && !isSaving
|
||||
|
||||
/** `true` when editing an existing note (existing != null). */
|
||||
val isEditing: Boolean get() = existing != null
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — `true` once a voice take exists (staged pending or
|
||||
* already persisted as an attachment).
|
||||
*/
|
||||
val hasVoiceTake: Boolean get() =
|
||||
pendingAttachments.any { it.mimeType.startsWith("audio/") } ||
|
||||
attachments.any { it.mimeType.startsWith("audio/") }
|
||||
|
||||
/**
|
||||
* `true` while content is non-blank and not in the middle of
|
||||
* saving. v0.4.2.0: a VOICE_NOTE may also save on the strength of
|
||||
* its recording alone — the take IS the note's content.
|
||||
*/
|
||||
val canSave: Boolean get() =
|
||||
(content.isNotBlank() || (type == NoteType.VOICE_NOTE && hasVoiceTake)) &&
|
||||
!isSaving
|
||||
|
||||
/** `true` while this note is an auto-saved draft (see Note.isDraft). */
|
||||
val isDraft: Boolean get() = existing?.isDraft == true
|
||||
|
||||
/** `true` when there's still room to add another tag. */
|
||||
val canAddMoreTags: Boolean get() = hashtags.size < MAX_TAGS
|
||||
|
||||
@@ -145,7 +166,7 @@ data class PendingAttachment(
|
||||
val isImage: Boolean get() = mimeType.startsWith("image/")
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||
class NoteEditorViewModel(
|
||||
private val repository: NoteRepository,
|
||||
private val noteId: Long?,
|
||||
@@ -209,6 +230,36 @@ class NoteEditorViewModel(
|
||||
*/
|
||||
private var nextPendingTempId: Long = -System.currentTimeMillis()
|
||||
|
||||
/**
|
||||
* Draft autosave. A NEW note (or one still flagged as a draft) is
|
||||
* persisted automatically: every edit lands in the DB ~400 ms after
|
||||
* the last keystroke (coalesced so typing doesn't write per char),
|
||||
* and [flushDraft] forces an immediate write whenever the editor
|
||||
* closes or disposes. A crash can therefore only ever lose the last
|
||||
* few keystrokes — never a whole draft.
|
||||
*/
|
||||
private val draftAutosave = noteId == null || noteId == 0L
|
||||
|
||||
/** True while this session autosaves: brand-new notes and draft editing. */
|
||||
val isDraftFlow: Boolean
|
||||
get() = draftAutosave || _state.value.isDraft
|
||||
|
||||
private var draftPersistInProgress = false
|
||||
|
||||
init {
|
||||
// Signature-driven debounced autosave: whenever anything a draft
|
||||
// persists changes, write the draft row shortly after.
|
||||
viewModelScope.launch {
|
||||
_state
|
||||
.map { s ->
|
||||
listOf(s.content, s.isFavorite, s.color, s.type, s.hashtags)
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.debounce(DRAFT_AUTOSAVE_DEBOUNCE_MS)
|
||||
.collect { persistDraftNow() }
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
// Tag autocomplete — re-query on every keystroke (debounced upstream
|
||||
// would be nice but ObjectBox is plenty fast for this size).
|
||||
@@ -294,6 +345,10 @@ class NoteEditorViewModel(
|
||||
initialHashtags = note.hashtags
|
||||
initialType = note.type
|
||||
}
|
||||
// Draft echoes: emissions caused by our own autosave
|
||||
// must not clobber in-progress edits mid-typing —
|
||||
// the local state is authoritative while drafting.
|
||||
if (note != null && note.isDraft && !firstLoad) return@collect
|
||||
// Parse list rows once on first load; later DB
|
||||
// emissions must not clobber in-progress edits.
|
||||
val listSeed: Pair<String, List<ChecklistItem>>? =
|
||||
@@ -409,13 +464,28 @@ class NoteEditorViewModel(
|
||||
fun convertTo(target: NoteType) {
|
||||
_state.update { s ->
|
||||
val next = if (s.type == target) NoteType.TEXT else target
|
||||
if (next == NoteType.TEXT) {
|
||||
if (next == NoteType.VOICE_NOTE) {
|
||||
// v0.4.2.0 — voice mode keeps the plain text field
|
||||
// (title = first line) exactly like TEXT; a list body
|
||||
// folds back to its plain form first. The recording is
|
||||
// NOT body content — it's an ordinary audio attachment,
|
||||
// so it also survives converting back to plain text.
|
||||
val source =
|
||||
if (s.type == NoteType.TEXT || s.type == NoteType.VOICE_NOTE) s.content
|
||||
else Note.serializeListContent(s.listHeader, s.items, NoteType.TEXT)
|
||||
s.copy(
|
||||
type = next,
|
||||
listHeader = "",
|
||||
items = emptyList(),
|
||||
content = source,
|
||||
)
|
||||
} else if (next == NoteType.TEXT) {
|
||||
// Content already holds the serialised `- [ ]` rows;
|
||||
// just drop out of the structured editor (the inline
|
||||
// GFM checklist rendering from v0.2.0.0 still applies).
|
||||
s.copy(type = NoteType.TEXT, listHeader = "", items = emptyList())
|
||||
} else {
|
||||
val source = if (s.type == NoteType.TEXT) {
|
||||
val source = if (s.type == NoteType.TEXT || s.type == NoteType.VOICE_NOTE) {
|
||||
s.content
|
||||
} else {
|
||||
// Serialise through the FOLDED legacy form (plain
|
||||
@@ -442,6 +512,7 @@ class NoteEditorViewModel(
|
||||
snackbar = when (it.type) {
|
||||
NoteType.TASK_LIST -> "Task list mode — first line stays the title."
|
||||
NoteType.SHOPPING_LIST -> "Shopping list mode — check an item once it's in your basket."
|
||||
NoteType.VOICE_NOTE -> "Voice note mode — record with the mic card above the text."
|
||||
else -> "Back to plain text."
|
||||
},
|
||||
)
|
||||
@@ -459,6 +530,20 @@ class NoteEditorViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a blank row right after [index] (or append it on the last
|
||||
* row). Driven by Enter/Return in the task/product field so the
|
||||
* writer flows downward into a fresh row instead of tabbing sideways.
|
||||
*/
|
||||
fun addListItemAfter(index: Int) {
|
||||
_state.update { s ->
|
||||
if (s.type == NoteType.TEXT) return@update s
|
||||
if (index !in s.items.indices) return@update s
|
||||
val updated = s.items.toMutableList().also { it.add(index + 1, ChecklistItem("")) }
|
||||
s.withListEdits(items = updated)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeListItem(index: Int) {
|
||||
_state.update { s ->
|
||||
if (index !in s.items.indices) return@update s
|
||||
@@ -575,6 +660,46 @@ class NoteEditorViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — stage/persist the finished take of a voice note.
|
||||
* One take per note: any previous take (pending or already
|
||||
* persisted) is discarded first. The bytes then ride the ordinary
|
||||
* attachment pipeline — staged as a [PendingAttachment] while the
|
||||
* note is unsaved, written straight to the DB afterwards — so
|
||||
* encryption, backup/restore, and the trash cascade all apply
|
||||
* without any voice-specific storage.
|
||||
*
|
||||
* [mimeType] is the container the recorder actually produced —
|
||||
* `audio/ogg` (Opus, 32 kbps mono) on API 29+, `audio/mp4` (AAC)
|
||||
* on API 26–28; the display-name extension follows suit.
|
||||
*/
|
||||
fun setVoiceRecording(bytes: ByteArray, mimeType: String = "audio/ogg") {
|
||||
if (bytes.size < 2048) {
|
||||
_state.update { it.copy(snackbar = "Recording too short \u2014 try again.") }
|
||||
return
|
||||
}
|
||||
viewModelScope.launch {
|
||||
_state.value.pendingAttachments
|
||||
.filter { it.mimeType.startsWith("audio/") }
|
||||
.forEach { removePendingAttachment(it.tempId) }
|
||||
val stalePersisted = _state.value.attachments
|
||||
.filter { it.mimeType.startsWith("audio/") }
|
||||
if (stalePersisted.isNotEmpty()) {
|
||||
withContext(Dispatchers.IO) {
|
||||
stalePersisted.forEach { repository.removeAttachment(it.id) }
|
||||
}
|
||||
}
|
||||
val stamp = java.text.SimpleDateFormat("yyyyMMdd_HHmmss", java.util.Locale.US)
|
||||
.format(java.util.Date())
|
||||
val ext = if (mimeType == "audio/mp4") "m4a" else "opus"
|
||||
importAttachmentBytes(
|
||||
bytes = bytes,
|
||||
mimeType = mimeType,
|
||||
displayName = "Voice_$stamp.$ext",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Open the full-screen image viewer for [viewerId]. */
|
||||
fun openFullScreen(viewerId: ViewerAttachmentId) {
|
||||
_state.update { it.copy(fullScreenAttachmentId = viewerId) }
|
||||
@@ -587,17 +712,74 @@ class NoteEditorViewModel(
|
||||
|
||||
// ---- save ----
|
||||
|
||||
/**
|
||||
* Force-write the current draft state to the DB right now — used
|
||||
* when the editor closes / disposes so pending edits never sit in
|
||||
* the debounce window. No-op for non-draft sessions and blank
|
||||
* content (see [persistDraftNow]).
|
||||
*/
|
||||
fun flushDraft() {
|
||||
viewModelScope.launch { persistDraftNow() }
|
||||
}
|
||||
|
||||
/** Write the draft row if this session is in the draft lifecycle. */
|
||||
private suspend fun persistDraftNow() {
|
||||
val current = _state.value
|
||||
if (current.isLoading || current.isSaving) return
|
||||
if (draftPersistInProgress) return
|
||||
val baseNote = current.existing
|
||||
if (baseNote != null && !baseNote.isDraft) return // already published
|
||||
if (!draftAutosave && baseNote?.isDraft != true) return
|
||||
if (current.content.isBlank()) return
|
||||
draftPersistInProgress = true
|
||||
try {
|
||||
val now = System.currentTimeMillis()
|
||||
val draft = baseNote?.copy(
|
||||
content = current.content,
|
||||
isFavorite = current.isFavorite,
|
||||
color = current.color,
|
||||
type = current.type,
|
||||
isDraft = true,
|
||||
) ?: Note(
|
||||
content = current.content,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
isFavorite = current.isFavorite,
|
||||
color = current.color,
|
||||
type = current.type,
|
||||
isDraft = true,
|
||||
)
|
||||
val previous = baseNote?.hashtags.orEmpty().toSet()
|
||||
val currentSet = current.hashtags.toSet()
|
||||
val saved = repository.saveNoteWithHashtags(
|
||||
note = draft,
|
||||
hashtagsToAdd = currentSet - previous,
|
||||
hashtagsToRemove = previous - currentSet,
|
||||
)
|
||||
// Adopt the persisted row so every later write updates the
|
||||
// SAME note — one draft per editing session.
|
||||
_state.update {
|
||||
it.copy(existing = saved.copy(isDraft = true, hashtags = current.hashtags))
|
||||
}
|
||||
} finally {
|
||||
draftPersistInProgress = false
|
||||
}
|
||||
}
|
||||
|
||||
fun save(onDone: () -> Unit) {
|
||||
val current = _state.value
|
||||
if (!current.canSave) return
|
||||
_state.update { it.copy(isSaving = true) }
|
||||
viewModelScope.launch {
|
||||
val baseNote = current.existing
|
||||
// An explicit Save PUBLISHES the note: a draft row loses
|
||||
// its flag here and joins the normal views for good.
|
||||
val toPersist = baseNote?.copy(
|
||||
content = current.content,
|
||||
isFavorite = current.isFavorite,
|
||||
color = current.color,
|
||||
type = current.type,
|
||||
isDraft = false,
|
||||
) ?: Note(
|
||||
content = current.content,
|
||||
createdAt = System.currentTimeMillis(),
|
||||
@@ -627,7 +809,25 @@ class NoteEditorViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
_state.update { it.copy(isSaving = false, pendingAttachments = emptyList(), pendingAttachmentBytes = emptyMap()) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
// v0.4.x FIX: adopt the PUBLISHED row into the UI
|
||||
// state. Without this the state still reported
|
||||
// isDraft = true, and the flushDraft() fired by the
|
||||
// editor's disposal immediately re-persisted the
|
||||
// note as a draft — every confirmed note landed in
|
||||
// Drafts. With the published row adopted, the
|
||||
// already-published guard in persistDraftNow() turns
|
||||
// that flush into a no-op.
|
||||
existing = saved.copy(
|
||||
isDraft = false,
|
||||
hashtags = current.hashtags,
|
||||
),
|
||||
isSaving = false,
|
||||
pendingAttachments = emptyList(),
|
||||
pendingAttachmentBytes = emptyMap(),
|
||||
)
|
||||
}
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
@@ -643,6 +843,9 @@ class NoteEditorViewModel(
|
||||
}
|
||||
|
||||
companion object {
|
||||
/** Typing-pause before a draft autosave fires (ms). */
|
||||
const val DRAFT_AUTOSAVE_DEBOUNCE_MS = 400L
|
||||
|
||||
fun factory(
|
||||
noteId: Long?,
|
||||
initialSharedText: String? = null,
|
||||
|
||||
@@ -0,0 +1,539 @@
|
||||
package org.incido.compose.ui.editor
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Download
|
||||
import androidx.compose.material.icons.filled.FiberManualRecord
|
||||
import androidx.compose.material.icons.filled.Mic
|
||||
import androidx.compose.material.icons.filled.Pause
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.filled.Stop
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.FileProvider
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.incido.compose.data.security.SecurityManager
|
||||
import org.incido.domain.model.NoteAttachment
|
||||
import org.incido.domain.repository.NoteRepository
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — the voice-note body section: sits at the very top of the
|
||||
* note body (above the text field) whenever the editor is in
|
||||
* [org.incido.domain.model.NoteType.VOICE_NOTE] mode.
|
||||
*
|
||||
* Three states:
|
||||
* * **No take** — "tap to record" card.
|
||||
* * **Recording** — live elapsed timer with stop / discard controls.
|
||||
* * **Take ready** (pending *or* persisted) — media player bar with
|
||||
* play/pause, seek, a **Download** action that copies the file to
|
||||
* the system Downloads folder, and a delete action (re-record via
|
||||
* the mic button — the ViewModel replaces the old take when a new
|
||||
* recording lands).
|
||||
*
|
||||
* The take rides the existing attachment pipeline: while the note is
|
||||
* unsaved it is a [PendingAttachment] whose bytes live in the UI
|
||||
* state; after save it is an ordinary `audio/ogg` attachment row
|
||||
* (encrypted at rest like every other attachment, backed up with the
|
||||
* note, and still visible in the attachment strip below).
|
||||
*/
|
||||
@Composable
|
||||
fun VoiceNoteSection(
|
||||
/** Pending (unsaved) voice take, or null. */
|
||||
voicePending: PendingAttachment?,
|
||||
/** Bytes of the pending take (null while still unrecorded). */
|
||||
voicePendingBytes: ByteArray?,
|
||||
/** Persisted voice take of a saved note, or null. */
|
||||
voicePersisted: NoteAttachment?,
|
||||
/** Source of persisted bytes (lazy-loaded by the player). */
|
||||
repository: NoteRepository?,
|
||||
/** Checked on every record tap — reflects RECORD_AUDIO state. */
|
||||
hasMicPermission: () -> Boolean,
|
||||
/** Launches the RECORD_AUDIO permission request. */
|
||||
onRequestPermission: () -> Unit,
|
||||
/** A finished recording is ready to stage/persist (replaces any old take);
|
||||
* second arg is the recorder's actual mime (`audio/ogg`, or `audio/mp4` on API 26–28). */
|
||||
onTakeRecorded: (ByteArray, String) -> Unit,
|
||||
/** Remove the current take (pending or persisted). */
|
||||
onDeleteTake: () -> Unit,
|
||||
/** Suppress auto-lock around the download share-sheet round-trip (API < 29). */
|
||||
securityManager: SecurityManager?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
val recorder = remember { VoiceRecorder() }
|
||||
var isRecording by remember { mutableStateOf(false) }
|
||||
var elapsedMs by remember { mutableStateOf(0L) }
|
||||
|
||||
// Abandon an in-flight take if the editor tears down mid-recording
|
||||
// (back navigation, config change) — no orphan temp files.
|
||||
DisposableEffect(Unit) {
|
||||
onDispose { recorder.cancel() }
|
||||
}
|
||||
|
||||
// Live tick for the recording timer.
|
||||
LaunchedEffect(isRecording) {
|
||||
if (!isRecording) return@LaunchedEffect
|
||||
val startedAt = android.os.SystemClock.elapsedRealtime() - elapsedMs
|
||||
while (isRecording) {
|
||||
elapsedMs = android.os.SystemClock.elapsedRealtime() - startedAt
|
||||
delay(100)
|
||||
}
|
||||
}
|
||||
|
||||
fun startRecording() {
|
||||
if (!hasMicPermission()) {
|
||||
onRequestPermission()
|
||||
return
|
||||
}
|
||||
try {
|
||||
recorder.start(ctx)
|
||||
elapsedMs = 0L
|
||||
isRecording = true
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(ctx, "Couldn't start recording", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun stopRecording() {
|
||||
val bytes = recorder.stopAndReadBytes()
|
||||
isRecording = false
|
||||
if (bytes == null) {
|
||||
Toast.makeText(ctx, "Recording failed", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
onTakeRecorded(bytes, recorder.recordedMimeType)
|
||||
}
|
||||
}
|
||||
|
||||
val hasTake = voicePending != null || voicePersisted != null
|
||||
|
||||
// Persisted bytes lazy-load on demand (same pattern as the
|
||||
// attachment thumbnails) so the StateFlow never holds the blob.
|
||||
val lazyPersistedBytes by produceState<ByteArray?>(
|
||||
initialValue = null,
|
||||
key1 = voicePersisted?.id,
|
||||
) {
|
||||
value = if (voicePersisted != null && repository != null) {
|
||||
withContext(Dispatchers.IO) { repository.getAttachmentBytes(voicePersisted.id) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
val takeBytes: ByteArray? = if (voicePending != null) voicePendingBytes else lazyPersistedBytes
|
||||
val takeName: String =
|
||||
voicePending?.displayName ?: voicePersisted?.displayName ?: "voice_note.opus"
|
||||
val takeMime: String =
|
||||
voicePending?.mimeType ?: voicePersisted?.mimeType ?: "audio/ogg"
|
||||
val takeKey: Long = voicePending?.tempId ?: voicePersisted?.id ?: 0L
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 8.dp)
|
||||
.border(
|
||||
1.dp,
|
||||
MaterialTheme.colorScheme.outlineVariant,
|
||||
RoundedCornerShape(12.dp),
|
||||
)
|
||||
.background(
|
||||
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.45f),
|
||||
RoundedCornerShape(12.dp),
|
||||
)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
when {
|
||||
isRecording -> Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.FiberManualRecord,
|
||||
contentDescription = null,
|
||||
tint = Color(0xFFD32F2F),
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
formatVoiceTime(elapsedMs),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
)
|
||||
Spacer(Modifier.weight(1f))
|
||||
IconButton(onClick = { stopRecording() }) {
|
||||
Icon(
|
||||
Icons.Filled.Stop,
|
||||
contentDescription = "Stop recording",
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = {
|
||||
recorder.cancel()
|
||||
isRecording = false
|
||||
}) {
|
||||
Icon(
|
||||
Icons.Filled.Close,
|
||||
contentDescription = "Discard recording",
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
hasTake && takeBytes == null -> Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(48.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp)
|
||||
Text(
|
||||
"Loading audio\u2026",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
hasTake && takeBytes != null -> VoicePlayerBar(
|
||||
bytes = takeBytes,
|
||||
mimeType = takeMime,
|
||||
sourceKey = takeKey,
|
||||
takeName = takeName,
|
||||
onDelete = onDeleteTake,
|
||||
onDownload = { saveVoiceTakeToDevice(ctx, securityManager, takeName, takeMime, takeBytes) },
|
||||
onRecordAgain = { startRecording() },
|
||||
)
|
||||
|
||||
else -> Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { startRecording() }
|
||||
.padding(vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.background(
|
||||
MaterialTheme.colorScheme.primary.copy(alpha = 0.12f),
|
||||
CircleShape,
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Mic,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(22.dp),
|
||||
)
|
||||
}
|
||||
Text(
|
||||
"Tap to record a voice note",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Media-player bar for a recorded take: play/pause + seek + elapsed /
|
||||
* total, plus download, re-record and delete actions. Backed by the
|
||||
* platform [MediaPlayer] — the bytes are written to a small cache file
|
||||
* (`cacheDir/voice_play/`) because MediaPlayer plays paths, not
|
||||
* in-memory blobs; the file is rewritten whenever a new take arrives
|
||||
* and is disposable cache data.
|
||||
*/
|
||||
@Composable
|
||||
private fun VoicePlayerBar(
|
||||
bytes: ByteArray,
|
||||
mimeType: String,
|
||||
sourceKey: Long,
|
||||
takeName: String,
|
||||
onDelete: () -> Unit,
|
||||
onDownload: () -> Unit,
|
||||
onRecordAgain: () -> Unit,
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
|
||||
// Materialise the take into a playable cache file.
|
||||
val playPath by produceState<String?>(
|
||||
initialValue = null,
|
||||
key1 = sourceKey,
|
||||
key2 = bytes,
|
||||
) {
|
||||
value = withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
val dir = File(ctx.cacheDir, "voice_play").apply { mkdirs() }
|
||||
val ext = if (mimeType == "audio/ogg") "opus" else "m4a"
|
||||
val file = File(dir, "take_$sourceKey.$ext")
|
||||
file.writeBytes(bytes)
|
||||
file.absolutePath
|
||||
}.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
var player by remember(sourceKey) { mutableStateOf<MediaPlayer?>(null) }
|
||||
var prepared by remember(sourceKey) { mutableStateOf(false) }
|
||||
var isPlaying by remember(sourceKey) { mutableStateOf(false) }
|
||||
var positionMs by remember(sourceKey) { mutableStateOf(0L) }
|
||||
var durationMs by remember(sourceKey) { mutableStateOf(0L) }
|
||||
var dragMs by remember(sourceKey) { mutableStateOf<Float?>(null) }
|
||||
|
||||
DisposableEffect(playPath) {
|
||||
val path = playPath
|
||||
if (path == null) {
|
||||
onDispose { }
|
||||
} else {
|
||||
val mp = MediaPlayer()
|
||||
player = mp
|
||||
mp.setOnPreparedListener {
|
||||
durationMs = it.duration.toLong()
|
||||
prepared = true
|
||||
}
|
||||
mp.setOnCompletionListener {
|
||||
isPlaying = false
|
||||
positionMs = durationMs
|
||||
}
|
||||
mp.setOnErrorListener { _, _, _ -> true }
|
||||
runCatching {
|
||||
mp.setDataSource(path)
|
||||
mp.prepareAsync()
|
||||
}
|
||||
onDispose {
|
||||
runCatching { mp.release() }
|
||||
player = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the slider in step while playing.
|
||||
LaunchedEffect(isPlaying, prepared) {
|
||||
if (!isPlaying || !prepared) return@LaunchedEffect
|
||||
while (isPlaying) {
|
||||
player?.let { positionMs = it.currentPosition.toLong() }
|
||||
delay(200)
|
||||
}
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
val mp = player ?: return@IconButton
|
||||
if (!prepared) return@IconButton
|
||||
if (mp.isPlaying) {
|
||||
mp.pause()
|
||||
isPlaying = false
|
||||
} else {
|
||||
if (positionMs >= durationMs && durationMs > 0) {
|
||||
mp.seekTo(0)
|
||||
positionMs = 0
|
||||
}
|
||||
mp.start()
|
||||
isPlaying = true
|
||||
}
|
||||
},
|
||||
enabled = prepared,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (isPlaying) Icons.Filled.Pause else Icons.Filled.PlayArrow,
|
||||
contentDescription = if (isPlaying) "Pause" else "Play",
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = formatVoiceTime((dragMs ?: positionMs.toFloat()).toLong()),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
)
|
||||
Slider(
|
||||
value = (dragMs ?: positionMs.toFloat()).coerceIn(
|
||||
0f,
|
||||
durationMs.coerceAtLeast(1).toFloat(),
|
||||
),
|
||||
onValueChange = { dragMs = it },
|
||||
onValueChangeFinished = {
|
||||
val target = dragMs
|
||||
if (target != null) {
|
||||
dragMs = null
|
||||
val seek = target.toInt()
|
||||
player?.let { mp ->
|
||||
if (prepared) {
|
||||
mp.seekTo(seek)
|
||||
positionMs = seek.toLong()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
valueRange = 0f..durationMs.coerceAtLeast(1).toFloat(),
|
||||
enabled = prepared,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp),
|
||||
)
|
||||
Text(
|
||||
text = formatVoiceTime(durationMs),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
)
|
||||
// Download = save a copy to the system Downloads folder
|
||||
// (pre-Q devices get the share sheet, which reaches the
|
||||
// same destinations).
|
||||
IconButton(onClick = onDownload) {
|
||||
Icon(
|
||||
Icons.Filled.Download,
|
||||
contentDescription = "Download recording",
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onRecordAgain) {
|
||||
Icon(
|
||||
Icons.Filled.Mic,
|
||||
contentDescription = "Re-record (replaces current take)",
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onDelete) {
|
||||
Icon(
|
||||
Icons.Filled.Delete,
|
||||
contentDescription = "Delete recording",
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = takeName,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the take to the system Downloads folder via MediaStore (API 29+,
|
||||
* no storage permission needed). On API 26–28 — where MediaStore
|
||||
* Downloads doesn't exist — fall back to the v0.3.1.3 FileProvider
|
||||
* outbox + share sheet, which reaches the same destinations plus
|
||||
* "Save to device" handlers.
|
||||
*/
|
||||
private fun saveVoiceTakeToDevice(
|
||||
ctx: Context,
|
||||
securityManager: SecurityManager?,
|
||||
displayName: String,
|
||||
mimeType: String,
|
||||
bytes: ByteArray,
|
||||
) {
|
||||
val safeName = displayName
|
||||
.replace(Regex("[/\\\\:*?\"<>|]"), "_")
|
||||
.ifEmpty { "voice_note.opus" }
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val saved = runCatching {
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.Downloads.DISPLAY_NAME, safeName)
|
||||
put(MediaStore.Downloads.MIME_TYPE, mimeType)
|
||||
put(
|
||||
MediaStore.Downloads.RELATIVE_PATH,
|
||||
Environment.DIRECTORY_DOWNLOADS,
|
||||
)
|
||||
}
|
||||
val uri = ctx.contentResolver.insert(
|
||||
MediaStore.Downloads.EXTERNAL_CONTENT_URI,
|
||||
values,
|
||||
) ?: return@runCatching false
|
||||
ctx.contentResolver.openOutputStream(uri)?.use { out ->
|
||||
out.write(bytes)
|
||||
} ?: return@runCatching false
|
||||
true
|
||||
}.getOrDefault(false)
|
||||
if (saved) {
|
||||
Toast.makeText(ctx, "Saved to Downloads", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
// MediaStore refused (provider hiccup) — fall through to the
|
||||
// share sheet as the last resort.
|
||||
}
|
||||
|
||||
runCatching {
|
||||
val outbox = File(ctx.cacheDir, "open_outbox").apply { mkdirs() }
|
||||
val tmp = File(outbox, "dl_${System.currentTimeMillis()}_$safeName")
|
||||
tmp.writeBytes(bytes)
|
||||
val uri = FileProvider.getUriForFile(ctx, "${ctx.packageName}.fileprovider", tmp)
|
||||
val send = Intent(Intent.ACTION_SEND).apply {
|
||||
type = mimeType
|
||||
putExtra(Intent.EXTRA_STREAM, uri)
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
}
|
||||
// Auto-Lock = Immediate must not fire while the chooser is up
|
||||
// (same v0.3.4.0 hotfix as the attachment viewer).
|
||||
securityManager?.beginExternalActivity()
|
||||
ctx.startActivity(Intent.createChooser(send, "Save recording"))
|
||||
}.onFailure {
|
||||
Toast.makeText(ctx, "Couldn't save recording", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
/** ms → "m:ss" (or "h:mm:ss" past an hour). */
|
||||
internal fun formatVoiceTime(ms: Long): String {
|
||||
val totalSec = ms / 1000
|
||||
val h = totalSec / 3600
|
||||
val m = (totalSec % 3600) / 60
|
||||
val s = totalSec % 60
|
||||
return if (h > 0) {
|
||||
String.format(Locale.US, "%d:%02d:%02d", h, m, s)
|
||||
} else {
|
||||
String.format(Locale.US, "%d:%02d", m, s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package org.incido.compose.ui.editor
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaRecorder
|
||||
import android.os.Build
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — thin MediaRecorder wrapper for voice notes.
|
||||
*
|
||||
* Records Opus audio in an Ogg container (`.opus`, mime `audio/ogg`)
|
||||
* at 32 kbps, single channel, 48 kHz — tiny files, excellent speech
|
||||
* quality, and produced by the platform MediaRecorder with no extra
|
||||
* dependencies (the app stays dependency-light per Development Plan
|
||||
* privacy/offline rules). Opus-in-Ogg output via MediaRecorder is
|
||||
* public API only from API 29, so API 26–28 devices keep the previous
|
||||
* AAC/MP4 path (`.m4a`, mime `audio/mp4`); [recordedMimeType] reports
|
||||
* which container [start] actually used.
|
||||
*
|
||||
* Note: the MediaRecorder surface exposes no encoder knobs for Opus
|
||||
* frame size or complexity, so both stay at platform defaults (Opus
|
||||
* on Android encodes 20 ms frames); hitting 120 ms frames /
|
||||
* complexity 10 would require bundling native libopus — deferred.
|
||||
*
|
||||
* The take lands in a temp file under `cacheDir/voice_rec/`; the
|
||||
* caller reads it back as a [ByteArray] on [stopAndReadBytes] and the
|
||||
* temp file is deleted immediately — the bytes then ride the ordinary
|
||||
* attachment pipeline into ObjectBox (same lifecycle as the camera
|
||||
* outbox from v0.3.1.0).
|
||||
*
|
||||
* Not thread-safe: drive it from the main thread only.
|
||||
*/
|
||||
class VoiceRecorder {
|
||||
|
||||
private var recorder: MediaRecorder? = null
|
||||
private var outFile: File? = null
|
||||
private var opus = false
|
||||
|
||||
/** True between a successful [start] and the matching stop/cancel. */
|
||||
val isRecording: Boolean get() = recorder != null
|
||||
|
||||
/**
|
||||
* Mime type of the container [start] actually used — `audio/ogg`
|
||||
* (Opus) on API 29+, `audio/mp4` (AAC) on API 26–28. Valid after
|
||||
* any successful [start]; callers use it to tag the finished take.
|
||||
*/
|
||||
val recordedMimeType: String get() = if (opus) "audio/ogg" else "audio/mp4"
|
||||
|
||||
/**
|
||||
* Start capturing from the mic into a fresh temp file.
|
||||
* Throws [IOException] / [RuntimeException] when the mic is busy,
|
||||
* the permission was revoked mid-session, or the device has none —
|
||||
* callers should catch and surface a snackbar.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
fun start(context: Context) {
|
||||
if (recorder != null) return
|
||||
// Opus-in-Ogg via MediaRecorder is public API only from API 29
|
||||
// (minSdk is 26), so older devices keep the AAC/MP4 path.
|
||||
val useOpus = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
val dir = File(context.cacheDir, "voice_rec").apply { mkdirs() }
|
||||
val file = File(
|
||||
dir,
|
||||
"take_${System.currentTimeMillis()}" + if (useOpus) ".opus" else ".m4a",
|
||||
)
|
||||
val rec = MediaRecorder()
|
||||
try {
|
||||
rec.apply {
|
||||
setAudioSource(MediaRecorder.AudioSource.MIC)
|
||||
if (useOpus) {
|
||||
setOutputFormat(MediaRecorder.OutputFormat.OGG)
|
||||
setAudioEncoder(MediaRecorder.AudioEncoder.OPUS)
|
||||
setAudioEncodingBitRate(32_000) // 32 kbps
|
||||
setAudioChannels(1) // single channel
|
||||
setAudioSamplingRate(48_000) // Opus native rate
|
||||
} else {
|
||||
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
|
||||
setAudioEncoder(MediaRecorder.AudioEncoder.AAC)
|
||||
setAudioEncodingBitRate(96_000)
|
||||
setAudioSamplingRate(44_100)
|
||||
}
|
||||
setOutputFile(file.absolutePath)
|
||||
prepare()
|
||||
start()
|
||||
}
|
||||
recorder = rec
|
||||
outFile = file
|
||||
opus = useOpus
|
||||
} catch (e: Exception) {
|
||||
rec.release()
|
||||
file.delete()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the capture, read the recorded bytes, and delete the temp
|
||||
* file. Returns `null` when nothing was recorded or the encoder
|
||||
* failed. Always safe to call — a no-op while idle.
|
||||
*/
|
||||
fun stopAndReadBytes(): ByteArray? {
|
||||
val rec = recorder ?: return null
|
||||
recorder = null
|
||||
val file = outFile
|
||||
outFile = null
|
||||
return try {
|
||||
rec.stop()
|
||||
val bytes = file?.readBytes()
|
||||
bytes?.takeIf { it.isNotEmpty() }
|
||||
} catch (e: RuntimeException) {
|
||||
null
|
||||
} finally {
|
||||
rec.release()
|
||||
file?.delete()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abandon the in-flight take without reading it (the ✕ while
|
||||
* recording). Always safe to call — a no-op while idle.
|
||||
*/
|
||||
fun cancel() {
|
||||
val rec = recorder ?: return
|
||||
recorder = null
|
||||
val file = outFile
|
||||
outFile = null
|
||||
runCatching { rec.stop() } // stop() throws if nothing was captured
|
||||
rec.release()
|
||||
file?.delete()
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,10 @@ import androidx.compose.material.icons.filled.AttachFile
|
||||
import androidx.compose.material.icons.filled.CheckBox
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.DeleteForever
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Mic
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.PhotoCamera
|
||||
import androidx.compose.material.icons.filled.Restore
|
||||
@@ -38,6 +40,7 @@ import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.ShoppingBasket
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.outlined.StarOutline
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||
@@ -51,6 +54,7 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -127,6 +131,7 @@ fun NoteListScreen(
|
||||
) {
|
||||
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
var localQuery by remember { mutableStateOf("") }
|
||||
var showEmptyTrashDialog by remember { mutableStateOf(false) }
|
||||
val searchFocusRequester = remember { FocusRequester() }
|
||||
|
||||
LaunchedEffect(filterMode) { viewModel.setFilter(filterMode) }
|
||||
@@ -139,6 +144,36 @@ fun NoteListScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// "Empty Trash" confirmation. The whole trash goes, attachments
|
||||
// included — say so plainly before the one tap that does it.
|
||||
if (showEmptyTrashDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showEmptyTrashDialog = false },
|
||||
title = { Text("Empty Trash?") },
|
||||
text = {
|
||||
Text(
|
||||
"Every note in the Trash, including attachments, will be " +
|
||||
"permanently deleted. This cannot be undone.",
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
showEmptyTrashDialog = false
|
||||
viewModel.emptyTrash()
|
||||
},
|
||||
) {
|
||||
Text("Empty Trash", color = MaterialTheme.colorScheme.error)
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showEmptyTrashDialog = false }) {
|
||||
Text("Cancel")
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
@@ -162,6 +197,17 @@ fun NoteListScreen(
|
||||
Icon(Icons.Default.Search, contentDescription = "Search notes")
|
||||
}
|
||||
}
|
||||
// Trash view gains an "Empty Trash" button whenever it
|
||||
// holds something; the destructive action is confirmed
|
||||
// through a dialog before anything is touched.
|
||||
if (filterMode == NoteFilter.Trash && state.notes.isNotEmpty()) {
|
||||
IconButton(onClick = { showEmptyTrashDialog = true }) {
|
||||
Icon(
|
||||
Icons.Default.DeleteForever,
|
||||
contentDescription = "Empty trash",
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
@@ -234,8 +280,10 @@ private fun screenTitle(filter: NoteFilter): String = when (filter) {
|
||||
NoteFilter.Home -> "Incido"
|
||||
NoteFilter.Favorites -> "Favorites"
|
||||
NoteFilter.Untagged -> "Untagged"
|
||||
NoteFilter.Drafts -> "Drafts"
|
||||
NoteFilter.Trash -> "Trash"
|
||||
is NoteFilter.ByTag -> "#${filter.hashtag}"
|
||||
is NoteFilter.ByColor -> filter.color.label
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -244,8 +292,10 @@ private fun EmptyState(filterMode: NoteFilter) {
|
||||
NoteFilter.Home -> "No notes yet. Tap + to start."
|
||||
NoteFilter.Favorites -> "No favourites yet. Tap ⭐ on a card to add one."
|
||||
NoteFilter.Untagged -> "All notes are tagged. 🎉"
|
||||
NoteFilter.Drafts -> "No drafts yet. Start typing a new note and it lands here."
|
||||
NoteFilter.Trash -> "Trash is empty."
|
||||
is NoteFilter.ByTag -> "No notes tagged #${filterMode.hashtag} yet."
|
||||
is NoteFilter.ByColor -> "No " + filterMode.color.label.lowercase() + " notes yet. Pick a colour in the editor."
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -265,7 +315,9 @@ private fun EmptyState(filterMode: NoteFilter) {
|
||||
private fun NoResultsState(filterMode: NoteFilter) {
|
||||
val message = when (filterMode) {
|
||||
NoteFilter.Home -> "No matching notes."
|
||||
NoteFilter.Drafts -> "No drafts match your search."
|
||||
NoteFilter.Trash -> "No notes in Trash match your search."
|
||||
is NoteFilter.ByColor -> "No matching notes of this colour."
|
||||
else -> "Nothing here."
|
||||
}
|
||||
Box(
|
||||
@@ -393,8 +445,21 @@ private fun NoteCard(
|
||||
// v0.3.8.0: task / shopping lists render marker-free on cards —
|
||||
// header line becomes the title, items show as clean "Name ×qty @$X"
|
||||
// text. The checkbox state lives in the summary row below instead.
|
||||
val (title, body) = if (note.type == NoteType.TEXT) Note.titleAndBody(note.content)
|
||||
else Note.cardPresentation(note.content, note.type)
|
||||
// v0.4.2.0: voice notes carry a plain prose body (title = first
|
||||
// line), so they split like TEXT — the cardPresentation list parser
|
||||
// would mangle their content.
|
||||
val (title, body) =
|
||||
if (note.type == NoteType.TEXT || note.type == NoteType.VOICE_NOTE)
|
||||
Note.titleAndBody(note.content)
|
||||
else Note.cardPresentation(note.content, note.type)
|
||||
// Drafts with no title introduce themselves by kind — "Shopping
|
||||
// List - (draft)" beats a bare "Untitled" in the Drafts view. The
|
||||
// stored content is untouched; this is display-only, so typing a
|
||||
// real title (or publishing) reverts the card to normal instantly.
|
||||
val displayTitle =
|
||||
if (note.isDraft && title == Note.UNTITLED)
|
||||
"${note.type.displayName} - (draft)"
|
||||
else title
|
||||
val bodyPreview = Note.bodyPreview(body)
|
||||
val checklistSummary = Note.checklistSummary(note.content)
|
||||
val noteColor = note.color
|
||||
@@ -508,7 +573,7 @@ private fun NoteCard(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
text = displayTitle,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = titleColor,
|
||||
maxLines = 1,
|
||||
@@ -547,6 +612,27 @@ private fun NoteCard(
|
||||
)
|
||||
}
|
||||
}
|
||||
if (note.type == NoteType.VOICE_NOTE) {
|
||||
// v0.4.2.0: voice notes carry a mic badge so the
|
||||
// kind is recognisable on the card even when the
|
||||
// body is empty (the take itself is an audio
|
||||
// attachment, not visible as a thumbnail).
|
||||
Spacer(modifier = Modifier.padding(top = 4.dp))
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
Icons.Default.Mic,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(14.dp),
|
||||
tint = secondaryColor,
|
||||
)
|
||||
Spacer(Modifier.size(6.dp))
|
||||
Text(
|
||||
text = note.type.displayName,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = secondaryColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (note.hashtags.isNotEmpty()) {
|
||||
Spacer(modifier = Modifier.padding(top = 4.dp))
|
||||
HashtagRow(
|
||||
|
||||
@@ -44,7 +44,8 @@ data class NoteListUiState(
|
||||
) {
|
||||
val isEmpty: Boolean
|
||||
get() = !isLoading && notes.isEmpty() && !isSearchActive &&
|
||||
(filter == NoteFilter.Home || filter == NoteFilter.Trash)
|
||||
(filter == NoteFilter.Home || filter == NoteFilter.Trash ||
|
||||
filter == NoteFilter.Drafts)
|
||||
val noResults: Boolean get() = !isLoading && notes.isEmpty() && !isEmpty
|
||||
}
|
||||
|
||||
@@ -73,8 +74,11 @@ class NoteListViewModel(
|
||||
NoteFilter.Home -> if (q.isBlank()) repository.observeAll() else repository.search(q)
|
||||
NoteFilter.Favorites -> if (q.isBlank()) repository.observeFavorites() else repository.searchFavorites(q)
|
||||
NoteFilter.Untagged -> if (q.isBlank()) repository.observeUntagged() else repository.searchUntagged(q)
|
||||
NoteFilter.Drafts -> if (q.isBlank()) repository.observeDrafts() else repository.searchDrafts(q)
|
||||
NoteFilter.Trash -> if (q.isBlank()) repository.observeTrashed() else repository.searchTrashed(q)
|
||||
is NoteFilter.ByTag -> repository.observeNotesForHashtag(f.hashtag)
|
||||
is NoteFilter.ByColor ->
|
||||
if (q.isBlank()) repository.observeByColor(f.color) else repository.searchByColor(q, f.color)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +160,11 @@ class NoteListViewModel(
|
||||
viewModelScope.launch { repository.delete(id) }
|
||||
}
|
||||
|
||||
/** "Empty Trash": permanently destroy every note in the Trash. */
|
||||
fun emptyTrash() {
|
||||
viewModelScope.launch { repository.deleteAllTrashed() }
|
||||
}
|
||||
|
||||
/** Restore a note from Trash. */
|
||||
fun restore(id: Long) {
|
||||
viewModelScope.launch { repository.restore(id) }
|
||||
|
||||
@@ -354,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.4.0.0"
|
||||
const val APP_VERSION = "0.4.2.0"
|
||||
|
||||
val Factory: ViewModelProvider.Factory = viewModelFactory {
|
||||
initializer {
|
||||
|
||||
@@ -43,6 +43,8 @@ data class NoteEntity(
|
||||
@Index var isTrashed: Boolean = false,
|
||||
/** v0.3.8.0 — [org.incido.domain.model.NoteType] storage key (0 text, 1 task, 2 shopping). */
|
||||
var typeKey: Short = 0,
|
||||
/** True while a new note is being drafted; only the Drafts view shows these rows. */
|
||||
@Index var isDraft: Boolean = false,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
@@ -57,6 +59,7 @@ data class NoteEntity(
|
||||
if (cipherVersion != other.cipherVersion) return false
|
||||
if (!contentBlob.contentEquals(other.contentBlob)) return false
|
||||
if (typeKey != other.typeKey) return false
|
||||
if (isDraft != other.isDraft) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -71,6 +74,7 @@ data class NoteEntity(
|
||||
result = 31 * result + cipherVersion.hashCode()
|
||||
result = 31 * result + contentBlob.contentHashCode()
|
||||
result = 31 * result + typeKey.hashCode()
|
||||
result = 31 * result + isDraft.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -84,6 +88,7 @@ internal fun NoteEntity.toDomain(): Note = Note(
|
||||
color = NoteColor.fromStorageKey(colorKey),
|
||||
isTrashed = isTrashed,
|
||||
type = NoteType.fromStorageKey(typeKey),
|
||||
isDraft = isDraft,
|
||||
)
|
||||
|
||||
internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
@@ -95,4 +100,5 @@ internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
colorKey = color.storageKey,
|
||||
isTrashed = isTrashed,
|
||||
typeKey = type.storageKey,
|
||||
isDraft = isDraft,
|
||||
)
|
||||
@@ -34,6 +34,7 @@ import org.incido.domain.model.Hashtag
|
||||
import org.incido.domain.model.HashtagUsage
|
||||
import org.incido.domain.model.Note
|
||||
import org.incido.domain.model.NoteAttachment
|
||||
import org.incido.domain.model.NoteColor
|
||||
import org.incido.domain.model.NoteType
|
||||
import org.incido.domain.repository.NoteRepository
|
||||
|
||||
@@ -119,6 +120,45 @@ class NoteRepositoryImpl(
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeDrafts(): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotDrafts())
|
||||
val sub = noteBox.query()
|
||||
.equal(NoteEntity_.isDraft, true)
|
||||
.build()
|
||||
.subscribe()
|
||||
.observer { trySend(snapshotDrafts()) }
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun searchDrafts(query: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotDraftsSearch(query))
|
||||
val sub = noteBox.query().build().subscribe().observer {
|
||||
trySend(snapshotDraftsSearch(query))
|
||||
}
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeByColor(color: NoteColor): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotByColor(color))
|
||||
// Kotlin stubs expose only equal(Property, Long) for integer
|
||||
// columns — widen the Short storage key (ObjectBox integer
|
||||
// columns are width-agnostic, so the match is exact).
|
||||
val sub = noteBox.query()
|
||||
.equal(NoteEntity_.colorKey, color.storageKey.toLong())
|
||||
.build()
|
||||
.subscribe()
|
||||
.observer { trySend(snapshotByColor(color)) }
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun searchByColor(query: String, color: NoteColor): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotByColorSearch(query, color))
|
||||
val sub = noteBox.query().build().subscribe().observer {
|
||||
trySend(snapshotByColorSearch(query, color))
|
||||
}
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeNotesForHashtag(name: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotForHashtag(name))
|
||||
val sub = noteBox.query().build().subscribe().observer { trySend(snapshotForHashtag(name)) }
|
||||
@@ -318,6 +358,7 @@ class NoteRepositoryImpl(
|
||||
private fun contentMatchingNoteIds(
|
||||
query: String,
|
||||
includeTrashed: Boolean = false,
|
||||
includeDrafts: Boolean = false,
|
||||
): List<Long> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return emptyList()
|
||||
@@ -332,13 +373,15 @@ class NoteRepositoryImpl(
|
||||
noteBox.all.filter { toReadable(it).content.lowercase().contains(needle) }
|
||||
}
|
||||
return candidates
|
||||
.filter { it.isTrashed == includeTrashed }
|
||||
.filter {
|
||||
it.isTrashed == includeTrashed && (includeDrafts || !it.isDraft)
|
||||
}
|
||||
.map { it.id }
|
||||
}
|
||||
|
||||
/** IDs of rows eligible for all active-note queries. */
|
||||
/** IDs of rows eligible for all active-note queries (never trashed, never drafts). */
|
||||
private fun activeNoteIds(): Set<Long> =
|
||||
noteBox.all.filter { !it.isTrashed }.mapTo(HashSet()) { it.id }
|
||||
noteBox.all.filter { !it.isTrashed && !it.isDraft }.mapTo(HashSet()) { it.id }
|
||||
|
||||
/** IDs of tags currently used by at least one active note. */
|
||||
private fun activeTagIds(): Set<Long> {
|
||||
@@ -374,7 +417,7 @@ class NoteRepositoryImpl(
|
||||
.build()
|
||||
.find()
|
||||
.mapNotNull { ref -> noteBox.get(ref.noteId) }
|
||||
.filter { it.isTrashed == includeTrashed }
|
||||
.filter { it.isTrashed == includeTrashed && !it.isDraft }
|
||||
.map { it.id }
|
||||
}
|
||||
|
||||
@@ -453,11 +496,47 @@ class NoteRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "Empty Trash": permanently delete every trashed row with the
|
||||
* exact same cascade as [delete] — note row, hashtag cross-links,
|
||||
* and attachment rows (their blobs live inside the attachment
|
||||
* entities, so removing the row frees them too).
|
||||
*/
|
||||
override suspend fun deleteAllTrashed() {
|
||||
val trashedIds: LongArray = noteBox.query()
|
||||
.equal(NoteEntity_.isTrashed, true)
|
||||
.build()
|
||||
.find()
|
||||
.map { it.id }
|
||||
.toLongArray()
|
||||
if (trashedIds.isEmpty()) return
|
||||
noteBox.remove(*trashedIds)
|
||||
trashedIds.forEach { id ->
|
||||
val orphanXrefs: List<NoteHashtagCrossRef> = xrefBox.query()
|
||||
.equal(NoteHashtagCrossRef_.noteId, id)
|
||||
.build()
|
||||
.find()
|
||||
if (orphanXrefs.isNotEmpty()) {
|
||||
xrefBox.remove(*orphanXrefs.map { it.id }.toLongArray())
|
||||
}
|
||||
val orphanAttachments: List<NoteAttachmentEntity> = attachmentBox.query()
|
||||
.equal(NoteAttachmentEntity_.noteId, id)
|
||||
.build()
|
||||
.find()
|
||||
if (orphanAttachments.isNotEmpty()) {
|
||||
attachmentBox.remove(*orphanAttachments.map { it.id }.toLongArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Soft-delete only changes state; the row, links, and blobs remain intact. */
|
||||
override suspend fun softDelete(id: Long) {
|
||||
val entity = noteBox.get(id) ?: return
|
||||
if (entity.isTrashed) return
|
||||
entity.isTrashed = true
|
||||
// A trashed draft comes back as a normal note on Restore — the
|
||||
// draft lifecycle ends the moment it moves to Trash.
|
||||
entity.isDraft = false
|
||||
// `put` is intentional here: content may be ciphertext already,
|
||||
// so do not pass it through toWritable and encrypt the ciphertext a
|
||||
// second time. Only the additive flag is changing.
|
||||
@@ -603,11 +682,15 @@ class NoteRepositoryImpl(
|
||||
private fun decorate(
|
||||
entities: List<NoteEntity>,
|
||||
includeTrashed: Boolean? = false,
|
||||
includeDrafts: Boolean = false,
|
||||
): List<Note> {
|
||||
val tags = hashtagsByNoteId()
|
||||
val attachments = attachmentsByNoteId()
|
||||
return entities
|
||||
.filter { includeTrashed == null || it.isTrashed == includeTrashed }
|
||||
.filter {
|
||||
(includeTrashed == null || it.isTrashed == includeTrashed) &&
|
||||
(includeDrafts || !it.isDraft)
|
||||
}
|
||||
.sortedWith(
|
||||
compareByDescending<NoteEntity> { it.isFavorite }
|
||||
.thenByDescending { it.updatedAt },
|
||||
@@ -636,7 +719,8 @@ class NoteRepositoryImpl(
|
||||
|
||||
private fun snapshotAll(): List<Note> = decorate(noteBox.all)
|
||||
|
||||
private fun snapshotAllIncludingTrashed(): List<Note> = decorate(noteBox.all, includeTrashed = null)
|
||||
private fun snapshotAllIncludingTrashed(): List<Note> =
|
||||
decorate(noteBox.all, includeTrashed = null, includeDrafts = true)
|
||||
|
||||
private fun snapshotSearch(query: String): List<Note> {
|
||||
val allIds = matchingNoteIds(query, includeTrashed = false)
|
||||
@@ -661,6 +745,66 @@ class NoteRepositoryImpl(
|
||||
return decorate(trashedEntities, includeTrashed = true)
|
||||
}
|
||||
|
||||
private fun snapshotDrafts(): List<Note> {
|
||||
val draftEntities: List<NoteEntity> = noteBox.query()
|
||||
.equal(NoteEntity_.isDraft, true)
|
||||
.build()
|
||||
.find()
|
||||
return decorate(draftEntities, includeTrashed = null, includeDrafts = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Content search restricted to drafts (tag-name matches are not
|
||||
* folded in, mirroring the plain-text scope of the Drafts view).
|
||||
*/
|
||||
private fun snapshotDraftsSearch(query: String): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotDrafts()
|
||||
val draftIds: Set<Long> = noteBox.query()
|
||||
.equal(NoteEntity_.isDraft, true)
|
||||
.build()
|
||||
.find()
|
||||
.mapTo(HashSet()) { it.id }
|
||||
val matches: List<Long> = contentMatchingNoteIds(
|
||||
q,
|
||||
includeTrashed = false,
|
||||
includeDrafts = true,
|
||||
).filter { it in draftIds }
|
||||
val entities: List<NoteEntity> = matches.mapNotNull { noteBox.get(it) }
|
||||
return decorate(entities, includeTrashed = null, includeDrafts = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Active notes of one accent colour. The colour query already
|
||||
* excludes nothing on trash state, so `decorate` (default
|
||||
* `includeTrashed = false`) drops trashed rows exactly like
|
||||
* [snapshotFavorites] / [snapshotUntagged] do.
|
||||
*/
|
||||
private fun snapshotByColor(color: NoteColor): List<Note> {
|
||||
val colorEntities: List<NoteEntity> = noteBox.query()
|
||||
.equal(NoteEntity_.colorKey, color.storageKey.toLong())
|
||||
.build()
|
||||
.find()
|
||||
return decorate(colorEntities)
|
||||
}
|
||||
|
||||
/**
|
||||
* Context-aware search across notes of [color] only. Blank [query]
|
||||
* degrades to [snapshotByColor]. Otherwise runs the same content +
|
||||
* hashtag-name matching as [snapshotFavoritesSearch] and intersects
|
||||
* with the colour (never trashed rows — matchingNoteIds already
|
||||
* excludes them via includeTrashed = false).
|
||||
*/
|
||||
private fun snapshotByColorSearch(query: String, color: NoteColor): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotByColor(color)
|
||||
val allIds: Set<Long> = matchingNoteIds(q, includeTrashed = false)
|
||||
if (allIds.isEmpty()) return emptyList()
|
||||
val entities: List<NoteEntity> = allIds.mapNotNull { id -> noteBox.get(id) }
|
||||
.filter { it.colorKey == color.storageKey }
|
||||
return decorate(entities)
|
||||
}
|
||||
|
||||
private fun snapshotUntagged(): List<Note> {
|
||||
val activeIds = activeNoteIds()
|
||||
val noteIdsWithTags: Set<Long> = xrefBox.all
|
||||
|
||||
@@ -24,14 +24,30 @@ data class Note(
|
||||
val attachments: List<NoteAttachment> = emptyList(),
|
||||
/** True only for notes moved to the Trash view; active-note queries exclude these rows. */
|
||||
val isTrashed: Boolean = false,
|
||||
/**
|
||||
* True while a new note is being drafted. Drafts auto-save every
|
||||
* edit and are visible only in the Drafts view — Home / Favorites /
|
||||
* Untagged / tag / colour views / ordinary search / Trash all
|
||||
* exclude them. Saving from the editor (or moving to Trash) clears
|
||||
* the flag.
|
||||
*/
|
||||
val isDraft: Boolean = false,
|
||||
/** v0.3.8.0 — which editor surface opens this note (see [NoteType]). */
|
||||
val type: NoteType = NoteType.TEXT,
|
||||
) {
|
||||
/** Convenience: the first image attachment, or `null` if none. */
|
||||
val firstImageAttachment: NoteAttachment?
|
||||
get() = attachments.firstOrNull { it.isImage }
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — Convenience: the first audio attachment (the note's
|
||||
* voice take, see [NoteType.VOICE_NOTE]), or `null` if none.
|
||||
*/
|
||||
val firstAudioAttachment: NoteAttachment?
|
||||
get() = attachments.firstOrNull { it.mimeType.startsWith("audio/") }
|
||||
companion object {
|
||||
private const val UNTITLED = "Untitled"
|
||||
/** Shown when a note's content has no usable first line. */
|
||||
const val UNTITLED = "Untitled"
|
||||
|
||||
/**
|
||||
* Splits [content] into a (title, body) pair. The title is the first
|
||||
|
||||
@@ -24,4 +24,7 @@ data class NoteAttachment(
|
||||
) {
|
||||
/** Convenience: true for any image-prefixed mime type. */
|
||||
val isImage: Boolean get() = mimeType.startsWith("image/")
|
||||
|
||||
/** v0.4.2.0 — true for any audio-prefixed mime type (voice-note take). */
|
||||
val isAudio: Boolean get() = mimeType.startsWith("audio/")
|
||||
}
|
||||
@@ -5,13 +5,13 @@ package org.incido.domain.model
|
||||
* Stored as a short (`SHORT`) in ObjectBox — additive-safe migration from
|
||||
* the v0.1 schema.
|
||||
*/
|
||||
enum class NoteColor(val storageKey: Short) {
|
||||
NONE(0),
|
||||
BLUE(1),
|
||||
GREEN(2),
|
||||
AMBER(3),
|
||||
RED(4),
|
||||
PURPLE(5);
|
||||
enum class NoteColor(val storageKey: Short, val label: String) {
|
||||
NONE(0, "None"),
|
||||
BLUE(1, "Blue"),
|
||||
GREEN(2, "Green"),
|
||||
AMBER(3, "Amber"),
|
||||
RED(4, "Red"),
|
||||
PURPLE(5, "Purple");
|
||||
|
||||
companion object {
|
||||
/** Convert from the stored [Short] back to the enum, defaulting to [NONE]. */
|
||||
|
||||
@@ -9,21 +9,29 @@ package org.incido.domain.model
|
||||
* - [Favorites] — only notes with `isFavorite = true`; ordinary search is enabled.
|
||||
* - [Untagged] — only notes that have zero hashtags; ordinary search is enabled.
|
||||
* - [ByTag] — only notes tagged with [hashtag]; text search is not offered.
|
||||
* - [ByColor] — active notes with accent colour [color]; ordinary search is
|
||||
* enabled and narrows within the colour (like Favorites).
|
||||
* - [Drafts] — auto-saved new notes; visible nowhere else until saved
|
||||
* or trashed. Ordinary search is enabled.
|
||||
* - [Trash] — only notes moved out of the active list; no edit actions.
|
||||
*/
|
||||
sealed class NoteFilter {
|
||||
object Home : NoteFilter()
|
||||
object Favorites : NoteFilter()
|
||||
object Untagged : NoteFilter()
|
||||
object Drafts : NoteFilter()
|
||||
object Trash : NoteFilter()
|
||||
data class ByTag(val hashtag: String) : NoteFilter()
|
||||
data class ByColor(val color: NoteColor) : NoteFilter()
|
||||
|
||||
/** Stable identifier used by the drawer for `selected` matching. */
|
||||
fun key(): String = when (this) {
|
||||
Home -> "home"
|
||||
Favorites -> "favorites"
|
||||
Untagged -> "untagged"
|
||||
Drafts -> "drafts"
|
||||
Trash -> "trash"
|
||||
is ByTag -> "tag:$hashtag"
|
||||
is ByColor -> "color:${color.name}"
|
||||
}
|
||||
}
|
||||
@@ -13,15 +13,24 @@ package org.incido.domain.model
|
||||
* Stored as a `Short` in ObjectBox — additive-safe migration from
|
||||
* the pre-v0.3.8.0 schema (rows without the column default to [TEXT]).
|
||||
*/
|
||||
enum class NoteType(val storageKey: Short) {
|
||||
enum class NoteType(val storageKey: Short, val displayName: String) {
|
||||
/** Free-form body edited in the plain multi-line field. */
|
||||
TEXT(0),
|
||||
TEXT(0, "Text Note"),
|
||||
|
||||
/** Editable checklist: checkbox + item text rows. */
|
||||
TASK_LIST(1),
|
||||
TASK_LIST(1, "Task List"),
|
||||
|
||||
/** Checklist plus a per-item cost (number pad) and a running total. */
|
||||
SHOPPING_LIST(2);
|
||||
SHOPPING_LIST(2, "Shopping List"),
|
||||
|
||||
/**
|
||||
* v0.4.2.0 — a note carrying a voice recording. The body stays a
|
||||
* plain text field (title = first line, exactly like [TEXT]); the
|
||||
* audio itself is an ordinary audio-prefixed attachment (see
|
||||
* [Note.firstAudioAttachment]), rendered by the editor's audio
|
||||
* player bar directly above the body.
|
||||
*/
|
||||
VOICE_NOTE(3, "Voice Note");
|
||||
|
||||
companion object {
|
||||
/** Convert from the stored [Short] back to the enum, defaulting to [TEXT]. */
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.incido.domain.repository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.incido.domain.model.HashtagUsage
|
||||
import org.incido.domain.model.Note
|
||||
import org.incido.domain.model.NoteColor
|
||||
import org.incido.domain.model.NoteAttachment
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,13 @@ interface NoteRepository {
|
||||
/** Permanently delete a note by id. No-op if it doesn't exist. */
|
||||
suspend fun delete(id: Long)
|
||||
|
||||
/**
|
||||
* "Empty Trash": permanently delete EVERY trashed note in one go,
|
||||
* with the same cascade as [delete] (row + hashtag links +
|
||||
* attachment blobs). No-op when the Trash is already empty.
|
||||
*/
|
||||
suspend fun deleteAllTrashed()
|
||||
|
||||
/** Move a note to Trash without removing its row, tags, or attachments. */
|
||||
suspend fun softDelete(id: Long)
|
||||
|
||||
@@ -56,6 +64,35 @@ interface NoteRepository {
|
||||
/** Only notes in Trash, sorted by updatedAt DESC. */
|
||||
fun observeTrashed(): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Only auto-saved draft notes (new notes the user hasn't saved yet),
|
||||
* sorted favourites-first then newest-first. Drafts appear in no
|
||||
* other view — see [Note.isDraft].
|
||||
*/
|
||||
fun observeDrafts(): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Context-aware content search across drafts only; blank [query]
|
||||
* returns the same as [observeDrafts].
|
||||
*/
|
||||
fun searchDrafts(query: String): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Only **active** notes (never trashed) whose accent colour is
|
||||
* [color], sorted favourites-first then newest-first. Tagged and
|
||||
* untagged notes are both eligible — only the colour matters.
|
||||
*/
|
||||
fun observeByColor(color: NoteColor): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Context-aware search across notes of [color] only — matches
|
||||
* [Note.content] (contains, case-insensitive) AND any of the
|
||||
* note's hashtags (case-insensitive equality), intersected with
|
||||
* the colour and the active (non-trashed) set. Blank [query]
|
||||
* returns the same as [observeByColor].
|
||||
*/
|
||||
fun searchByColor(query: String, color: NoteColor): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Context-aware search across **favourites only** — matches
|
||||
* [Note.content] (contains, case-insensitive) AND any of the note's
|
||||
|
||||
Reference in new issue
Block a user