Convert :source-api and :source-local to android library module (#3636)
- There's really no plan to support other platforms on this code base - The "KMP" modules only had android target which is rather pointless - `i18n` involves more work but given it has no actual code keeping it as is
This commit is contained in:
@@ -1,46 +1,30 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
|
||||
plugins {
|
||||
alias(mihonx.plugins.kotlin.multiplatform)
|
||||
alias(mihonx.plugins.android.library)
|
||||
alias(mihonx.plugins.spotless)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "tachiyomi.source.local"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
android {
|
||||
namespace = "tachiyomi.source.local"
|
||||
|
||||
// TODO(antsy): Remove when https://youtrack.jetbrains.com/issue/KT-83319 is resolved
|
||||
withHostTest { }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
dependencies {
|
||||
implementation(projects.sourceApi)
|
||||
api(projects.i18n)
|
||||
|
||||
implementation(libs.unifile)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
androidMain {
|
||||
dependencies {
|
||||
implementation(projects.core.archive)
|
||||
implementation(projects.core.common)
|
||||
implementation(projects.coreMetadata)
|
||||
|
||||
// Move ChapterRecognition to separate module?
|
||||
implementation(projects.domain)
|
||||
|
||||
implementation(libs.bundles.serialization)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll(
|
||||
"-Xexpect-actual-classes",
|
||||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
)
|
||||
optIn.add("kotlinx.serialization.ExperimentalSerializationApi")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.sourceApi)
|
||||
implementation(projects.i18n)
|
||||
|
||||
implementation(projects.core.archive)
|
||||
implementation(projects.core.common)
|
||||
implementation(projects.coreMetadata)
|
||||
implementation(projects.domain)
|
||||
|
||||
implementation(libs.unifile)
|
||||
implementation(libs.bundles.serialization)
|
||||
|
||||
implementation(libs.injekt)
|
||||
implementation(libs.jsoup)
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package tachiyomi.source.local
|
||||
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.UnmeteredSource
|
||||
|
||||
expect class LocalSource : Source, UnmeteredSource
|
||||
@@ -1,12 +0,0 @@
|
||||
package tachiyomi.source.local.image
|
||||
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import java.io.InputStream
|
||||
|
||||
expect class LocalCoverManager {
|
||||
|
||||
fun find(mangaUrl: String): UniFile?
|
||||
|
||||
fun update(manga: SManga, inputStream: InputStream): UniFile?
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package tachiyomi.source.local.io
|
||||
|
||||
import com.hippo.unifile.UniFile
|
||||
|
||||
expect class LocalSourceFileSystem {
|
||||
|
||||
fun getBaseDirectory(): UniFile?
|
||||
|
||||
fun getFilesInBaseDirectory(): List<UniFile>
|
||||
|
||||
fun getMangaDirectory(name: String): UniFile?
|
||||
|
||||
fun getFilesInMangaDirectory(name: String): List<UniFile>
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ import java.nio.charset.StandardCharsets
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import tachiyomi.domain.source.model.Source as DomainSource
|
||||
|
||||
actual class LocalSource(
|
||||
class LocalSource(
|
||||
private val context: Context,
|
||||
private val fileSystem: LocalSourceFileSystem,
|
||||
private val coverManager: LocalCoverManager,
|
||||
+3
-3
@@ -11,12 +11,12 @@ import java.io.InputStream
|
||||
|
||||
private const val DEFAULT_COVER_NAME = "cover.jpg"
|
||||
|
||||
actual class LocalCoverManager(
|
||||
class LocalCoverManager(
|
||||
private val context: Context,
|
||||
private val fileSystem: LocalSourceFileSystem,
|
||||
) {
|
||||
|
||||
actual fun find(mangaUrl: String): UniFile? {
|
||||
fun find(mangaUrl: String): UniFile? {
|
||||
return fileSystem.getFilesInMangaDirectory(mangaUrl)
|
||||
// Get all file whose names start with "cover"
|
||||
.filter { it.isFile && it.nameWithoutExtension.equals("cover", ignoreCase = true) }
|
||||
@@ -24,7 +24,7 @@ actual class LocalCoverManager(
|
||||
.firstOrNull { ImageUtil.isImage(it.name) { it.openInputStream() } }
|
||||
}
|
||||
|
||||
actual fun update(
|
||||
fun update(
|
||||
manga: SManga,
|
||||
inputStream: InputStream,
|
||||
): UniFile? {
|
||||
+5
-5
@@ -3,25 +3,25 @@ package tachiyomi.source.local.io
|
||||
import com.hippo.unifile.UniFile
|
||||
import tachiyomi.domain.storage.service.StorageManager
|
||||
|
||||
actual class LocalSourceFileSystem(
|
||||
class LocalSourceFileSystem(
|
||||
private val storageManager: StorageManager,
|
||||
) {
|
||||
|
||||
actual fun getBaseDirectory(): UniFile? {
|
||||
fun getBaseDirectory(): UniFile? {
|
||||
return storageManager.getLocalSourceDirectory()
|
||||
}
|
||||
|
||||
actual fun getFilesInBaseDirectory(): List<UniFile> {
|
||||
fun getFilesInBaseDirectory(): List<UniFile> {
|
||||
return getBaseDirectory()?.listFiles().orEmpty().toList()
|
||||
}
|
||||
|
||||
actual fun getMangaDirectory(name: String): UniFile? {
|
||||
fun getMangaDirectory(name: String): UniFile? {
|
||||
return getBaseDirectory()
|
||||
?.findFile(name)
|
||||
?.takeIf { it.isDirectory }
|
||||
}
|
||||
|
||||
actual fun getFilesInMangaDirectory(name: String): List<UniFile> {
|
||||
fun getFilesInMangaDirectory(name: String): List<UniFile> {
|
||||
return getMangaDirectory(name)?.listFiles().orEmpty().toList()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user