diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index 87e85a4dd..5ac86b039 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.extension.api import android.content.Context import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.extension.model.AvailableExtensionSources import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.LoadResult import eu.kanade.tachiyomi.extension.util.ExtensionLoader @@ -80,12 +81,23 @@ internal class ExtensionGithubApi { versionCode = it.code, lang = it.lang, isNsfw = it.nsfw == 1, + sources = it.sources.toExtensionSources(), apkName = it.apk, iconUrl = "${REPO_URL_PREFIX}icon/${it.apk.replace(".apk", ".png")}" ) } } + private fun List.toExtensionSources(): List { + return this.map { + AvailableExtensionSources( + name = it.name, + id = it.id, + baseUrl = it.baseUrl + ) + } + } + fun getApkUrl(extension: Extension.Available): String { return "${REPO_URL_PREFIX}apk/${extension.apkName}" } @@ -98,8 +110,17 @@ private data class ExtensionJsonObject( val name: String, val pkg: String, val apk: String, - val version: String, - val code: Long, val lang: String, + val code: Long, + val version: String, val nsfw: Int, + val sources: List, +) + +@Serializable +private data class ExtensionSourceJsonObject( + val name: String, + val id: Long, + val baseUrl: String + ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt index b80d86161..0b38cb728 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt @@ -32,6 +32,7 @@ sealed class Extension { override val versionCode: Long, override val lang: String, override val isNsfw: Boolean, + val sources: List, val apkName: String, val iconUrl: String ) : Extension() @@ -46,3 +47,9 @@ sealed class Extension { override val isNsfw: Boolean = false ) : Extension() } + +data class AvailableExtensionSources( + val name: String, + val id: Long, + val baseUrl: String +) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt index ea1b55c73..496f3d193 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt @@ -15,6 +15,7 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.ExtensionControllerBinding import eu.kanade.tachiyomi.extension.model.Extension +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.browse.BrowseController @@ -56,7 +57,8 @@ open class ExtensionController : return ExtensionPresenter() } - override fun createBinding(inflater: LayoutInflater) = ExtensionControllerBinding.inflate(inflater) + override fun createBinding(inflater: LayoutInflater) = + ExtensionControllerBinding.inflate(inflater) override fun onViewCreated(view: View) { super.onViewCreated(view) @@ -189,11 +191,27 @@ open class ExtensionController : private fun updateExtensionsList() { if (query.isNotBlank()) { - val extensionNames = query.split(",") + val queries = query.split(",") adapter?.updateDataSet( extensions.filter { - extensionNames.any { queriedName -> - it.extension.name.contains(queriedName, ignoreCase = true) + queries.any { query -> + when (it.extension) { + is Extension.Available -> { + it.extension.sources.any { + it.name.contains(query, ignoreCase = true) || + it.baseUrl.contains(query, ignoreCase = true) || + it.id == query.toLongOrNull() + } || it.extension.name.contains(query, ignoreCase = true) + } + is Extension.Installed -> { + it.extension.sources.any { + it.name.contains(query, ignoreCase = true) || + it.id == query.toLongOrNull() || + if (it is HttpSource) { it.baseUrl.contains(query, ignoreCase = true) } else false + } || it.extension.name.contains(query, ignoreCase = true) + } + is Extension.Untrusted -> it.extension.name.contains(query, ignoreCase = true) + } } } )