[RU]Desu new domain (#7283)
* [RU]Desu new domain * no lazy * Update Desu.kt --------- Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
This commit is contained in:
parent
7c7553dec1
commit
28f152a029
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'Desu'
|
||||
extClass = '.Desu'
|
||||
extVersionCode = 25
|
||||
extVersionCode = 26
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.ru.desu
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.ListPreference
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
@ -40,7 +41,22 @@ class Desu : ConfigurableSource, HttpSource() {
|
||||
|
||||
override val id: Long = 6684416167758830305
|
||||
|
||||
override val baseUrl = "https://desu.win"
|
||||
private val preferences: SharedPreferences =
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
|
||||
init {
|
||||
preferences.getString(DEFAULT_DOMAIN_PREF, null).let { prefDefaultDomain ->
|
||||
if (prefDefaultDomain != DOMAIN_DEFAULT) {
|
||||
preferences.edit()
|
||||
.putString(DOMAIN_TITLE, DOMAIN_DEFAULT)
|
||||
.putString(DEFAULT_DOMAIN_PREF, DOMAIN_DEFAULT)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
||||
override val baseUrl: String = domain
|
||||
|
||||
override val lang = "ru"
|
||||
|
||||
@ -48,10 +64,6 @@ class Desu : ConfigurableSource, HttpSource() {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
override fun headersBuilder() = Headers.Builder().apply {
|
||||
add("User-Agent", "Tachiyomi")
|
||||
add("Referer", baseUrl)
|
||||
@ -349,6 +361,7 @@ class Desu : ConfigurableSource, HttpSource() {
|
||||
)
|
||||
|
||||
private var isEng: String? = preferences.getString(LANGUAGE_PREF, "eng")
|
||||
|
||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||
val titleLanguagePref = ListPreference(screen.context).apply {
|
||||
key = LANGUAGE_PREF
|
||||
@ -363,13 +376,31 @@ class Desu : ConfigurableSource, HttpSource() {
|
||||
true
|
||||
}
|
||||
}
|
||||
val domainDesuPref = EditTextPreference(screen.context).apply {
|
||||
key = DOMAIN_TITLE
|
||||
title = DOMAIN_TITLE
|
||||
summary = domain
|
||||
setDefaultValue(DOMAIN_DEFAULT)
|
||||
dialogTitle = DOMAIN_TITLE
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
val warning = "Для смены домена необходимо перезапустить приложение с полной остановкой."
|
||||
Toast.makeText(screen.context, warning, Toast.LENGTH_LONG).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
screen.addPreference(titleLanguagePref)
|
||||
screen.addPreference(domainDesuPref)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PREFIX_SLUG_SEARCH = "slug:"
|
||||
|
||||
private const val LANGUAGE_PREF = "DesuTitleLanguage"
|
||||
|
||||
private const val API_URL = "/manga/api"
|
||||
|
||||
private const val DOMAIN_TITLE = "Домен"
|
||||
private const val DEFAULT_DOMAIN_PREF = "default_domain"
|
||||
private const val DOMAIN_DEFAULT = "https://desu.store"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user