add mirrors link MangaAe "ar" (#2930)

* add mirrors link MangaAe "ar"

* rephrasing
This commit is contained in:
mohamedotaku 2024-05-12 05:16:51 +01:00 committed by Draff
parent 6ed5e31f37
commit 3df4684c88
2 changed files with 26 additions and 19 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Manga.ae' extName = 'Manga.ae'
extClass = '.MangaAe' extClass = '.MangaAe'
extVersionCode = 12 extVersionCode = 13
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -2,9 +2,8 @@ package eu.kanade.tachiyomi.extension.ar.mangaae
import android.app.Application import android.app.Application
import android.widget.Toast import android.widget.Toast
import androidx.preference.EditTextPreference import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.extension.BuildConfig
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.ConfigurableSource
@ -25,7 +24,12 @@ class MangaAe : ParsedHttpSource(), ConfigurableSource {
override val name = "مانجا العرب" override val name = "مانجا العرب"
override val baseUrl by lazy { getPrefBaseUrl() } override val baseUrl by lazy {
when {
System.getenv("CI") == "true" -> MIRROR_PREF_ENTRY_VALUES.joinToString("#, ")
else -> preferences.getString(MIRROR_PREF_KEY, MIRROR_PREF_DEFAULT_VALUE)!!
}
}
private val preferences by lazy { private val preferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000) Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
@ -159,28 +163,31 @@ class MangaAe : ParsedHttpSource(), ConfigurableSource {
// ============================== Settings ============================== // ============================== Settings ==============================
companion object { companion object {
private const val RESTART_TACHIYOMI = ".لتطبيق الإعدادات الجديدة Tachiyomi أعد تشغيل" private const val RESTART_TACHIYOMI = "أعد تشغيل التطبيق لتمكين الإعدادات الجديدة."
private const val BASE_URL_PREF_TITLE = "تعديل الرابط" private const val MIRROR_PREF_KEY = "MIRROR"
private const val BASE_URL_PREF_DEFAULT = "https://mangaae.com" private const val MIRROR_PREF_TITLE = "تعديل الرابط"
private const val BASE_URL_PREF = "overrideBaseUrl_v${BuildConfig.VERSION_CODE}" internal val MIRROR_PREF_ENTRY_VALUES = arrayOf(
private const val BASE_URL_PREF_SUMMARY = ".للاستخدام المؤقت. تحديث التطبيق سيؤدي الى حذف الإعدادات" "https://mangaae.com",
"https://mangaat.com",
"https://mngaar.com",
)
private val MIRROR_PREF_DEFAULT_VALUE = MIRROR_PREF_ENTRY_VALUES[0]
} }
override fun setupPreferenceScreen(screen: PreferenceScreen) { override fun setupPreferenceScreen(screen: PreferenceScreen) {
EditTextPreference(screen.context).apply { val mirrorPref = ListPreference(screen.context).apply {
key = BASE_URL_PREF key = MIRROR_PREF_KEY
title = BASE_URL_PREF_TITLE title = MIRROR_PREF_TITLE
summary = BASE_URL_PREF_SUMMARY entries = MIRROR_PREF_ENTRY_VALUES
setDefaultValue(BASE_URL_PREF_DEFAULT) entryValues = MIRROR_PREF_ENTRY_VALUES
dialogTitle = BASE_URL_PREF_TITLE setDefaultValue(MIRROR_PREF_DEFAULT_VALUE)
dialogMessage = "Default: $BASE_URL_PREF_DEFAULT" summary = "%s"
setOnPreferenceChangeListener { _, _ -> setOnPreferenceChangeListener { _, _ ->
Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show() Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show()
true true
} }
}.also(screen::addPreference)
} }
screen.addPreference(mirrorPref)
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, BASE_URL_PREF_DEFAULT)!! }
} }