MangaSwat: Added custom url setting (#16067)
added the custom url setting
This commit is contained in:
parent
0bb01b70b8
commit
d04dd2f18d
|
@ -1,5 +1,10 @@
|
|||
package eu.kanade.tachiyomi.extension.ar.mangaswat
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.extension.BuildConfig
|
||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
|
||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
|
@ -8,6 +13,8 @@ import kotlinx.serialization.decodeFromString
|
|||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import org.jsoup.nodes.Document
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -17,6 +24,14 @@ class MangaSwat : MangaThemesia(
|
|||
"ar",
|
||||
dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.US),
|
||||
) {
|
||||
private val defaultBaseUrl = "https://swatmanga.me"
|
||||
|
||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.rateLimit(1)
|
||||
.build()
|
||||
|
@ -48,4 +63,31 @@ class MangaSwat : MangaThemesia(
|
|||
val source: String,
|
||||
val images: List<String>,
|
||||
)
|
||||
|
||||
companion object {
|
||||
private const val RESTART_TACHIYOMI = "Restart Tachiyomi to apply new setting."
|
||||
private const val BASE_URL_PREF_TITLE = "Override BaseUrl"
|
||||
private const val BASE_URL_PREF = "overrideBaseUrl_v${BuildConfig.VERSION_CODE}"
|
||||
private const val BASE_URL_PREF_SUMMARY = "For temporary uses. Updating the extension will erase this setting."
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
|
||||
key = BASE_URL_PREF
|
||||
title = BASE_URL_PREF_TITLE
|
||||
summary = BASE_URL_PREF_SUMMARY
|
||||
this.setDefaultValue(defaultBaseUrl)
|
||||
dialogTitle = BASE_URL_PREF_TITLE
|
||||
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
screen.addPreference(baseUrlPref)
|
||||
|
||||
super.setupPreferenceScreen(screen)
|
||||
}
|
||||
|
||||
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
|
|||
SingleLang("MangaWT", "https://mangawt.com", "tr", overrideVersionCode = 5),
|
||||
SingleLang("Mangayaro", "https://mangayaro.net", "id"),
|
||||
SingleLang("Manhwa Lover", "https://manhwalover.com", "en", isNsfw = true, overrideVersionCode = 1),
|
||||
SingleLang("MangaSwat", "https://swatmanga.me", "ar", overrideVersionCode = 7),
|
||||
SingleLang("MangaSwat", "https://swatmanga.me", "ar", overrideVersionCode = 8),
|
||||
SingleLang("MangKomik", "https://mangkomik.net", "id", overrideVersionCode = 1),
|
||||
SingleLang("Mangás Chan", "https://mangaschan.com", "pt-BR", className = "MangasChan"),
|
||||
SingleLang("Manhwa Freak", "https://manhwafreak.com", "en", overrideVersionCode = 1),
|
||||
|
|
Loading…
Reference in New Issue