loloof64
06/08/2024, 11:33 AMexpect fun getStartDirectory() : String
Which, on Android should return the application folder as String, and on Desktop (Windows/Linux) should return the content of user.home system property.
But on Android I need a Context, while on Desktop I don't need anything in order to compute it.
So is there a clean way to handle this ?loloof64
06/08/2024, 11:36 AMactual fun getStartDirectory(): String {
return System.getProperty("user.home")
}
loloof64
06/08/2024, 11:37 AMactual fun getStartDirectory(): String {
return context.getApplicationInfo().dataDir
}
where here the main concern is the context value, which can't be declared in the common code.louiscad
06/08/2024, 12:47 PMloloof64
06/08/2024, 1:04 PMlouiscad
06/08/2024, 1:04 PMloloof64
06/08/2024, 1:04 PMlouiscad
06/08/2024, 1:05 PMloloof64
06/08/2024, 1:05 PMlouiscad
06/08/2024, 1:06 PMimplementation("com.louiscad.splitties:splitties-appctx:3.0.0")
should get you goingloloof64
06/08/2024, 1:07 PMloloof64
06/08/2024, 1:14 PMlouiscad
06/08/2024, 1:15 PMloloof64
06/08/2024, 1:15 PMloloof64
06/08/2024, 1:16 PMandroidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.coroutines.android)
implementation(libs.splitties.app.ctx)
}
louiscad
06/08/2024, 1:17 PMloloof64
06/08/2024, 1:19 PMloloof64
06/08/2024, 1:20 PM