EmpireWebtoon: Update domain (#4669)
* Update domain * Change baseurl pref implementation * Remove BuildConfig.VERSION_CODE * Add Suggested change Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> --------- Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
This commit is contained in:
parent
c3fe4230fe
commit
042abd4e93
|
@ -2,8 +2,8 @@ ext {
|
||||||
extName = 'Empire Webtoon'
|
extName = 'Empire Webtoon'
|
||||||
extClass = '.EmpireWebtoon'
|
extClass = '.EmpireWebtoon'
|
||||||
themePkg = 'madara'
|
themePkg = 'madara'
|
||||||
baseUrl = 'https://webtoonsempireron.com'
|
baseUrl = 'https://webtoonempire-ron.com'
|
||||||
overrideVersionCode = 3
|
overrideVersionCode = 4
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.extension.BuildConfig
|
|
||||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -15,46 +14,56 @@ import java.util.Locale
|
||||||
class EmpireWebtoon :
|
class EmpireWebtoon :
|
||||||
Madara(
|
Madara(
|
||||||
"Empire Webtoon",
|
"Empire Webtoon",
|
||||||
"https://webtoonsempireron.com",
|
"https://webtoonempire-ron.com",
|
||||||
"ar",
|
"ar",
|
||||||
SimpleDateFormat("d MMMM، yyyy", Locale("ar")),
|
SimpleDateFormat("d MMMM، yyyy", Locale("ar")),
|
||||||
),
|
),
|
||||||
ConfigurableSource {
|
ConfigurableSource {
|
||||||
|
|
||||||
private val defaultBaseUrl = "https://webtoonsempireron.com"
|
private val preferences: SharedPreferences =
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
|
||||||
|
init {
|
||||||
|
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
|
||||||
|
if (prefDefaultBaseUrl != super.baseUrl) {
|
||||||
|
preferences.edit()
|
||||||
|
.putString(BASE_URL_PREF, super.baseUrl)
|
||||||
|
.putString(DEFAULT_BASE_URL_PREF, super.baseUrl)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val mangaSubString = "webtoon"
|
override val mangaSubString = "webtoon"
|
||||||
|
|
||||||
override val useNewChapterEndpoint = false
|
override val useNewChapterEndpoint = false
|
||||||
|
|
||||||
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) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
|
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
|
||||||
key = BASE_URL_PREF
|
key = BASE_URL_PREF
|
||||||
title = BASE_URL_PREF_TITLE
|
title = BASE_URL_PREF_TITLE
|
||||||
summary = BASE_URL_PREF_SUMMARY
|
summary = BASE_URL_PREF_SUMMARY
|
||||||
this.setDefaultValue(defaultBaseUrl)
|
setDefaultValue(super.baseUrl)
|
||||||
dialogTitle = BASE_URL_PREF_TITLE
|
dialogTitle = BASE_URL_PREF_TITLE
|
||||||
|
dialogMessage = "Default: ${super.baseUrl}"
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, _ ->
|
setOnPreferenceChangeListener { _, _ ->
|
||||||
Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show()
|
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
screen.addPreference(baseUrlPref)
|
screen.addPreference(baseUrlPref)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
|
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, super.baseUrl)!!
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
|
||||||
|
private const val RESTART_APP = "Restart app to apply new setting."
|
||||||
|
private const val BASE_URL_PREF_TITLE = "Override BaseUrl"
|
||||||
|
private const val BASE_URL_PREF = "overrideBaseUrl"
|
||||||
|
private const val BASE_URL_PREF_SUMMARY = "For temporary uses. Updating the extension will erase this setting."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue