Android Phase D: Project foundation, Room DB, Retrofit API, Hilt
- Android CLI Setup: initialized empty-activity app (AGP 9.0, Kotlin 2.3.20)
- Version catalog: Compose BOM 2026.03.01, Material 3, Hilt 2.60.1, Room 2.7.2,
Retrofit 2.11.0, OkHttp 4.12.0, WorkManager 2.10.2, Kotlinx Serialization
- Room Database (v1): ListEntity, ItemEntity, OpLogEntity
- Room DAOs: ListDao, ItemDao, OpLogDao with LWW upsert queries
- Network layer: MitbringslApi Retrofit interface + DTOs + AuthInterceptor
- Dependency Injection: DatabaseModule, NetworkModule, RepositoryModule, HiltAndroidApp
- Build verification: assembleDebug & test green ✅
41
AGENTS.md
|
|
@ -164,9 +164,9 @@ Legende: ✅ erledigt · 🚧 in Arbeit · ⬜ offen
|
||||||
`upsertItemName` in Projektion (innerhalb Push-Transaktion).
|
`upsertItemName` in Projektion (innerhalb Push-Transaktion).
|
||||||
- ✅ **Phase C – Caddy:** `Caddyfile.behind-proxy` (auto_https off, trusted_proxies),
|
- ✅ **Phase C – Caddy:** `Caddyfile.behind-proxy` (auto_https off, trusted_proxies),
|
||||||
`CADDY_HTTP_PORT`/`CADDY_HTTPS_PORT` in docker-compose.
|
`CADDY_HTTP_PORT`/`CADDY_HTTPS_PORT` in docker-compose.
|
||||||
- ⬜ **Phase D – Android-Fundament:** Gradle (Kotlin DSL, Version Catalog, Hilt/KSP, Compose BOM),
|
- ✅ **Phase D – Android-Fundament:** Gradle (Kotlin DSL, Version Catalog, Hilt/KSP, Compose BOM, Room, Retrofit, WorkManager), Theme, Nav.
|
||||||
Theme, Nav, Room.
|
**Verifiziert:** `./gradlew assembleDebug` und `./gradlew test` erfolgreich.
|
||||||
- ⬜ **Phase D – Repository + Retrofit-API + DTOs.**
|
- ✅ **Phase D – Repository + Retrofit-API + DTOs:** Room DB (`lists`, `items`, `op_log`), DAOs (LWW upsert), `MitbringslApi`, AuthInterceptor, Hilt Modules (`DatabaseModule`, `NetworkModule`, `RepositoryModule`).
|
||||||
- ⬜ **Phase D – Login-Screen** (eigene User + Google Credential Manager + Generic OIDC PKCE).
|
- ⬜ **Phase D – Login-Screen** (eigene User + Google Credential Manager + Generic OIDC PKCE).
|
||||||
- ⬜ **Phase E – SyncEngine** (OutboxDrain + CursorPull via WorkManager), HLC client-side.
|
- ⬜ **Phase E – SyncEngine** (OutboxDrain + CursorPull via WorkManager), HLC client-side.
|
||||||
- ⬜ **Phase E – Listen-Übersicht + Detail + AddItemBar (Autocomplete) + Settings.**
|
- ⬜ **Phase E – Listen-Übersicht + Detail + AddItemBar (Autocomplete) + Settings.**
|
||||||
|
|
@ -174,27 +174,16 @@ Legende: ✅ erledigt · 🚧 in Arbeit · ⬜ offen
|
||||||
- ⬜ **Phase F – README + docs** (ARCHITECTURE/SYNC/API).
|
- ⬜ **Phase F – README + docs** (ARCHITECTURE/SYNC/API).
|
||||||
|
|
||||||
### Wo genau weitermachen?
|
### Wo genau weitermachen?
|
||||||
**Phase C ist komplett ✅. Nächster Schritt = Phase D (Android-Fundament).**
|
**Phase D (Fundament + Repositories) ist komplett ✅. Nächster Schritt = Phase D Login-Screen / Phase E SyncEngine.**
|
||||||
|
|
||||||
Phase C erledigt:
|
Phase D erledigt:
|
||||||
- ✅ `internal/sync/hlc.go` – HLC (wall_ms<<16|counter, Tick/Now/After, global mutex).
|
- ✅ Android CLI Setup (`android create empty-activity`).
|
||||||
- ✅ `internal/store/opstore.go` – AppendOps idempotent (ON CONFLICT DO NOTHING), LWW-Projektion
|
- ✅ Version Catalog (`libs.versions.toml`) mit Compose BOM, Hilt, Room, Retrofit, OkHttp, WorkManager, Kotlinx Serialization.
|
||||||
(list_create/rename/delete, item_add/update/remove), PullOps (cursor, 500er Pages).
|
- ✅ AGP 9.0 Compatibility (Kotlin Plugin built-in).
|
||||||
- ✅ `internal/store/liststore.go` – CreateList / GetLists / GetList (owner-check MVP).
|
- ✅ Room DB (`AppDatabase`), Entities (`ListEntity`, `ItemEntity`, `OpLogEntity`), DAOs mit LWW Upsert (`ListDao`, `ItemDao`, `OpLogDao`).
|
||||||
- ✅ `internal/store/itemstore.go` – GetItems (nicht-gelöschte Items einer Liste).
|
- ✅ Retrofit API Interface (`MitbringslApi`), DTOs (`Dtos.kt`), AuthInterceptor (Bearer Token Injection).
|
||||||
- ✅ `internal/store/suggeststore.go` – Search (pg_trgm fuzzy, LIKE-fallback, 10 Ergebnisse).
|
- ✅ Hilt Dependency Injection (`DatabaseModule`, `NetworkModule`, `RepositoryModule`, `@HiltAndroidApp MitbringslApp`).
|
||||||
- ✅ `internal/httpapi/lists.go` – GET/POST /api/lists, GET /api/lists/{id} + Items.
|
- ✅ Gradle build & unit tests verifiziert (`assembleDebug` & `test` grün).
|
||||||
- ✅ `internal/httpapi/ops.go` – POST /api/lists/{id}/ops (Push), GET /api/lists/{id}/ops (Pull).
|
|
||||||
- ✅ `internal/httpapi/suggest.go` – GET /api/suggestions?q=.
|
|
||||||
- ✅ `internal/httpapi/api.go` – alle Routen verdrahtet.
|
|
||||||
- ✅ `deploy/Caddyfile.behind-proxy` – auto_https off + trusted_proxies.
|
|
||||||
- ✅ `deploy/docker-compose.yml` – CADDY_HTTP_PORT / CADDY_HTTPS_PORT.
|
|
||||||
|
|
||||||
Phase D – Android-Fundament (offen):
|
|
||||||
1. Gradle-Setup: Kotlin DSL + `libs.versions.toml`, Hilt/KSP, Compose BOM, Room, Retrofit.
|
|
||||||
2. Theme (Material 3) + Navigation (Compose Nav).
|
|
||||||
3. Room-Datenbankschema (Listen/Items/OpLog/Outbox).
|
|
||||||
4. Retrofit-API + DTOs passend zu den Backend-Endpoints.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -238,6 +227,6 @@ docker run --rm --network <net> \
|
||||||
|
|
||||||
## Git-Status
|
## Git-Status
|
||||||
- Repo initialisiert, Branch `main`. Remote ist konfiguriert (`origin`).
|
- Repo initialisiert, Branch `main`. Remote ist konfiguriert (`origin`).
|
||||||
- Phase A + Phase B (vollständig) committed und gepusht.
|
- Phase A + Phase B + Phase C committed und gepusht.
|
||||||
- Phase C (Sync-Kern + Caddy behind-proxy) committed und gepusht. **Phase C vollständig ✅.**
|
- Phase D (Android-Fundament, Room DB, Retrofit API, Hilt Setup) committed und gepusht. **Phase D Fundament vollständig ✅.**
|
||||||
- Nächster Schritt: **Phase D – Android-Fundament** (siehe Roadmap oben).
|
- Nächster Schritt: **Login-Screen / Phase E SyncEngine** (siehe Roadmap oben).
|
||||||
|
|
|
||||||
17
android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
1
android/app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/build
|
||||||
125
android/app/build.gradle.kts
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.compose.compiler)
|
||||||
|
alias(libs.plugins.hilt)
|
||||||
|
alias(libs.plugins.kotlin.serialization)
|
||||||
|
alias(libs.plugins.ksp)
|
||||||
|
alias(libs.plugins.room)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.example.mitbringsl"
|
||||||
|
compileSdk = 36
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.example.mitbringsl"
|
||||||
|
minSdk = 26
|
||||||
|
targetSdk = 36
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
// Backend base URL – override in release build or via local.properties
|
||||||
|
buildConfigField("String", "BASE_URL", "\"http://10.0.2.2:8080/\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||||
|
// Override BASE_URL for production
|
||||||
|
buildConfigField("String", "BASE_URL", "\"https://mitbringsl.example.com/\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
buildConfig = true // needed for BASE_URL injection
|
||||||
|
aidl = false
|
||||||
|
shaders = false
|
||||||
|
}
|
||||||
|
|
||||||
|
packaging {
|
||||||
|
resources {
|
||||||
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Room schema export directory
|
||||||
|
room {
|
||||||
|
schemaDirectory("$projectDir/schemas")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(17)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
val composeBom = platform(libs.androidx.compose.bom)
|
||||||
|
implementation(composeBom)
|
||||||
|
androidTestImplementation(composeBom)
|
||||||
|
|
||||||
|
// Core Android
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||||
|
implementation(libs.androidx.activity.compose)
|
||||||
|
|
||||||
|
// Lifecycle / ViewModel
|
||||||
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
||||||
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||||
|
|
||||||
|
// Compose UI + Material3
|
||||||
|
implementation(libs.androidx.compose.ui)
|
||||||
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||||
|
implementation(libs.androidx.compose.material3)
|
||||||
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
|
|
||||||
|
// Navigation 3
|
||||||
|
implementation(libs.androidx.navigation3.ui)
|
||||||
|
implementation(libs.androidx.navigation3.runtime)
|
||||||
|
implementation(libs.androidx.lifecycle.viewmodel.navigation3)
|
||||||
|
|
||||||
|
// Hilt (DI)
|
||||||
|
implementation(libs.hilt.android)
|
||||||
|
ksp(libs.hilt.android.compiler)
|
||||||
|
implementation(libs.hilt.navigation.compose)
|
||||||
|
|
||||||
|
// Room (local DB – source of truth)
|
||||||
|
implementation(libs.room.runtime)
|
||||||
|
implementation(libs.room.ktx)
|
||||||
|
ksp(libs.room.compiler)
|
||||||
|
|
||||||
|
// Retrofit + OkHttp (network)
|
||||||
|
implementation(libs.retrofit)
|
||||||
|
implementation(libs.retrofit.serialization)
|
||||||
|
implementation(libs.okhttp)
|
||||||
|
implementation(libs.okhttp.logging)
|
||||||
|
|
||||||
|
// Kotlinx Serialization (JSON)
|
||||||
|
implementation(libs.kotlinx.serialization.json)
|
||||||
|
|
||||||
|
// Coroutines
|
||||||
|
implementation(libs.kotlinx.coroutines.android)
|
||||||
|
|
||||||
|
// WorkManager (background sync)
|
||||||
|
implementation(libs.workmanager.ktx)
|
||||||
|
implementation(libs.hilt.work)
|
||||||
|
ksp(libs.hilt.work.compiler)
|
||||||
|
|
||||||
|
// Tests
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
|
androidTestImplementation(libs.androidx.test.core)
|
||||||
|
androidTestImplementation(libs.androidx.test.ext.junit)
|
||||||
|
androidTestImplementation(libs.androidx.test.runner)
|
||||||
|
androidTestImplementation(libs.androidx.test.espresso.core)
|
||||||
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||||
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,305 @@
|
||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 1,
|
||||||
|
"identityHash": "c5e70cf816f82a65da0a30d8315b70e8",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "lists",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `ownerId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `hlcTs` INTEGER NOT NULL, PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ownerId",
|
||||||
|
"columnName": "ownerId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "createdAt",
|
||||||
|
"columnName": "createdAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "updatedAt",
|
||||||
|
"columnName": "updatedAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "deletedAt",
|
||||||
|
"columnName": "deletedAt",
|
||||||
|
"affinity": "INTEGER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hlcTs",
|
||||||
|
"columnName": "hlcTs",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_lists_ownerId",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"ownerId"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_lists_ownerId` ON `${TABLE_NAME}` (`ownerId`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_lists_deletedAt",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"deletedAt"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_lists_deletedAt` ON `${TABLE_NAME}` (`deletedAt`)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "items",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `listId` TEXT NOT NULL, `name` TEXT NOT NULL, `quantity` TEXT, `checked` INTEGER NOT NULL, `sortOrder` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `hlcTs` INTEGER NOT NULL, `clientId` TEXT, `checkedAt` INTEGER, PRIMARY KEY(`id`), FOREIGN KEY(`listId`) REFERENCES `lists`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "listId",
|
||||||
|
"columnName": "listId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "quantity",
|
||||||
|
"columnName": "quantity",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "checked",
|
||||||
|
"columnName": "checked",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "sortOrder",
|
||||||
|
"columnName": "sortOrder",
|
||||||
|
"affinity": "INTEGER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "createdAt",
|
||||||
|
"columnName": "createdAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "updatedAt",
|
||||||
|
"columnName": "updatedAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "deletedAt",
|
||||||
|
"columnName": "deletedAt",
|
||||||
|
"affinity": "INTEGER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hlcTs",
|
||||||
|
"columnName": "hlcTs",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "clientId",
|
||||||
|
"columnName": "clientId",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "checkedAt",
|
||||||
|
"columnName": "checkedAt",
|
||||||
|
"affinity": "INTEGER"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_items_listId",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"listId"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_items_listId` ON `${TABLE_NAME}` (`listId`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_items_deletedAt",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"deletedAt"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_items_deletedAt` ON `${TABLE_NAME}` (`deletedAt`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "lists",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"listId"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "op_log",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `listId` TEXT NOT NULL, `clientId` TEXT NOT NULL, `clientSeq` INTEGER NOT NULL, `opType` TEXT NOT NULL, `targetId` TEXT NOT NULL, `payload` TEXT NOT NULL, `hlcTs` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `serverSeq` INTEGER, `synced` INTEGER NOT NULL)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "localId",
|
||||||
|
"columnName": "localId",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "listId",
|
||||||
|
"columnName": "listId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "clientId",
|
||||||
|
"columnName": "clientId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "clientSeq",
|
||||||
|
"columnName": "clientSeq",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "opType",
|
||||||
|
"columnName": "opType",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "targetId",
|
||||||
|
"columnName": "targetId",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "payload",
|
||||||
|
"columnName": "payload",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hlcTs",
|
||||||
|
"columnName": "hlcTs",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "createdAt",
|
||||||
|
"columnName": "createdAt",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "serverSeq",
|
||||||
|
"columnName": "serverSeq",
|
||||||
|
"affinity": "INTEGER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "synced",
|
||||||
|
"columnName": "synced",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"localId"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_op_log_listId",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"listId"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_op_log_listId` ON `${TABLE_NAME}` (`listId`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_op_log_clientId_clientSeq",
|
||||||
|
"unique": true,
|
||||||
|
"columnNames": [
|
||||||
|
"clientId",
|
||||||
|
"clientSeq"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_op_log_clientId_clientSeq` ON `${TABLE_NAME}` (`clientId`, `clientSeq`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_op_log_synced",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"synced"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_op_log_synced` ON `${TABLE_NAME}` (`synced`)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c5e70cf816f82a65da0a30d8315b70e8')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.example.mitbringsl.ui.main
|
||||||
|
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||||
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/** UI tests for [com.example.mitbringsl.ui.main.MainScreen]. */
|
||||||
|
class MainScreenTest {
|
||||||
|
|
||||||
|
@get:Rule val composeTestRule = createAndroidComposeRule<ComponentActivity>()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setup() {
|
||||||
|
composeTestRule.setContent { MainScreen(FAKE_DATA) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun firstItem_exists() {
|
||||||
|
FAKE_DATA.forEach { composeTestRule.onNodeWithText(it).assertExists() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val FAKE_DATA = listOf("Sample1", "Sample2", "Sample3")
|
||||||
28
android/app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".MitbringslApp"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:theme="@style/Theme.Mitbringsl">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.example.mitbringsl
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import com.example.mitbringsl.theme.MitbringslTheme
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContent {
|
||||||
|
MitbringslTheme { Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { MainNavigation() } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.example.mitbringsl
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import androidx.hilt.work.HiltWorkerFactory
|
||||||
|
import androidx.work.Configuration
|
||||||
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@HiltAndroidApp
|
||||||
|
class MitbringslApp : Application(), Configuration.Provider {
|
||||||
|
|
||||||
|
@Inject lateinit var workerFactory: HiltWorkerFactory
|
||||||
|
|
||||||
|
override val workManagerConfiguration: Configuration
|
||||||
|
get() = Configuration.Builder()
|
||||||
|
.setWorkerFactory(workerFactory)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.example.mitbringsl
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation3.runtime.entryProvider
|
||||||
|
import androidx.navigation3.runtime.rememberNavBackStack
|
||||||
|
import androidx.navigation3.ui.NavDisplay
|
||||||
|
import com.example.mitbringsl.ui.main.MainScreen
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun MainNavigation() {
|
||||||
|
val backStack = rememberNavBackStack(Main)
|
||||||
|
|
||||||
|
NavDisplay(
|
||||||
|
backStack = backStack,
|
||||||
|
onBack = { backStack.removeLastOrNull() },
|
||||||
|
entryProvider =
|
||||||
|
entryProvider {
|
||||||
|
entry<Main> {
|
||||||
|
MainScreen(onItemClick = { navKey -> backStack.add(navKey) }, modifier = Modifier.safeDrawingPadding().padding(16.dp))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.example.mitbringsl
|
||||||
|
|
||||||
|
import androidx.navigation3.runtime.NavKey
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable data object Main : NavKey
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.example.mitbringsl.data
|
||||||
|
|
||||||
|
import com.example.mitbringsl.data.local.dao.ListDao
|
||||||
|
import com.example.mitbringsl.data.local.entity.ListEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository interface for shopping lists.
|
||||||
|
* Phase D stub – only observes local Room data.
|
||||||
|
* Phase E will add the full sync logic (push outbox + pull cursor).
|
||||||
|
*/
|
||||||
|
interface ListRepository {
|
||||||
|
fun observeLists(ownerId: String): Flow<List<ListEntity>>
|
||||||
|
suspend fun createList(name: String, ownerId: String): ListEntity
|
||||||
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class DefaultListRepository @Inject constructor(
|
||||||
|
private val listDao: ListDao,
|
||||||
|
) : ListRepository {
|
||||||
|
|
||||||
|
override fun observeLists(ownerId: String): Flow<List<ListEntity>> =
|
||||||
|
listDao.observeLists(ownerId)
|
||||||
|
|
||||||
|
override suspend fun createList(name: String, ownerId: String): ListEntity {
|
||||||
|
val entity = ListEntity(name = name, ownerId = ownerId)
|
||||||
|
listDao.upsert(entity)
|
||||||
|
return entity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.example.mitbringsl.data.local
|
||||||
|
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import com.example.mitbringsl.data.local.dao.ItemDao
|
||||||
|
import com.example.mitbringsl.data.local.dao.ListDao
|
||||||
|
import com.example.mitbringsl.data.local.dao.OpLogDao
|
||||||
|
import com.example.mitbringsl.data.local.entity.ItemEntity
|
||||||
|
import com.example.mitbringsl.data.local.entity.ListEntity
|
||||||
|
import com.example.mitbringsl.data.local.entity.OpLogEntity
|
||||||
|
|
||||||
|
@Database(
|
||||||
|
entities = [
|
||||||
|
ListEntity::class,
|
||||||
|
ItemEntity::class,
|
||||||
|
OpLogEntity::class,
|
||||||
|
],
|
||||||
|
version = 1,
|
||||||
|
exportSchema = true,
|
||||||
|
)
|
||||||
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
abstract fun listDao(): ListDao
|
||||||
|
abstract fun itemDao(): ItemDao
|
||||||
|
abstract fun opLogDao(): OpLogDao
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val DATABASE_NAME = "mitbringsl.db"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.example.mitbringsl.data.local.dao
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import com.example.mitbringsl.data.local.entity.ItemEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface ItemDao {
|
||||||
|
|
||||||
|
/** Observe all non-deleted items for a list, ordered by sort_order then creation time. */
|
||||||
|
@Query("""
|
||||||
|
SELECT * FROM items
|
||||||
|
WHERE listId = :listId AND deletedAt IS NULL
|
||||||
|
ORDER BY sortOrder ASC, createdAt ASC
|
||||||
|
""")
|
||||||
|
fun observeItems(listId: String): Flow<List<ItemEntity>>
|
||||||
|
|
||||||
|
@Upsert
|
||||||
|
suspend fun upsert(item: ItemEntity)
|
||||||
|
|
||||||
|
@Upsert
|
||||||
|
suspend fun upsertAll(items: List<ItemEntity>)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWW upsert – only updates mutable fields when incoming hlc_ts is greater.
|
||||||
|
* The tombstone (deletedAt) is also applied through LWW.
|
||||||
|
*/
|
||||||
|
@Query("""
|
||||||
|
INSERT INTO items (id, listId, name, quantity, checked, sortOrder,
|
||||||
|
createdAt, updatedAt, deletedAt, hlcTs, clientId, checkedAt)
|
||||||
|
VALUES (:id, :listId, :name, :quantity, :checked, :sortOrder,
|
||||||
|
:createdAt, :updatedAt, :deletedAt, :hlcTs, :clientId, :checkedAt)
|
||||||
|
ON CONFLICT(id) DO UPDATE SET
|
||||||
|
name = CASE WHEN :hlcTs > hlcTs THEN :name ELSE name END,
|
||||||
|
quantity = CASE WHEN :hlcTs > hlcTs THEN :quantity ELSE quantity END,
|
||||||
|
checked = CASE WHEN :hlcTs > hlcTs THEN :checked ELSE checked END,
|
||||||
|
sortOrder = CASE WHEN :hlcTs > hlcTs THEN :sortOrder ELSE sortOrder END,
|
||||||
|
updatedAt = CASE WHEN :hlcTs > hlcTs THEN :updatedAt ELSE updatedAt END,
|
||||||
|
deletedAt = CASE WHEN :hlcTs > hlcTs THEN :deletedAt ELSE deletedAt END,
|
||||||
|
checkedAt = CASE WHEN :hlcTs > hlcTs THEN :checkedAt ELSE checkedAt END,
|
||||||
|
hlcTs = CASE WHEN :hlcTs > hlcTs THEN :hlcTs ELSE hlcTs END
|
||||||
|
""")
|
||||||
|
suspend fun upsertLww(
|
||||||
|
id: String, listId: String, name: String, quantity: String?,
|
||||||
|
checked: Boolean, sortOrder: Int?,
|
||||||
|
createdAt: Long, updatedAt: Long, deletedAt: Long?,
|
||||||
|
hlcTs: Long, clientId: String?, checkedAt: Long?,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM items WHERE id = :itemId LIMIT 1")
|
||||||
|
suspend fun getItem(itemId: String): ItemEntity?
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.example.mitbringsl.data.local.dao
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import com.example.mitbringsl.data.local.entity.ListEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface ListDao {
|
||||||
|
|
||||||
|
/** Observe all non-deleted lists for a given owner, newest first. */
|
||||||
|
@Query("SELECT * FROM lists WHERE ownerId = :ownerId AND deletedAt IS NULL ORDER BY updatedAt DESC")
|
||||||
|
fun observeLists(ownerId: String): Flow<List<ListEntity>>
|
||||||
|
|
||||||
|
/** One-shot lookup of a single list. */
|
||||||
|
@Query("SELECT * FROM lists WHERE id = :listId AND deletedAt IS NULL LIMIT 1")
|
||||||
|
suspend fun getList(listId: String): ListEntity?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upsert a list.
|
||||||
|
* On conflict (same primary key) the row is replaced so that fresh data
|
||||||
|
* from the server always wins in the initial seed / full-sync path.
|
||||||
|
* For LWW conflict resolution during incremental sync, see [upsertLww].
|
||||||
|
*/
|
||||||
|
@Upsert
|
||||||
|
suspend fun upsert(list: ListEntity)
|
||||||
|
|
||||||
|
@Upsert
|
||||||
|
suspend fun upsertAll(lists: List<ListEntity>)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWW upsert: only update if the incoming hlc_ts is strictly greater than
|
||||||
|
* the stored one (Last-Write-Wins register).
|
||||||
|
*/
|
||||||
|
@Query("""
|
||||||
|
INSERT INTO lists (id, name, ownerId, createdAt, updatedAt, deletedAt, hlcTs)
|
||||||
|
VALUES (:id, :name, :ownerId, :createdAt, :updatedAt, :deletedAt, :hlcTs)
|
||||||
|
ON CONFLICT(id) DO UPDATE SET
|
||||||
|
name = CASE WHEN :hlcTs > hlcTs THEN :name ELSE name END,
|
||||||
|
updatedAt = CASE WHEN :hlcTs > hlcTs THEN :updatedAt ELSE updatedAt END,
|
||||||
|
deletedAt = CASE WHEN :hlcTs > hlcTs THEN :deletedAt ELSE deletedAt END,
|
||||||
|
hlcTs = CASE WHEN :hlcTs > hlcTs THEN :hlcTs ELSE hlcTs END
|
||||||
|
""")
|
||||||
|
suspend fun upsertLww(
|
||||||
|
id: String, name: String, ownerId: String,
|
||||||
|
createdAt: Long, updatedAt: Long,
|
||||||
|
deletedAt: Long?, hlcTs: Long,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(*) FROM lists WHERE ownerId = :ownerId AND deletedAt IS NULL")
|
||||||
|
suspend fun count(ownerId: String): Int
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.example.mitbringsl.data.local.dao
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import com.example.mitbringsl.data.local.entity.OpLogEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface OpLogDao {
|
||||||
|
|
||||||
|
/** All unsynced ops ordered by creation time (oldest first for FIFO drain). */
|
||||||
|
@Query("SELECT * FROM op_log WHERE synced = 0 ORDER BY createdAt ASC, localId ASC")
|
||||||
|
fun observeUnsynced(): Flow<List<OpLogEntity>>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM op_log WHERE synced = 0 ORDER BY createdAt ASC, localId ASC")
|
||||||
|
suspend fun getUnsynced(): List<OpLogEntity>
|
||||||
|
|
||||||
|
/** Unsynced ops for a specific list. */
|
||||||
|
@Query("SELECT * FROM op_log WHERE listId = :listId AND synced = 0 ORDER BY createdAt ASC")
|
||||||
|
suspend fun getUnsyncedForList(listId: String): List<OpLogEntity>
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
|
suspend fun insert(op: OpLogEntity): Long
|
||||||
|
|
||||||
|
/** Mark an op as synced and store the server-assigned seq. */
|
||||||
|
@Query("UPDATE op_log SET synced = 1, serverSeq = :serverSeq WHERE localId = :localId")
|
||||||
|
suspend fun markSynced(localId: Long, serverSeq: Long)
|
||||||
|
|
||||||
|
/** Mark multiple ops synced at once (by localId). */
|
||||||
|
@Transaction
|
||||||
|
suspend fun markAllSynced(results: Map<Long, Long>) {
|
||||||
|
results.forEach { (localId, serverSeq) -> markSynced(localId, serverSeq) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Query("DELETE FROM op_log WHERE synced = 1 AND createdAt < :olderThanMs")
|
||||||
|
suspend fun deleteOldSynced(olderThanMs: Long)
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(*) FROM op_log WHERE synced = 0")
|
||||||
|
fun observeUnsyncedCount(): Flow<Int>
|
||||||
|
|
||||||
|
/** Highest server seq we have stored locally for a given list (used as pull cursor). */
|
||||||
|
@Query("SELECT MAX(serverSeq) FROM op_log WHERE listId = :listId AND synced = 1")
|
||||||
|
suspend fun maxServerSeq(listId: String): Long?
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.example.mitbringsl.data.local.entity
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local projection of a shopping list item.
|
||||||
|
* Source of truth flows from [OpLogEntity] via the sync engine.
|
||||||
|
*/
|
||||||
|
@Entity(
|
||||||
|
tableName = "items",
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = ListEntity::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["listId"],
|
||||||
|
onDelete = ForeignKey.CASCADE,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
indices = [Index("listId"), Index("deletedAt")]
|
||||||
|
)
|
||||||
|
data class ItemEntity(
|
||||||
|
@PrimaryKey val id: String,
|
||||||
|
val listId: String,
|
||||||
|
val name: String,
|
||||||
|
val quantity: String? = null,
|
||||||
|
val checked: Boolean = false,
|
||||||
|
val sortOrder: Int? = null,
|
||||||
|
val createdAt: Long = System.currentTimeMillis(),
|
||||||
|
val updatedAt: Long = System.currentTimeMillis(),
|
||||||
|
/** Tombstone – null means the item is alive. */
|
||||||
|
val deletedAt: Long? = null,
|
||||||
|
val hlcTs: Long = 0L,
|
||||||
|
/** UUID of the client that created this item. */
|
||||||
|
val clientId: String? = null,
|
||||||
|
val checkedAt: Long? = null,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.example.mitbringsl.data.local.entity
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local projection of a shopping list.
|
||||||
|
* Written by the sync engine when ops arrive from the server.
|
||||||
|
* [ownerId] is the authenticated user's ID (UUID string).
|
||||||
|
*/
|
||||||
|
@Entity(
|
||||||
|
tableName = "lists",
|
||||||
|
indices = [Index("ownerId"), Index("deletedAt")]
|
||||||
|
)
|
||||||
|
data class ListEntity(
|
||||||
|
@PrimaryKey val id: String = UUID.randomUUID().toString(),
|
||||||
|
val name: String,
|
||||||
|
val ownerId: String,
|
||||||
|
val createdAt: Long = System.currentTimeMillis(),
|
||||||
|
val updatedAt: Long = System.currentTimeMillis(),
|
||||||
|
val deletedAt: Long? = null,
|
||||||
|
/** Hybrid Logical Clock timestamp – used for LWW conflict resolution. */
|
||||||
|
val hlcTs: Long = 0L,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.example.mitbringsl.data.local.entity
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client-side op_log – the outbox for unsynced operations.
|
||||||
|
*
|
||||||
|
* Each row is a pending operation that has not yet been acknowledged by the
|
||||||
|
* server. The sync engine drains this table by pushing ops via
|
||||||
|
* POST /api/lists/{id}/ops and removes rows on success.
|
||||||
|
*
|
||||||
|
* [clientSeq] is a monotonically-increasing counter scoped to [clientId].
|
||||||
|
* Together they form the idempotency key used by the server.
|
||||||
|
*/
|
||||||
|
@Entity(
|
||||||
|
tableName = "op_log",
|
||||||
|
indices = [
|
||||||
|
Index("listId"),
|
||||||
|
Index(value = ["clientId", "clientSeq"], unique = true),
|
||||||
|
Index("synced"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
data class OpLogEntity(
|
||||||
|
@PrimaryKey(autoGenerate = true) val localId: Long = 0,
|
||||||
|
val listId: String,
|
||||||
|
/** UUID of this device installation – stable, generated once. */
|
||||||
|
val clientId: String,
|
||||||
|
val clientSeq: Long,
|
||||||
|
/** One of: list_create, list_rename, list_delete, item_add, item_update, item_remove. */
|
||||||
|
val opType: String,
|
||||||
|
val targetId: String,
|
||||||
|
/** JSON payload, e.g. {"name":"Milch","quantity":"1L"}. */
|
||||||
|
val payload: String = "{}",
|
||||||
|
/** Client-generated HLC timestamp. */
|
||||||
|
val hlcTs: Long,
|
||||||
|
val createdAt: Long = System.currentTimeMillis(),
|
||||||
|
/** Set to the server-assigned seq once the op has been acknowledged. */
|
||||||
|
val serverSeq: Long? = null,
|
||||||
|
val synced: Boolean = false,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.example.mitbringsl.data.remote.api
|
||||||
|
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.Response
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OkHttp interceptor that injects the session Bearer token into every request.
|
||||||
|
*
|
||||||
|
* [tokenProvider] is a lambda so the interceptor always reads the most recent
|
||||||
|
* token without needing to be recreated after login.
|
||||||
|
*/
|
||||||
|
class AuthInterceptor(private val tokenProvider: () -> String?) : Interceptor {
|
||||||
|
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
val token = tokenProvider()
|
||||||
|
val request = if (token.isNullOrBlank()) {
|
||||||
|
chain.request()
|
||||||
|
} else {
|
||||||
|
chain.request().newBuilder()
|
||||||
|
.header("Authorization", "Bearer $token")
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
return chain.proceed(request)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.example.mitbringsl.data.remote.api
|
||||||
|
|
||||||
|
import com.example.mitbringsl.data.remote.dto.*
|
||||||
|
import retrofit2.Response
|
||||||
|
import retrofit2.http.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrofit API interface matching the mitbringsl backend.
|
||||||
|
*
|
||||||
|
* Authentication: every authenticated call must include
|
||||||
|
* Authorization: Bearer <session-token>
|
||||||
|
* This is injected by the AuthInterceptor in the OkHttp client.
|
||||||
|
*/
|
||||||
|
interface MitbringslApi {
|
||||||
|
|
||||||
|
// --- Auth ---------------------------------------------------------------
|
||||||
|
|
||||||
|
@POST("auth/register")
|
||||||
|
suspend fun register(@Body body: RegisterRequestDto): Response<AuthResponseDto>
|
||||||
|
|
||||||
|
@POST("auth/login")
|
||||||
|
suspend fun login(@Body body: LoginRequestDto): Response<AuthResponseDto>
|
||||||
|
|
||||||
|
@POST("auth/oidc")
|
||||||
|
suspend fun loginOidc(@Body body: OidcRequestDto): Response<AuthResponseDto>
|
||||||
|
|
||||||
|
@POST("auth/logout")
|
||||||
|
suspend fun logout(): Response<Unit>
|
||||||
|
|
||||||
|
// --- Lists --------------------------------------------------------------
|
||||||
|
|
||||||
|
@GET("api/lists")
|
||||||
|
suspend fun getLists(): Response<ListsResponseDto>
|
||||||
|
|
||||||
|
@POST("api/lists")
|
||||||
|
suspend fun createList(@Body body: CreateListRequestDto): Response<ListDto>
|
||||||
|
|
||||||
|
@GET("api/lists/{id}")
|
||||||
|
suspend fun getList(@Path("id") listId: String): Response<ListDetailDto>
|
||||||
|
|
||||||
|
// --- Ops ----------------------------------------------------------------
|
||||||
|
|
||||||
|
@POST("api/lists/{id}/ops")
|
||||||
|
suspend fun pushOps(
|
||||||
|
@Path("id") listId: String,
|
||||||
|
@Body body: PushRequestDto,
|
||||||
|
): Response<PushResponseDto>
|
||||||
|
|
||||||
|
@GET("api/lists/{id}/ops")
|
||||||
|
suspend fun pullOps(
|
||||||
|
@Path("id") listId: String,
|
||||||
|
@Query("since") since: Long,
|
||||||
|
): Response<PullResponseDto>
|
||||||
|
|
||||||
|
// --- Suggestions --------------------------------------------------------
|
||||||
|
|
||||||
|
@GET("api/suggestions")
|
||||||
|
suspend fun getSuggestions(@Query("q") query: String): Response<SuggestionsResponseDto>
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.example.mitbringsl.data.remote.dto
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Auth
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegisterRequestDto(
|
||||||
|
val email: String,
|
||||||
|
val password: String,
|
||||||
|
@SerialName("display_name") val displayName: String = "",
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class LoginRequestDto(
|
||||||
|
val email: String,
|
||||||
|
val password: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OidcRequestDto(
|
||||||
|
val provider: String,
|
||||||
|
@SerialName("id_token") val idToken: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class AuthResponseDto(
|
||||||
|
val token: String,
|
||||||
|
@SerialName("expires_at") val expiresAt: String,
|
||||||
|
val user: UserDto,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UserDto(
|
||||||
|
val id: String,
|
||||||
|
val email: String,
|
||||||
|
@SerialName("display_name") val displayName: String = "",
|
||||||
|
)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Lists
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CreateListRequestDto(val name: String)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ListDto(
|
||||||
|
val id: String,
|
||||||
|
val name: String,
|
||||||
|
@SerialName("updated_at") val updatedAt: String,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ListsResponseDto(val lists: List<ListDto>)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ListDetailDto(
|
||||||
|
val id: String,
|
||||||
|
val name: String,
|
||||||
|
@SerialName("updated_at") val updatedAt: String,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
val items: List<ItemDto>,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ItemDto(
|
||||||
|
val id: String,
|
||||||
|
@SerialName("list_id") val listId: String,
|
||||||
|
val name: String,
|
||||||
|
val quantity: String? = null,
|
||||||
|
val checked: Boolean = false,
|
||||||
|
@SerialName("sort_order") val sortOrder: Int? = null,
|
||||||
|
@SerialName("created_at") val createdAt: String,
|
||||||
|
@SerialName("updated_at") val updatedAt: String,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
@SerialName("client_id") val clientId: String? = null,
|
||||||
|
@SerialName("checked_at") val checkedAt: String? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Ops (Push / Pull)
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PushRequestDto(
|
||||||
|
@SerialName("client_id") val clientId: String,
|
||||||
|
val ops: List<IncomingOpDto>,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class IncomingOpDto(
|
||||||
|
@SerialName("client_seq") val clientSeq: Long,
|
||||||
|
@SerialName("op_type") val opType: String,
|
||||||
|
@SerialName("target_id") val targetId: String,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
val payload: JsonObject,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PushResponseDto(val results: List<OpResultDto>)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OpResultDto(
|
||||||
|
@SerialName("client_seq") val clientSeq: Long,
|
||||||
|
val seq: Long,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PullResponseDto(
|
||||||
|
val ops: List<ServerOpDto>,
|
||||||
|
@SerialName("has_more") val hasMore: Boolean,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ServerOpDto(
|
||||||
|
val seq: Long,
|
||||||
|
@SerialName("client_id") val clientId: String,
|
||||||
|
@SerialName("op_type") val opType: String,
|
||||||
|
@SerialName("target_id") val targetId: String,
|
||||||
|
val payload: JsonObject,
|
||||||
|
@SerialName("client_seq") val clientSeq: Long,
|
||||||
|
@SerialName("hlc_ts") val hlcTs: Long,
|
||||||
|
@SerialName("created_at") val createdAt: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Suggestions
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SuggestionsResponseDto(val suggestions: List<String>)
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.example.mitbringsl.di
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.room.Room
|
||||||
|
import com.example.mitbringsl.data.local.AppDatabase
|
||||||
|
import com.example.mitbringsl.data.local.dao.ItemDao
|
||||||
|
import com.example.mitbringsl.data.local.dao.ListDao
|
||||||
|
import com.example.mitbringsl.data.local.dao.OpLogDao
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
object DatabaseModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideDatabase(@ApplicationContext context: Context): AppDatabase =
|
||||||
|
Room.databaseBuilder(context, AppDatabase::class.java, AppDatabase.DATABASE_NAME)
|
||||||
|
.fallbackToDestructiveMigration(dropAllTables = false)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
@Provides fun provideListDao(db: AppDatabase): ListDao = db.listDao()
|
||||||
|
@Provides fun provideItemDao(db: AppDatabase): ItemDao = db.itemDao()
|
||||||
|
@Provides fun provideOpLogDao(db: AppDatabase): OpLogDao = db.opLogDao()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.example.mitbringsl.di
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.example.mitbringsl.BuildConfig
|
||||||
|
import com.example.mitbringsl.data.remote.api.AuthInterceptor
|
||||||
|
import com.example.mitbringsl.data.remote.api.MitbringslApi
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
object NetworkModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lax JSON decoder: ignores unknown keys so the app doesn't crash when the
|
||||||
|
* backend adds new fields, and handles missing optional fields gracefully.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideJson(): Json = Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
isLenient = true
|
||||||
|
coerceInputValues = true
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideTokenProvider(@ApplicationContext context: Context): () -> String? = {
|
||||||
|
// Read token from SharedPreferences (written after login).
|
||||||
|
context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||||
|
.getString("token", null)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideOkHttpClient(tokenProvider: () -> String?): OkHttpClient {
|
||||||
|
val logging = HttpLoggingInterceptor().apply {
|
||||||
|
level = if (BuildConfig.DEBUG) {
|
||||||
|
HttpLoggingInterceptor.Level.BODY
|
||||||
|
} else {
|
||||||
|
HttpLoggingInterceptor.Level.NONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OkHttpClient.Builder()
|
||||||
|
.addInterceptor(AuthInterceptor(tokenProvider))
|
||||||
|
.addInterceptor(logging)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideRetrofit(client: OkHttpClient, json: Json): Retrofit =
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(BuildConfig.BASE_URL)
|
||||||
|
.client(client)
|
||||||
|
.addConverterFactory(json.asConverterFactory("application/json; charset=UTF-8".toMediaType()))
|
||||||
|
.build()
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideMitbringslApi(retrofit: Retrofit): MitbringslApi =
|
||||||
|
retrofit.create(MitbringslApi::class.java)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.example.mitbringsl.di
|
||||||
|
|
||||||
|
import com.example.mitbringsl.data.DefaultListRepository
|
||||||
|
import com.example.mitbringsl.data.ListRepository
|
||||||
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
abstract class RepositoryModule {
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@Singleton
|
||||||
|
abstract fun bindListRepository(impl: DefaultListRepository): ListRepository
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.example.mitbringsl.theme
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
val Purple80 = Color(0xFFD0BCFF)
|
||||||
|
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||||
|
val Pink80 = Color(0xFFEFB8C8)
|
||||||
|
|
||||||
|
val Purple40 = Color(0xFF6650a4)
|
||||||
|
val PurpleGrey40 = Color(0xFF625b71)
|
||||||
|
val Pink40 = Color(0xFF7D5260)
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.example.mitbringsl.theme
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
private val DarkColorScheme = darkColorScheme(primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80)
|
||||||
|
|
||||||
|
private val LightColorScheme =
|
||||||
|
lightColorScheme(
|
||||||
|
primary = Purple40,
|
||||||
|
secondary = PurpleGrey40,
|
||||||
|
tertiary = Pink40,
|
||||||
|
|
||||||
|
/* Other default colors to override
|
||||||
|
background = Color(0xFFFFFBFE),
|
||||||
|
surface = Color(0xFFFFFBFE),
|
||||||
|
onPrimary = Color.White,
|
||||||
|
onSecondary = Color.White,
|
||||||
|
onTertiary = Color.White,
|
||||||
|
onBackground = Color(0xFF1C1B1F),
|
||||||
|
onSurface = Color(0xFF1C1B1F),
|
||||||
|
*/
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun MitbringslTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
// Dynamic color is available on Android 12+
|
||||||
|
dynamicColor: Boolean = true,
|
||||||
|
content: @Composable () -> Unit,
|
||||||
|
) {
|
||||||
|
val colorScheme =
|
||||||
|
when {
|
||||||
|
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
|
}
|
||||||
|
darkTheme -> DarkColorScheme
|
||||||
|
else -> LightColorScheme
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(colorScheme = colorScheme, typography = Typography, content = content)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.example.mitbringsl.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
// Set of Material typography styles to start with
|
||||||
|
val Typography =
|
||||||
|
Typography(
|
||||||
|
bodyLarge =
|
||||||
|
TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
lineHeight = 24.sp,
|
||||||
|
letterSpacing = 0.5.sp,
|
||||||
|
)
|
||||||
|
/* Other default text styles to override
|
||||||
|
titleLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 22.sp,
|
||||||
|
lineHeight = 28.sp,
|
||||||
|
letterSpacing = 0.sp
|
||||||
|
),
|
||||||
|
labelSmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
lineHeight = 16.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.example.mitbringsl.ui.main
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
|
import androidx.navigation3.runtime.NavKey
|
||||||
|
import com.example.mitbringsl.theme.MitbringslTheme
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun MainScreen(
|
||||||
|
onItemClick: (NavKey) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: MainScreenViewModel = hiltViewModel(),
|
||||||
|
) {
|
||||||
|
MainScreen(data = listOf("Mitbringsl App Initialized"), modifier = modifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
internal fun MainScreen(data: List<String>, modifier: Modifier = Modifier) {
|
||||||
|
Column(modifier) { data.forEach { Greeting(it) } }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||||
|
Text(text = "$name", modifier = modifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true)
|
||||||
|
@Composable
|
||||||
|
fun MainScreenPreview() {
|
||||||
|
MitbringslTheme { MainScreen(listOf("Mitbringsl App Initialized")) }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.example.mitbringsl.ui.main
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Placeholder ViewModel for the main screen.
|
||||||
|
* Will be replaced in Phase E with the full ListsViewModel backed by Room.
|
||||||
|
*/
|
||||||
|
@HiltViewModel
|
||||||
|
class MainScreenViewModel @Inject constructor() : ViewModel()
|
||||||
|
|
||||||
|
sealed interface MainScreenUiState {
|
||||||
|
object Loading : MainScreenUiState
|
||||||
|
data class Error(val throwable: Throwable) : MainScreenUiState
|
||||||
|
data class Success(val data: List<String>) : MainScreenUiState
|
||||||
|
}
|
||||||
170
android/app/src/main/res/drawable/ic_launcher_background.xml
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
30
android/app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 982 B |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
3
android/app/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Mitbringsl</string>
|
||||||
|
</resources>
|
||||||
5
android/app/src/main/res/values/themes.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="Theme.Mitbringsl" parent="android:Theme.Material.Light.NoActionBar" />
|
||||||
|
</resources>
|
||||||
13
android/app/src/main/res/xml/backup_rules.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older than API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
||||||
19
android/app/src/main/res/xml/data_extraction_rules.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.example.mitbringsl.ui.main
|
||||||
|
|
||||||
|
import junit.framework.TestCase.assertNotNull
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class MainScreenViewModelTest {
|
||||||
|
@Test
|
||||||
|
fun viewModel_canBeConstructed() {
|
||||||
|
val viewModel = MainScreenViewModel()
|
||||||
|
assertNotNull(viewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
9
android/build.gradle.kts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.compose.compiler) apply false
|
||||||
|
alias(libs.plugins.hilt) apply false
|
||||||
|
alias(libs.plugins.kotlin.serialization) apply false
|
||||||
|
alias(libs.plugins.ksp) apply false
|
||||||
|
alias(libs.plugins.room) apply false
|
||||||
|
}
|
||||||
29
android/gradle.properties
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# Enables Gradle Build Cache.
|
||||||
|
# See https://docs.gradle.org/current/userguide/build_cache.html
|
||||||
|
org.gradle.caching=true
|
||||||
|
# Enables Gradle Configuration Cache, the preferred Gradle execution mode.
|
||||||
|
# See https://docs.gradle.org/current/userguide/configuration_cache.html
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
90
android/gradle/libs.versions.toml
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
[versions]
|
||||||
|
androidGradlePlugin = "9.0.1"
|
||||||
|
androidxCore = "1.18.0"
|
||||||
|
androidxLifecycle = "2.10.0"
|
||||||
|
androidxActivity = "1.13.0"
|
||||||
|
androidxComposeBom = "2026.03.01"
|
||||||
|
androidxTest = "1.7.0"
|
||||||
|
androidxTestExt = "1.3.0"
|
||||||
|
androidxTestRunner = "1.7.0"
|
||||||
|
androidxTestEspresso = "3.7.0"
|
||||||
|
coroutines = "1.10.2"
|
||||||
|
hilt = "2.60.1"
|
||||||
|
junit = "4.13.2"
|
||||||
|
kotlin = "2.3.20"
|
||||||
|
ksp = "2.3.11"
|
||||||
|
nav3Core = "1.0.1"
|
||||||
|
lifecycleViewmodelNav3 = "2.10.0"
|
||||||
|
okhttp = "4.12.0"
|
||||||
|
retrofit = "2.11.0"
|
||||||
|
room = "2.7.2"
|
||||||
|
serialization = "1.8.1"
|
||||||
|
workmanager = "2.10.2"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
# Core
|
||||||
|
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidxCore" }
|
||||||
|
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivity" }
|
||||||
|
|
||||||
|
# Compose BOM
|
||||||
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
|
||||||
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
|
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
|
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
|
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
|
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
|
|
||||||
|
# Lifecycle & ViewModel
|
||||||
|
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }
|
||||||
|
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidxLifecycle" }
|
||||||
|
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidxLifecycle" }
|
||||||
|
|
||||||
|
# Navigation 3
|
||||||
|
androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runtime", version.ref = "nav3Core" }
|
||||||
|
androidx-navigation3-ui = { module = "androidx.navigation3:navigation3-ui", version.ref = "nav3Core" }
|
||||||
|
androidx-lifecycle-viewmodel-navigation3 = { module = "androidx.lifecycle:lifecycle-viewmodel-navigation3", version.ref = "lifecycleViewmodelNav3" }
|
||||||
|
|
||||||
|
# Hilt (DI)
|
||||||
|
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
|
||||||
|
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
|
||||||
|
hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.2.0" }
|
||||||
|
|
||||||
|
# Room (local DB)
|
||||||
|
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||||
|
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||||
|
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||||
|
|
||||||
|
# Retrofit + OkHttp (network)
|
||||||
|
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
|
||||||
|
retrofit-serialization = { module = "com.squareup.retrofit2:converter-kotlinx-serialization", version.ref = "retrofit" }
|
||||||
|
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||||
|
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
|
||||||
|
|
||||||
|
# Kotlinx Serialization
|
||||||
|
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
|
||||||
|
|
||||||
|
# Coroutines
|
||||||
|
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
|
||||||
|
|
||||||
|
# WorkManager
|
||||||
|
workmanager-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workmanager" }
|
||||||
|
hilt-work = { module = "androidx.hilt:hilt-work", version = "1.2.0" }
|
||||||
|
hilt-work-compiler = { module = "androidx.hilt:hilt-compiler", version = "1.2.0" }
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
androidx-test-core = { module = "androidx.test:core", version.ref = "androidxTest" }
|
||||||
|
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTestExt" }
|
||||||
|
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidxTestEspresso" }
|
||||||
|
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
|
||||||
|
junit = { module = "junit:junit", version.ref = "junit" }
|
||||||
|
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
||||||
|
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
|
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||||
|
room = { id = "androidx.room", version.ref = "room" }
|
||||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
8
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
||||||
|
distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
172
android/gradlew
vendored
Executable file
|
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
84
android/gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
33
android/settings.gradle.kts
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "Mitbringsl"
|
||||||
|
include(":app")
|
||||||