-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MangaThemesia] Option to hide paid chapters (#6598)
* Initial implementation * Move implementation to helper * Update gradle files * Formatting * Use base class
- Loading branch information
Showing
6 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...themesia/src/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaPaidChapterHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters