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

View File

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

View File

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

View File

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