From 53c58990e75b963407b1bb5e4e6e5d39b6cc71e7 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:21:52 +0600 Subject: [PATCH 1/7] Add language and search related methods in Source --- .../tachiyomi/source/CatalogueSource.kt | 8 +--- .../java/eu/kanade/tachiyomi/source/Source.kt | 40 ++++++++++++++++++- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt index fbb17fc..44d1a7c 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt @@ -10,6 +10,7 @@ interface CatalogueSource : Source { /** * An ISO 639-1 compliant language code (two letters in lower case). */ + @Deprecated("Use language instead", ReplaceWith("language")) val lang: String /** @@ -39,9 +40,4 @@ interface CatalogueSource : Source { * @param page the page number to retrieve. */ fun fetchLatestUpdates(page: Int): Observable - - /** - * Returns the list of filters for the source. - */ - fun getFilterList(): FilterList -} \ No newline at end of file +} diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 83f9af4..f0179a6 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.source +import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga @@ -21,6 +23,36 @@ interface Source { */ val name: String + /** + * Represents an IETF BCP 47 compliant language tag. + * Special cases include: + * - [Language.MULTI]: Indicates multiple languages. + * - [Language.OTHER]: Refers to a language not explicitly defined. + * + * Besides the above two [Language.ALL] (all) is also supported due to legacy reasons. + * Usage of it is highly discouraged + * + * @since extensions-lib 1.5 + */ + val language: String + + /** + * Returns the list of filters for the source. + * + * @since extensions-lib 1.5 + */ + fun getFilterList(): FilterList + + /** + * Get a page with a list of manga. + * + * @since extensions-lib 1.5 + * @param query the search query. + * @param filters the list of filters to apply. + * @param page the page number to retrieve. + */ + suspend fun getMangaList(query: String, filters: FilterList, page: Int): MangasPage = throw Exception("Stub!") + /** * Get the updated details for a manga. * @@ -66,4 +98,10 @@ interface Source { ReplaceWith("getPageList"), ) fun fetchPageList(chapter: SChapter): Observable> = throw Exception("Stub!") -} \ No newline at end of file + + object Language { + const val ALL = "all" + const val MULTI = "multi" + const val OTHER = "other" + } +} From c8095c0b2a7118875b87d286ec2c55f0be480e8e Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:45:35 +0600 Subject: [PATCH 2/7] Remove Language.ALL --- library/src/main/java/eu/kanade/tachiyomi/source/Source.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index f0179a6..4186a1d 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -29,8 +29,8 @@ interface Source { * - [Language.MULTI]: Indicates multiple languages. * - [Language.OTHER]: Refers to a language not explicitly defined. * - * Besides the above two [Language.ALL] (all) is also supported due to legacy reasons. - * Usage of it is highly discouraged + * Besides the above two 'all' is also supported due to legacy reasons. + * Usage of it is highly discouraged for new sources * * @since extensions-lib 1.5 */ @@ -100,7 +100,6 @@ interface Source { fun fetchPageList(chapter: SChapter): Observable> = throw Exception("Stub!") object Language { - const val ALL = "all" const val MULTI = "multi" const val OTHER = "other" } From 79373e146ae1832b4a098ed5fef91ab4652e3daa Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:21:05 +0600 Subject: [PATCH 3/7] Add getMangaDetailsAndChapters --- .../src/main/java/eu/kanade/tachiyomi/source/Source.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 4186a1d..81a3a19 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -53,6 +53,15 @@ interface Source { */ suspend fun getMangaList(query: String, filters: FilterList, page: Int): MangasPage = throw Exception("Stub!") + /** + * Get the updated details for a manga and its chapters + * + * @since extensions-lib 1.5 + * @param manga manga to get details and chapters for + * @return the updated manga and its chapters + */ + suspend fun getMangaDetailsAndChapters(manga: SManga): Pair> = throw Exception("Stub!") + /** * Get the updated details for a manga. * From a6b030b0f1ac9c427ade289e5f7c58e71ca20ed9 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:57:16 +0600 Subject: [PATCH 4/7] Update language javadoc --- library/src/main/java/eu/kanade/tachiyomi/source/Source.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 81a3a19..5b94a94 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -28,9 +28,9 @@ interface Source { * Special cases include: * - [Language.MULTI]: Indicates multiple languages. * - [Language.OTHER]: Refers to a language not explicitly defined. - * - * Besides the above two 'all' is also supported due to legacy reasons. - * Usage of it is highly discouraged for new sources + * - 'all': Indicates multiple language. + * + * Usage of 'all' is highly discouraged and is only supported due to legacy reasons. * * @since extensions-lib 1.5 */ From 1287faccc48cde60f385a6871315b5a0e4aff342 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:28:15 +0600 Subject: [PATCH 5/7] Update Source.kt --- library/src/main/java/eu/kanade/tachiyomi/source/Source.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 5b94a94..2ce1848 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -29,7 +29,7 @@ interface Source { * - [Language.MULTI]: Indicates multiple languages. * - [Language.OTHER]: Refers to a language not explicitly defined. * - 'all': Indicates multiple language. - * + * * Usage of 'all' is highly discouraged and is only supported due to legacy reasons. * * @since extensions-lib 1.5 From 7bb8803ef16a3b85bc7600e7d79dbecaf621f823 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:36:27 +0600 Subject: [PATCH 6/7] Add 'suspend fun getSearchFilters()' and some cleanup --- .../java/eu/kanade/tachiyomi/source/CatalogueSource.kt | 6 ++++++ .../src/main/java/eu/kanade/tachiyomi/source/Source.kt | 7 ++++++- .../eu/kanade/tachiyomi/source/online/HttpSource.kt | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt index 44d1a7c..fb04675 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt @@ -40,4 +40,10 @@ interface CatalogueSource : Source { * @param page the page number to retrieve. */ fun fetchLatestUpdates(page: Int): Observable + + /** + * Returns the list of filters for the source. + */ + @Deprecated("Use the new suspend variant instead", ReplaceWith("getSearchFilters")) + fun getFilterList(): FilterList } diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 2ce1848..7fd5baa 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -36,12 +36,17 @@ interface Source { */ val language: String + /** + * Indicates if the source supports search filters + */ + val hasSearchFilters: Boolean + /** * Returns the list of filters for the source. * * @since extensions-lib 1.5 */ - fun getFilterList(): FilterList + suspend fun getSearchFilters(): FilterList /** * Get a page with a list of manga. diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index f1d2c26..6536a30 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -15,6 +15,12 @@ import rx.Observable @Suppress("unused", "unused_parameter") abstract class HttpSource : CatalogueSource { + @Suppress("DEPRECATION") + override val language: String get() = lang + + @Suppress("DEPRECATION") + override val hasSearchFilters: Boolean get() = getFilterList().isNotEmpty() + /** * Network service. */ @@ -328,6 +334,10 @@ abstract class HttpSource : CatalogueSource { /** * Returns the list of filters for the source. */ + @Deprecated( + "Use the new suspend variant instead", + replaceWith = ReplaceWith("getSearchFilters") + ) override fun getFilterList(): FilterList { throw Exception("Stub!") } From 55e041ff0748a69aa2ab0bf3a7913a90515a9bd0 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:38:41 +0600 Subject: [PATCH 7/7] Add default implementation of `getSearchFilters` --- .../java/eu/kanade/tachiyomi/source/online/HttpSource.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index 6536a30..fbae961 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -54,6 +54,11 @@ abstract class HttpSource : CatalogueSource { */ open val client: OkHttpClient = throw Exception("Stub!") + override suspend fun getSearchFilters(): FilterList { + @Suppress("DEPRECATION") + return getFilterList() + } + /** * Headers builder for requests. Implementations can override this method for custom headers. */