From fa05c351f47ee6e822d62718f492fc10455f0af0 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:07:04 +0700 Subject: [PATCH] removed unused --- apps/multiplatform/common/build.gradle.kts | 1 - .../common/other/mokoresources/ImageReader.kt | 59 ------------------- .../common/platform/Resources.desktop.kt | 3 +- 3 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/other/mokoresources/ImageReader.kt diff --git a/apps/multiplatform/common/build.gradle.kts b/apps/multiplatform/common/build.gradle.kts index 5cc19d62fc..42e4ac2591 100644 --- a/apps/multiplatform/common/build.gradle.kts +++ b/apps/multiplatform/common/build.gradle.kts @@ -102,7 +102,6 @@ kotlin { implementation("uk.co.caprica:vlcj:4.8.2") implementation("com.github.NanoHttpd.nanohttpd:nanohttpd:efb2ebf85a") implementation("com.github.NanoHttpd.nanohttpd:nanohttpd-websocket:efb2ebf85a") - implementation("org.apache.xmlgraphics:batik-transcoder:1.16") } } val desktopTest by getting diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/other/mokoresources/ImageReader.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/other/mokoresources/ImageReader.kt deleted file mode 100644 index a978886914..0000000000 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/other/mokoresources/ImageReader.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -package chat.simplex.common.other.mokoresources - -import chat.simplex.res.MR.assets.resourcesClassLoader -import dev.icerock.moko.resources.ImageResource -import org.apache.batik.transcoder.* -import org.apache.batik.transcoder.image.PNGTranscoder -import java.awt.image.BufferedImage -import java.io.File -import java.io.FileNotFoundException -import java.io.InputStream -import javax.imageio.ImageIO - -private var cache: Pair? = null - -// Get rid of this file when we update to moko-resources >= 0.24.0 and use `image` instead of `customImage()` -// See https://github.com/icerockdev/moko-resources/commit/93900ca2690d2c70cf4db24902a4b89f30877176 -fun ImageResource.customImage(): BufferedImage { - if (cache?.first == filePath) return cache!!.second - - val stream = resourcesClassLoader.getResourceAsStream(filePath) - ?: throw FileNotFoundException("Couldn't open resource as stream at: $filePath") - val res = stream.use { - if (filePath.endsWith(".svg", ignoreCase = true)) { - readSvg(it) - } else { - ImageIO.read(it) - } - } - cache = filePath to res - return res -} - -private fun readSvg( - inputStream: InputStream - ): BufferedImage { - // Create a PNG transcoder. - val t: Transcoder = PNGTranscoder() - // Create the transcoder input. - val input = TranscoderInput(inputStream) - - // Create the transcoder output. - val tempFile: File = File.createTempFile("moko-resources", ".png") - - try { - tempFile.outputStream().use { - val output = TranscoderOutput(it) - t.transcode(input, output) - } - return tempFile.inputStream().use { - ImageIO.read(it) - } - } finally { - tempFile.delete() - } -} diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Resources.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Resources.desktop.kt index f9d3902b6e..e02f852259 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Resources.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Resources.desktop.kt @@ -7,7 +7,6 @@ import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.* -import chat.simplex.common.other.mokoresources.customImage import chat.simplex.common.simplexWindowState import com.russhwolf.settings.* import dev.icerock.moko.resources.ImageResource @@ -64,4 +63,4 @@ actual fun isRtl(text: CharSequence): Boolean { } actual fun ImageResource.toComposeImageBitmap(): ImageBitmap? = - customImage().toComposeImageBitmap() \ No newline at end of file + image.toComposeImageBitmap() \ No newline at end of file