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

+19
View File
@@ -0,0 +1,19 @@
// core/domain — pure-Kotlin domain module (no Android dependencies).
// Contains business types and repository interfaces only.
// Implementation lives in :core:data.
plugins {
alias(libs.plugins.kotlinJvm)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
dependencies {
implementation(libs.kotlinx.coroutines.core)
}
@@ -0,0 +1,64 @@
package org.incido.domain.model
/**
* Domain representation of a note. This is the only [Note] type the UI layer
* should depend on. The ObjectBox-backed implementation in `:core:data` maps
* to/from its own entity type.
*/
data class Note(
val id: Long = 0L,
val content: String,
val createdAt: Long,
val updatedAt: Long,
) {
companion object {
private const val UNTITLED = "Untitled"
/**
* Splits [content] into a (title, body) pair. The title is the first
* non-empty line (trimmed); the body is everything after the first
* newline, with leading blank lines stripped.
*
* If the content is empty or has no non-empty line, the title is
* `"Untitled"` and the body is empty.
*/
fun titleAndBody(content: String): Pair<String, String> {
val lines = content.split('\n')
val title = lines.firstOrNull { it.isNotBlank() }?.trim() ?: UNTITLED
val firstTitleIdx = lines.indexOfFirst { it.isNotBlank() }
val bodyLines = if (firstTitleIdx >= 0) lines.drop(firstTitleIdx + 1) else emptyList()
// Strip leading blank lines from the body.
val bodyStart = bodyLines.indexOfFirst { it.isNotBlank() }
val body = if (bodyStart >= 0) {
bodyLines.drop(bodyStart).joinToString("\n").trimEnd()
} else {
""
}
return title to body
}
/**
* Returns a single-line preview of [content] for places that don't
* care about title vs. body (e.g. share previews, toasts).
*
* For the list-card title+body split, prefer [titleAndBody].
*/
fun preview(content: String, maxChars: Int = 240): String {
val collapsed = content.replace('\n', ' ').trim()
if (collapsed.length <= maxChars) return collapsed
return collapsed.take(maxChars).trimEnd() + "…"
}
/**
* Returns a multi-line preview of [body] for list-card body display.
* Whitespace runs are collapsed to single spaces, then truncated to
* [maxChars]. An ellipsis is appended when truncated.
*/
fun bodyPreview(body: String, maxChars: Int = 160): String {
if (body.isBlank()) return ""
val collapsed = body.replace(Regex("\\s+"), " ").trim()
if (collapsed.length <= maxChars) return collapsed
return collapsed.take(maxChars).trimEnd() + "…"
}
}
}
@@ -0,0 +1,28 @@
package org.incido.domain.repository
import kotlinx.coroutines.flow.Flow
import org.incido.domain.model.Note
/**
* Persistence boundary for [Note]s. The UI layer depends on this interface
* only — never on the ObjectBox-backed implementation in `:core:data`.
*
* Implementations are expected to:
* - Return a [Flow] that emits whenever the underlying data changes,
* 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.
*/
interface NoteRepository {
/** Stream of all notes, newest-first. */
fun observeAll(): Flow<List<Note>>
/** Stream of a single note by id, or `null` if it has been deleted. */
fun observeById(id: Long): Flow<Note?>
/** Persist a new note or update an existing one. Returns the persisted [Note]. */
suspend fun upsert(note: Note): Note
/** Delete a note by id. No-op if it doesn't exist. */
suspend fun delete(id: Long)
}