Remove deprecated LibrarySort (#7659)

* Remove deprecated LibrarySort

* Apply suggestions from code review

(cherry picked from commit 58acf0a8aa3aa37b5d9c63d99987a05ee2f8790f)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySort.kt
(cherry picked from commit 4b87831bdd125bbd7c6f2cbddcab97279d71933b)

# Conflicts:
#	app/src/main/java/exh/EXHMigrations.kt
This commit is contained in:
Andreas 2022-07-31 17:17:43 +02:00 committed by Jobobby04
parent 9a5ea9b507
commit 9a577e1c69
3 changed files with 40 additions and 63 deletions

View File

@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.updater.AppUpdateJob import eu.kanade.tachiyomi.data.updater.AppUpdateJob
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
import eu.kanade.tachiyomi.ui.library.LibrarySort
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
@ -106,10 +105,9 @@ object Migrations {
// Reset sorting preference if using removed sort by source // Reset sorting preference if using removed sort by source
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0) val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0)
@Suppress("DEPRECATION") if (oldSortingMode == 5 /* SOURCE */) {
if (oldSortingMode == LibrarySort.SOURCE) {
prefs.edit { prefs.edit {
putInt(PreferenceKeys.librarySortingMode, LibrarySort.ALPHA) putInt(PreferenceKeys.librarySortingMode, 0 /* ALPHABETICAL */)
} }
} }
} }
@ -202,16 +200,15 @@ object Migrations {
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0) val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0)
val oldSortingDirection = prefs.getBoolean(PreferenceKeys.librarySortingDirection, true) val oldSortingDirection = prefs.getBoolean(PreferenceKeys.librarySortingDirection, true)
@Suppress("DEPRECATION")
val newSortingMode = when (oldSortingMode) { val newSortingMode = when (oldSortingMode) {
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL 0 -> SortModeSetting.ALPHABETICAL
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ 1 -> SortModeSetting.LAST_READ
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED 2 -> SortModeSetting.LAST_CHECKED
LibrarySort.UNREAD -> SortModeSetting.UNREAD 3 -> SortModeSetting.UNREAD
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS 4 -> SortModeSetting.TOTAL_CHAPTERS
LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER 6 -> SortModeSetting.LATEST_CHAPTER
LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED 8 -> SortModeSetting.DATE_FETCHED
LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED 7 -> SortModeSetting.DATE_ADDED
else -> SortModeSetting.ALPHABETICAL else -> SortModeSetting.ALPHABETICAL
} }

View File

@ -1,23 +0,0 @@
package eu.kanade.tachiyomi.ui.library
@Deprecated("Deprecated in favor for SortModeSetting")
object LibrarySort {
const val ALPHA = 0
const val LAST_READ = 1
const val LAST_CHECKED = 2
const val UNREAD = 3
const val TOTAL = 4
const val LATEST_CHAPTER = 6
const val CHAPTER_FETCH_DATE = 10
const val DATE_ADDED = 8
// SY -->
const val DRAG_AND_DROP = 7
const val TAG_LIST = 9
// SY <--
@Deprecated("Removed in favor of searching by source")
const val SOURCE = 5
}

View File

@ -31,7 +31,6 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.all.Hitomi import eu.kanade.tachiyomi.source.online.all.Hitomi
import eu.kanade.tachiyomi.source.online.all.NHentai import eu.kanade.tachiyomi.source.online.all.NHentai
import eu.kanade.tachiyomi.ui.library.LibrarySort
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
@ -308,20 +307,21 @@ object EXHMigrations {
} }
} }
if (oldVersion under 20) { if (oldVersion under 20) {
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0) try {
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0 /* ALPHABETICAL */)
val oldSortingDirection = prefs.getBoolean(PreferenceKeys.librarySortingDirection, true) val oldSortingDirection = prefs.getBoolean(PreferenceKeys.librarySortingDirection, true)
val newSortingMode = when (oldSortingMode) { val newSortingMode = when (oldSortingMode) {
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL 0 -> SortModeSetting.ALPHABETICAL
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ 1 -> SortModeSetting.LAST_READ
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED 2 -> SortModeSetting.LAST_MANGA_UPDATE
LibrarySort.UNREAD -> SortModeSetting.UNREAD 3 -> SortModeSetting.UNREAD_COUNT
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS 4 -> SortModeSetting.TOTAL_CHAPTERS
LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER 6 -> SortModeSetting.LATEST_CHAPTER
LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED 7 -> SortModeSetting.DRAG_AND_DROP
LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED 8 -> SortModeSetting.DATE_ADDED
LibrarySort.DRAG_AND_DROP -> SortModeSetting.DRAG_AND_DROP 9 -> SortModeSetting.TAG_LIST
LibrarySort.TAG_LIST -> SortModeSetting.TAG_LIST 10 -> SortModeSetting.CHAPTER_FETCH_DATE
else -> SortModeSetting.ALPHABETICAL else -> SortModeSetting.ALPHABETICAL
} }
@ -339,6 +339,9 @@ object EXHMigrations {
putString(PreferenceKeys.librarySortingMode, newSortingMode.name) putString(PreferenceKeys.librarySortingMode, newSortingMode.name)
putString(PreferenceKeys.librarySortingDirection, newSortingDirection.name) putString(PreferenceKeys.librarySortingDirection, newSortingDirection.name)
} }
} catch (e: Exception) {
logcat(throwable = e) { "Already done migration" }
}
} }
if (oldVersion under 21) { if (oldVersion under 21) {
// Setup EH updater task after migrating to WorkManager // Setup EH updater task after migrating to WorkManager