Fix crash when using renamed library sort methods (fixes #7092)

This commit is contained in:
arkon 2022-05-07 23:48:53 -04:00
parent 85ef40d0ff
commit 681e9396b3
4 changed files with 27 additions and 5 deletions

View file

@ -25,7 +25,7 @@ android {
applicationId = "eu.kanade.tachiyomi" applicationId = "eu.kanade.tachiyomi"
minSdk = AndroidConfig.minSdk minSdk = AndroidConfig.minSdk
targetSdk = AndroidConfig.targetSdk targetSdk = AndroidConfig.targetSdk
versionCode = 80 versionCode = 81
versionName = "0.13.4" versionName = "0.13.4"
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"") buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")

View file

@ -204,11 +204,11 @@ object Migrations {
val newSortingMode = when (oldSortingMode) { val newSortingMode = when (oldSortingMode) {
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ LibrarySort.LAST_READ -> SortModeSetting.LAST_READ
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_MANGA_UPDATE LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED
LibrarySort.UNREAD -> SortModeSetting.UNREAD_COUNT LibrarySort.UNREAD -> SortModeSetting.UNREAD
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS
LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER
LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.CHAPTER_FETCH_DATE LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED
LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED
else -> SortModeSetting.ALPHABETICAL else -> SortModeSetting.ALPHABETICAL
} }
@ -266,6 +266,17 @@ object Migrations {
preferences.navigationModeWebtoon().set(5) preferences.navigationModeWebtoon().set(5)
} }
} }
if (oldVersion < 81) {
// Handle renamed enum values
@Suppress("DEPRECATION")
val newSortingMode = when (val oldSortingMode = preferences.librarySortingMode().get()) {
SortModeSetting.LAST_CHECKED -> SortModeSetting.LAST_MANGA_UPDATE
SortModeSetting.UNREAD -> SortModeSetting.UNREAD_COUNT
SortModeSetting.DATE_FETCHED -> SortModeSetting.CHAPTER_FETCH_DATE
else -> oldSortingMode
}
preferences.librarySortingMode().set(newSortingMode)
}
return true return true
} }

View file

@ -318,6 +318,7 @@ class LibraryPresenter(
SortModeSetting.DATE_ADDED -> { SortModeSetting.DATE_ADDED -> {
i1.manga.date_added.compareTo(i2.manga.date_added) i1.manga.date_added.compareTo(i2.manga.date_added)
} }
else -> throw IllegalStateException("Invalid SortModeSetting: $sortingMode")
} }
} }

View file

@ -11,7 +11,17 @@ enum class SortModeSetting(val flag: Int) {
TOTAL_CHAPTERS(0b00010000), TOTAL_CHAPTERS(0b00010000),
LATEST_CHAPTER(0b00010100), LATEST_CHAPTER(0b00010100),
CHAPTER_FETCH_DATE(0b00011000), CHAPTER_FETCH_DATE(0b00011000),
DATE_ADDED(0b00011100); DATE_ADDED(0b00011100),
@Deprecated("Use LAST_MANGA_UPDATE")
LAST_CHECKED(0b00001000),
@Deprecated("Use UNREAD_COUNT")
UNREAD(0b00001100),
@Deprecated("Use CHAPTER_FETCH_DATE")
DATE_FETCHED(0b00011000),
;
companion object { companion object {
// Mask supports for more sorting flags if necessary // Mask supports for more sorting flags if necessary