diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt index 860013a69..b056fc143 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt @@ -15,9 +15,7 @@ import com.bluelinelabs.conductor.changehandler.FadeChangeHandler import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.ExtensionControllerBinding -import eu.kanade.tachiyomi.extension.ExtensionUpdateJob import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction @@ -27,7 +25,6 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.appcompat.queryTextChanges import reactivecircus.flowbinding.swiperefreshlayout.refreshes -import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get /** @@ -40,8 +37,6 @@ open class ExtensionController : FlexibleAdapter.OnItemLongClickListener, ExtensionTrustDialog.Listener { - private val preferences: PreferencesHelper = Injekt.get() - /** * Adapter containing the list of manga from the catalogue. */ @@ -100,11 +95,6 @@ open class ExtensionController : .pushChangeHandler(FadeChangeHandler()) ) } - R.id.action_auto_check -> { - item.isChecked = !item.isChecked - preferences.automaticExtUpdates().set(item.isChecked) - ExtensionUpdateJob.setupTask(activity!!, item.isChecked) - } else -> return super.onOptionsItemSelected(item) } return super.onOptionsItemSelected(item) @@ -159,8 +149,6 @@ open class ExtensionController : // Fixes problem with the overflow icon showing up in lieu of search searchItem.fixExpand(onExpand = { invalidateMenuOnExpand() }) - - menu.findItem(R.id.action_auto_check).isChecked = preferences.automaticExtUpdates().get() } override fun onItemClick(view: View, position: Int): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt new file mode 100644 index 000000000..69df8fc02 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt @@ -0,0 +1,29 @@ +package eu.kanade.tachiyomi.ui.setting + +import androidx.preference.PreferenceScreen +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.extension.ExtensionUpdateJob +import eu.kanade.tachiyomi.util.preference.defaultValue +import eu.kanade.tachiyomi.util.preference.onChange +import eu.kanade.tachiyomi.util.preference.switchPreference +import eu.kanade.tachiyomi.util.preference.titleRes + +class SettingsBrowseController : SettingsController() { + + override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { + titleRes = R.string.browse + + switchPreference { + key = Keys.automaticExtUpdates + titleRes = R.string.pref_enable_automatic_extension_updates + defaultValue = true + + onChange { newValue -> + val checked = newValue as Boolean + ExtensionUpdateJob.setupTask(activity!!, checked) + true + } + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index c84327507..68900ee80 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -47,6 +47,12 @@ class SettingsMainController : SettingsController() { titleRes = R.string.pref_category_tracking onClick { navigateTo(SettingsTrackingController()) } } + preference { + iconRes = R.drawable.ic_explore_24dp + iconTint = tintColor + titleRes = R.string.browse + onClick { navigateTo(SettingsBrowseController()) } + } preference { iconRes = R.drawable.ic_backup_24dp iconTint = tintColor diff --git a/app/src/main/res/menu/extension_main.xml b/app/src/main/res/menu/extension_main.xml index f71533988..578441c5c 100644 --- a/app/src/main/res/menu/extension_main.xml +++ b/app/src/main/res/menu/extension_main.xml @@ -16,10 +16,4 @@ app:iconTint="?attr/colorOnPrimary" app:showAsAction="ifRoom" /> - -