From 0bf9f6e37c24ebdbe85809a5fa528a8b27430ecc Mon Sep 17 00:00:00 2001 From: Logan B Date: Tue, 12 Mar 2019 03:39:55 +1300 Subject: [PATCH] Split out Mangadex thumbnail changes from PR #887 (#889) Split out Mangadex thumbnail changes from PR #887 --- src/all/mangadex/build.gradle | 2 +- .../extension/all/mangadex/Mangadex.kt | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 9e90e1835..721bb2ebb 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangadexFactory' - extVersionCode = 52 + extVersionCode = 53 libVersion = '1.2' } 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 9b2a25efb..ded35ca49 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 @@ -86,15 +86,21 @@ open class Mangadex(override val lang: String, private val internalLang: String, manga.setUrlWithoutDomain(url) manga.title = it.text().trim() } - if (getShowThumbnail() == LOW_QUALITY) { - manga.thumbnail_url = formThumbUrl(manga.url) - } + manga.thumbnail_url = formThumbUrl(manga.url) return manga } private fun modifyMangaUrl(url: String): String = url.replace("/title/", "/manga/").substringBeforeLast("/") + "/" - private fun formThumbUrl(mangaUrl: String): String = cdnUrl + "/images/manga/" + getMangaId(mangaUrl) +".thumb.jpg" + private fun formThumbUrl(mangaUrl: String): String { + var ext = ".jpg" + + if (getShowThumbnail() == LOW_QUALITY) { + ext = ".thumb$ext" + } + + return cdnUrl + "/images/manga/" + getMangaId(mangaUrl) + ext + } override fun latestUpdatesFromElement(element: Element): SManga { val manga = SManga.create() @@ -103,9 +109,7 @@ open class Mangadex(override val lang: String, private val internalLang: String, manga.title = it.text().trim() } - if (getShowThumbnail() == LOW_QUALITY) { - manga.thumbnail_url = formThumbUrl(manga.url) - } + manga.thumbnail_url = formThumbUrl(manga.url) return manga } @@ -272,9 +276,7 @@ open class Mangadex(override val lang: String, private val internalLang: String, manga.title = it.text().trim() } - if (getShowThumbnail() == LOW_QUALITY) { - manga.thumbnail_url = formThumbUrl(manga.url) - } + manga.thumbnail_url = formThumbUrl(manga.url) return manga } @@ -493,8 +495,6 @@ open class Mangadex(override val lang: String, private val internalLang: String, } val thumbsPref = ListPreference(screen.context).apply { key = SHOW_THUMBNAIL_PREF_Title - title = SHOW_THUMBNAIL_PREF_Title - title = SHOW_THUMBNAIL_PREF_Title entries = arrayOf("Show high quality", "Show low quality") entryValues = arrayOf("0", "1") @@ -652,7 +652,6 @@ open class Mangadex(override val lang: String, private val internalLang: String, private const val SHOW_R18_PREF_Title = "Default R18 Setting" private const val SHOW_R18_PREF = "showR18Default" - private const val HIGH_QUALITY = 0 private const val LOW_QUALITY = 1 private const val SHOW_THUMBNAIL_PREF_Title = "Default thumbnail quality"