diff --git a/src/ar/empirewebtoon/build.gradle b/src/ar/empirewebtoon/build.gradle index bfcef7e7d..abeb36d86 100644 --- a/src/ar/empirewebtoon/build.gradle +++ b/src/ar/empirewebtoon/build.gradle @@ -2,8 +2,8 @@ ext { extName = 'Empire Webtoon' extClass = '.EmpireWebtoon' themePkg = 'madara' - baseUrl = 'https://webtoonsempireron.com' - overrideVersionCode = 3 + baseUrl = 'https://webtoonempire-ron.com' + overrideVersionCode = 4 isNsfw = true } diff --git a/src/ar/empirewebtoon/src/eu/kanade/tachiyomi/extension/ar/empirewebtoon/EmpireWebtoon.kt b/src/ar/empirewebtoon/src/eu/kanade/tachiyomi/extension/ar/empirewebtoon/EmpireWebtoon.kt index f640172ac..55a3dc332 100644 --- a/src/ar/empirewebtoon/src/eu/kanade/tachiyomi/extension/ar/empirewebtoon/EmpireWebtoon.kt +++ b/src/ar/empirewebtoon/src/eu/kanade/tachiyomi/extension/ar/empirewebtoon/EmpireWebtoon.kt @@ -4,7 +4,6 @@ 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.madara.Madara import eu.kanade.tachiyomi.source.ConfigurableSource import uy.kohesive.injekt.Injekt @@ -15,46 +14,56 @@ import java.util.Locale class EmpireWebtoon : Madara( "Empire Webtoon", - "https://webtoonsempireron.com", + "https://webtoonempire-ron.com", "ar", SimpleDateFormat("d MMMMŲŒ yyyy", Locale("ar")), ), ConfigurableSource { - private val defaultBaseUrl = "https://webtoonsempireron.com" + private val preferences: SharedPreferences = + Injekt.get().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() } - private val preferences: SharedPreferences by lazy { - Injekt.get().getSharedPreferences("source_$id", 0x0000) - } - override val mangaSubString = "webtoon" 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) { 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) + setDefaultValue(super.baseUrl) dialogTitle = BASE_URL_PREF_TITLE + dialogMessage = "Default: ${super.baseUrl}" setOnPreferenceChangeListener { _, _ -> - Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show() + Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show() true } } 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." + } }