diff --git a/shared/src/androidMain/kotlin/app/klottr/ui/AboutActual.android.kt b/shared/src/androidMain/kotlin/app/klottr/platform/Platform.android.kt similarity index 75% rename from shared/src/androidMain/kotlin/app/klottr/ui/AboutActual.android.kt rename to shared/src/androidMain/kotlin/app/klottr/platform/Platform.android.kt index 128d8f9..dbc090c 100644 --- a/shared/src/androidMain/kotlin/app/klottr/ui/AboutActual.android.kt +++ b/shared/src/androidMain/kotlin/app/klottr/platform/Platform.android.kt @@ -1,6 +1,5 @@ -package app.klottr.ui +package app.klottr.platform -import android.content.pm.PackageManager import androidx.core.content.pm.PackageInfoCompat import app.klottr.BuildKonfig import java.text.SimpleDateFormat @@ -13,12 +12,11 @@ import java.util.TimeZone //private val appContext get() = app.klottr.App.instance // adjust to your app actual fun appAboutInfo(): AboutInfo { -// val pm = appContext.packageManager -// val pi = pm.getPackageInfo(appContext.packageName, 0) -// val versionName = pi.versionName ?: "0.0" -// val versionCode = PackageInfoCompat.getLongVersionCode(pi) - val versionName = "Fix Me" - val versionCode = 0L + val appContext = AndroidAppContext.get()?: throw IllegalStateException("AppAboutInfo needs android app context") + val pm = appContext.packageManager + val pi = pm.getPackageInfo(appContext.packageName, 0) + val versionName = pi.versionName ?: "0.0" + val versionCode = PackageInfoCompat.getLongVersionCode(pi) val buildType = BuildKonfig.BUILD_TYPE val buildTime = try { // If you expose BUILD_TIME_UTC in BuildConfig (recommended), use it directly @@ -39,3 +37,5 @@ actual fun appAboutInfo(): AboutInfo { contactEmail = "utv@ointressant.se" ) } + +actual fun platform() = "Android" \ No newline at end of file diff --git a/shared/src/androidMain/kotlin/app/klottr/shared/Platform.android.kt b/shared/src/androidMain/kotlin/app/klottr/shared/Platform.android.kt deleted file mode 100644 index 437062e..0000000 --- a/shared/src/androidMain/kotlin/app/klottr/shared/Platform.android.kt +++ /dev/null @@ -1,3 +0,0 @@ -package app.klottr.shared - -actual fun platform() = "Android" \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/app/klottr/ui/PlatformExpect.kt b/shared/src/commonMain/kotlin/app/klottr/platform/Platform.kt similarity index 91% rename from shared/src/commonMain/kotlin/app/klottr/ui/PlatformExpect.kt rename to shared/src/commonMain/kotlin/app/klottr/platform/Platform.kt index 2d04c5d..6d6ecee 100644 --- a/shared/src/commonMain/kotlin/app/klottr/ui/PlatformExpect.kt +++ b/shared/src/commonMain/kotlin/app/klottr/platform/Platform.kt @@ -1,6 +1,4 @@ -package app.klottr.ui - -import androidx.compose.runtime.Composable +package app.klottr.platform // TODO: Samla all platformsintegration på ett och samma ställe. @@ -23,3 +21,6 @@ data class AboutInfo( /** Platform provides app/build metadata for About dialog. */ expect fun appAboutInfo(): AboutInfo + + +expect fun platform(): String \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/app/klottr/shared/Platform.kt b/shared/src/commonMain/kotlin/app/klottr/shared/Platform.kt deleted file mode 100644 index 1f4a549..0000000 --- a/shared/src/commonMain/kotlin/app/klottr/shared/Platform.kt +++ /dev/null @@ -1,3 +0,0 @@ -package app.klottr.shared - -expect fun platform(): String \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/app/klottr/ui/CommonDialogsShell.kt b/shared/src/commonMain/kotlin/app/klottr/ui/CommonDialogsShell.kt index 2cd89ac..f7aa4df 100644 --- a/shared/src/commonMain/kotlin/app/klottr/ui/CommonDialogsShell.kt +++ b/shared/src/commonMain/kotlin/app/klottr/ui/CommonDialogsShell.kt @@ -47,6 +47,7 @@ import app.klottr.nearby.FoundOpenAction import app.klottr.nearby.NearbyEntryShared import app.klottr.net.DigitaltMuseumItem import app.klottr.net.FornsokItem +import app.klottr.platform.appAboutInfo import coil3.PlatformContext import coil3.compose.AsyncImage import coil3.compose.LocalPlatformContext diff --git a/shared/src/iosMain/kotlin/app/klottr/platform/Platform.ios.kt b/shared/src/iosMain/kotlin/app/klottr/platform/Platform.ios.kt new file mode 100644 index 0000000..c771d24 --- /dev/null +++ b/shared/src/iosMain/kotlin/app/klottr/platform/Platform.ios.kt @@ -0,0 +1,47 @@ +package app.klottr.platform + +import platform.Foundation.NSBundle +import platform.Foundation.NSDate +import platform.Foundation.NSDateFormatter +import platform.Foundation.NSTimeZone +import platform.Foundation.timeZoneWithAbbreviation + +actual fun appAboutInfo(): AboutInfo { + val bundle = NSBundle.mainBundle + + val versionName = + (bundle.objectForInfoDictionaryKey("CFBundleShortVersionString") as? String) + ?: "0.0" + + val buildNumber = + (bundle.objectForInfoDictionaryKey("CFBundleVersion") as? String) + ?.toLongOrNull() ?: 0L + + // Same approach as Android: prefer BuildKonfig, fallback to current UTC + val buildType = try { + app.klottr.BuildKonfig.BUILD_TYPE + } catch (_: Throwable) { + "release" // or "debug" if you prefer; keep stable default + } + + val buildTimeUtc = try { + app.klottr.BuildKonfig.BUILD_TIME_UTC + } catch (_: Throwable) { + NSDateFormatter().apply { + dateFormat = "yyyy-MM-dd HH:mm 'UTC'" + timeZone = NSTimeZone.timeZoneWithAbbreviation("UTC") !! + }.stringFromDate(NSDate()) + } + + return AboutInfo( + versionName = versionName, + buildType = buildType, + buildNumber = buildNumber, + buildTimeUtc = buildTimeUtc, + devBy = "Fabian Norlin", + iosLead = "Olof Hedman", + contactEmail = "utv@ointressant.se" + ) +} + +actual fun platform() = "iOS" \ No newline at end of file diff --git a/shared/src/iosMain/kotlin/app/klottr/shared/Platform.ios.kt b/shared/src/iosMain/kotlin/app/klottr/shared/Platform.ios.kt deleted file mode 100644 index 186f3e4..0000000 --- a/shared/src/iosMain/kotlin/app/klottr/shared/Platform.ios.kt +++ /dev/null @@ -1,3 +0,0 @@ -package app.klottr.shared - -actual fun platform() = "iOS" \ No newline at end of file