From ac7f49ba64f6b2b78197a9dfc106fca9943b6d93 Mon Sep 17 00:00:00 2001 From: Kirill Taran Date: Fri, 13 Jan 2023 21:11:51 +0300 Subject: [PATCH] Adapting to changes in arklib [work in progress] --- app/build.gradle | 2 +- .../mvp/model/repo/index/ResourceId.kt | 10 ++++------ .../mvp/model/repo/index/ResourceMeta.kt | 6 ++++-- .../preview/generator/LinkPreviewGenerator.kt | 16 +++++++--------- .../preview/generator/PdfPreviewGenerator.kt | 1 + .../arknavigator/ui/activity/MainActivity.kt | 2 +- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3ddb0a5e..e43a032a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,7 +83,7 @@ android { } dependencies { - implementation 'space.taran:arklib:0.1.0-SNAPSHOT-560bfc5d8d' + implementation 'space.taran:arklib:0.1.0-SNAPSHOT-3334850384' implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7" diff --git a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceId.kt b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceId.kt index 0d2918f3..5de79889 100644 --- a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceId.kt +++ b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceId.kt @@ -1,15 +1,13 @@ package space.taran.arknavigator.mvp.model.repo.index -import java.nio.file.Path - typealias ResourceId = Long // Reading from SD card is up to 3 times slower! // Calculating CRC-32 hash of a file takes about the // same time as reading the file from internal storage. -private external fun computeIdNative(size: Long, file: String): Long +// private external fun computeIdNative(size: Long, file: String): Long -fun computeId(size: Long, file: Path): ResourceId { - return computeIdNative(size, file.toString()) -} +// fun computeId(size: Long, file: Path): ResourceId { +// return computeIdNative(size, file.toString()) +// } diff --git a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceMeta.kt b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceMeta.kt index 96829c52..8a918758 100644 --- a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceMeta.kt +++ b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/index/ResourceMeta.kt @@ -1,5 +1,6 @@ package space.taran.arknavigator.mvp.model.repo.index +import space.taran.arklib.computeId import space.taran.arknavigator.mvp.model.dao.ResourceWithExtra import space.taran.arknavigator.mvp.model.repo.kind.GeneralKindFactory import space.taran.arknavigator.mvp.model.repo.kind.ResourceKind @@ -12,7 +13,7 @@ import java.nio.file.Path import java.nio.file.attribute.FileTime data class ResourceMeta( - val id: ResourceId, + val id: Long, // TODO: must be ResourceId val name: String, val extension: String, val modified: FileTime, @@ -27,7 +28,8 @@ data class ResourceMeta( return MetaResult.failure(IOException("Invalid file size")) } - val id = computeId(size, path) + // TODO: must be full id after migration + val id = computeId(size, path).crc32 val meta = ResourceMeta( id = id, diff --git a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/LinkPreviewGenerator.kt b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/LinkPreviewGenerator.kt index 64a675ec..7db82879 100644 --- a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/LinkPreviewGenerator.kt +++ b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/LinkPreviewGenerator.kt @@ -1,10 +1,7 @@ package space.taran.arknavigator.mvp.model.repo.preview.generator import android.graphics.Bitmap -import android.graphics.BitmapFactory -import space.taran.arklib.loadLinkPreview import java.nio.file.Path -import kotlin.io.path.pathString object LinkPreviewGenerator : PreviewGenerator() { override val acceptedExtensions = setOf("link") @@ -18,11 +15,12 @@ object LinkPreviewGenerator : PreviewGenerator() { } private fun generatePreview(source: Path): Bitmap { - val previewBytes = - loadLinkPreview(source.pathString) ?: error("No image inside .link file") - if (previewBytes.isEmpty()) { - error("Image inside .link file was empty") - } - return BitmapFactory.decodeByteArray(previewBytes, 0, previewBytes.size) + throw NotImplementedError() + // val previewBytes = + // loadLinkPreview(source.pathString) ?: error("No image inside .link file") + // if (previewBytes.isEmpty()) { + // error("Image inside .link file was empty") + // } + // return BitmapFactory.decodeByteArray(previewBytes, 0, previewBytes.size) } } diff --git a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/PdfPreviewGenerator.kt b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/PdfPreviewGenerator.kt index a0a96bad..c6f2daaa 100644 --- a/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/PdfPreviewGenerator.kt +++ b/app/src/main/java/space/taran/arknavigator/mvp/model/repo/preview/generator/PdfPreviewGenerator.kt @@ -17,6 +17,7 @@ object PdfPreviewGenerator : PreviewGenerator() { } private fun generatePreview(source: Path): Bitmap { + // TODO: quality must be configurable in preferences screen return pdfPreviewGenerate(source.toString(), PreviewQuality.HIGH) } } diff --git a/app/src/main/java/space/taran/arknavigator/ui/activity/MainActivity.kt b/app/src/main/java/space/taran/arknavigator/ui/activity/MainActivity.kt index 3bb582e1..ef1ceed0 100644 --- a/app/src/main/java/space/taran/arknavigator/ui/activity/MainActivity.kt +++ b/app/src/main/java/space/taran/arknavigator/ui/activity/MainActivity.kt @@ -58,7 +58,7 @@ class MainActivity : MvpAppCompatActivity(), MainView { System.loadLibrary("arklib") initRustLogger() - setSupportActionBar(binding.toolbar) + // setSupportActionBar(binding.toolbar) binding.bottomNavigation.setOnApplyWindowInsetsListener(null) binding.bottomNavigation.setOnItemSelectedListener { item -> when (item.itemId) {