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:
@@ -36,5 +36,7 @@ dependencies {
|
||||
implementation(libs.kotlinx.serialization.jsonOkio)
|
||||
implementation(libs.kotlinx.serialization.protobuf)
|
||||
|
||||
implementation(libs.injekt)
|
||||
|
||||
api(libs.bundles.sqldelight)
|
||||
}
|
||||
|
||||
+13
-31
@@ -1,46 +1,28 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
|
||||
plugins {
|
||||
alias(mihonx.plugins.kotlin.multiplatform)
|
||||
alias(mihonx.plugins.android.library)
|
||||
alias(mihonx.plugins.spotless)
|
||||
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@Suppress("UnstableApiUsage")
|
||||
android {
|
||||
namespace = "eu.kanade.tachiyomi.source"
|
||||
optimization {
|
||||
consumerKeepRules.file("consumer-proguard.pro")
|
||||
|
||||
defaultConfig {
|
||||
consumerProguardFiles("consumer-proguard.pro")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(antsy): Remove when https://youtrack.jetbrains.com/issue/KT-83319 is resolved
|
||||
withHostTest { }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
dependencies {
|
||||
api(libs.kotlinx.serialization.json)
|
||||
api(libs.injekt)
|
||||
api(libs.rxJava)
|
||||
api(libs.jsoup)
|
||||
implementation(projects.core.common)
|
||||
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(libs.injekt)
|
||||
implementation(libs.rxJava)
|
||||
implementation(libs.jsoup)
|
||||
|
||||
implementation(libs.androidx.preference)
|
||||
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.compose.runtime)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
androidMain {
|
||||
dependencies {
|
||||
implementation(projects.core.common)
|
||||
api(libs.androidx.preference)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package eu.kanade.tachiyomi.source
|
||||
|
||||
actual typealias PreferenceScreen = androidx.preference.PreferenceScreen
|
||||
@@ -1,3 +0,0 @@
|
||||
package eu.kanade.tachiyomi.source
|
||||
|
||||
expect class PreferenceScreen
|
||||
@@ -1,5 +0,0 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import rx.Observable
|
||||
|
||||
expect suspend fun <T> Observable<T>.awaitSingle(): T
|
||||
+1
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.source
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceScreen
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ package eu.kanade.tachiyomi.util
|
||||
import rx.Observable
|
||||
import tachiyomi.core.common.util.lang.awaitSingle
|
||||
|
||||
actual suspend fun <T> Observable<T>.awaitSingle(): T = awaitSingle()
|
||||
suspend fun <T> Observable<T>.awaitSingle(): T = awaitSingle()
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
android {
|
||||
namespace = "tachiyomi.source.local"
|
||||
|
||||
// TODO(antsy): Remove when https://youtrack.jetbrains.com/issue/KT-83319 is resolved
|
||||
withHostTest { }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
optIn.add("kotlinx.serialization.ExperimentalSerializationApi")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.sourceApi)
|
||||
api(projects.i18n)
|
||||
implementation(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.unifile)
|
||||
implementation(libs.bundles.serialization)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll(
|
||||
"-Xexpect-actual-classes",
|
||||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
)
|
||||
}
|
||||
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