Migrate more preferences

(cherry picked from commit 53a3be0703)
This commit is contained in:
Jobobby04
2020-05-01 22:16:04 -04:00
parent e97d1ac257
commit 24850450cb
5 changed files with 13 additions and 9 deletions

View File

@ -94,7 +94,7 @@ class MigrationBottomSheetDialog(
} }
sourceGroup.bindToPreference(preferences.useSourceWithMost()) sourceGroup.bindToPreference(preferences.useSourceWithMost())
skip_step.isChecked = preferences.skipPreMigration().getOrDefault() skip_step.isChecked = preferences.skipPreMigration().get()
skip_step.setOnCheckedChangeListener { _, isChecked -> skip_step.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) if (isChecked)
(listener as? Controller)?.activity?.toast(R.string.pre_migration_skip_toast, (listener as? Controller)?.activity?.toast(R.string.pre_migration_skip_toast,

View File

@ -129,7 +129,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController<PreMigrati
* @return list containing enabled sources. * @return list containing enabled sources.
*/ */
private fun getEnabledSources(): List<HttpSource> { private fun getEnabledSources(): List<HttpSource> {
val languages = prefs.enabledLanguages().getOrDefault() val languages = prefs.enabledLanguages().get()
val sourcesSaved = prefs.migrationSources().getOrDefault().split("/") val sourcesSaved = prefs.migrationSources().getOrDefault().split("/")
var sources = sourceManager.getVisibleCatalogueSources() var sources = sourceManager.getVisibleCatalogueSources()
.filterIsInstance<HttpSource>() .filterIsInstance<HttpSource>()
@ -146,7 +146,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController<PreMigrati
fun isEnabled(id: String): Boolean { fun isEnabled(id: String): Boolean {
val sourcesSaved = prefs.migrationSources().getOrDefault() val sourcesSaved = prefs.migrationSources().getOrDefault()
val hiddenCatalogues = prefs.hiddenCatalogues().getOrDefault() val hiddenCatalogues = prefs.hiddenCatalogues().get()
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
else sourcesSaved.split("/").contains(id) else sourcesSaved.split("/").contains(id)
} }

View File

@ -210,7 +210,7 @@ class SettingsLibraryController : SettingsController() {
true true
} }
} }
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources() if (preferences.skipPreMigration().get() || preferences.migrationSources()
.getOrDefault().isNotEmpty()) { .getOrDefault().isNotEmpty()) {
switchPreference { switchPreference {
key = Keys.skipPreMigration key = Keys.skipPreMigration

View File

@ -8,10 +8,10 @@ import com.afollestad.materialdialogs.MaterialDialog
import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.combineLatest
import eu.kanade.tachiyomi.util.lang.launchInUI
import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.lang.plusAssign
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.galleries_box import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.galleries_box
import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_log import kotlinx.android.synthetic.main.eh_fragment_batch_add.view.progress_log
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.android.view.clicks import reactivecircus.flowbinding.android.view.clicks
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
@ -38,13 +38,13 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
.onEach { .onEach {
addGalleries(binding.galleriesBox.text.toString()) addGalleries(binding.galleriesBox.text.toString())
} }
.launchInUI() .launchIn(scope)
binding.progressDismissBtn.clicks() binding.progressDismissBtn.clicks()
.onEach { .onEach {
presenter.currentlyAddingRelay.call(BatchAddPresenter.STATE_PROGRESS_TO_INPUT) presenter.currentlyAddingRelay.call(BatchAddPresenter.STATE_PROGRESS_TO_INPUT)
} }
.launchInUI() .launchIn(scope)
val progressSubscriptions = CompositeSubscription() val progressSubscriptions = CompositeSubscription()

View File

@ -6,7 +6,9 @@ import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.lang.launchInUI import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -15,6 +17,8 @@ object LockActivityDelegate {
var willLock: Boolean = true var willLock: Boolean = true
private val uiScope = CoroutineScope(Dispatchers.Main)
fun doLock(router: Router, animate: Boolean = false) { fun doLock(router: Router, animate: Boolean = false) {
router.pushController(RouterTransaction.with(LockController()) router.pushController(RouterTransaction.with(LockController())
.popChangeHandler(LockChangeHandler(animate))) .popChangeHandler(LockChangeHandler(animate)))
@ -29,7 +33,7 @@ object LockActivityDelegate {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
} }
} }
.launchInUI() .launchIn(uiScope)
} }
fun onResume(activity: FragmentActivity, router: Router) { fun onResume(activity: FragmentActivity, router: Router) {