diff --git a/src/en/zoro/build.gradle b/src/en/zoro/build.gradle index 6e64c6053..da3dc1e07 100644 --- a/src/en/zoro/build.gradle +++ b/src/en/zoro/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'zoro.to (experimental)' pkgNameSuffix = 'en.zoro' extClass = '.Zoro' - extVersionCode = 26 + extVersionCode = 27 libVersion = '13' } diff --git a/src/en/zoro/src/eu/kanade/tachiyomi/animeextension/en/zoro/Zoro.kt b/src/en/zoro/src/eu/kanade/tachiyomi/animeextension/en/zoro/Zoro.kt index 0ef53df20..fdb07f5c7 100644 --- a/src/en/zoro/src/eu/kanade/tachiyomi/animeextension/en/zoro/Zoro.kt +++ b/src/en/zoro/src/eu/kanade/tachiyomi/animeextension/en/zoro/Zoro.kt @@ -47,7 +47,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() { override val name = "zoro.to (experimental)" - override val baseUrl = "https://zoro.to" + override val baseUrl by lazy { preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! } override val lang = "en" @@ -325,6 +325,21 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() { // ============================== Settings ============================== override fun setupPreferenceScreen(screen: PreferenceScreen) { + val domainPref = ListPreference(screen.context).apply { + key = PREF_DOMAIN_KEY + title = PREF_DOMAIN_TITLE + entries = PREF_DOMAIN_ENTRIES + entryValues = PREF_DOMAIN_ENTRY_VALUES + setDefaultValue(PREF_DOMAIN_DEFAULT) + summary = "%s" + + setOnPreferenceChangeListener { _, newValue -> + val selected = newValue as String + val index = findIndexOfValue(selected) + val entry = entryValues[index] as String + preferences.edit().putString(key, entry).commit() + } + } val videoQualityPref = ListPreference(screen.context).apply { key = PREF_QUALITY_KEY title = PREF_QUALITY_TITLE @@ -372,6 +387,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() { preferences.edit().putString(key, entry).commit() } } + screen.addPreference(domainPref) screen.addPreference(videoQualityPref) screen.addPreference(epTypePref) screen.addPreference(subLangPref) @@ -424,6 +440,12 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() { private const val PREF_TYPE_TITLE = "Preferred episode type/mode" private val PREF_TYPE_ENTRIES = arrayOf("sub", "dub") + private const val PREF_DOMAIN_KEY = "preferred_domain" + private const val PREF_DOMAIN_TITLE = "Preferred domain (requires app restart)" + private const val PREF_DOMAIN_DEFAULT = "https://zoro.to" + private val PREF_DOMAIN_ENTRIES = arrayOf("zoro.to", "zoro.moe", "zoro.sx", "zoro.pm", "sanji.to") + private val PREF_DOMAIN_ENTRY_VALUES = arrayOf("https://zoro.to", "https://zoro.moe", "https://zoro.sx", "https://zoro.pm", "https://sanji.to") + private const val PREF_SUB_KEY = "preferred_subLang" private const val PREF_SUB_TITLE = "Preferred sub language" private val PREF_SUB_ENTRIES = arrayOf(