Add source setting controllers to search settings, hide settings in the E-Hentai settings when not logged in
This commit is contained in:
parent
1038913e2c
commit
a903a48718
@ -18,6 +18,7 @@ import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
@ -191,7 +192,10 @@ class SettingsEhController : SettingsController() {
|
||||
entryValues = arrayOf("0", "1")
|
||||
|
||||
onChange { preferences.useHentaiAtHome().reconfigure() }
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.show_japanese_titles
|
||||
@ -201,7 +205,10 @@ class SettingsEhController : SettingsController() {
|
||||
defaultValue = false
|
||||
|
||||
onChange { preferences.useJapaneseTitle().reconfigure() }
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.use_original_images
|
||||
@ -211,7 +218,10 @@ class SettingsEhController : SettingsController() {
|
||||
defaultValue = false
|
||||
|
||||
onChange { preferences.eh_useOriginalImages().reconfigure() }
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
preference {
|
||||
key = "pref_watched_tags"
|
||||
@ -225,7 +235,10 @@ class SettingsEhController : SettingsController() {
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
preference {
|
||||
titleRes = R.string.tag_filtering_threshold
|
||||
@ -261,7 +274,10 @@ class SettingsEhController : SettingsController() {
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.show()
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
preference {
|
||||
titleRes = R.string.tag_watching_threshhold
|
||||
@ -298,7 +314,10 @@ class SettingsEhController : SettingsController() {
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.show()
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
preference {
|
||||
key = "pref_language_filtering"
|
||||
@ -437,7 +456,10 @@ class SettingsEhController : SettingsController() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
preference {
|
||||
key = "pref_front_page_categories"
|
||||
@ -489,14 +511,20 @@ class SettingsEhController : SettingsController() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
defaultValue = false
|
||||
key = PreferenceKeys.eh_watched_list_default_state
|
||||
titleRes = R.string.watched_list_default
|
||||
summaryRes = R.string.watched_list_state_summary
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
listPreference {
|
||||
defaultValue = "auto"
|
||||
@ -521,7 +549,10 @@ class SettingsEhController : SettingsController() {
|
||||
)
|
||||
|
||||
onChange { preferences.imageQuality().reconfigure() }
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.pref_enhanced_e_hentai_view
|
||||
|
@ -26,7 +26,7 @@ class SettingsMangaDexController :
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||
titleRes = R.string.mangadex_specific_settings
|
||||
if (mdex == null) router.popCurrentController()
|
||||
if (mdex == null) return@apply
|
||||
val sourcePreference = MangaDexLoginPreference(context, mdex!!).apply {
|
||||
title = mdex!!.name + " Login"
|
||||
key = getSourceKey(source.id)
|
||||
@ -43,7 +43,7 @@ class SettingsMangaDexController :
|
||||
}
|
||||
}
|
||||
|
||||
preferenceScreen.addPreference(sourcePreference)
|
||||
addPreference(sourcePreference)
|
||||
|
||||
listPreference {
|
||||
titleRes = R.string.mangadex_preffered_source
|
||||
|
@ -7,19 +7,25 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceGroup
|
||||
import androidx.preference.PreferenceManager
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsAdvancedController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsBackupController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsBrowseController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsDownloadController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsEhController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsGeneralController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsLibraryController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsMangaDexController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsParentalControlsController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsReaderController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsSecurityController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsTrackingController
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import exh.md.utils.MdUtil
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.createInstance
|
||||
|
||||
@ -29,7 +35,9 @@ object SettingsSearchHelper {
|
||||
/**
|
||||
* All subclasses of `SettingsController` should be listed here, in order to have their preferences searchable.
|
||||
*/
|
||||
private val settingControllersList: List<KClass<out SettingsController>> = listOf(
|
||||
// SY -->
|
||||
private val settingControllersList: List<KClass<out SettingsController>> = {
|
||||
val controllers = mutableListOf(
|
||||
SettingsAdvancedController::class,
|
||||
SettingsBackupController::class,
|
||||
SettingsBrowseController::class,
|
||||
@ -41,6 +49,16 @@ object SettingsSearchHelper {
|
||||
SettingsSecurityController::class,
|
||||
SettingsTrackingController::class
|
||||
)
|
||||
val preferences = Injekt.get<PreferencesHelper>()
|
||||
if (MdUtil.getEnabledMangaDexs(preferences).isNotEmpty()) {
|
||||
controllers += SettingsMangaDexController::class
|
||||
}
|
||||
if (preferences.eh_isHentaiEnabled().get()) {
|
||||
controllers += SettingsEhController::class
|
||||
}
|
||||
controllers
|
||||
}()
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* Must be called to populate `prefSearchResultList`
|
||||
|
Loading…
x
Reference in New Issue
Block a user