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
@@ -4,10 +4,14 @@ import io.objectbox.annotation.Entity
|
||||
import io.objectbox.annotation.Id
|
||||
import io.objectbox.annotation.Index
|
||||
import org.incido.domain.model.Note
|
||||
import org.incido.domain.model.NoteColor
|
||||
|
||||
/**
|
||||
* ObjectBox entity. The plugin generates a corresponding property mirror
|
||||
* class (`NoteEntity_`) at build time, plus the [MyObjectBox] container.
|
||||
*
|
||||
* v0.2 adds [isFavorite] and [color]. Both are additive (the prior v0.1
|
||||
* schema had neither) so existing user notes auto-migrate on first launch.
|
||||
*/
|
||||
@Entity
|
||||
data class NoteEntity(
|
||||
@@ -15,6 +19,8 @@ data class NoteEntity(
|
||||
var content: String = "",
|
||||
@Index var createdAt: Long = 0,
|
||||
var updatedAt: Long = 0,
|
||||
@Index var isFavorite: Boolean = false,
|
||||
var colorKey: Short = 0,
|
||||
)
|
||||
|
||||
internal fun NoteEntity.toDomain(): Note = Note(
|
||||
@@ -22,6 +28,8 @@ internal fun NoteEntity.toDomain(): Note = Note(
|
||||
content = content,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt,
|
||||
isFavorite = isFavorite,
|
||||
color = NoteColor.fromStorageKey(colorKey),
|
||||
)
|
||||
|
||||
internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
@@ -29,4 +37,6 @@ internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
content = content,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt,
|
||||
isFavorite = isFavorite,
|
||||
colorKey = color.storageKey,
|
||||
)
|
||||
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import org.incido.data.entity.NoteEntity
|
||||
import org.incido.data.entity.NoteEntity_
|
||||
import org.incido.data.entity.toDomain
|
||||
import org.incido.data.entity.toEntity
|
||||
import org.incido.domain.model.Note
|
||||
@@ -18,6 +19,9 @@ import org.incido.domain.repository.NoteRepository
|
||||
* ObjectBox-backed implementation of [NoteRepository]. All writes are
|
||||
* dispatched to `Default`; reads use ObjectBox's reactive subscription so
|
||||
* the UI auto-refreshes whenever a row changes (F7).
|
||||
*
|
||||
* Sort order is `isFavorite DESC, updatedAt DESC` for both [observeAll] and
|
||||
* [search] so favourites always float to the top.
|
||||
*/
|
||||
class NoteRepositoryImpl(
|
||||
private val boxStore: BoxStore,
|
||||
@@ -26,15 +30,28 @@ class NoteRepositoryImpl(
|
||||
private val box = boxStore.boxFor<NoteEntity>()
|
||||
|
||||
override fun observeAll(): Flow<List<Note>> = callbackFlow {
|
||||
// Emit the current snapshot first so the UI renders without waiting
|
||||
// for the first change.
|
||||
trySend(currentSnapshot())
|
||||
trySend(sortedSnapshot(""))
|
||||
|
||||
val subscription: DataSubscription = box
|
||||
val subscription = box
|
||||
.query()
|
||||
.build()
|
||||
.subscribe()
|
||||
.observer { trySend(currentSnapshot()) }
|
||||
.observer { trySend(sortedSnapshot("")) }
|
||||
|
||||
awaitClose { subscription.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun search(query: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(sortedSnapshot(query))
|
||||
|
||||
val subscription = if (query.isBlank()) {
|
||||
box.query().build().subscribe()
|
||||
} else {
|
||||
box.query()
|
||||
.contains(NoteEntity_.content, query, io.objectbox.query.QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.subscribe()
|
||||
}.observer { trySend(sortedSnapshot(query)) }
|
||||
|
||||
awaitClose { subscription.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
@@ -67,6 +84,30 @@ class NoteRepositoryImpl(
|
||||
box.remove(id)
|
||||
}
|
||||
|
||||
private fun currentSnapshot(): List<Note> =
|
||||
box.all.sortedByDescending { it.updatedAt }.map { it.toDomain() }
|
||||
override suspend fun setFavorite(id: Long, isFavorite: Boolean) {
|
||||
val entity = box.get(id) ?: return
|
||||
if (entity.isFavorite == isFavorite) return
|
||||
entity.isFavorite = isFavorite
|
||||
box.put(entity)
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot helper. If [query] is non-blank, only notes whose content
|
||||
* contains it (case-insensitive) are included; otherwise all notes.
|
||||
* The result is sorted favourites-first, then newest-first.
|
||||
*/
|
||||
private fun sortedSnapshot(query: String): List<Note> {
|
||||
val raw = if (query.isBlank()) {
|
||||
box.all
|
||||
} else {
|
||||
box.query()
|
||||
.contains(NoteEntity_.content, query, io.objectbox.query.QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.find()
|
||||
}
|
||||
return raw.sortedWith(
|
||||
compareByDescending<NoteEntity> { it.isFavorite }
|
||||
.thenByDescending { it.updatedAt }
|
||||
).map { it.toDomain() }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user