mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 21:41:50 +01:00
More FlowPreferences migrations
This commit is contained in:
parent
678c004a64
commit
b8152dd7f9
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||
import java.io.File
|
||||
@ -18,7 +17,7 @@ object Migrations {
|
||||
*/
|
||||
fun upgrade(preferences: PreferencesHelper): Boolean {
|
||||
val context = preferences.context
|
||||
val oldVersion = preferences.lastVersionCode().getOrDefault()
|
||||
val oldVersion = preferences.lastVersionCode().get()
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
preferences.lastVersionCode().set(BuildConfig.VERSION_CODE)
|
||||
|
||||
|
@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
||||
import java.io.File
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
@ -131,7 +132,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun lastUsedCategory() = rxPrefs.getInteger(Keys.lastUsedCategory, 0)
|
||||
|
||||
fun lastVersionCode() = rxPrefs.getInteger("last_version_code", 0)
|
||||
fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0)
|
||||
|
||||
fun catalogueAsList() = rxPrefs.getBoolean(Keys.catalogueAsList, false)
|
||||
|
||||
@ -150,7 +151,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun trackToken(sync: TrackService) = rxPrefs.getString(Keys.trackToken(sync.id), "")
|
||||
|
||||
fun anilistScoreType() = rxPrefs.getString("anilist_score_type", "POINT_10")
|
||||
fun anilistScoreType() = rxPrefs.getString("anilist_score_type", Anilist.POINT_10)
|
||||
|
||||
fun backupsDirectory() = rxPrefs.getString(Keys.backupDirectory, defaultBackupDir.toString())
|
||||
|
||||
@ -194,7 +195,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true)
|
||||
|
||||
fun extensionUpdatesCount() = rxPrefs.getInteger("ext_updates_count", 0)
|
||||
fun extensionUpdatesCount() = flowPrefs.getInt("ext_updates_count", 0)
|
||||
|
||||
fun lastExtCheck() = flowPrefs.getLong("last_ext_check", 0)
|
||||
|
||||
|
@ -12,8 +12,6 @@ import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.clearFindViewByIdCache
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import timber.log.Timber
|
||||
|
||||
abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateController(bundle),
|
||||
@ -43,8 +41,6 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr
|
||||
})
|
||||
}
|
||||
|
||||
val uiScope = CoroutineScope(Dispatchers.Main)
|
||||
|
||||
override val containerView: View?
|
||||
get() = view
|
||||
|
||||
|
@ -9,8 +9,6 @@ import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
/**
|
||||
* A controller that displays a dialog window, floating on top of its activity's window.
|
||||
@ -26,8 +24,6 @@ abstract class DialogController : RestoreViewOnCreateController {
|
||||
|
||||
private var dismissed = false
|
||||
|
||||
val uiScope = CoroutineScope(Dispatchers.Main)
|
||||
|
||||
/**
|
||||
* Convenience constructor for use when no arguments are needed.
|
||||
*/
|
||||
|
@ -12,7 +12,6 @@ import com.bluelinelabs.conductor.RouterTransaction
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||
@ -30,10 +29,12 @@ import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
@ -141,10 +142,11 @@ class MainActivity : BaseActivity() {
|
||||
ChangelogDialogController().showDialog(router)
|
||||
}
|
||||
}
|
||||
preferences.extensionUpdatesCount().asObservable().subscribe {
|
||||
setExtensionsBadge()
|
||||
}
|
||||
|
||||
setExtensionsBadge()
|
||||
preferences.extensionUpdatesCount().asFlow()
|
||||
.onEach { setExtensionsBadge() }
|
||||
.launchInUI()
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
@ -159,7 +161,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun setExtensionsBadge() {
|
||||
val updates = preferences.extensionUpdatesCount().getOrDefault()
|
||||
val updates = preferences.extensionUpdatesCount().get()
|
||||
if (updates > 0) {
|
||||
binding.bottomNav.getOrCreateBadge(R.id.nav_more).number = updates
|
||||
} else {
|
||||
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.more
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||
@ -34,7 +33,7 @@ class MoreController : SettingsController(), RootController {
|
||||
titleRes = R.string.label_extensions
|
||||
iconRes = R.drawable.ic_extension_24dp
|
||||
iconTint = tintColor
|
||||
setBadge(Injekt.get<PreferencesHelper>().extensionUpdatesCount().getOrDefault())
|
||||
setBadge(Injekt.get<PreferencesHelper>().extensionUpdatesCount().get())
|
||||
onClick {
|
||||
router.pushController(ExtensionController().withFadeTransaction())
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import eu.kanade.tachiyomi.util.lang.addTo
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import eu.kanade.tachiyomi.util.lang.addTo
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user