From c2b107a8bd17b366286dcbeba06fcdfd9fc0ac7e Mon Sep 17 00:00:00 2001 From: Yush0DAN <157328957+Yush0DAN@users.noreply.github.com> Date: Sat, 13 Jul 2024 00:45:20 -0600 Subject: [PATCH] MangaSwat: Update domain (#3975) * Update domain * add configurable url * Update src/ar/mangaswat/src/eu/kanade/tachiyomi/extension/ar/mangaswat/MangaSwat.kt * Update MangaSwat.kt * Update MangaSwat.kt --------- Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> --- src/ar/mangaswat/build.gradle | 4 +-- .../extension/ar/mangaswat/MangaSwat.kt | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/ar/mangaswat/build.gradle b/src/ar/mangaswat/build.gradle index 6065bcf1c..2dc6775d9 100644 --- a/src/ar/mangaswat/build.gradle +++ b/src/ar/mangaswat/build.gradle @@ -2,8 +2,8 @@ ext { extName = 'MangaSwat' extClass = '.MangaSwat' themePkg = 'mangathemesia' - baseUrl = 'https://normoyun.com' - overrideVersionCode = 18 + baseUrl = 'https://t1manga.com' + overrideVersionCode = 19 } apply from: "$rootDir/common.gradle" diff --git a/src/ar/mangaswat/src/eu/kanade/tachiyomi/extension/ar/mangaswat/MangaSwat.kt b/src/ar/mangaswat/src/eu/kanade/tachiyomi/extension/ar/mangaswat/MangaSwat.kt index d5a261594..3e8f38855 100644 --- a/src/ar/mangaswat/src/eu/kanade/tachiyomi/extension/ar/mangaswat/MangaSwat.kt +++ b/src/ar/mangaswat/src/eu/kanade/tachiyomi/extension/ar/mangaswat/MangaSwat.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.mangathemesia.MangaThemesia import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.ConfigurableSource @@ -22,17 +21,14 @@ import uy.kohesive.injekt.api.get import java.text.SimpleDateFormat import java.util.Locale -private const val swatUrl = "https://normoyun.com" - class MangaSwat : MangaThemesia( "MangaSwat", - swatUrl, + "https://t1manga.com", "ar", dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale("ar")), ), ConfigurableSource { - private val defaultBaseUrl = swatUrl override val baseUrl by lazy { getPrefBaseUrl() } @@ -99,8 +95,9 @@ class MangaSwat : 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 = "overrideBaseUrl" private const val BASE_URL_PREF_SUMMARY = "For temporary uses. Updating the extension will erase this setting." + private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl" } override fun setupPreferenceScreen(screen: PreferenceScreen) { @@ -108,8 +105,9 @@ class MangaSwat : 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() @@ -119,5 +117,16 @@ class MangaSwat : screen.addPreference(baseUrlPref) } - private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!! + private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, super.baseUrl)!! + + 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() + } + } + } }