From e3938f6fb52b9e0eea05a90e8f9a25a2a2eb3ebf Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Wed, 8 Nov 2023 06:58:19 +0800 Subject: [PATCH] android: replaced function that requires higher API (#3324) --- .../kotlin/chat/simplex/common/views/helpers/Utils.kt | 2 +- .../kotlin/chat/simplex/common/platform/Images.desktop.kt | 3 +-- .../kotlin/chat/simplex/common/views/call/CallView.desktop.kt | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/Utils.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/Utils.kt index dae79e6fc..5e64de2c5 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/Utils.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/Utils.kt @@ -137,7 +137,7 @@ fun saveAnimImage(uri: URI, encrypted: Boolean): CryptoFile? { val destFileName = generateNewFileName("IMG", ext) val destFile = File(getAppFilePath(destFileName)) if (encrypted) { - val args = writeCryptoFile(destFile.absolutePath, uri.inputStream()?.readAllBytes() ?: return null) + val args = writeCryptoFile(destFile.absolutePath, uri.inputStream()?.readBytes() ?: return null) CryptoFile(destFileName, args) } else { Files.copy(uri.inputStream(), destFile.toPath()) diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Images.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Images.desktop.kt index c04587656..0df5ee815 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Images.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/Images.desktop.kt @@ -170,9 +170,8 @@ actual fun isAnimImage(uri: URI, drawable: Any?): Boolean { return path.endsWith(".gif") || path.endsWith(".webp") } -@Suppress("NewApi") actual fun loadImageBitmap(inputStream: InputStream): ImageBitmap = - Image.makeFromEncoded(inputStream.readAllBytes()).toComposeImageBitmap() + Image.makeFromEncoded(inputStream.readBytes()).toComposeImageBitmap() // https://stackoverflow.com/a/68926993 fun BufferedImage.rotate(angle: Double): BufferedImage { diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt index 42def0c75..cce8a3ce8 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt @@ -189,12 +189,11 @@ fun startServer(onResponse: (WVAPIMessage) -> Unit): NanoWSD { val server = object: NanoWSD(SERVER_HOST, SERVER_PORT) { override fun openWebSocket(session: IHTTPSession): WebSocket = MyWebSocket(onResponse, session) - @Suppress("NewApi") fun resourcesToResponse(path: String): Response { val uri = Class.forName("chat.simplex.common.AppKt").getResource("/assets/www$path") ?: return resourceNotFound val response = newFixedLengthResponse( Status.OK, getMimeTypeForFile(uri.file), - uri.openStream().readAllBytes() + uri.openStream().readBytes() ) response.setKeepAlive(true) response.setUseGzip(true)