mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Remove unused migrations
Yokai earliest version starts at version code 111 anyway, so older migrations are basically useless
This commit is contained in:
parent
6c8bd82d41
commit
d3149abf9c
26 changed files with 11 additions and 535 deletions
|
@ -52,7 +52,7 @@
|
||||||
- Some code refactors
|
- Some code refactors
|
||||||
- Simplify some messy code
|
- Simplify some messy code
|
||||||
- Rewrite version checker
|
- Rewrite version checker
|
||||||
- Rewrite Migrator
|
- Rewrite Migrator (ghostbear)
|
||||||
- Split the project into several modules
|
- Split the project into several modules
|
||||||
- Migrated i18n to use Moko Resources
|
- Migrated i18n to use Moko Resources
|
||||||
- Removed unnecessary dependencies
|
- Removed unnecessary dependencies
|
||||||
|
|
|
@ -54,7 +54,7 @@ val supportedAbis = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
||||||
android {
|
android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "eu.kanade.tachiyomi"
|
applicationId = "eu.kanade.tachiyomi"
|
||||||
versionCode = 140
|
versionCode = 141
|
||||||
versionName = _versionName
|
versionName = _versionName
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
|
|
|
@ -172,12 +172,7 @@ open class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.F
|
||||||
Preference.appStateKey("last_version_code"),
|
Preference.appStateKey("last_version_code"),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
// TODO: Remove later
|
if (preference.get() < 141) preference.set(0)
|
||||||
val old = preferenceStore.getInt("last_version_code", -1)
|
|
||||||
if (old.get() >= preference.get()) {
|
|
||||||
preference.set(old.get())
|
|
||||||
old.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.i { "Migration from ${preference.get()} to ${BuildConfig.VERSION_CODE}" }
|
Logger.i { "Migration from ${preference.get()} to ${BuildConfig.VERSION_CODE}" }
|
||||||
Migrator.initialize(
|
Migrator.initialize(
|
||||||
|
|
|
@ -68,9 +68,11 @@ object ThemeUtil {
|
||||||
|
|
||||||
fun AppCompatActivity.setThemeByPref(preferences: PreferencesHelper) {
|
fun AppCompatActivity.setThemeByPref(preferences: PreferencesHelper) {
|
||||||
setTheme(getPrefTheme(preferences).styleRes)
|
setTheme(getPrefTheme(preferences).styleRes)
|
||||||
|
if (preferences.nightMode().get() != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) {
|
||||||
val wic = WindowInsetsControllerCompat(window, window.decorView)
|
val wic = WindowInsetsControllerCompat(window, window.decorView)
|
||||||
wic.isAppearanceLightStatusBars = !isDarkMode(preferences)
|
wic.isAppearanceLightStatusBars = !isDarkMode(preferences)
|
||||||
wic.isAppearanceLightNavigationBars = !isDarkMode(preferences)
|
wic.isAppearanceLightNavigationBars = !isDarkMode(preferences)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper, oldTheme: Resources.Theme?): Resources.Theme {
|
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper, oldTheme: Resources.Theme?): Resources.Theme {
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete external chapter cache dir.
|
|
||||||
*/
|
|
||||||
class ChapterCacheMigration : Migration {
|
|
||||||
override val version: Float = 26f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val extCache = context.externalCacheDir
|
|
||||||
if (extCache != null) {
|
|
||||||
val chapterCache = File(extCache, "chapter_disk_cache")
|
|
||||||
if (chapterCache.exists()) {
|
|
||||||
chapterCache.deleteRecursively()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Move covers to external files dir.
|
|
||||||
*/
|
|
||||||
class CoverCacheMigration : Migration {
|
|
||||||
override val version: Float = 19f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val oldDir = File(context.externalCacheDir, "cover_disk_cache")
|
|
||||||
if (oldDir.exists()) {
|
|
||||||
val destDir = context.getExternalFilesDir("covers")
|
|
||||||
if (destDir != null) {
|
|
||||||
oldDir.listFiles()?.forEach {
|
|
||||||
it.renameTo(File(destDir, it.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
|
||||||
import eu.kanade.tachiyomi.util.system.withIOContext
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class CustomInfoMigration : Migration {
|
|
||||||
override val version: Float = 66f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
try {
|
|
||||||
withIOContext { LibraryPresenter.updateCustoms() }
|
|
||||||
} catch (e: Exception) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,14 +21,12 @@ class CutoutMigration : Migration {
|
||||||
val oldCutoutBehaviour = prefs.getInt(PreferenceKeys.pagerCutoutBehavior, 0)
|
val oldCutoutBehaviour = prefs.getInt(PreferenceKeys.pagerCutoutBehavior, 0)
|
||||||
readerPreferences.pagerCutoutBehavior().set(CutoutBehaviour.migrate(oldCutoutBehaviour))
|
readerPreferences.pagerCutoutBehavior().set(CutoutBehaviour.migrate(oldCutoutBehaviour))
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
readerPreferences.pagerCutoutBehavior().set(CutoutBehaviour.SHOW)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val oldCutoutBehaviour = prefs.getInt("landscape_cutout_behavior", 0)
|
val oldCutoutBehaviour = prefs.getInt("landscape_cutout_behavior", 0)
|
||||||
readerPreferences.landscapeCutoutBehavior().set(LandscapeCutoutBehaviour.migrate(oldCutoutBehaviour))
|
readerPreferences.landscapeCutoutBehavior().set(LandscapeCutoutBehaviour.migrate(oldCutoutBehaviour))
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
readerPreferences.landscapeCutoutBehavior().set(LandscapeCutoutBehaviour.DEFAULT)
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class DoHMigration : Migration {
|
|
||||||
override val version: Float = 71f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
// Migrate DNS over HTTPS setting
|
|
||||||
val wasDohEnabled = prefs.getBoolean("enable_doh", false)
|
|
||||||
if (wasDohEnabled) {
|
|
||||||
prefs.edit {
|
|
||||||
putInt(PreferenceKeys.dohProvider, PREF_DOH_CLOUDFLARE)
|
|
||||||
remove("enable_doh")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class DownloadedChaptersMigration : Migration {
|
|
||||||
override val version: Float = 54f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
DownloadProvider(context).renameChapters()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class EnabledLanguageMigration : Migration {
|
|
||||||
override val version: Float = 83f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val preferences: PreferencesHelper = migrationContext.get() ?: return false
|
|
||||||
|
|
||||||
if (preferences.enabledLanguages().isSet()) {
|
|
||||||
preferences.enabledLanguages() += "all"
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateJob
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restore jobs after upgrading to evernote's job scheduler.
|
|
||||||
*/
|
|
||||||
class EvernoteJobUpgradeMigration : Migration {
|
|
||||||
override val version: Float = 14f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
if (BuildConfig.INCLUDE_UPDATER) {
|
|
||||||
AppUpdateJob.setupTask(context)
|
|
||||||
}
|
|
||||||
LibraryUpdateJob.setupTask(context)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,7 +21,6 @@ class ExtensionInstallerEnumMigration : Migration {
|
||||||
val oldExtensionInstall = prefs.getInt("extension_installer", 0)
|
val oldExtensionInstall = prefs.getInt("extension_installer", 0)
|
||||||
basePreferences.extensionInstaller().set(BasePreferences.ExtensionInstaller.migrate(oldExtensionInstall))
|
basePreferences.extensionInstaller().set(BasePreferences.ExtensionInstaller.migrate(oldExtensionInstall))
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
basePreferences.extensionInstaller().set(BasePreferences.ExtensionInstaller.PACKAGEINSTALLER)
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete internal chapter cache dir.
|
|
||||||
*/
|
|
||||||
class InternalChapterCacheUpdateMigration : Migration {
|
|
||||||
override val version: Float = 15f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
File(context.cacheDir, "chapter_disk_cache").deleteRecursively()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibrarySort
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class LibrarySortMigration : Migration {
|
|
||||||
override val version: Float = 110f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
try {
|
|
||||||
val librarySortString = prefs.getString("library_sorting_mode", "")
|
|
||||||
if (!librarySortString.isNullOrEmpty()) {
|
|
||||||
prefs.edit {
|
|
||||||
remove("library_sorting_mode")
|
|
||||||
putInt(
|
|
||||||
"library_sorting_mode",
|
|
||||||
LibrarySort.deserialize(librarySortString).mainValue,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (_: Exception) {
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class LibraryUpdateResetMigration : Migration {
|
|
||||||
override val version: Float = 105f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
LibraryUpdateJob.cancelAllWorks(context)
|
|
||||||
LibraryUpdateJob.setupTask(context)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,35 +5,15 @@ import kotlinx.collections.immutable.persistentListOf
|
||||||
import yokai.core.migration.Migration
|
import yokai.core.migration.Migration
|
||||||
|
|
||||||
val migrations: ImmutableList<Migration> = persistentListOf(
|
val migrations: ImmutableList<Migration> = persistentListOf(
|
||||||
|
// Always run
|
||||||
SetupAppUpdateMigration(),
|
SetupAppUpdateMigration(),
|
||||||
SetupBackupCreateMigration(),
|
SetupBackupCreateMigration(),
|
||||||
SetupExtensionUpdateMigration(),
|
SetupExtensionUpdateMigration(),
|
||||||
SetupLibraryUpdateMigration(),
|
SetupLibraryUpdateMigration(),
|
||||||
|
|
||||||
// For archive purposes
|
|
||||||
EvernoteJobUpgradeMigration(),
|
|
||||||
InternalChapterCacheUpdateMigration(),
|
|
||||||
CoverCacheMigration(),
|
|
||||||
ChapterCacheMigration(),
|
|
||||||
DownloadedChaptersMigration(),
|
|
||||||
WorkManagerMigration(),
|
|
||||||
CustomInfoMigration(),
|
|
||||||
MyAnimeListMigration(),
|
|
||||||
DoHMigration(),
|
|
||||||
RotationTypeMigration(),
|
|
||||||
ShortcutsMigration(),
|
|
||||||
RotationTypeEnumMigration(),
|
|
||||||
EnabledLanguageMigration(),
|
|
||||||
UpdateIntervalMigration(),
|
|
||||||
ReaderUpdateMigration(),
|
|
||||||
PrefsMigration(),
|
|
||||||
LibraryUpdateResetMigration(),
|
|
||||||
TrackerPrivateSettingsMigration(),
|
|
||||||
LibrarySortMigration(),
|
|
||||||
|
|
||||||
// Yokai fork
|
// Yokai fork
|
||||||
ThePurgeMigration(),
|
|
||||||
ExtensionInstallerEnumMigration(),
|
|
||||||
CutoutMigration(),
|
CutoutMigration(),
|
||||||
|
ExtensionInstallerEnumMigration(),
|
||||||
RepoJsonMigration(),
|
RepoJsonMigration(),
|
||||||
|
ThePurgeMigration(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
import yokai.i18n.MR
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force MAL log out due to login flow change
|
|
||||||
* v67: switched from scraping to WebView
|
|
||||||
* v68: switched from WebView to OAuth
|
|
||||||
*/
|
|
||||||
class MyAnimeListMigration : Migration {
|
|
||||||
override val version: Float = 68f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val trackManager = migrationContext.get<TrackManager>() ?: return false
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
|
|
||||||
if (trackManager.myAnimeList.isLogged) {
|
|
||||||
trackManager.myAnimeList.logout()
|
|
||||||
context.toast(MR.strings.myanimelist_relogin)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentsPresenter
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
class PrefsMigration : Migration {
|
|
||||||
override val version: Float = 102f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val preferences = migrationContext.get<PreferencesHelper>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
val oldSecureScreen = prefs.getBoolean("secure_screen", false)
|
|
||||||
if (oldSecureScreen) {
|
|
||||||
preferences.secureScreen().set(PreferenceValues.SecureScreenMode.ALWAYS)
|
|
||||||
}
|
|
||||||
|
|
||||||
val oldDLAfterReading = prefs.getInt("auto_download_after_reading", 0)
|
|
||||||
if (oldDLAfterReading > 0) {
|
|
||||||
preferences.autoDownloadWhileReading().set(max(2, oldDLAfterReading))
|
|
||||||
}
|
|
||||||
|
|
||||||
val oldGroupHistory = prefs.getBoolean("group_chapters_history", true)
|
|
||||||
if (!oldGroupHistory) {
|
|
||||||
preferences.groupChaptersHistory().set(RecentsPresenter.GroupType.Never)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
|
||||||
import eu.kanade.tachiyomi.util.system.withIOContext
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class ReaderUpdateMigration : Migration {
|
|
||||||
override val version: Float = 88f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val preferences = migrationContext.get<PreferencesHelper>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
withIOContext {
|
|
||||||
LibraryPresenter.updateRatiosAndColors()
|
|
||||||
}
|
|
||||||
val oldReaderTap = prefs.getBoolean("reader_tap", true)
|
|
||||||
if (!oldReaderTap) {
|
|
||||||
preferences.navigationModePager().set(5)
|
|
||||||
preferences.navigationModeWebtoon().set(5)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class RotationTypeEnumMigration : Migration {
|
|
||||||
override val version: Float = 77f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
// Migrate Rotation and Viewer values to default values for viewer_flags
|
|
||||||
val newOrientation = when (prefs.getInt("pref_rotation_type_key", 1)) {
|
|
||||||
1 -> OrientationType.FREE.flagValue
|
|
||||||
2 -> OrientationType.PORTRAIT.flagValue
|
|
||||||
3 -> OrientationType.LANDSCAPE.flagValue
|
|
||||||
4 -> OrientationType.LOCKED_PORTRAIT.flagValue
|
|
||||||
5 -> OrientationType.LOCKED_LANDSCAPE.flagValue
|
|
||||||
else -> OrientationType.FREE.flagValue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reading mode flag and prefValue is the same value
|
|
||||||
val newReadingMode = prefs.getInt("pref_default_viewer_key", 1)
|
|
||||||
|
|
||||||
prefs.edit {
|
|
||||||
putInt("pref_default_orientation_type_key", newOrientation)
|
|
||||||
remove("pref_rotation_type_key")
|
|
||||||
putInt("pref_default_reading_mode_key", newReadingMode)
|
|
||||||
remove("pref_default_viewer_key")
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class RotationTypeMigration : Migration {
|
|
||||||
override val version: Float = 73f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
if (prefs.contains("pref_rotation_type_key")) {
|
|
||||||
prefs.edit {
|
|
||||||
putInt("pref_rotation_type_key", 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class ShortcutsMigration : Migration {
|
|
||||||
override val version: Float = 75f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val preferences = migrationContext.get<PreferencesHelper>() ?: return false
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
|
|
||||||
val wasShortcutsDisabled = !prefs.getBoolean("show_manga_app_shortcuts", true)
|
|
||||||
if (wasShortcutsDisabled) {
|
|
||||||
prefs.edit {
|
|
||||||
putBoolean(PreferenceKeys.showSourcesInShortcuts, false)
|
|
||||||
putBoolean(PreferenceKeys.showSeriesInShortcuts, false)
|
|
||||||
remove("show_manga_app_shortcuts")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Handle removed every 1 or 2 hour library updates
|
|
||||||
val updateInterval = preferences.libraryUpdateInterval().get()
|
|
||||||
if (updateInterval == 1 || updateInterval == 2) {
|
|
||||||
preferences.libraryUpdateInterval().set(3)
|
|
||||||
LibraryUpdateJob.setupTask(context, 3)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.core.preference.Preference
|
|
||||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class TrackerPrivateSettingsMigration : Migration {
|
|
||||||
override val version: Float = 108f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val preferenceStore: PreferenceStore = migrationContext.get() ?: return false
|
|
||||||
preferenceStore.getAll()
|
|
||||||
.filter { it.key.startsWith("pref_mangasync_") || it.key.startsWith("track_token_") }
|
|
||||||
.forEach { (key, value) ->
|
|
||||||
if (value is String) {
|
|
||||||
preferenceStore
|
|
||||||
.getString(Preference.privateKey(key))
|
|
||||||
.set(value)
|
|
||||||
|
|
||||||
preferenceStore.getString(key).delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
class UpdateIntervalMigration : Migration {
|
|
||||||
override val version: Float = 86f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
val preferences = migrationContext.get<PreferencesHelper>() ?: return false
|
|
||||||
|
|
||||||
// Handle removed every 3, 4, 6, and 8 hour library updates
|
|
||||||
val updateInterval = preferences.libraryUpdateInterval().get()
|
|
||||||
if (updateInterval in listOf(3, 4, 6, 8)) {
|
|
||||||
preferences.libraryUpdateInterval().set(12)
|
|
||||||
LibraryUpdateJob.setupTask(context, 12)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package yokai.core.migration.migrations
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreatorJob
|
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
|
||||||
import eu.kanade.tachiyomi.util.system.withIOContext
|
|
||||||
import yokai.core.migration.Migration
|
|
||||||
import yokai.core.migration.MigrationContext
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restore jobs after migrating from Evernote's job scheduler to WorkManager.
|
|
||||||
*/
|
|
||||||
class WorkManagerMigration : Migration {
|
|
||||||
override val version: Float = 62f
|
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
|
||||||
val context = migrationContext.get<Application>() ?: return false
|
|
||||||
withIOContext {
|
|
||||||
LibraryPresenter.updateDB()
|
|
||||||
}
|
|
||||||
if (BuildConfig.INCLUDE_UPDATER) {
|
|
||||||
AppUpdateJob.setupTask(context)
|
|
||||||
}
|
|
||||||
LibraryUpdateJob.setupTask(context)
|
|
||||||
BackupCreatorJob.setupTask(context)
|
|
||||||
ExtensionUpdateJob.setupTask(context)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue