feat(lists): task and shopping-list note types with running total
dev / Build debug APK (push) Canceled after 15m52s
dev / Build debug APK (push) Canceled after 15m52s
NoteType (TEXT / TASK_LIST / SHOPPING_LIST) persists in an additive
NoteEntity.typeKey column (ObjectBox auto-migrates; old rows = TEXT).
List bodies stay GitHub-flavoured '- [ ]' lines so search, field
encryption, backups (defaulted noteType) and Trash keep working.
Editor: checklist + basket buttons convert any note; rows are uniform
underlined line fields (13sp) - product, 'Quan.' quantity (defaults to
1 on blur), and POS-style price showing raw cents while focused and
$1.23 on focus loss. Sticky total bar sums qty x price of checked
rows in integer cents via an explicit {q.. p..} end-of-line marker so
product text is never scanned for numbers.
Fixes found in device testing: cards rendered raw markdown for list
notes stranded as TEXT by partial builds - read-time Note.inferListType
now heals them; quantity field was clipped invisible (64dp vs the 48dp
icon target) - replaced by the free-text line; the serializer emitted
a bare 'q' slot (broken '{q p1.23}' markers, stray ' x' folds) - now
null-when-default. Add-tag suggestions rebuilt on flatMapLatest so the
autocomplete re-queries per keystroke.
versionCode 32->33, versionName 0.3.8.0, APP_VERSION in lockstep.
This commit is contained in:
1 parent
7b6187f99a
commit
32166a3100
14 files changed
+1044
-109
No files matched your search
@@ -5,6 +5,7 @@ import io.objectbox.annotation.Id
|
||||
import io.objectbox.annotation.Index
|
||||
import org.incido.domain.model.Note
|
||||
import org.incido.domain.model.NoteColor
|
||||
import org.incido.domain.model.NoteType
|
||||
|
||||
/**
|
||||
* ObjectBox entity. The plugin generates a corresponding property mirror
|
||||
@@ -20,6 +21,11 @@ import org.incido.domain.model.NoteColor
|
||||
* existing stores auto-migrate. The repository transparently
|
||||
* encrypts/decrypts on write/read when a [org.incido.data.crypto.FieldCipher]
|
||||
* is supplied.
|
||||
*
|
||||
* v0.3.8.0 — [typeKey] records the note editor mode
|
||||
* ([org.incido.domain.model.NoteType]: 0 text, 1 task list, 2 shopping
|
||||
* list). Additive column — existing stores auto-migrate and old rows
|
||||
* default to plain text.
|
||||
*/
|
||||
@Entity
|
||||
data class NoteEntity(
|
||||
@@ -35,6 +41,8 @@ data class NoteEntity(
|
||||
var contentBlob: ByteArray = ByteArray(0),
|
||||
/** True only for notes moved to the Trash view; active-note queries exclude these rows. */
|
||||
@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,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
@@ -48,6 +56,7 @@ data class NoteEntity(
|
||||
if (isTrashed != other.isTrashed) return false
|
||||
if (cipherVersion != other.cipherVersion) return false
|
||||
if (!contentBlob.contentEquals(other.contentBlob)) return false
|
||||
if (typeKey != other.typeKey) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -61,6 +70,7 @@ data class NoteEntity(
|
||||
result = 31 * result + isTrashed.hashCode()
|
||||
result = 31 * result + cipherVersion.hashCode()
|
||||
result = 31 * result + contentBlob.contentHashCode()
|
||||
result = 31 * result + typeKey.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -73,6 +83,7 @@ internal fun NoteEntity.toDomain(): Note = Note(
|
||||
isFavorite = isFavorite,
|
||||
color = NoteColor.fromStorageKey(colorKey),
|
||||
isTrashed = isTrashed,
|
||||
type = NoteType.fromStorageKey(typeKey),
|
||||
)
|
||||
|
||||
internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
@@ -83,4 +94,5 @@ internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
isFavorite = isFavorite,
|
||||
colorKey = color.storageKey,
|
||||
isTrashed = isTrashed,
|
||||
typeKey = type.storageKey,
|
||||
)
|
||||
@@ -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.NoteType
|
||||
import org.incido.domain.repository.NoteRepository
|
||||
|
||||
/**
|
||||
@@ -611,7 +612,7 @@ class NoteRepositoryImpl(
|
||||
compareByDescending<NoteEntity> { it.isFavorite }
|
||||
.thenByDescending { it.updatedAt },
|
||||
).map { e ->
|
||||
val base = toReadable(e).toDomain()
|
||||
val base = toReadable(e).toDomain().withHealedListType()
|
||||
base.copy(
|
||||
hashtags = tags[e.id].orEmpty(),
|
||||
attachments = attachments[e.id].orEmpty(),
|
||||
@@ -619,6 +620,20 @@ class NoteRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.3.8.0 FIX — notes whose bodies ARE checklist lines but which
|
||||
* persisted with `typeKey = 0` (written by a build predating the
|
||||
* column, or by a partial save of the list feature) would render as
|
||||
* raw `- [ ] …` markdown on cards and open in the plain editor.
|
||||
* Infer the list type from the content itself at READ time; the next
|
||||
* save from the editor then persists the healed `typeKey` for good.
|
||||
* TEXT notes containing only occasional hand-typed `- [ ]` lines in
|
||||
* prose are left untouched (see [Note.inferListType]).
|
||||
*/
|
||||
private fun Note.withHealedListType(): Note =
|
||||
if (type != NoteType.TEXT) this
|
||||
else Note.inferListType(content)?.let { copy(type = it) } ?: this
|
||||
|
||||
private fun snapshotAll(): List<Note> = decorate(noteBox.all)
|
||||
|
||||
private fun snapshotAllIncludingTrashed(): List<Note> = decorate(noteBox.all, includeTrashed = null)
|
||||
@@ -728,7 +743,7 @@ class NoteRepositoryImpl(
|
||||
val entity = noteBox.get(id) ?: return null
|
||||
val tags = hashtagsByNoteId()[id].orEmpty()
|
||||
val attachments = attachmentsByNoteId()[id].orEmpty()
|
||||
return toReadable(entity).toDomain().copy(
|
||||
return toReadable(entity).toDomain().withHealedListType().copy(
|
||||
hashtags = tags,
|
||||
attachments = attachments,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user