Skip to content

Commit

Permalink
fix animelib sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Jun 29, 2021
1 parent 8388676 commit 92b1732
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 57 deletions.
26 changes: 0 additions & 26 deletions app/src/main/java/eu/kanade/tachiyomi/Migrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.updater.UpdaterJob
import eu.kanade.tachiyomi.extension.AnimeExtensionUpdateJob
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
import eu.kanade.tachiyomi.ui.animelib.AnimelibSort
import eu.kanade.tachiyomi.ui.library.LibrarySort
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
Expand Down Expand Up @@ -242,39 +241,14 @@ object Migrations {
else -> SortDirectionSetting.DESCENDING
}

val oldSortingModeAnime = prefs.getInt(PreferenceKeys.animelibSortingMode, 0)
val oldSortingDirectionAnime = prefs.getBoolean(PreferenceKeys.animelibSortingDirection, true)

@Suppress("DEPRECATION")
val newSortingModeAnime = when (oldSortingModeAnime) {
AnimelibSort.ALPHA -> SortModeSetting.ALPHABETICAL
AnimelibSort.LAST_READ -> SortModeSetting.LAST_READ
AnimelibSort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED
AnimelibSort.UNREAD -> SortModeSetting.UNREAD
AnimelibSort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS
AnimelibSort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER
AnimelibSort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED
AnimelibSort.DATE_ADDED -> SortModeSetting.DATE_ADDED
else -> SortModeSetting.ALPHABETICAL
}

val newSortingDirectionAnime = when (oldSortingDirectionAnime) {
true -> SortDirectionSetting.ASCENDING
else -> SortDirectionSetting.DESCENDING
}

prefs.edit(commit = true) {
remove(PreferenceKeys.librarySortingMode)
remove(PreferenceKeys.librarySortingDirection)
remove(PreferenceKeys.animelibSortingMode)
remove(PreferenceKeys.animelibSortingDirection)
}

prefs.edit {
putString(PreferenceKeys.librarySortingMode, newSortingMode.name)
putString(PreferenceKeys.librarySortingDirection, newSortingDirection.name)
putString(PreferenceKeys.animelibSortingMode, newSortingModeAnime.name)
putString(PreferenceKeys.animelibSortingDirection, newSortingDirectionAnime.name)
}
}
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ object PreferenceKeys {
const val librarySortingMode = "library_sorting_mode"
const val librarySortingDirection = "library_sorting_ascending"

const val animelibSortingMode = "animelib_sorting_mode"
const val animelibSortingDirection = "animelib_sorting_ascending"

const val automaticExtUpdates = "automatic_ext_updates"

const val showNsfwSource = "show_nsfw_source"
Expand Down Expand Up @@ -202,8 +199,6 @@ object PreferenceKeys {

const val libraryDisplayMode = "pref_display_mode_library"

const val animelibDisplayMode = "pref_display_mode_animelib"

const val lang = "app_language"

const val dateFormat = "app_date_format"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ class PreferencesHelper(val context: Context) {

fun libraryDisplayMode() = flowPrefs.getEnum(Keys.libraryDisplayMode, DisplayModeSetting.COMPACT_GRID)

fun animelibDisplayMode() = flowPrefs.getEnum(Keys.animelibDisplayMode, DisplayModeSetting.COMPACT_GRID)

fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false)

fun localBadge() = flowPrefs.getBoolean(Keys.localBadge, true)
Expand Down Expand Up @@ -291,9 +289,6 @@ class PreferencesHelper(val context: Context) {
fun librarySortingMode() = flowPrefs.getEnum(Keys.librarySortingMode, SortModeSetting.ALPHABETICAL)
fun librarySortingAscending() = flowPrefs.getEnum(Keys.librarySortingDirection, SortDirectionSetting.ASCENDING)

fun animelibSortingMode() = flowPrefs.getEnum(Keys.animelibSortingMode, SortModeSetting.ALPHABETICAL)
fun animelibSortingAscending() = flowPrefs.getEnum(Keys.animelibSortingDirection, SortDirectionSetting.ASCENDING)

fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true)

fun showNsfwSource() = flowPrefs.getBoolean(Keys.showNsfwSource, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class AnimelibSettingsSheet(

db.insertCategory(currentCategory!!).executeAsBlocking()
} else {
preferences.animelibSortingAscending().set(flag)
preferences.librarySortingAscending().set(flag)
}
}

Expand All @@ -272,7 +272,7 @@ class AnimelibSettingsSheet(

db.insertCategory(currentCategory!!).executeAsBlocking()
} else {
preferences.animelibSortingMode().set(flag)
preferences.librarySortingMode().set(flag)
}
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ class AnimelibSettingsSheet(
return if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
DisplayModeSetting.fromFlag(currentCategory?.displayMode)
} else {
preferences.animelibDisplayMode().get()
preferences.libraryDisplayMode().get()
}
}

Expand Down Expand Up @@ -358,7 +358,7 @@ class AnimelibSettingsSheet(

db.insertCategory(currentCategory!!).executeAsBlocking()
} else {
preferences.animelibDisplayMode().set(flag)
preferences.libraryDisplayMode().set(flag)
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions app/src/main/java/eu/kanade/tachiyomi/ui/animelib/AnimelibSort.kt

This file was deleted.

0 comments on commit 92b1732

Please sign in to comment.