Update AnimeOnlineNinja.kt

Feat(es/AnimeOnline.Ninja): add select server in settings
This commit is contained in:
Dark25 2024-07-18 20:47:42 +01:00 committed by GitHub
parent 9c77593863
commit 4f23a0d174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -222,6 +222,21 @@ class AnimeOnlineNinja : DooPlay(
preferences.edit().putString(key, entry).commit() preferences.edit().putString(key, entry).commit()
} }
} }
ListPreference(screen.context).apply {
key = PREF_SERVER_KEY
title = "Preferred server"
entries = SERVER_LIST
entryValues = SERVER_LIST
setDefaultValue(PREF_SERVER_DEFAULT)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}.also(screen::addPreference)
val vrfIterceptPref = CheckBoxPreference(screen.context).apply { val vrfIterceptPref = CheckBoxPreference(screen.context).apply {
key = PREF_VRF_INTERCEPT_KEY key = PREF_VRF_INTERCEPT_KEY
@ -240,9 +255,11 @@ class AnimeOnlineNinja : DooPlay(
override fun List<Video>.sort(): List<Video> { override fun List<Video>.sort(): List<Video> {
val quality = preferences.getString(prefQualityKey, prefQualityDefault)!! val quality = preferences.getString(prefQualityKey, prefQualityDefault)!!
val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!! val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!!
val server = preferences.getString(PREF_SERVER_KEY, PREF_SERVER_DEFAULT)!!
return sortedWith( return sortedWith(
compareBy( compareBy(
{ it.quality.contains(lang) }, { it.quality.contains(lang) },
{ it.quality.contains(server, true) },
{ it.quality.contains(quality) }, { it.quality.contains(quality) },
), ),
).reversed() ).reversed()
@ -255,8 +272,11 @@ class AnimeOnlineNinja : DooPlay(
private const val PREF_LANG_KEY = "preferred_lang" private const val PREF_LANG_KEY = "preferred_lang"
private const val PREF_LANG_TITLE = "Preferred language" private const val PREF_LANG_TITLE = "Preferred language"
private const val PREF_LANG_DEFAULT = "SUB" private const val PREF_LANG_DEFAULT = "SUB"
private const val PREF_SERVER_KEY = "preferred_server"
private const val PREF_SERVER_DEFAULT = "Uqload"
private val PREF_LANG_ENTRIES = arrayOf("SUB", "All", "ES", "LAT") private val PREF_LANG_ENTRIES = arrayOf("SUB", "All", "ES", "LAT")
private val PREF_LANG_VALUES = arrayOf("SUB", "", "ES", "LAT") private val PREF_LANG_VALUES = arrayOf("SUB", "", "ES", "LAT")
private val SERVER_LIST = arrayOf("Filemoon", "DoodStream", "StreamTape", "MixDrop", "Uqload", "WolfStream", "saidochesto.top")
private const val PREF_VRF_INTERCEPT_KEY = "vrf_intercept" private const val PREF_VRF_INTERCEPT_KEY = "vrf_intercept"
private const val PREF_VRF_INTERCEPT_TITLE = "Intercept VRF links (Requiere Reiniciar)" private const val PREF_VRF_INTERCEPT_TITLE = "Intercept VRF links (Requiere Reiniciar)"