Option to exclude NSFW content from history
This commit is contained in:
@@ -79,6 +79,8 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
|
||||
|
||||
var historyGrouping by BoolPreferenceDelegate(KEY_HISTORY_GROUPING, true)
|
||||
|
||||
var isHistoryExcludeNsfw by BoolPreferenceDelegate(KEY_HISTORY_EXCLUDE_NSFW, false)
|
||||
|
||||
var chaptersReverse by BoolPreferenceDelegate(KEY_REVERSE_CHAPTERS, false)
|
||||
|
||||
val zoomMode by EnumPreferenceDelegate(
|
||||
@@ -192,6 +194,7 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
|
||||
const val KEY_RESTORE = "restore"
|
||||
const val KEY_HISTORY_GROUPING = "history_grouping"
|
||||
const val KEY_REVERSE_CHAPTERS = "reverse_chapters"
|
||||
const val KEY_HISTORY_EXCLUDE_NSFW = "history_exclude_nsfw"
|
||||
|
||||
// About
|
||||
const val KEY_APP_UPDATE = "app_update"
|
||||
|
||||
@@ -8,6 +8,6 @@ import org.koitharu.kotatsu.history.ui.HistoryListViewModel
|
||||
val historyModule
|
||||
get() = module {
|
||||
|
||||
single { HistoryRepository(get(), get()) }
|
||||
single { HistoryRepository(get(), get(), get()) }
|
||||
viewModel { HistoryListViewModel(get(), get(), get()) }
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
||||
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaHistory
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.history.data.HistoryEntity
|
||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||
import org.koitharu.kotatsu.utils.ext.mapItems
|
||||
@@ -16,6 +17,7 @@ import org.koitharu.kotatsu.utils.ext.mapToSet
|
||||
class HistoryRepository(
|
||||
private val db: MangaDatabase,
|
||||
private val trackingRepository: TrackingRepository,
|
||||
private val settings: AppSettings,
|
||||
) {
|
||||
|
||||
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
|
||||
@@ -45,6 +47,9 @@ class HistoryRepository(
|
||||
}
|
||||
|
||||
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Int) {
|
||||
if (manga.isNsfw && settings.isHistoryExcludeNsfw) {
|
||||
return
|
||||
}
|
||||
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
||||
db.withTransaction {
|
||||
db.tagsDao.upsert(tags)
|
||||
|
||||
@@ -243,4 +243,5 @@
|
||||
<string name="state_ongoing">Онгоинг</string>
|
||||
<string name="date_format">Формат даты</string>
|
||||
<string name="system_default">По умолчанию</string>
|
||||
<string name="exclude_nsfw_from_history">Исключить NSFW мангу из истории</string>
|
||||
</resources>
|
||||
@@ -244,4 +244,5 @@
|
||||
<string name="state_ongoing">Ongoing</string>
|
||||
<string name="date_format">Date format</string>
|
||||
<string name="system_default">Default</string>
|
||||
<string name="exclude_nsfw_from_history">Exclude NSFW manga from history</string>
|
||||
</resources>
|
||||
@@ -15,6 +15,11 @@
|
||||
android:title="@string/clear_updates_feed"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="history_exclude_nsfw"
|
||||
android:title="@string/exclude_nsfw_from_history"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/cache"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
Reference in New Issue
Block a user