Inverted filter presets
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package org.koitharu.kotatsu.history.domain
|
package org.koitharu.kotatsu.history.domain
|
||||||
|
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.core.os.NetworkState
|
import org.koitharu.kotatsu.core.os.NetworkState
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
import org.koitharu.kotatsu.history.data.HistoryRepository
|
||||||
@@ -25,14 +24,7 @@ class HistoryListQuickFilter @Inject constructor(
|
|||||||
}
|
}
|
||||||
add(ListFilterOption.Macro.COMPLETED)
|
add(ListFilterOption.Macro.COMPLETED)
|
||||||
add(ListFilterOption.Macro.FAVORITE)
|
add(ListFilterOption.Macro.FAVORITE)
|
||||||
add(
|
add(ListFilterOption.NOT_FAVORITE)
|
||||||
ListFilterOption.Inverted(
|
|
||||||
option = ListFilterOption.Macro.FAVORITE,
|
|
||||||
iconResId = R.drawable.ic_heart_off,
|
|
||||||
titleResId = R.string.not_in_favorites,
|
|
||||||
titleText = null,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
if (!settings.isNsfwContentDisabled && !settings.isHistoryExcludeNsfw) {
|
if (!settings.isNsfwContentDisabled && !settings.isHistoryExcludeNsfw) {
|
||||||
add(ListFilterOption.Macro.NSFW)
|
add(ListFilterOption.Macro.NSFW)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,4 +98,23 @@ sealed interface ListFilterOption {
|
|||||||
override val groupKey: String
|
override val groupKey: String
|
||||||
get() = "_inv" + option.groupKey
|
get() = "_inv" + option.groupKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
val SFW
|
||||||
|
get() = Inverted(
|
||||||
|
option = Macro.NSFW,
|
||||||
|
iconResId = R.drawable.ic_sfw,
|
||||||
|
titleResId = R.string.sfw,
|
||||||
|
titleText = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
val NOT_FAVORITE
|
||||||
|
get() = Inverted(
|
||||||
|
option = Macro.FAVORITE,
|
||||||
|
iconResId = R.drawable.ic_heart_off,
|
||||||
|
titleResId = R.string.not_in_favorites,
|
||||||
|
titleText = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.filter
|
|||||||
import kotlinx.coroutines.flow.onStart
|
import kotlinx.coroutines.flow.onStart
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.plus
|
import kotlinx.coroutines.plus
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.prefs.ListMode
|
import org.koitharu.kotatsu.core.prefs.ListMode
|
||||||
import org.koitharu.kotatsu.core.prefs.observeAsFlow
|
import org.koitharu.kotatsu.core.prefs.observeAsFlow
|
||||||
@@ -67,7 +66,7 @@ abstract class MangaListViewModel(
|
|||||||
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
||||||
) { filters, skipNsfw ->
|
) { filters, skipNsfw ->
|
||||||
if (skipNsfw) {
|
if (skipNsfw) {
|
||||||
filters + ListFilterOption.Inverted(ListFilterOption.Macro.NSFW, R.drawable.ic_sfw, R.string.sfw, null)
|
filters + ListFilterOption.SFW
|
||||||
} else {
|
} else {
|
||||||
filters
|
filters
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,7 @@ class SuggestionsListQuickFilter @Inject constructor(
|
|||||||
}
|
}
|
||||||
if (!settings.isNsfwContentDisabled && !settings.isSuggestionsExcludeNsfw) {
|
if (!settings.isNsfwContentDisabled && !settings.isSuggestionsExcludeNsfw) {
|
||||||
add(ListFilterOption.Macro.NSFW)
|
add(ListFilterOption.Macro.NSFW)
|
||||||
add(
|
add(ListFilterOption.SFW)
|
||||||
ListFilterOption.Inverted(
|
|
||||||
option = ListFilterOption.Macro.NSFW,
|
|
||||||
iconResId = R.drawable.ic_sfw,
|
|
||||||
titleResId = R.string.sfw,
|
|
||||||
titleText = null,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class FeedViewModel @Inject constructor(
|
|||||||
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
||||||
) { filters, skipNsfw ->
|
) { filters, skipNsfw ->
|
||||||
if (skipNsfw) {
|
if (skipNsfw) {
|
||||||
filters + ListFilterOption.Inverted(ListFilterOption.Macro.NSFW, R.drawable.ic_sfw, R.string.sfw, null)
|
filters + ListFilterOption.SFW
|
||||||
} else {
|
} else {
|
||||||
filters
|
filters
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user