From 840670c2311802b6734d5f350960a2731cf76ac4 Mon Sep 17 00:00:00 2001 From: mohamedotaku Date: Sun, 12 May 2024 05:16:51 +0100 Subject: [PATCH] add mirrors link MangaAe "ar" (#2930) * add mirrors link MangaAe "ar" * rephrasing --- src/ar/mangaae/build.gradle | 2 +- .../tachiyomi/extension/ar/mangaae/MangaAe.kt | 43 +++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/ar/mangaae/build.gradle b/src/ar/mangaae/build.gradle index a4e841810..7cb63a477 100644 --- a/src/ar/mangaae/build.gradle +++ b/src/ar/mangaae/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Manga.ae' extClass = '.MangaAe' - extVersionCode = 12 + extVersionCode = 13 } apply from: "$rootDir/common.gradle" diff --git a/src/ar/mangaae/src/eu/kanade/tachiyomi/extension/ar/mangaae/MangaAe.kt b/src/ar/mangaae/src/eu/kanade/tachiyomi/extension/ar/mangaae/MangaAe.kt index ea4009b82..eb1201a70 100644 --- a/src/ar/mangaae/src/eu/kanade/tachiyomi/extension/ar/mangaae/MangaAe.kt +++ b/src/ar/mangaae/src/eu/kanade/tachiyomi/extension/ar/mangaae/MangaAe.kt @@ -2,9 +2,8 @@ package eu.kanade.tachiyomi.extension.ar.mangaae import android.app.Application import android.widget.Toast -import androidx.preference.EditTextPreference +import androidx.preference.ListPreference import androidx.preference.PreferenceScreen -import eu.kanade.tachiyomi.extension.BuildConfig import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.ConfigurableSource @@ -25,7 +24,12 @@ class MangaAe : ParsedHttpSource(), ConfigurableSource { 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 { Injekt.get().getSharedPreferences("source_$id", 0x0000) @@ -159,28 +163,31 @@ class MangaAe : ParsedHttpSource(), ConfigurableSource { // ============================== Settings ============================== companion object { - private const val RESTART_TACHIYOMI = ".لتطبيق الإعدادات الجديدة Tachiyomi أعد تشغيل" - private const val BASE_URL_PREF_TITLE = "تعديل الرابط" - private const val BASE_URL_PREF_DEFAULT = "https://mangaae.com" - private const val BASE_URL_PREF = "overrideBaseUrl_v${BuildConfig.VERSION_CODE}" - private const val BASE_URL_PREF_SUMMARY = ".للاستخدام المؤقت. تحديث التطبيق سيؤدي الى حذف الإعدادات" + private const val RESTART_TACHIYOMI = "أعد تشغيل التطبيق لتمكين الإعدادات الجديدة." + private const val MIRROR_PREF_KEY = "MIRROR" + private const val MIRROR_PREF_TITLE = "تعديل الرابط" + internal val MIRROR_PREF_ENTRY_VALUES = arrayOf( + "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) { - EditTextPreference(screen.context).apply { - key = BASE_URL_PREF - title = BASE_URL_PREF_TITLE - summary = BASE_URL_PREF_SUMMARY - setDefaultValue(BASE_URL_PREF_DEFAULT) - dialogTitle = BASE_URL_PREF_TITLE - dialogMessage = "Default: $BASE_URL_PREF_DEFAULT" + val mirrorPref = ListPreference(screen.context).apply { + key = MIRROR_PREF_KEY + title = MIRROR_PREF_TITLE + entries = MIRROR_PREF_ENTRY_VALUES + entryValues = MIRROR_PREF_ENTRY_VALUES + setDefaultValue(MIRROR_PREF_DEFAULT_VALUE) + summary = "%s" setOnPreferenceChangeListener { _, _ -> Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show() true } - }.also(screen::addPreference) + } + screen.addPreference(mirrorPref) } - - private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, BASE_URL_PREF_DEFAULT)!! }