Move extension update preference to settings

This commit is contained in:
arkon 2020-04-29 09:13:10 -04:00
parent 4f806a921f
commit 8077e421e6
4 changed files with 35 additions and 18 deletions

View file

@ -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 {

View file

@ -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
}
}
}
}

View file

@ -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

View file

@ -16,10 +16,4 @@
app:iconTint="?attr/colorOnPrimary"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_auto_check"
android:checkable="true"
android:title="@string/pref_enable_automatic_extension_updates"
app:showAsAction="never" />
</menu>