feat(phase-1/m1b): :desktopApp — desktop shell over the real repository
Phase 1 milestone M1b: a Compose Multiplatform window driven by the same
NoteRepositoryImpl the Android app uses, over its own ObjectBox library.
DesktopContainer mirrors AppContainer's construction order (store,
CipherHolder, repository). Owns its library at
$XDG_DATA_HOME/incido — a separate library per machine,
since ObjectBox is single-writer; the backup file (M2)
is the only bridge to the phone. --data-dir opens
another library, e.g. one pulled off a phone.
Main.kt two panes, save-as-you-type with a 400ms debounce,
favourite toggle. Material 3 defaults on purpose: the
app's theme and screens arrive with the M4 composeApp
conversion, which deletes this stand-in.
Verified headlessly (--self-test drives the same repository calls the "+"
button and the star make, --exit-after auto-closes), against a library
previously written by :core:data-jvm:smoke — i.e. a different module's
generated MyObjectBox, same schema:
RENDER notes=0 selected=null first frame (collectAsState initial value)
RENDER notes=1 selected=1 ObjectBox flow delivered
SELFTEST wrote note id=2 write path through the UI's own calls
RENDER notes=2 selected=2 and it came back through the flow
reopen -> RENDER notes=2 persisted
Gotcha recorded in the findings doc: the first composition always sees the
empty initial value of collectAsState, so anything asserting on note counts
must watch the flow rather than the first frame.
Still synthetic: theme + screens. Not wired yet: settings, encryption (M3),
backup bridge (M2), packaging (M5). assembleDebug verified green.
This commit is contained in:
1 parent
9fe4763aa7
commit
5f45b0921b
7 files changed
+442
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package org.incido.desktop
|
||||
|
||||
import java.io.File
|
||||
import org.incido.data.ImageOrientationNormalizer
|
||||
import org.incido.data.ObjectBoxStore
|
||||
import org.incido.data.crypto.CipherHolder
|
||||
import org.incido.data.repository.NoteRepositoryImpl
|
||||
import org.incido.domain.repository.NoteRepository
|
||||
|
||||
/**
|
||||
* Hand-rolled DI container for the desktop build — the JVM counterpart of
|
||||
* the Android app's `AppContainer` (Development Plan §6, Phase 1, M1b).
|
||||
*
|
||||
* Deliberately mirrors Android's construction order: open the store, then
|
||||
* build the repository over a shared [CipherHolder] so installing or removing
|
||||
* at-rest encryption later is a one-line change here instead of a rebuild of
|
||||
* the graph.
|
||||
*
|
||||
* Two Android behaviours are intentionally absent, both planned work:
|
||||
* - at-rest encryption (milestone M3 — needs a JVM KeyProvider; the
|
||||
* recovery-key envelope is already proven portable), and
|
||||
* - EXIF rotation (milestone M4 — needs a JVM image decoder, so inbound
|
||||
* images are stored exactly as received for now).
|
||||
*/
|
||||
class DesktopContainer(dataDir: File) {
|
||||
|
||||
val cipherHolder = CipherHolder()
|
||||
|
||||
val boxStore = ObjectBoxStore.init(dataDir)
|
||||
|
||||
val repository: NoteRepository = NoteRepositoryImpl(
|
||||
boxStore = boxStore,
|
||||
cipherHolder = cipherHolder,
|
||||
orientationNormalizer = ImageOrientationNormalizer.NoOp,
|
||||
)
|
||||
|
||||
fun shutdown() = ObjectBoxStore.reset()
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the desktop library lives: `$XDG_DATA_HOME/incido`, falling back to
|
||||
* `~/.local/share/incido` (Development Plan §6 — a *separate* library per
|
||||
* machine; the backup file is the bridge to the phone, never the DB itself,
|
||||
* because ObjectBox is single-writer).
|
||||
*/
|
||||
fun defaultDataDir(): File {
|
||||
val sep = File.separator
|
||||
val base = System.getenv("XDG_DATA_HOME")?.takeIf { it.isNotBlank() }
|
||||
?: System.getProperty("user.home") + sep + ".local" + sep + "share"
|
||||
return File(base + sep + "incido").also { it.mkdirs() }
|
||||
}
|
||||
Reference in new issue
Block a user