[MangaThemesia] Option to hide paid chapters (#6598)
* Initial implementation * Move implementation to helper * Update gradle files * Formatting * Use base class
This commit is contained in:
parent
9ad46416f5
commit
e78ddcb9ed
|
@ -30,3 +30,5 @@ project_filter_warning=NOTE: Can't be used with other filter!
|
|||
project_filter_name=%s Project List page
|
||||
pref_dynamic_url_title=Automatically update dynamic URLs
|
||||
pref_dynamic_url_summary=Automatically update random numbers in manga URLs.\nHelps mitigating HTTP 404 errors during update and "in library" marks when browsing.\nNote: This setting may require clearing database in advanced settings and migrating all manga to the same source.
|
||||
pref_hide_paid_chapters_title=Hide chapters which require a purchase
|
||||
pref_hide_paid_chapters_summary=Hide chapters which must be purchased using coins.\nYou might want to disable this if you want to be notified of paid chapters so that you can go purchase them.
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package eu.kanade.tachiyomi.multisrc.mangathemesia
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import eu.kanade.tachiyomi.lib.i18n.Intl
|
||||
|
||||
class MangaThemesiaPaidChapterHelper(
|
||||
private val hidePaidChaptersPrefKey: String = "pref_hide_paid_chapters",
|
||||
private val lockedChapterSelector: String = "a[data-bs-target='#lockedChapterModal']",
|
||||
) {
|
||||
fun addHidePaidChaptersPreferenceToScreen(screen: PreferenceScreen, intl: Intl) {
|
||||
SwitchPreferenceCompat(screen.context).apply {
|
||||
key = hidePaidChaptersPrefKey
|
||||
title = intl["pref_hide_paid_chapters_title"]
|
||||
summary = intl["pref_hide_paid_chapters_summary"]
|
||||
setDefaultValue(true)
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
fun getHidePaidChaptersPref(preferences: SharedPreferences) = preferences.getBoolean(hidePaidChaptersPrefKey, true)
|
||||
|
||||
fun getChapterListSelectorBasedOnHidePaidChaptersPref(baseChapterListSelector: String, preferences: SharedPreferences): String {
|
||||
if (!getHidePaidChaptersPref(preferences)) {
|
||||
return baseChapterListSelector
|
||||
}
|
||||
|
||||
return ":is($baseChapterListSelector):not($lockedChapterSelector):not(:has($lockedChapterSelector))"
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ ext {
|
|||
extClass = '.ThunderScansFactory'
|
||||
themePkg = 'mangathemesia'
|
||||
baseUrl = 'https://en-thunderscans.com'
|
||||
overrideVersionCode = 7
|
||||
overrideVersionCode = 8
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.all.thunderscans
|
||||
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaAlt
|
||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaPaidChapterHelper
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
@ -12,7 +14,29 @@ class ThunderScansFactory : SourceFactory {
|
|||
)
|
||||
}
|
||||
|
||||
class LavaScans : MangaThemesiaAlt(
|
||||
abstract class ThunderScansBase(
|
||||
name: String,
|
||||
baseUrl: String,
|
||||
lang: String,
|
||||
mangaUrlDirectory: String = "/manga",
|
||||
dateFormat: SimpleDateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale.US),
|
||||
) : MangaThemesiaAlt(name, baseUrl, lang, mangaUrlDirectory, dateFormat) {
|
||||
private val paidChapterHelper = MangaThemesiaPaidChapterHelper()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
super.setupPreferenceScreen(screen)
|
||||
paidChapterHelper.addHidePaidChaptersPreferenceToScreen(screen, intl)
|
||||
}
|
||||
|
||||
override fun chapterListSelector(): String {
|
||||
return paidChapterHelper.getChapterListSelectorBasedOnHidePaidChaptersPref(
|
||||
super.chapterListSelector(),
|
||||
preferences,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class LavaScans : ThunderScansBase(
|
||||
"Lava Scans",
|
||||
"https://lavatoons.com",
|
||||
"ar",
|
||||
|
@ -21,7 +45,7 @@ class LavaScans : MangaThemesiaAlt(
|
|||
override val id = 3209001028102012989
|
||||
}
|
||||
|
||||
class ThunderScans : MangaThemesiaAlt(
|
||||
class ThunderScans : ThunderScansBase(
|
||||
"Thunder Scans",
|
||||
"https://en-thunderscans.com",
|
||||
"en",
|
||||
|
|
|
@ -3,7 +3,7 @@ ext {
|
|||
extClass = '.NightScans'
|
||||
themePkg = 'mangathemesia'
|
||||
baseUrl = 'https://nightsup.net'
|
||||
overrideVersionCode = 8
|
||||
overrideVersionCode = 9
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.en.nightscans
|
||||
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaAlt
|
||||
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaPaidChapterHelper
|
||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||
import okhttp3.OkHttpClient
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -13,4 +15,18 @@ class NightScans : MangaThemesiaAlt("NIGHT SCANS", "https://nightsup.net", "en",
|
|||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.rateLimit(20, 4, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
private val paidChapterHelper = MangaThemesiaPaidChapterHelper()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
super.setupPreferenceScreen(screen)
|
||||
paidChapterHelper.addHidePaidChaptersPreferenceToScreen(screen, intl)
|
||||
}
|
||||
|
||||
override fun chapterListSelector(): String {
|
||||
return paidChapterHelper.getChapterListSelectorBasedOnHidePaidChaptersPref(
|
||||
super.chapterListSelector(),
|
||||
preferences,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue