diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index a07db024a..ae4b99d2d 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangaDexFactory' - extVersionCode = 130 + extVersionCode = 131 libVersion = '1.2' containsNsfw = true } diff --git a/src/all/mangadex/res/mipmap-hdpi/ic_launcher.png b/src/all/mangadex/res/mipmap-hdpi/ic_launcher.png index 1a7f25b74..8de6d7f3b 100644 Binary files a/src/all/mangadex/res/mipmap-hdpi/ic_launcher.png and b/src/all/mangadex/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/all/mangadex/res/mipmap-mdpi/ic_launcher.png b/src/all/mangadex/res/mipmap-mdpi/ic_launcher.png index ab536517d..04105b6cd 100644 Binary files a/src/all/mangadex/res/mipmap-mdpi/ic_launcher.png and b/src/all/mangadex/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/all/mangadex/res/mipmap-xhdpi/ic_launcher.png b/src/all/mangadex/res/mipmap-xhdpi/ic_launcher.png index f5c650b4d..6f5065fa3 100644 Binary files a/src/all/mangadex/res/mipmap-xhdpi/ic_launcher.png and b/src/all/mangadex/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/all/mangadex/res/mipmap-xxhdpi/ic_launcher.png b/src/all/mangadex/res/mipmap-xxhdpi/ic_launcher.png index 49da94a01..fc989680e 100644 Binary files a/src/all/mangadex/res/mipmap-xxhdpi/ic_launcher.png and b/src/all/mangadex/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/all/mangadex/res/mipmap-xxxhdpi/ic_launcher.png b/src/all/mangadex/res/mipmap-xxxhdpi/ic_launcher.png index 7fd2132ec..48d4d3037 100644 Binary files a/src/all/mangadex/res/mipmap-xxxhdpi/ic_launcher.png and b/src/all/mangadex/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/all/mangadex/res/web_hi_res_512.png b/src/all/mangadex/res/web_hi_res_512.png index 6b845b7ef..24ff723c0 100644 Binary files a/src/all/mangadex/res/web_hi_res_512.png and b/src/all/mangadex/res/web_hi_res_512.png differ diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt index 987edf1cb..4b471b55a 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt @@ -38,11 +38,11 @@ object MDConstants { fun getCoverQualityPreferenceKey(dexLang: String): String { return "${coverQualityPref}_$dexLang" } - + fun getCoverQualityPreferenceEntries() = arrayOf("Original", "Medium", "Low") - + fun getCoverQualityPreferenceEntryValues() = arrayOf("", ".512.jpg", ".256.jpg") - + fun getCoverQualityPreferenceDefaultValue() = getCoverQualityPreferenceEntryValues()[0] const val dataSaverPref = "dataSaverV5" @@ -80,4 +80,22 @@ object MDConstants { fun getContentRatingPornographicPrefKey(dexLang: String): String { return "${contentRatingPornographicPref}_$dexLang" } + + private const val originalLanguageJapanesePref = "originalLanguageJapanese" + + fun getOriginalLanguageJapanesePref(dexLang: String): String { + return "${originalLanguageJapanesePref}_$dexLang" + } + + private const val originalLanguageChinesePref = "originalLanguageChinese" + + fun getOriginalLanguageChinesePref(dexLang: String): String { + return "${originalLanguageChinesePref}_$dexLang" + } + + private const val originalLanguageKoreanPref = "originalLanguageKorean" + + fun getOriginalLanguageKoreanPref(dexLang: String): String { + return "${originalLanguageKoreanPref}_$dexLang" + } } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt index df28e6066..c930d9662 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt @@ -61,7 +61,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : override fun popularMangaRequest(page: Int): Request { val url = MDConstants.apiMangaUrl.toHttpUrl().newBuilder().apply { - addQueryParameter("order[updatedAt]", "desc") + addQueryParameter("order[followedCount]", "desc") addQueryParameter("limit", MDConstants.mangaLimit.toString()) addQueryParameter("offset", helper.getMangaListOffset(page)) addQueryParameter("includes[]", MDConstants.coverArt) @@ -89,6 +89,29 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : ) { addQueryParameter("contentRating[]", "pornographic") } + if (preferences.getBoolean( + MDConstants.getOriginalLanguageJapanesePref(dexLang), + false + ) + ) { + addQueryParameter("originalLanguage[]", "ja") + } + // dex has zh and zh-hk for chinese manhua + if (preferences.getBoolean( + MDConstants.getOriginalLanguageChinesePref(dexLang), + false + ) + ) { + addQueryParameter("originalLanguage[]", "zh") + addQueryParameter("originalLanguage[]", "zh-hk") + } + if (preferences.getBoolean( + MDConstants.getOriginalLanguageKoreanPref(dexLang), + false + ) + ) { + addQueryParameter("originalLanguage[]", "ko") + } }.build().toUrl().toString() return GET( url = url, @@ -144,6 +167,17 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : if (preferences.getBoolean(MDConstants.getContentRatingPornographicPrefKey(dexLang), false)) { addQueryParameter("contentRating[]", "pornographic") } + if (preferences.getBoolean(MDConstants.getOriginalLanguageJapanesePref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "ja") + } + // dex has zh and zh-hk for chinese manhua + if (preferences.getBoolean(MDConstants.getOriginalLanguageChinesePref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "zh") + addQueryParameter("originalLanguage[]", "zh-hk") + } + if (preferences.getBoolean(MDConstants.getOriginalLanguageKoreanPref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "ko") + } mangaIds.forEach { id -> addQueryParameter("ids[]", id) @@ -308,15 +342,16 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : /** * Required because api is paged */ - private fun actualChapterListRequest(mangaId: String, offset: Int) = - GET( - url = helper.getChapterEndpoint(mangaId, offset, dexLang), - headers = headers, - cache = CacheControl.FORCE_NETWORK - ) - + private fun actualChapterListRequest(mangaId: String, offset: Int): Request { + val url = helper.getChapterEndpoint(mangaId, offset, dexLang).toHttpUrlOrNull()!!.newBuilder().apply { + addQueryParameter("contentRating[]", "safe") + addQueryParameter("contentRating[]", "suggestive") + addQueryParameter("contentRating[]", "erotica") + addQueryParameter("contentRating[]", "pornographic") + }.build().toString() + return GET(url, headers = headers, cache = CacheControl.FORCE_NETWORK) + } override fun chapterListParse(response: Response): List { - if (response.isSuccessful.not()) { throw Exception("HTTP ${response.code}") } @@ -350,15 +385,15 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val now = Date().time - return chapterListResults.map { helper.createChapter(it) } - .filter { it.date_upload <= now && "MangaPlus" != it.scanlator - && "Comikey" != it.scanlator} + return chapterListResults.mapNotNull { helper.createChapter(it) } + .filter { + it.date_upload <= now + } } catch (e: Exception) { Log.e("MangaDex", "error parsing chapter list", e) throw(e) } } - override fun pageListRequest(chapter: SChapter): Request { if (!helper.containsUuid(chapter.url)) { throw Exception("Migrate this manga from MangaDex to MangaDex to update it") @@ -515,6 +550,48 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : } } + val originalLanguageJapanesePref = SwitchPreferenceCompat(screen.context).apply { + key = MDConstants.getOriginalLanguageJapanesePref(dexLang) + title = "Japanese" + summary = "If enabled, only shows content that was originally published in Japanese in both latest and browse" + setDefaultValue(false) + + setOnPreferenceChangeListener { _, newValue -> + val checkValue = newValue as Boolean + preferences.edit() + .putBoolean(MDConstants.getOriginalLanguageJapanesePref(dexLang), checkValue) + .commit() + } + } + + val originalLanguageChinesePref = SwitchPreferenceCompat(screen.context).apply { + key = MDConstants.getOriginalLanguageChinesePref(dexLang) + title = "Chinese" + summary = "If enabled, only shows content that was originally published in Chinese in both latest and browse" + setDefaultValue(false) + + setOnPreferenceChangeListener { _, newValue -> + val checkValue = newValue as Boolean + preferences.edit() + .putBoolean(MDConstants.getOriginalLanguageChinesePref(dexLang), checkValue) + .commit() + } + } + + val originalLanguageKoreanPref = SwitchPreferenceCompat(screen.context).apply { + key = MDConstants.getOriginalLanguageKoreanPref(dexLang) + title = "Korean" + summary = "If enabled, only shows content that was originally published in Korean in both latest and browse" + setDefaultValue(false) + + setOnPreferenceChangeListener { _, newValue -> + val checkValue = newValue as Boolean + preferences.edit() + .putBoolean(MDConstants.getOriginalLanguageKoreanPref(dexLang), checkValue) + .commit() + } + } + screen.addPreference(coverQualityPref) screen.addPreference(dataSaverPref) screen.addPreference(standardHttpsPortPref) @@ -522,6 +599,9 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : screen.addPreference(contentRatingSuggestivePref) screen.addPreference(contentRatingEroticaPref) screen.addPreference(contentRatingPornographicPref) + screen.addPreference(originalLanguageJapanesePref) + screen.addPreference(originalLanguageChinesePref) + screen.addPreference(originalLanguageKoreanPref) } override fun getFilterList(): FilterList = diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt index a26972a1e..36f1ac0e5 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt @@ -11,7 +11,7 @@ class MangaDexFilters { internal fun getMDFilterList(preferences: SharedPreferences, dexLang: String): FilterList { return FilterList( - OriginalLanguageList(getOriginalLanguage()), + OriginalLanguageList(getOriginalLanguage(preferences, dexLang)), ContentRatingList(getContentRating(preferences, dexLang)), DemographicList(getDemographics()), StatusList(getStatus()), @@ -24,8 +24,10 @@ class MangaDexFilters { private fun getContentRating(preferences: SharedPreferences, dexLang: String) = listOf( ContentRating("Safe").apply { - state = - preferences.getBoolean(MDConstants.getContentRatingSafePrefKey(dexLang), true) + state = preferences.getBoolean( + MDConstants.getContentRatingSafePrefKey(dexLang), + true + ) }, ContentRating("Suggestive").apply { state = preferences.getBoolean( @@ -78,10 +80,25 @@ class MangaDexFilters { private class OriginalLanguageList(originalLanguage: List) : Filter.Group("Original language", originalLanguage) - private fun getOriginalLanguage() = listOf( - OriginalLanguage("Japanese (Manga)", "ja"), - OriginalLanguage("Chinese (Manhua)", "zh"), - OriginalLanguage("Korean (Manhwa)", "ko"), + private fun getOriginalLanguage(preferences: SharedPreferences, dexLang: String) = listOf( + OriginalLanguage("Japanese (Manga)", "ja").apply { + state = preferences.getBoolean( + MDConstants.getOriginalLanguageJapanesePref(dexLang), + false + ) + }, + OriginalLanguage("Chinese (Manhua)", "zh").apply { + state = preferences.getBoolean( + MDConstants.getOriginalLanguageChinesePref(dexLang), + false + ) + }, + OriginalLanguage("Korean (Manhwa)", "ko").apply { + state = preferences.getBoolean( + MDConstants.getOriginalLanguageKoreanPref(dexLang), + false + ) + }, ) internal class Tag(val id: String, name: String) : Filter.TriState(name) diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt index d74a8e07a..977bcea95 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt @@ -172,7 +172,7 @@ class MangaDexHelper() { title = cleanString(mangaDto.data.attributes.title.asMdMap()["en"] ?: "") coverFileName?.let { - thumbnail_url = when(coverSuffix != null && coverSuffix != "") { + thumbnail_url = when (coverSuffix != null && coverSuffix != "") { true -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName$coverSuffix" else -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName" } @@ -248,7 +248,7 @@ class MangaDexHelper() { /** * create the SChapter from json */ - fun createChapter(chapterDto: ChapterDto): SChapter { + fun createChapter(chapterDto: ChapterDto): SChapter? { try { val data = chapterDto.data val attr = data.attributes @@ -287,6 +287,10 @@ class MangaDexHelper() { } } + if (attr.externalUrl != null && attr.data.isEmpty()) { + return null + } + // if volume, chapter and title is empty its a oneshot if (chapterName.isEmpty()) { chapterName.add("Oneshot") diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt index f89b7a34f..e1ebb753b 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt @@ -33,4 +33,5 @@ data class ChapterAttributesDto( val data: List, val dataSaver: List, val hash: String, + val externalUrl: String?, )