MangaDex: Scanlation Group blocking (#10376)
* Add (somewhat) working group blocking blocks an input scanlator group doesn't seem to block official/external-link groups * Fine tuning adjustments* - sanitise inputs as much as possible - add to summary a bit more - `setDefaultValue` looks to set once and never again. So even if EditText receives an empty String, it is still valid... Not sure if I could do it better * Increment mangadex.extversioncode
This commit is contained in:
parent
01ecbdc833
commit
97458d6998
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'MangaDex'
|
||||
pkgNameSuffix = 'all.mangadex'
|
||||
extClass = '.MangaDexFactory'
|
||||
extVersionCode = 149
|
||||
extVersionCode = 150
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -80,4 +80,14 @@ object MDConstants {
|
|||
fun getOriginalLanguagePrefKey(dexLang: String): String {
|
||||
return "${originalLanguagePref}_$dexLang"
|
||||
}
|
||||
|
||||
private const val blockedGroupsPref = "blockedGroups"
|
||||
private const val groupMangaPlus = "4f1de6a2-f0c5-4ac5-bce5-02c7dbb67deb"
|
||||
private const val groupComikey = "8d8ecf83-8d42-4f8c-add8-60963f9f28d9"
|
||||
private const val groupBilibili = "06a9fecb-b608-4f19-b93c-7caab06b7f44"
|
||||
private const val groupAzuki = "5fed0576-8b94-4f9a-b6a7-08eecd69800d"
|
||||
const val blockedGroupsPrefDefaults = "$groupMangaPlus, $groupComikey, $groupBilibili, $groupAzuki"
|
||||
fun getBlockedGroupsPrefKey(dexLang: String): String {
|
||||
return "${blockedGroupsPref}_$dexLang"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.all.mangadex
|
|||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.MultiSelectListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
|
@ -173,6 +174,10 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||
MDConstants.getContentRatingPrefKey(dexLang),
|
||||
MDConstants.contentRatingPrefDefaults
|
||||
)?.forEach { addQueryParameter("contentRating[]", it) }
|
||||
preferences.getString(
|
||||
MDConstants.getBlockedGroupsPrefKey(dexLang),
|
||||
MDConstants.blockedGroupsPrefDefaults
|
||||
)?.split(",")?.forEach { if (it.isNotEmpty()) addQueryParameter("excludedGroups[]", it.trim()) }
|
||||
}.build().toString()
|
||||
return GET(url, headers, CacheControl.FORCE_NETWORK)
|
||||
}
|
||||
|
@ -325,6 +330,10 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||
addQueryParameter("contentRating[]", "suggestive")
|
||||
addQueryParameter("contentRating[]", "erotica")
|
||||
addQueryParameter("contentRating[]", "pornographic")
|
||||
preferences.getString(
|
||||
MDConstants.getBlockedGroupsPrefKey(dexLang),
|
||||
MDConstants.blockedGroupsPrefDefaults
|
||||
)?.split(",")?.forEach { if (it.isNotEmpty()) addQueryParameter("excludedGroups[]", it.trim()) }
|
||||
}.build().toString()
|
||||
return GET(url, headers = headers, cache = CacheControl.FORCE_NETWORK)
|
||||
}
|
||||
|
@ -501,11 +510,31 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||
}
|
||||
}
|
||||
|
||||
val blockedGroupsPref = EditTextPreference(screen.context).apply {
|
||||
key = MDConstants.getBlockedGroupsPrefKey(dexLang)
|
||||
title = "Block Groups by UUID"
|
||||
summary = "Chapters from blocked groups will not show up in Latest or Manga feed.\n" +
|
||||
"Enter as a Comma-separated list of group UUIDs"
|
||||
setDefaultValue(MDConstants.blockedGroupsPrefDefaults)
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val groupsBlocked = newValue.toString()
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
.filter { helper.containsUuid(it) }
|
||||
.joinToString(separator = ", ")
|
||||
|
||||
preferences.edit()
|
||||
.putString(MDConstants.getBlockedGroupsPrefKey(dexLang), groupsBlocked)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
screen.addPreference(coverQualityPref)
|
||||
screen.addPreference(dataSaverPref)
|
||||
screen.addPreference(standardHttpsPortPref)
|
||||
screen.addPreference(contentRatingPref)
|
||||
screen.addPreference(originalLanguagePref)
|
||||
screen.addPreference(blockedGroupsPref)
|
||||
}
|
||||
|
||||
override fun getFilterList(): FilterList =
|
||||
|
|
Loading…
Reference in New Issue