android: replaced function that requires higher API (#3324)
This commit is contained in:
parent
2dc621a56c
commit
e3938f6fb5
@ -137,7 +137,7 @@ fun saveAnimImage(uri: URI, encrypted: Boolean): CryptoFile? {
|
|||||||
val destFileName = generateNewFileName("IMG", ext)
|
val destFileName = generateNewFileName("IMG", ext)
|
||||||
val destFile = File(getAppFilePath(destFileName))
|
val destFile = File(getAppFilePath(destFileName))
|
||||||
if (encrypted) {
|
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)
|
CryptoFile(destFileName, args)
|
||||||
} else {
|
} else {
|
||||||
Files.copy(uri.inputStream(), destFile.toPath())
|
Files.copy(uri.inputStream(), destFile.toPath())
|
||||||
|
@ -170,9 +170,8 @@ actual fun isAnimImage(uri: URI, drawable: Any?): Boolean {
|
|||||||
return path.endsWith(".gif") || path.endsWith(".webp")
|
return path.endsWith(".gif") || path.endsWith(".webp")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("NewApi")
|
|
||||||
actual fun loadImageBitmap(inputStream: InputStream): ImageBitmap =
|
actual fun loadImageBitmap(inputStream: InputStream): ImageBitmap =
|
||||||
Image.makeFromEncoded(inputStream.readAllBytes()).toComposeImageBitmap()
|
Image.makeFromEncoded(inputStream.readBytes()).toComposeImageBitmap()
|
||||||
|
|
||||||
// https://stackoverflow.com/a/68926993
|
// https://stackoverflow.com/a/68926993
|
||||||
fun BufferedImage.rotate(angle: Double): BufferedImage {
|
fun BufferedImage.rotate(angle: Double): BufferedImage {
|
||||||
|
@ -189,12 +189,11 @@ fun startServer(onResponse: (WVAPIMessage) -> Unit): NanoWSD {
|
|||||||
val server = object: NanoWSD(SERVER_HOST, SERVER_PORT) {
|
val server = object: NanoWSD(SERVER_HOST, SERVER_PORT) {
|
||||||
override fun openWebSocket(session: IHTTPSession): WebSocket = MyWebSocket(onResponse, session)
|
override fun openWebSocket(session: IHTTPSession): WebSocket = MyWebSocket(onResponse, session)
|
||||||
|
|
||||||
@Suppress("NewApi")
|
|
||||||
fun resourcesToResponse(path: String): Response {
|
fun resourcesToResponse(path: String): Response {
|
||||||
val uri = Class.forName("chat.simplex.common.AppKt").getResource("/assets/www$path") ?: return resourceNotFound
|
val uri = Class.forName("chat.simplex.common.AppKt").getResource("/assets/www$path") ?: return resourceNotFound
|
||||||
val response = newFixedLengthResponse(
|
val response = newFixedLengthResponse(
|
||||||
Status.OK, getMimeTypeForFile(uri.file),
|
Status.OK, getMimeTypeForFile(uri.file),
|
||||||
uri.openStream().readAllBytes()
|
uri.openStream().readBytes()
|
||||||
)
|
)
|
||||||
response.setKeepAlive(true)
|
response.setKeepAlive(true)
|
||||||
response.setUseGzip(true)
|
response.setUseGzip(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user