From 145ae9f4db46a34b1acdd1cd609aa346f933bf67 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 6 Feb 2024 21:49:12 +0100 Subject: [PATCH] Fix issues with image caching on UWP --- app/desktop/src/commonMain/kotlin/NativeUtil.kt | 5 ----- app/shared/src/commonMain/kotlin/ImageLoader.kt | 6 +++--- .../kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt | 5 +---- .../kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt | 3 ++- build.gradle.kts | 2 +- 5 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 app/desktop/src/commonMain/kotlin/NativeUtil.kt diff --git a/app/desktop/src/commonMain/kotlin/NativeUtil.kt b/app/desktop/src/commonMain/kotlin/NativeUtil.kt deleted file mode 100644 index 943f32a4..00000000 --- a/app/desktop/src/commonMain/kotlin/NativeUtil.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.schlaubi.tonbrett.app.desktop - -import java.net.URI -import java.nio.file.Path - diff --git a/app/shared/src/commonMain/kotlin/ImageLoader.kt b/app/shared/src/commonMain/kotlin/ImageLoader.kt index 9b2349c6..20f8dd51 100644 --- a/app/shared/src/commonMain/kotlin/ImageLoader.kt +++ b/app/shared/src/commonMain/kotlin/ImageLoader.kt @@ -17,7 +17,7 @@ import coil3.request.ImageRequest import coil3.request.crossfade import dev.schlaubi.tonbrett.app.api.AppContext import mu.KotlinLogging -import okio.FileSystem +import okio.Path private val LOG = KotlinLogging.logger { } @@ -67,7 +67,7 @@ fun newImageLoader(appContext: AppContext): ImageLoader = ImageLoader.Builder(ap expect fun newDiskCache(): DiskCache? -internal fun fileSystemDiskCache(directory: String) = - DiskCache.Builder().directory(FileSystem.SYSTEM_TEMPORARY_DIRECTORY / "image_cache") +internal fun fileSystemDiskCache(directory: Path) = + DiskCache.Builder().directory(directory / "image_cache") .maxSizeBytes(512L * 1024 * 1024) // 512MB .build() diff --git a/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt b/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt index 0c785844..41a3cd4a 100644 --- a/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt +++ b/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt @@ -6,9 +6,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.awt.ComposeWindow -import androidx.compose.ui.window.FrameWindowScope -import androidx.compose.ui.window.WindowScope -import androidx.compose.ui.window.WindowState import coil3.disk.DiskCache import okio.Path import okio.Path.Companion.toPath @@ -47,4 +44,4 @@ private fun getBasePath(): Path { return basePath / "Tonbrett" } -actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(getBasePath().toString()) +actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(getBasePath()) diff --git a/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt b/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt index c4a5e4de..5ac050fa 100644 --- a/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt +++ b/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/ImageLoader.kt @@ -1,8 +1,9 @@ @file:JvmName("ImageLoaderMobile") + package dev.schlaubi.tonbrett.app import coil3.disk.DiskCache import okio.FileSystem import kotlin.jvm.JvmName -actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(FileSystem.SYSTEM_TEMPORARY_DIRECTORY.toString()) +actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(FileSystem.SYSTEM_TEMPORARY_DIRECTORY) diff --git a/build.gradle.kts b/build.gradle.kts index e978903b..baa6e65e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { allprojects { group = "dev.schlaubi.tonbrett" - version = "1.18.12" + version = "1.18.13" repositories { mavenCentral()