ReadComicOnline - Adds Quality Preference (#1991)
ReadComicOnline - Adds Quality Preference
This commit is contained in:
parent
738a878314
commit
ac681f3633
|
@ -5,8 +5,13 @@ ext {
|
||||||
appName = 'Tachiyomi: ReadComicOnline'
|
appName = 'Tachiyomi: ReadComicOnline'
|
||||||
pkgNameSuffix = 'en.readcomiconline'
|
pkgNameSuffix = 'en.readcomiconline'
|
||||||
extClass = '.Readcomiconline'
|
extClass = '.Readcomiconline'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly project(':preference-stub')
|
||||||
|
compileOnly 'com.github.inorichi.injekt:injekt-core:65b0440'
|
||||||
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package eu.kanade.tachiyomi.extension.en.readcomiconline
|
package eu.kanade.tachiyomi.extension.en.readcomiconline
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.support.v7.preference.ListPreference
|
||||||
|
import android.support.v7.preference.PreferenceScreen
|
||||||
|
import android.util.Log
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.source.model.*
|
import eu.kanade.tachiyomi.source.model.*
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
|
@ -10,10 +16,12 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class Readcomiconline : ParsedHttpSource() {
|
class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
|
||||||
|
|
||||||
override val name = "ReadComicOnline"
|
override val name = "ReadComicOnline"
|
||||||
|
|
||||||
|
@ -25,6 +33,10 @@ class Readcomiconline : ParsedHttpSource() {
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
override fun popularMangaSelector() = "table.listing tr:gt(1)"
|
override fun popularMangaSelector() = "table.listing tr:gt(1)"
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = "table.listing tr:gt(1)"
|
override fun latestUpdatesSelector() = "table.listing tr:gt(1)"
|
||||||
|
@ -34,7 +46,7 @@ class Readcomiconline : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
return GET("https://readcomiconline.to/ComicList/LatestUpdate?page=$page", headers)
|
return GET("$baseUrl/ComicList/LatestUpdate?page=$page", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaFromElement(element: Element): SManga {
|
override fun popularMangaFromElement(element: Element): SManga {
|
||||||
|
@ -110,7 +122,7 @@ class Readcomiconline : ParsedHttpSource() {
|
||||||
return chapter
|
return chapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter) = POST(baseUrl + chapter.url+"&quality=hq", headers)
|
override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url + "&quality=${qualitypref()}", headers)
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val pages = mutableListOf<Page>()
|
val pages = mutableListOf<Page>()
|
||||||
|
@ -194,4 +206,50 @@ class Readcomiconline : ParsedHttpSource() {
|
||||||
Genre("Western"),
|
Genre("Western"),
|
||||||
Genre("Zombies")
|
Genre("Zombies")
|
||||||
)
|
)
|
||||||
|
// Preferences Code
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||||
|
val qualitypref = androidx.preference.ListPreference(screen.context).apply {
|
||||||
|
key = QUALITY_PREF_Title
|
||||||
|
title = QUALITY_PREF_Title
|
||||||
|
entries = arrayOf("High Quality", "Low Quality")
|
||||||
|
entryValues = arrayOf("hq", "lq")
|
||||||
|
summary = "%s"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val selected = newValue as String
|
||||||
|
val index = this.findIndexOfValue(selected)
|
||||||
|
val entry = entryValues.get(index) as String
|
||||||
|
preferences.edit().putString(QUALITY_PREF, entry).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
screen.addPreference(qualitypref)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val qualitypref = ListPreference(screen.context).apply {
|
||||||
|
key = QUALITY_PREF_Title
|
||||||
|
title = QUALITY_PREF_Title
|
||||||
|
entries = arrayOf("High Quality", "Low Quality")
|
||||||
|
entryValues = arrayOf("hq", "lq")
|
||||||
|
summary = "%s"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val selected = newValue as String
|
||||||
|
val index = this.findIndexOfValue(selected)
|
||||||
|
val entry = entryValues.get(index) as String
|
||||||
|
preferences.edit().putString(QUALITY_PREF, entry).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
screen.addPreference(qualitypref)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun qualitypref() = preferences.getString(QUALITY_PREF, "hq")
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val QUALITY_PREF_Title = "Image Quality Selector"
|
||||||
|
private const val QUALITY_PREF = "qualitypref"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue