feat: Enable/Disable Sources Swipe (#396)

* Update SourceItem.kt

* Update SettingsBrowseController.kt 1

* Update SettingsBrowseController.kt

* Update SettingsBrowseController.kt

* Update strings.xml

* Update SettingsBrowseController.kt

* Update UiPreferences.kt

* Update SettingsBrowseController.kt

* Update SourceItem.kt
This commit is contained in:
Hiirbaf 2025-05-04 20:46:29 -03:00 committed by GitHub
parent 66241774dc
commit 94c314559b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import androidx.preference.PreferenceScreen
import androidx.preference.SwitchPreferenceCompat
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import yokai.domain.ui.UiPreferences
import yokai.i18n.MR
import yokai.util.lang.getString
import dev.icerock.moko.resources.compose.stringResource
@ -45,6 +46,8 @@ class SettingsBrowseController : SettingsLegacyController() {
val sourceManager: SourceManager by injectLazy()
var updatedExtNotifPref: SwitchPreferenceCompat? = null
private val uiPreferences: UiPreferences by injectLazy()
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
titleRes = MR.strings.browse
@ -198,6 +201,15 @@ class SettingsBrowseController : SettingsLegacyController() {
infoPreference(MR.strings.you_can_migrate_in_library)
}
preferenceCategory {
titleRes = MR.strings.sources
switchPreference {
bindTo(uiPreferences.enableSourceSwipeAction())
titleRes = MR.strings.enable_source_swipe_action
}
}
preferenceCategory {
titleRes = MR.strings.nsfw_sources

View file

@ -11,6 +11,9 @@ import yokai.util.lang.getString
import dev.icerock.moko.resources.compose.stringResource
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.LocalSource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import yokai.domain.ui.UiPreferences
/**
* Item that contains source information.
@ -29,7 +32,7 @@ class SourceItem(val source: CatalogueSource, header: LangItem? = null, val isPi
}
override fun isSwipeable(): Boolean {
return source.id != LocalSource.ID && header != null && header.code != SourcePresenter.LAST_USED_KEY
return Injekt.get<UiPreferences>().enableSourceSwipeAction().get() && source.id != LocalSource.ID && header != null && header.code != SourcePresenter.LAST_USED_KEY
}
/**

View file

@ -11,4 +11,6 @@ class UiPreferences(private val preferenceStore: PreferenceStore) {
fun uniformGrid() = preferenceStore.getBoolean(PreferenceKeys.uniformGrid, true)
fun enableChapterSwipeAction() = preferenceStore.getBoolean("enable_chapter_swipe_action", true)
fun enableSourceSwipeAction() = preferenceStore.getBoolean("enable_source_swipe_action", true)
}