Split out Mangadex thumbnail changes from PR #887 (#889)

Split out Mangadex thumbnail changes from PR #887
This commit is contained in:
Logan B 2019-03-12 03:39:55 +13:00 committed by Carlos
parent 0c3c3a938a
commit 0bf9f6e37c
2 changed files with 13 additions and 14 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaDex' appName = 'Tachiyomi: MangaDex'
pkgNameSuffix = 'all.mangadex' pkgNameSuffix = 'all.mangadex'
extClass = '.MangadexFactory' extClass = '.MangadexFactory'
extVersionCode = 52 extVersionCode = 53
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -86,15 +86,21 @@ open class Mangadex(override val lang: String, private val internalLang: String,
manga.setUrlWithoutDomain(url) manga.setUrlWithoutDomain(url)
manga.title = it.text().trim() manga.title = it.text().trim()
} }
if (getShowThumbnail() == LOW_QUALITY) {
manga.thumbnail_url = formThumbUrl(manga.url) manga.thumbnail_url = formThumbUrl(manga.url)
}
return manga return manga
} }
private fun modifyMangaUrl(url: String): String = url.replace("/title/", "/manga/").substringBeforeLast("/") + "/" 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 { override fun latestUpdatesFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
@ -103,9 +109,7 @@ open class Mangadex(override val lang: String, private val internalLang: String,
manga.title = it.text().trim() manga.title = it.text().trim()
} }
if (getShowThumbnail() == LOW_QUALITY) {
manga.thumbnail_url = formThumbUrl(manga.url) manga.thumbnail_url = formThumbUrl(manga.url)
}
return manga return manga
} }
@ -272,9 +276,7 @@ open class Mangadex(override val lang: String, private val internalLang: String,
manga.title = it.text().trim() manga.title = it.text().trim()
} }
if (getShowThumbnail() == LOW_QUALITY) {
manga.thumbnail_url = formThumbUrl(manga.url) manga.thumbnail_url = formThumbUrl(manga.url)
}
return manga return manga
} }
@ -493,8 +495,6 @@ open class Mangadex(override val lang: String, private val internalLang: String,
} }
val thumbsPref = ListPreference(screen.context).apply { val thumbsPref = ListPreference(screen.context).apply {
key = SHOW_THUMBNAIL_PREF_Title key = SHOW_THUMBNAIL_PREF_Title
title = SHOW_THUMBNAIL_PREF_Title
title = SHOW_THUMBNAIL_PREF_Title title = SHOW_THUMBNAIL_PREF_Title
entries = arrayOf("Show high quality", "Show low quality") entries = arrayOf("Show high quality", "Show low quality")
entryValues = arrayOf("0", "1") 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_Title = "Default R18 Setting"
private const val SHOW_R18_PREF = "showR18Default" private const val SHOW_R18_PREF = "showR18Default"
private const val HIGH_QUALITY = 0
private const val LOW_QUALITY = 1 private const val LOW_QUALITY = 1
private const val SHOW_THUMBNAIL_PREF_Title = "Default thumbnail quality" private const val SHOW_THUMBNAIL_PREF_Title = "Default thumbnail quality"