Add vertical chapter navigator for paged reader with height adjustment option (#3531)
This commit is contained in:
@@ -2,7 +2,10 @@ package mihon.core.migration
|
||||
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
||||
class MigrationContext(val dryrun: Boolean) {
|
||||
class MigrationContext(
|
||||
val dryrun: Boolean,
|
||||
val previousVersion: Int,
|
||||
) {
|
||||
|
||||
inline fun <reified T> get(): T? {
|
||||
return Injekt.getInstanceOrNull(T::class.java)
|
||||
|
||||
@@ -19,7 +19,7 @@ object Migrator {
|
||||
dryrun: Boolean = false,
|
||||
onMigrationComplete: () -> Unit,
|
||||
) {
|
||||
val migrationContext = MigrationContext(dryrun)
|
||||
val migrationContext = MigrationContext(dryrun, old)
|
||||
val migrationJobFactory = MigrationJobFactory(migrationContext, scope)
|
||||
val migrationStrategyFactory = MigrationStrategyFactory(migrationJobFactory, onMigrationComplete)
|
||||
val strategy = migrationStrategyFactory.create(old, new)
|
||||
|
||||
@@ -9,4 +9,5 @@ val migrations: List<Migration>
|
||||
TrustExtensionRepositoryMigration(),
|
||||
CategoryPreferencesCleanupMigration(),
|
||||
InstallationIdMigration(),
|
||||
VerticalNavigatorMigration(),
|
||||
)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package mihon.core.migration.migrations
|
||||
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||
import mihon.core.migration.Migration
|
||||
import mihon.core.migration.MigrationContext
|
||||
import tachiyomi.core.common.preference.PreferenceStore
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
|
||||
class VerticalNavigatorMigration : Migration {
|
||||
override val version: Float = 25f
|
||||
|
||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
||||
val preferenceStore = migrationContext.get<PreferenceStore>() ?: return@withIOContext false
|
||||
val readerPreferences = migrationContext.get<ReaderPreferences>() ?: return@withIOContext false
|
||||
|
||||
if (migrationContext.previousVersion == 24) {
|
||||
val oldVerticalNavigator = preferenceStore.getBoolean("pref_webtoon_vertical_navigator", true)
|
||||
if (oldVerticalNavigator.get()) {
|
||||
readerPreferences.verticalNavigator.set(setOf(ReadingMode.WEBTOON, ReadingMode.CONTINUOUS_VERTICAL))
|
||||
}
|
||||
if (oldVerticalNavigator.isSet()) oldVerticalNavigator.delete()
|
||||
}
|
||||
|
||||
val oldVerticalNavigatorOnLeft = preferenceStore.getBoolean("pref_webtoon_vertical_navigator_on_left", false)
|
||||
if (oldVerticalNavigatorOnLeft.isSet()) {
|
||||
readerPreferences.verticalNavigatorOnLeft.set(oldVerticalNavigatorOnLeft.get())
|
||||
oldVerticalNavigatorOnLeft.delete()
|
||||
}
|
||||
|
||||
return@withIOContext true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user