feat(phase-1/m4.1): :composeApp in-place → Kotlin Multiplatform (androidTarget + jvm)
Plan §6.1 step 1, the conservative shape: build converts, Android code
moves UNMODIFIED (git shows pure renames; behaviour diff = zero), and
commonMain starts with only the files that compile for both targets
today — theme Color/Type, PasswordPolicy, ReleaseNotes, LinkedShare-
Composer — behind two new expect/actual seams (justification per §9):
* platformDynamicColorScheme — Android actual keeps the pre-M4
Build.VERSION + dynamicColorScheme branch verbatim; JVM actual
returns null (desktop hides dynamic color, per M3's posture).
* relativeTimestamp — Android actual is DateUtils verbatim; JVM
actual is a java.time approximation of the same format (English-
only until M4 follow-up; desktop has no locale switch yet).
New friction found paying itself into §3/§2 (all fixed in-tree):
* kotlinMultiplatform must be registered at the ROOT with apply false
like the other Kotlin markers — sibling modules' markers put KGP on
the buildscript classpath and the subproject request then dies with
the kapt-style 'already on classpath with unknown version' (§2.5).
* KMP source-set dependency handlers: platform(libs.x) returns raw
notation, not a Dependency — use project.dependencies.platform(…);
debugImplementation is not on the handler (moved to a project-level
dependencies block); androidTestImplementation dropped (no tests).
* ColorScheme is androidx.compose.material3.ColorScheme, NOT
ui.graphics — desktop ships it inside material3-desktop, no extra
artifact needed.
* AGP 8.7.2 > KGP 2.0.21's tested max 8.5 — warning only, same as
the kapt modules; assembleDebug green.
Deliberate deferrals (documented in the build file): :core:domain is
still kotlin("jvm") so commonMain can't see it — NoteColors moves
when domain converts (M4.2, per the Phase-0 recommendation); screens,
ViewModels and AppContainer move with the container seam (M4.3).
Verified: ./gradlew :composeApp:compileKotlinJvm + assembleDebug +
:core:data-jvm:smoke (M1a PASS) + :desktopApp:run --self-test
(SELFTEST wrote note, clean exit) + git status clean over
core/**/objectbox-models (ID model file unchanged, invariant 2).
This commit is contained in:
1 parent
6b8db18cdf
commit
fef8f9c2e9
43 files changed
+229
-83
No files matched your search
+105
-52
@@ -1,16 +1,107 @@
|
||||
// composeApp — Android UI module hosting all screens, ViewModels, theme,
|
||||
// navigation, and the manual DI container. Regular Android Compose (not
|
||||
// Compose Multiplatform) is used in v0.1 to keep the build simple; the
|
||||
// migration path to Multiplatform in v0.2 is a module-level refactor.
|
||||
// composeApp — Incido's UI module: all screens, ViewModels, theme,
|
||||
// navigation, and the manual DI container.
|
||||
//
|
||||
// Phase 1 (M4.1): converted in place from `kotlin("android")` to
|
||||
// `kotlin("multiplatform")` with `androidTarget()` + `jvm()`, per the
|
||||
// order of attack in tools/DESKTOP_PHASE_PLAN.md §6.1. The split is
|
||||
// deliberately conservative — the goal of THIS step is the build shape:
|
||||
//
|
||||
// * commonMain — every file that compiles for both targets today
|
||||
// (theme Color/Type, PasswordPolicy, ReleaseNotes,
|
||||
// LinkedShareComposer) plus two expect/actual seams:
|
||||
// `platformDynamicColorScheme` and `relativeTimestamp`.
|
||||
// The Android actuals keep the pre-M4 code verbatim.
|
||||
// * androidMain — everything still touching `android.*` (screens,
|
||||
// ViewModels, AppContainer, security, backup IO, …),
|
||||
// moved UNMODIFIED. Zero behaviour change; the seams
|
||||
// for these move file-by-file in M4.2/M4.3.
|
||||
// * jvmMain — the JVM actuals. Nothing else yet: :desktopApp keeps
|
||||
// its own stand-in UI until M4.5 consumes this target.
|
||||
//
|
||||
// Note: :core:domain is still a plain kotlin("jvm") module, so
|
||||
// commonMain cannot reference it yet — that is why NoteColors.kt stays
|
||||
// in androidMain until :core:domain is converted in M4.2.
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.androidLibrary)
|
||||
alias(libs.plugins.kotlinAndroid)
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
// org.jetbrains.compose provides the `compose.*` dependency accessors
|
||||
// that resolve to the right artifact per target (androidx.compose.*
|
||||
// on androidTarget, *-desktop jars on jvm).
|
||||
alias(libs.plugins.compose)
|
||||
alias(libs.plugins.kotlinCompose)
|
||||
// v0.3.2.0 — Kotlin Serialization for the Backup JSON codec.
|
||||
// v0.3.2.0 — Kotlin Serialization for the Backup JSON codec (used by
|
||||
// CarnetImporter today; the plugin stays target-agnostic).
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
|
||||
androidTarget()
|
||||
jvm()
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
}
|
||||
|
||||
androidMain.dependencies {
|
||||
implementation(project(":core:domain"))
|
||||
implementation(project(":core:data"))
|
||||
// Phase 1 (M2 task 1): backup codecs + bridge now live here; the
|
||||
// org.incido.compose.data.backup package name was kept, so no imports
|
||||
// changed — only this dependency line.
|
||||
implementation(project(":core:backup"))
|
||||
// Phase 1 (M3 task 1): settings repository, same treatment — package
|
||||
// kept, the Context-based construction moved to AndroidSettingsStore.kt.
|
||||
implementation(project(":core:settings"))
|
||||
|
||||
// Core / lifecycle
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.viewmodel)
|
||||
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||
implementation(libs.androidx.lifecycle.runtime)
|
||||
implementation(libs.androidx.lifecycle.process)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
|
||||
// Compose BOM keeps all Compose artefact versions aligned.
|
||||
// (Called inline — the KMP source-set dependency handler's
|
||||
// platform() returns a raw notation, not a Dependency, so the
|
||||
// old `val composeBom = platform(…)` idiom fails here.)
|
||||
implementation(project.dependencies.platform(libs.composeBom))
|
||||
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
|
||||
// Compose (same org.jetbrains.compose artifacts as before the
|
||||
// M4.1 conversion — they resolve to the androidx variants on
|
||||
// this target; version alignment unchanged).
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.material.icons.extended)
|
||||
|
||||
// v0.3.2.0 — Settings (DataStore Preferences), Security (Biometric),
|
||||
// and Backup (Kotlin Serialization JSON) support.
|
||||
implementation(libs.androidx.datastore.preferences)
|
||||
implementation(libs.androidx.biometric)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
|
||||
jvmMain.dependencies {
|
||||
// Nothing yet — the compose artifacts arrive via commonMain;
|
||||
// :core:data-jvm / :core:settings wiring lands with M4.3's
|
||||
// container seam when :desktopApp starts consuming this target.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.incido.compose"
|
||||
compileSdk = 35
|
||||
@@ -19,20 +110,15 @@ android {
|
||||
minSdk = 26
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
// M4.1: `buildFeatures.compose` is NOT set — the org.jetbrains.compose
|
||||
// plugin owns Compose wiring on this target (setting it here alongside
|
||||
// the KMP plugin is the classic double-wire; see §3 trap 6's sibling).
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
@@ -40,44 +126,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// AGP's debug-only configurations are project-level, so the Compose
|
||||
// tooling dependency that was `debugImplementation` before the M4.1
|
||||
// conversion keeps that exact scope here (the KMP `sourceSets { … }`
|
||||
// dependency handlers only expose implementation/api/compileOnly).
|
||||
dependencies {
|
||||
implementation(project(":core:domain"))
|
||||
implementation(project(":core:data"))
|
||||
// Phase 1 (M2 task 1): backup codecs + bridge now live here; the
|
||||
// org.incido.compose.data.backup package name was kept, so no imports
|
||||
// changed — only this dependency line.
|
||||
implementation(project(":core:backup"))
|
||||
// Phase 1 (M3 task 1): settings repository, same treatment — package
|
||||
// kept, the Context-based construction moved to AndroidSettingsStore.kt.
|
||||
implementation(project(":core:settings"))
|
||||
|
||||
// Core / lifecycle
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.viewmodel)
|
||||
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||
implementation(libs.androidx.lifecycle.runtime)
|
||||
implementation(libs.androidx.lifecycle.process)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
|
||||
// Compose BOM keeps all Compose artefact versions aligned
|
||||
val composeBom = platform(libs.composeBom)
|
||||
implementation(composeBom)
|
||||
androidTestImplementation(composeBom)
|
||||
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
|
||||
// Compose
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.material.icons.extended)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
|
||||
// v0.3.2.0 — Settings (DataStore Preferences), Security (Biometric),
|
||||
// and Backup (Kotlin Serialization JSON) support.
|
||||
implementation(libs.androidx.datastore.preferences)
|
||||
implementation(libs.androidx.biometric)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,18 @@
|
||||
package org.incido.compose.ui.theme
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.material3.ColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
/** Android actual — the verbatim pre-M4 dynamic-colour branch: a real
|
||||
* Material You scheme on API 31+ (S), null below that. */
|
||||
@Composable
|
||||
actual fun platformDynamicColorScheme(darkTheme: Boolean): ColorScheme? {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return null
|
||||
val context = LocalContext.current
|
||||
return if (darkTheme) dynamicDarkColorScheme(context)
|
||||
else dynamicLightColorScheme(context)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.incido.compose.util
|
||||
|
||||
import android.text.format.DateUtils
|
||||
|
||||
/** Android actual — verbatim pre-M4 formatting: Android's own
|
||||
* localised relative-time helper, unchanged. */
|
||||
actual fun relativeTimestamp(epochMillis: Long, nowMillis: Long): String =
|
||||
DateUtils.getRelativeTimeSpanString(
|
||||
epochMillis,
|
||||
nowMillis,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE,
|
||||
).toString()
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+15
-9
@@ -1,14 +1,23 @@
|
||||
package org.incido.compose.ui.theme
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ColorScheme
|
||||
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
|
||||
|
||||
/**
|
||||
* Phase 1 (M4.1) platform seam for Material You dynamic color.
|
||||
*
|
||||
* Android returns a real scheme on API 31+ (the pre-M4 behaviour, kept
|
||||
* verbatim in `androidMain`); every other platform returns null and the
|
||||
* brand palette below applies. Desktop deliberately has no dynamic
|
||||
* colour — same decision as M3 ("desktop hides the four Android-only
|
||||
* security/appearance features").
|
||||
*/
|
||||
@Composable
|
||||
expect fun platformDynamicColorScheme(darkTheme: Boolean): ColorScheme?
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
@@ -34,11 +43,8 @@ fun IncidoTheme(
|
||||
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)
|
||||
}
|
||||
dynamicColor -> platformDynamicColorScheme(darkTheme)
|
||||
?: if (darkTheme) DarkColorScheme else LightColorScheme
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,22 @@
|
||||
package org.incido.compose.util
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
|
||||
/**
|
||||
* Returns a localised "X ago" style timestamp for the given epoch millis.
|
||||
*
|
||||
* Phase 1 (M4.1) platform seam: Android formats via
|
||||
* [android.text.format.DateUtils.getRelativeTimeSpanString] (verbatim
|
||||
* pre-M4 behaviour, kept in `androidMain`); the JVM target formats with
|
||||
* `java.time` (see `RelativeTime.jvm.kt`).
|
||||
*/
|
||||
@Composable
|
||||
fun rememberRelativeTimestamp(epochMillis: Long): String {
|
||||
val now = remember { System.currentTimeMillis() }
|
||||
return remember(epochMillis) { relativeTimestamp(epochMillis, now) }
|
||||
}
|
||||
|
||||
/** Formats [epochMillis] relative to [nowMillis] — "23 min. ago" /
|
||||
* "Today" / "Yesterday" / "3 days ago" / absolute date beyond that. */
|
||||
expect fun relativeTimestamp(epochMillis: Long, nowMillis: Long): String
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.incido.compose.ui.theme
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.material3.ColorScheme
|
||||
|
||||
/** JVM actual — desktop has no Material You (hidden, not faked; same
|
||||
* posture as M3's four hidden Android-only features). Always null, so
|
||||
* [IncidoTheme] falls through to the brand palette. */
|
||||
@Composable
|
||||
actual fun platformDynamicColorScheme(darkTheme: Boolean): ColorScheme? = null
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.incido.compose.util
|
||||
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.ChronoUnit
|
||||
|
||||
/**
|
||||
* JVM actual — a `java.time` port of the Android `DateUtils` abbreviated
|
||||
* relative format ("23 min. ago" / "Today" / "Yesterday" / "3 days
|
||||
* ago" / absolute date beyond a week).
|
||||
*
|
||||
* English-only for now (desktop has no UI locale switch yet); matching
|
||||
* Android's localisation exactly is M4 follow-up work — the Android
|
||||
* actual above remains the reference behaviour.
|
||||
*/
|
||||
actual fun relativeTimestamp(epochMillis: Long, nowMillis: Long): String {
|
||||
val zone = ZoneId.systemDefault()
|
||||
val then = Instant.ofEpochMilli(epochMillis).atZone(zone).toLocalDate()
|
||||
val now = Instant.ofEpochMilli(nowMillis).atZone(zone).toLocalDate()
|
||||
val days = ChronoUnit.DAYS.between(then, now)
|
||||
val deltaMillis = nowMillis - epochMillis
|
||||
|
||||
// Same-day (and future / sub-minute) timestamps: relative clock time.
|
||||
if (days <= 0L) {
|
||||
if (deltaMillis < 60_000L) return "Just now"
|
||||
val minutes = deltaMillis / 60_000L
|
||||
if (minutes < 60L) return "$minutes min. ago"
|
||||
val hours = minutes / 60L
|
||||
return if (hours < 24L) "$hours hr. ago" else "Today"
|
||||
}
|
||||
if (days == 1L) return "Yesterday"
|
||||
if (days < 7L) return "$days days ago"
|
||||
|
||||
// Beyond a week: absolute date, year shown only when it differs —
|
||||
// DateUtils' "Oct 5" / "Oct 5, 2025" shape.
|
||||
val pattern = if (then.year == now.year) "MMM d" else "MMM d, yyyy"
|
||||
return then.format(DateTimeFormatter.ofPattern(pattern))
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.incido.compose.util
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
|
||||
/**
|
||||
* Returns a localised "X ago" style timestamp for the given epoch millis.
|
||||
* Uses Android's [DateUtils.getRelativeTimeSpanString] which handles all
|
||||
* the edge cases (Today / Yesterday / N days ago / N weeks ago / …) and
|
||||
* is automatically localised to the device language.
|
||||
*/
|
||||
@Composable
|
||||
fun rememberRelativeTimestamp(epochMillis: Long): String {
|
||||
val now = remember { System.currentTimeMillis() }
|
||||
return DateUtils.getRelativeTimeSpanString(
|
||||
epochMillis,
|
||||
now,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE,
|
||||
).toString()
|
||||
}
|
||||
Reference in new issue
Block a user