Initial v0.1.1 scaffold

- Multi-module Android project: app/ (entry point), composeApp/ (UI),
  core/domain/ (pure-Kotlin interfaces), core/data/ (ObjectBox-backed
  repository).
- Privacy-first: no INTERNET permission, no analytics, auto-backup
  disabled (data_extraction_rules.xml excludes all domains).
- AGPL-3.0 licensed with full LICENSE + NOTICE files.
- Material 3 UI with dynamic color on Android 12+, dark/light theme
  follows system.
- v0.1.1 polish:
    * Editor text field shrinks above the soft keyboard (Scaffold
      contentWindowInsets union(systemBars, ime) + windowSoftInputMode
      adjustResize).
    * List cards now render title (first non-empty line, titleMedium)
      plus abbreviated body preview (max 2 lines, ellipsised). Empty
      notes display as 'Untitled'.
    * versionCode 1 -> 2, versionName 0.1.0 -> 0.1.1.
This commit is contained in:
Incido Developer committed 2026-08-14 22:51:59 +12:00
commit 1477e2426d
44 files changed
+2880

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -0,0 +1,25 @@
package org.incido.data
import android.content.Context
import io.objectbox.BoxStore
import org.incido.data.entity.MyObjectBox
/**
* Singleton holder for the process-wide [BoxStore]. Initialised once from
* the Application/Activity context.
*/
object ObjectBoxStore {
@Volatile
private var instance: BoxStore? = null
fun init(context: Context): BoxStore =
instance ?: synchronized(this) {
instance ?: MyObjectBox.builder()
.androidContext(context.applicationContext)
.build()
.also { instance = it }
}
fun get(): BoxStore =
instance ?: error("ObjectBoxStore not initialised — call init(context) first")
}
@@ -0,0 +1,32 @@
package org.incido.data.entity
import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id
import io.objectbox.annotation.Index
import org.incido.domain.model.Note
/**
* ObjectBox entity. The plugin generates a corresponding property mirror
* class (`NoteEntity_`) at build time, plus the [MyObjectBox] container.
*/
@Entity
data class NoteEntity(
@Id var id: Long = 0,
var content: String = "",
@Index var createdAt: Long = 0,
var updatedAt: Long = 0,
)
internal fun NoteEntity.toDomain(): Note = Note(
id = id,
content = content,
createdAt = createdAt,
updatedAt = updatedAt,
)
internal fun Note.toEntity(): NoteEntity = NoteEntity(
id = id,
content = content,
createdAt = createdAt,
updatedAt = updatedAt,
)
@@ -0,0 +1,72 @@
package org.incido.data.repository
import io.objectbox.BoxStore
import io.objectbox.kotlin.boxFor
import io.objectbox.reactive.DataSubscription
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
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.toDomain
import org.incido.data.entity.toEntity
import org.incido.domain.model.Note
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).
*/
class NoteRepositoryImpl(
private val boxStore: BoxStore,
) : NoteRepository {
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())
val subscription: DataSubscription = box
.query()
.build()
.subscribe()
.observer { trySend(currentSnapshot()) }
awaitClose { subscription.cancel() }
}.flowOn(Dispatchers.Default)
override fun observeById(id: Long): Flow<Note?> = callbackFlow {
trySend(box.get(id)?.toDomain())
val subscription = box
.query()
.build()
.subscribe()
.observer { trySend(box.get(id)?.toDomain()) }
awaitClose { subscription.cancel() }
}.flowOn(Dispatchers.Default)
override suspend fun upsert(note: Note): Note {
val now = System.currentTimeMillis()
val toPersist = if (note.id == 0L) {
note.copy(createdAt = now, updatedAt = now).toEntity()
} else {
note.copy(updatedAt = now).toEntity()
}
val assignedId = box.put(toPersist)
val existing = box.get(assignedId)
return existing?.toDomain() ?: note.copy(id = assignedId)
}
override suspend fun delete(id: Long) {
box.remove(id)
}
private fun currentSnapshot(): List<Note> =
box.all.sortedByDescending { it.updatedAt }.map { it.toDomain() }
}