feat: v0.2 - polish, favourites, search, colours, checklists, signing
v0.2 bundles all four phases from the planning session into a single
shippable release. versionCode 2 -> 3, versionName 0.1.1 -> 0.2.
DOMAIN
- Add NoteColor enum (NONE / BLUE / GREEN / AMBER / RED / PURPLE).
- Note: isFavorite + color fields; checklistCounts / checklistSummary
helpers parsing '- [ ]' / '- [x]' lines.
- NoteRepository: new search(query) + setFavorite(id, value) methods.
DATA
- NoteEntity: additive @Index isFavorite + colorKey (Short).
- NoteRepositoryImpl: search uses ObjectBox 'contains' case-insensitive;
observeAll + search sort favourites-first then updatedAt DESC.
UI
- NoteListViewModel: debounced(150ms) query -> repository.search;
openSearch / closeSearch helpers; toggleFavorite.
- NoteListScreen: search bar in top app bar; star icon + 4dp colour
stripe per card; checklist summary line ('N open - M done').
- NoteEditorViewModel: toggleFavorite + setColor; initial-snapshot
fields captured on first non-null observeById for dirty detection.
- NoteEditorScreen: BackHandler + AlertDialog 'Discard changes?' on
unsaved edits; star toggle in top bar; LazyRow of colour swatches.
POLISH
- Discard-confirm dialog implements Development Plan §5.2.
- Real release signing config (signingConfigs.release pointing at the
dev keystore in keystore/); keystore/release.jks gitignored;
keystore/README.md documents generation & rotation.
- KMP migration deferred to v0.5 (tracked in plan §10).
COMMUNITY / GITEA
- .gitea/workflows/build.yml: assembleDebug on push & PR, APK as
artefact.
- CONTRIBUTING.md, CODE_OF_CONDUCT.md (Contributor Covenant v2.1),
.gitea/ISSUE_TEMPLATE/{bug_report,feature_request}.yml,
.gitea/PULL_REQUEST_TEMPLATE.md.
- README: v0.2 changelog + Gitea remote-setup instructions.
VERIFIED
- ./gradlew assembleDebug assembleRelease both green.
- Debug APK 25.6 MB, release 19.8 MB, both v0.2 / versionCode 3.
- apksigner verify: 'Verifies' / v2 scheme true.
- No INTERNET permission in either APK (privacy posture unchanged).
This commit is contained in:
1 parent
2215c3447b
commit
5e1b77bedf
21 files changed
+1242
-118
No files matched your search
@@ -10,6 +10,8 @@ data class Note(
|
||||
val content: String,
|
||||
val createdAt: Long,
|
||||
val updatedAt: Long,
|
||||
val isFavorite: Boolean = false,
|
||||
val color: NoteColor = NoteColor.NONE,
|
||||
) {
|
||||
companion object {
|
||||
private const val UNTITLED = "Untitled"
|
||||
@@ -60,5 +62,35 @@ data class Note(
|
||||
if (collapsed.length <= maxChars) return collapsed
|
||||
return collapsed.take(maxChars).trimEnd() + "…"
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses GitHub-flavoured task-list lines from [content] and
|
||||
* returns (openCount, doneCount). Lines starting with `- [ ]` count
|
||||
* as open; `- [x]` (case-insensitive) count as done.
|
||||
*/
|
||||
fun checklistCounts(content: String): Pair<Int, Int> {
|
||||
val pattern = Regex("""^\s*-\s+\[( x| )]""", RegexOption.IGNORE_CASE)
|
||||
var open = 0
|
||||
var done = 0
|
||||
content.lineSequence().forEach { line ->
|
||||
val match = pattern.find(line) ?: return@forEach
|
||||
val isDone = match.groupValues[1].equals("x", ignoreCase = true)
|
||||
if (isDone) done++ else open++
|
||||
}
|
||||
return open to done
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience: "1 open" / "2 open · 3 done" / empty when no items.
|
||||
*/
|
||||
fun checklistSummary(content: String): String {
|
||||
val (open, done) = checklistCounts(content)
|
||||
return when {
|
||||
open == 0 && done == 0 -> ""
|
||||
done == 0 -> "$open open"
|
||||
open == 0 -> "$done done"
|
||||
else -> "$open open · $done done"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.incido.domain.model
|
||||
|
||||
/**
|
||||
* Six preset accent colours for notes, plus a sentinel "no colour" value.
|
||||
* 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);
|
||||
|
||||
companion object {
|
||||
/** Convert from the stored [Short] back to the enum, defaulting to [NONE]. */
|
||||
fun fromStorageKey(key: Short): NoteColor =
|
||||
values().firstOrNull { it.storageKey == key } ?: NONE
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,20 @@ import org.incido.domain.model.Note
|
||||
* so the list screen satisfies F7 (auto-refresh).
|
||||
* - Assign a fresh id (0 or 0L on construction) for new notes and use the
|
||||
* ObjectBox-managed id once persisted.
|
||||
* - Sort [observeAll] / [search] with favourites first, then by [Note.updatedAt]
|
||||
* descending.
|
||||
*/
|
||||
interface NoteRepository {
|
||||
/** Stream of all notes, newest-first. */
|
||||
/** Stream of all notes, newest-first, favourites pinned to the top. */
|
||||
fun observeAll(): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Stream of notes whose [Note.content] contains [query] (case-insensitive),
|
||||
* favourites first then newest-first. An empty / blank [query] returns
|
||||
* the same list as [observeAll].
|
||||
*/
|
||||
fun search(query: String): Flow<List<Note>>
|
||||
|
||||
/** Stream of a single note by id, or `null` if it has been deleted. */
|
||||
fun observeById(id: Long): Flow<Note?>
|
||||
|
||||
@@ -25,4 +34,7 @@ interface NoteRepository {
|
||||
|
||||
/** Delete a note by id. No-op if it doesn't exist. */
|
||||
suspend fun delete(id: Long)
|
||||
|
||||
/** Toggle the favourite flag on a single note. */
|
||||
suspend fun setFavorite(id: Long, isFavorite: Boolean)
|
||||
}
|
||||
Reference in new issue
Block a user