Sort per category (#5408)

* Add flags for sorting per category

* Add logic to LibrarySettingsSheet

* Add  logic to LibraryPresenter

* Minor tweaks

* Use enum instead of variables

Also deprecates LibrarySort in favour of the new enum classes

* Remove debug log and suppress deprecation

* Convert DisplayMode setting to enum

Also fix bug were adapter would get de-synced with the current per category setting

* Fix migration crashing app due to values being access before migration
This commit is contained in:
Andreas 2021-06-26 19:30:16 +02:00 committed by GitHub
parent 64c95305b9
commit 60890147c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 289 additions and 124 deletions

View File

@ -30,7 +30,7 @@ android {
minSdkVersion(AndroidConfig.minSdk) minSdkVersion(AndroidConfig.minSdk)
targetSdkVersion(AndroidConfig.targetSdk) targetSdkVersion(AndroidConfig.targetSdk)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
versionCode = 63 versionCode = 64
versionName = "0.11.1" versionName = "0.11.1"
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"") buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")

View File

@ -12,6 +12,8 @@ import eu.kanade.tachiyomi.data.updater.UpdaterJob
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.LibrarySort
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView
@ -96,9 +98,15 @@ object Migrations {
} }
if (oldVersion < 44) { if (oldVersion < 44) {
// Reset sorting preference if using removed sort by source // Reset sorting preference if using removed sort by source
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0)
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
if (preferences.librarySortingMode().get() == LibrarySort.SOURCE) { if (oldSortingMode == LibrarySort.SOURCE) {
preferences.librarySortingMode().set(LibrarySort.ALPHA) prefs.edit {
putInt(PreferenceKeys.librarySortingMode, LibrarySort.ALPHA)
}
} }
} }
if (oldVersion < 52) { if (oldVersion < 52) {
@ -190,6 +198,40 @@ object Migrations {
LibraryUpdateJob.setupTask(context, 3) LibraryUpdateJob.setupTask(context, 3)
} }
} }
if (oldVersion < 64) {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0)
val oldSortingDirection = prefs.getBoolean(PreferenceKeys.librarySortingDirection, true)
@Suppress("DEPRECATION")
val newSortingMode = when (oldSortingMode) {
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED
LibrarySort.UNREAD -> SortModeSetting.UNREAD
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS
LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER
LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED
LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED
else -> SortModeSetting.ALPHABETICAL
}
val newSortingDirection = when (oldSortingDirection) {
true -> SortDirectionSetting.ASCENDING
else -> SortDirectionSetting.DESCENDING
}
prefs.edit(commit = true) {
remove(PreferenceKeys.librarySortingMode)
remove(PreferenceKeys.librarySortingDirection)
}
prefs.edit {
putString(PreferenceKeys.librarySortingMode, newSortingMode.name)
putString(PreferenceKeys.librarySortingDirection, newSortingDirection.name)
}
}
return true return true
} }

View File

@ -1,5 +1,8 @@
package eu.kanade.tachiyomi.data.database.models package eu.kanade.tachiyomi.data.database.models
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import java.io.Serializable import java.io.Serializable
interface Category : Serializable { interface Category : Serializable {
@ -17,16 +20,19 @@ interface Category : Serializable {
} }
var displayMode: Int var displayMode: Int
get() = flags and MASK get() = flags and DisplayModeSetting.MASK
set(mode) = setFlags(mode, MASK) set(mode) = setFlags(mode, DisplayModeSetting.MASK)
var sortMode: Int
get() = flags and SortModeSetting.MASK
set(mode) = setFlags(mode, SortModeSetting.MASK)
var sortDirection: Int
get() = flags and SortDirectionSetting.MASK
set(mode) = setFlags(mode, SortDirectionSetting.MASK)
companion object { companion object {
const val COMPACT_GRID = 0b00000000
const val COMFORTABLE_GRID = 0b00000001
const val LIST = 0b00000010
const val MASK = 0b00000011
fun create(name: String): Category = CategoryImpl().apply { fun create(name: String): Category = CategoryImpl().apply {
this.name = name this.name = name
} }

View File

@ -147,6 +147,7 @@ object PreferenceKeys {
const val filterTracked = "pref_filter_library_tracked" const val filterTracked = "pref_filter_library_tracked"
const val librarySortingMode = "library_sorting_mode" const val librarySortingMode = "library_sorting_mode"
const val librarySortingDirection = "library_sorting_ascending"
const val automaticExtUpdates = "automatic_ext_updates" const val automaticExtUpdates = "automatic_ext_updates"

View File

@ -37,12 +37,6 @@ object PreferenceValues {
/* ktlint-enable experimental:enum-entry-name-case */ /* ktlint-enable experimental:enum-entry-name-case */
enum class DisplayMode {
COMPACT_GRID,
COMFORTABLE_GRID,
LIST,
}
enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) { enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) {
NONE, NONE,
HORIZONTAL(shouldInvertHorizontal = true), HORIZONTAL(shouldInvertHorizontal = true),

View File

@ -10,10 +10,12 @@ import com.tfcporciuncula.flow.FlowSharedPreferences
import com.tfcporciuncula.flow.Preference import com.tfcporciuncula.flow.Preference
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.data.preference.PreferenceValues.ThemeMode.* import eu.kanade.tachiyomi.data.preference.PreferenceValues.ThemeMode.*
import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.data.track.anilist.Anilist import eu.kanade.tachiyomi.data.track.anilist.Anilist
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView
@ -184,7 +186,7 @@ class PreferencesHelper(val context: Context) {
fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0) fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0)
fun sourceDisplayMode() = flowPrefs.getEnum(Keys.sourceDisplayMode, DisplayMode.COMPACT_GRID) fun sourceDisplayMode() = flowPrefs.getEnum(Keys.sourceDisplayMode, DisplayModeSetting.COMPACT_GRID)
fun enabledLanguages() = flowPrefs.getStringSet(Keys.enabledLanguages, setOf("en", Locale.getDefault().language)) fun enabledLanguages() = flowPrefs.getStringSet(Keys.enabledLanguages, setOf("en", Locale.getDefault().language))
@ -235,7 +237,7 @@ class PreferencesHelper(val context: Context) {
fun libraryUpdatePrioritization() = flowPrefs.getInt(Keys.libraryUpdatePrioritization, 0) fun libraryUpdatePrioritization() = flowPrefs.getInt(Keys.libraryUpdatePrioritization, 0)
fun libraryDisplayMode() = flowPrefs.getEnum(Keys.libraryDisplayMode, DisplayMode.COMPACT_GRID) fun libraryDisplayMode() = flowPrefs.getEnum(Keys.libraryDisplayMode, DisplayModeSetting.COMPACT_GRID)
fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false) fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false)
@ -257,9 +259,8 @@ class PreferencesHelper(val context: Context) {
fun filterTracking(name: Int) = flowPrefs.getInt("${Keys.filterTracked}_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value) fun filterTracking(name: Int) = flowPrefs.getInt("${Keys.filterTracked}_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
fun librarySortingMode() = flowPrefs.getInt(Keys.librarySortingMode, 0) fun librarySortingMode() = flowPrefs.getEnum(Keys.librarySortingMode, SortModeSetting.ALPHABETICAL)
fun librarySortingAscending() = flowPrefs.getEnum(Keys.librarySortingDirection, SortDirectionSetting.ASCENDING)
fun librarySortingAscending() = flowPrefs.getBoolean("library_sorting_ascending", true)
fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true) fun automaticExtUpdates() = flowPrefs.getBoolean(Keys.automaticExtUpdates, true)

View File

@ -24,7 +24,6 @@ import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.databinding.SourceControllerBinding import eu.kanade.tachiyomi.databinding.SourceControllerBinding
@ -37,6 +36,7 @@ import eu.kanade.tachiyomi.ui.base.controller.SearchableNucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.more.MoreController import eu.kanade.tachiyomi.ui.more.MoreController
@ -205,7 +205,7 @@ open class BrowseSourceController(bundle: Bundle) :
binding.catalogueView.removeView(oldRecycler) binding.catalogueView.removeView(oldRecycler)
} }
val recycler = if (preferences.sourceDisplayMode().get() == DisplayMode.LIST) { val recycler = if (preferences.sourceDisplayMode().get() == DisplayModeSetting.LIST) {
RecyclerView(view.context).apply { RecyclerView(view.context).apply {
id = R.id.recycler id = R.id.recycler
layoutManager = LinearLayoutManager(context) layoutManager = LinearLayoutManager(context)
@ -273,9 +273,9 @@ open class BrowseSourceController(bundle: Bundle) :
) )
val displayItem = when (preferences.sourceDisplayMode().get()) { val displayItem = when (preferences.sourceDisplayMode().get()) {
DisplayMode.COMPACT_GRID -> R.id.action_compact_grid DisplayModeSetting.COMPACT_GRID -> R.id.action_compact_grid
DisplayMode.COMFORTABLE_GRID -> R.id.action_comfortable_grid DisplayModeSetting.COMFORTABLE_GRID -> R.id.action_comfortable_grid
DisplayMode.LIST -> R.id.action_list DisplayModeSetting.LIST -> R.id.action_list
} }
menu.findItem(displayItem).isChecked = true menu.findItem(displayItem).isChecked = true
} }
@ -297,9 +297,9 @@ open class BrowseSourceController(bundle: Bundle) :
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.action_search -> expandActionViewFromInteraction = true R.id.action_search -> expandActionViewFromInteraction = true
R.id.action_compact_grid -> setDisplayMode(DisplayMode.COMPACT_GRID) R.id.action_compact_grid -> setDisplayMode(DisplayModeSetting.COMPACT_GRID)
R.id.action_comfortable_grid -> setDisplayMode(DisplayMode.COMFORTABLE_GRID) R.id.action_comfortable_grid -> setDisplayMode(DisplayModeSetting.COMFORTABLE_GRID)
R.id.action_list -> setDisplayMode(DisplayMode.LIST) R.id.action_list -> setDisplayMode(DisplayModeSetting.LIST)
R.id.action_open_in_web_view -> openInWebView() R.id.action_open_in_web_view -> openInWebView()
R.id.action_local_source_help -> openLocalSourceHelpGuide() R.id.action_local_source_help -> openLocalSourceHelpGuide()
} }
@ -446,7 +446,7 @@ open class BrowseSourceController(bundle: Bundle) :
* *
* @param mode the mode to change to * @param mode the mode to change to
*/ */
private fun setDisplayMode(mode: DisplayMode) { private fun setDisplayMode(mode: DisplayModeSetting) {
val view = view ?: return val view = view ?: return
val adapter = adapter ?: return val adapter = adapter ?: return

View File

@ -12,19 +12,19 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.widget.AutofitRecyclerView import eu.kanade.tachiyomi.widget.AutofitRecyclerView
class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMode>) : class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayModeSetting>) :
AbstractFlexibleItem<SourceHolder<*>>() { AbstractFlexibleItem<SourceHolder<*>>() {
override fun getLayoutRes(): Int { override fun getLayoutRes(): Int {
return when (displayMode.get()) { return when (displayMode.get()) {
DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item DisplayModeSetting.COMPACT_GRID -> R.layout.source_compact_grid_item
DisplayMode.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
DisplayMode.LIST -> R.layout.source_list_item DisplayModeSetting.LIST -> R.layout.source_list_item
} }
} }
@ -33,7 +33,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>> adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
): SourceHolder<*> { ): SourceHolder<*> {
return when (displayMode.get()) { return when (displayMode.get()) {
DisplayMode.COMPACT_GRID -> { DisplayModeSetting.COMPACT_GRID -> {
val binding = SourceCompactGridItemBinding.bind(view) val binding = SourceCompactGridItemBinding.bind(view)
val parent = adapter.recyclerView as AutofitRecyclerView val parent = adapter.recyclerView as AutofitRecyclerView
val coverHeight = parent.itemWidth / 3 * 4 val coverHeight = parent.itemWidth / 3 * 4
@ -50,7 +50,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
} }
SourceGridHolder(view, adapter) SourceGridHolder(view, adapter)
} }
DisplayMode.COMFORTABLE_GRID -> { DisplayModeSetting.COMFORTABLE_GRID -> {
val binding = SourceComfortableGridItemBinding.bind(view) val binding = SourceComfortableGridItemBinding.bind(view)
val parent = adapter.recyclerView as AutofitRecyclerView val parent = adapter.recyclerView as AutofitRecyclerView
val coverHeight = parent.itemWidth / 3 * 4 val coverHeight = parent.itemWidth / 3 * 4
@ -62,7 +62,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
} }
SourceComfortableGridHolder(view, adapter) SourceComfortableGridHolder(view, adapter)
} }
DisplayMode.LIST -> { DisplayModeSetting.LIST -> {
SourceListHolder(view, adapter) SourceListHolder(view, adapter)
} }
} }

View File

@ -12,7 +12,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.LibraryCategoryBinding import eu.kanade.tachiyomi.databinding.LibraryCategoryBinding
import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.lang.plusAssign
@ -28,6 +27,7 @@ import reactivecircus.flowbinding.swiperefreshlayout.refreshes
import rx.subscriptions.CompositeSubscription import rx.subscriptions.CompositeSubscription
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.ArrayDeque import java.util.ArrayDeque
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting as DisplayMode
/** /**
* Fragment containing the library manga for a certain category. * Fragment containing the library manga for a certain category.
@ -125,7 +125,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
// If displayMode should be set from category adjust manga count per row // If displayMode should be set from category adjust manga count per row
if (preferences.categorisedDisplaySettings().get()) { if (preferences.categorisedDisplaySettings().get()) {
recycler.spanCount = if (category.displayMode == Category.LIST || (preferences.libraryDisplayMode().get() == DisplayMode.LIST && category.id == 0)) { recycler.spanCount = if (DisplayMode.fromFlag(category.displayMode) == DisplayMode.LIST || (preferences.libraryDisplayMode().get() == DisplayMode.LIST && category.id == 0)) {
1 1
} else { } else {
controller.mangaPerRow controller.mangaPerRow

View File

@ -295,6 +295,11 @@ class LibraryController(
.map { (it.id ?: -1) to (mangaMap[it.id]?.size ?: 0) } .map { (it.id ?: -1) to (mangaMap[it.id]?.size ?: 0) }
.toMap() .toMap()
if (preferences.categorisedDisplaySettings().get()) {
// Reattach adapter so it doesn't get de-synced
reattachAdapter()
}
// Restore active category. // Restore active category.
binding.libraryPager.setCurrentItem(activeCat, false) binding.libraryPager.setCurrentItem(activeCat, false)

View File

@ -13,10 +13,10 @@ import eu.davidea.flexibleadapter.items.IFilterable
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.LibraryManga import eu.kanade.tachiyomi.data.database.models.LibraryManga
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.widget.AutofitRecyclerView import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
@ -24,7 +24,7 @@ import uy.kohesive.injekt.api.get
class LibraryItem( class LibraryItem(
val manga: LibraryManga, val manga: LibraryManga,
private val shouldSetFromCategory: Preference<Boolean>, private val shouldSetFromCategory: Preference<Boolean>,
private val defaultLibraryDisplayMode: Preference<DisplayMode> private val defaultLibraryDisplayMode: Preference<DisplayModeSetting>
) : ) :
AbstractFlexibleItem<LibraryHolder<*>>(), IFilterable<String> { AbstractFlexibleItem<LibraryHolder<*>>(), IFilterable<String> {
@ -35,13 +35,9 @@ class LibraryItem(
var unreadCount = -1 var unreadCount = -1
var isLocal = false var isLocal = false
private fun getDisplayMode(): DisplayMode { private fun getDisplayMode(): DisplayModeSetting {
return if (shouldSetFromCategory.get() && manga.category != 0) { return if (shouldSetFromCategory.get() && manga.category != 0) {
if (displayMode != -1) { DisplayModeSetting.fromFlag(displayMode)
DisplayMode.values()[displayMode]
} else {
DisplayMode.COMPACT_GRID
}
} else { } else {
defaultLibraryDisplayMode.get() defaultLibraryDisplayMode.get()
} }
@ -49,15 +45,15 @@ class LibraryItem(
override fun getLayoutRes(): Int { override fun getLayoutRes(): Int {
return when (getDisplayMode()) { return when (getDisplayMode()) {
DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item DisplayModeSetting.COMPACT_GRID -> R.layout.source_compact_grid_item
DisplayMode.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item DisplayModeSetting.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
DisplayMode.LIST -> R.layout.source_list_item DisplayModeSetting.LIST -> R.layout.source_list_item
} }
} }
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder<*> { override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder<*> {
return when (getDisplayMode()) { return when (getDisplayMode()) {
DisplayMode.COMPACT_GRID -> { DisplayModeSetting.COMPACT_GRID -> {
val binding = SourceCompactGridItemBinding.bind(view) val binding = SourceCompactGridItemBinding.bind(view)
val parent = adapter.recyclerView as AutofitRecyclerView val parent = adapter.recyclerView as AutofitRecyclerView
val coverHeight = parent.itemWidth / 3 * 4 val coverHeight = parent.itemWidth / 3 * 4
@ -71,7 +67,7 @@ class LibraryItem(
} }
LibraryCompactGridHolder(view, adapter) LibraryCompactGridHolder(view, adapter)
} }
DisplayMode.COMFORTABLE_GRID -> { DisplayModeSetting.COMFORTABLE_GRID -> {
val binding = SourceComfortableGridItemBinding.bind(view) val binding = SourceComfortableGridItemBinding.bind(view)
val parent = adapter.recyclerView as AutofitRecyclerView val parent = adapter.recyclerView as AutofitRecyclerView
val coverHeight = parent.itemWidth / 3 * 4 val coverHeight = parent.itemWidth / 3 * 4
@ -83,7 +79,7 @@ class LibraryItem(
} }
LibraryComfortableGridHolder(view, adapter) LibraryComfortableGridHolder(view, adapter)
} }
DisplayMode.LIST -> { DisplayModeSetting.LIST -> {
LibraryListHolder(view, adapter) LibraryListHolder(view, adapter)
} }
} }

View File

@ -15,6 +15,8 @@ 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.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.combineLatest
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
@ -98,7 +100,7 @@ class LibraryPresenter(
lib.copy(mangaMap = applyFilters(lib.mangaMap, tracks)) lib.copy(mangaMap = applyFilters(lib.mangaMap, tracks))
} }
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) { lib, _ -> .combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) { lib, _ ->
lib.copy(mangaMap = applySort(lib.mangaMap)) lib.copy(mangaMap = applySort(lib.categories, lib.mangaMap))
} }
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeLatestCache({ view, (categories, mangaMap) -> .subscribeLatestCache({ view, (categories, mangaMap) ->
@ -228,9 +230,7 @@ class LibraryPresenter(
* *
* @param map the map to sort. * @param map the map to sort.
*/ */
private fun applySort(map: LibraryMap): LibraryMap { private fun applySort(categories: List<Category>, map: LibraryMap): LibraryMap {
val sortingMode = preferences.librarySortingMode().get()
val lastReadManga by lazy { val lastReadManga by lazy {
var counter = 0 var counter = 0
db.getLastReadManga().executeAsBlocking().associate { it.id!! to counter++ } db.getLastReadManga().executeAsBlocking().associate { it.id!! to counter++ }
@ -248,55 +248,67 @@ class LibraryPresenter(
db.getChapterFetchDateManga().executeAsBlocking().associate { it.id!! to counter++ } db.getChapterFetchDateManga().executeAsBlocking().associate { it.id!! to counter++ }
} }
val sortAscending = preferences.librarySortingAscending().get() val sortingModes = categories.associate { category ->
(category.id ?: 0) to SortModeSetting.get(preferences, category)
}
val sortAscending = categories.associate { category ->
(category.id ?: 0) to SortDirectionSetting.get(preferences, category)
}
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 -> val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
val sortingMode = sortingModes[i1.manga.category]!!
val sortAscending = sortAscending[i1.manga.category]!! == SortDirectionSetting.ASCENDING
when (sortingMode) { when (sortingMode) {
LibrarySort.ALPHA -> i1.manga.title.compareTo(i2.manga.title, true) SortModeSetting.ALPHABETICAL -> i1.manga.title.compareTo(i2.manga.title, true)
LibrarySort.LAST_READ -> { SortModeSetting.LAST_READ -> {
// Get index of manga, set equal to list if size unknown. // Get index of manga, set equal to list if size unknown.
val manga1LastRead = lastReadManga[i1.manga.id!!] ?: lastReadManga.size val manga1LastRead = lastReadManga[i1.manga.id!!] ?: lastReadManga.size
val manga2LastRead = lastReadManga[i2.manga.id!!] ?: lastReadManga.size val manga2LastRead = lastReadManga[i2.manga.id!!] ?: lastReadManga.size
manga1LastRead.compareTo(manga2LastRead) manga1LastRead.compareTo(manga2LastRead)
} }
LibrarySort.LAST_CHECKED -> i2.manga.last_update.compareTo(i1.manga.last_update) SortModeSetting.LAST_CHECKED -> i2.manga.last_update.compareTo(i1.manga.last_update)
LibrarySort.UNREAD -> when { SortModeSetting.UNREAD -> when {
// Ensure unread content comes first // Ensure unread content comes first
i1.manga.unread == i2.manga.unread -> 0 i1.manga.unread == i2.manga.unread -> 0
i1.manga.unread == 0 -> if (sortAscending) 1 else -1 i1.manga.unread == 0 -> if (sortAscending) 1 else -1
i2.manga.unread == 0 -> if (sortAscending) -1 else 1 i2.manga.unread == 0 -> if (sortAscending) -1 else 1
else -> i1.manga.unread.compareTo(i2.manga.unread) else -> i1.manga.unread.compareTo(i2.manga.unread)
} }
LibrarySort.TOTAL -> { SortModeSetting.TOTAL_CHAPTERS -> {
val manga1TotalChapter = totalChapterManga[i1.manga.id!!] ?: 0 val manga1TotalChapter = totalChapterManga[i1.manga.id!!] ?: 0
val mange2TotalChapter = totalChapterManga[i2.manga.id!!] ?: 0 val mange2TotalChapter = totalChapterManga[i2.manga.id!!] ?: 0
manga1TotalChapter.compareTo(mange2TotalChapter) manga1TotalChapter.compareTo(mange2TotalChapter)
} }
LibrarySort.LATEST_CHAPTER -> { SortModeSetting.LATEST_CHAPTER -> {
val manga1latestChapter = latestChapterManga[i1.manga.id!!] val manga1latestChapter = latestChapterManga[i1.manga.id!!]
?: latestChapterManga.size ?: latestChapterManga.size
val manga2latestChapter = latestChapterManga[i2.manga.id!!] val manga2latestChapter = latestChapterManga[i2.manga.id!!]
?: latestChapterManga.size ?: latestChapterManga.size
manga1latestChapter.compareTo(manga2latestChapter) manga1latestChapter.compareTo(manga2latestChapter)
} }
LibrarySort.CHAPTER_FETCH_DATE -> { SortModeSetting.DATE_FETCHED -> {
val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!]
?: chapterFetchDateManga.size ?: chapterFetchDateManga.size
val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!]
?: chapterFetchDateManga.size ?: chapterFetchDateManga.size
manga1chapterFetchDate.compareTo(manga2chapterFetchDate) manga1chapterFetchDate.compareTo(manga2chapterFetchDate)
} }
LibrarySort.DATE_ADDED -> i2.manga.date_added.compareTo(i1.manga.date_added) SortModeSetting.DATE_ADDED -> i2.manga.date_added.compareTo(i1.manga.date_added)
else -> throw Exception("Unknown sorting mode")
} }
} }
val comparator = if (sortAscending) { return map.mapValues { entry ->
Comparator(sortFn) val sortAscending = sortAscending[entry.key]!! == SortDirectionSetting.ASCENDING
} else {
Collections.reverseOrder(sortFn)
}
return map.mapValues { entry -> entry.value.sortedWith(comparator) } val comparator = if (sortAscending) {
Comparator(sortFn)
} else {
Collections.reverseOrder(sortFn)
}
entry.value.sortedWith(comparator)
}
} }
/** /**

View File

@ -7,10 +7,12 @@ import com.bluelinelabs.conductor.Router
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
import eu.kanade.tachiyomi.widget.ExtendedNavigationView import eu.kanade.tachiyomi.widget.ExtendedNavigationView
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
import eu.kanade.tachiyomi.widget.sheet.TabbedBottomSheetDialog import eu.kanade.tachiyomi.widget.sheet.TabbedBottomSheetDialog
@ -45,6 +47,8 @@ class LibrarySettingsSheet(
* @param currentCategory ID of currently shown category * @param currentCategory ID of currently shown category
*/ */
fun show(currentCategory: Category) { fun show(currentCategory: Category) {
sort.currentCategory = currentCategory
sort.adjustDisplaySelection()
display.currentCategory = currentCategory display.currentCategory = currentCategory
display.adjustDisplaySelection() display.adjustDisplaySelection()
super.show() super.show()
@ -158,8 +162,16 @@ class LibrarySettingsSheet(
inner class Sort @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : inner class Sort @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Settings(context, attrs) { Settings(context, attrs) {
private val sort = SortGroup()
init { init {
setGroups(listOf(SortGroup())) setGroups(listOf(sort))
}
// Refreshes Display Setting selections
fun adjustDisplaySelection() {
sort.initModels()
sort.items.forEach { adapter.notifyItemChanged(it) }
} }
inner class SortGroup : Group { inner class SortGroup : Group {
@ -179,29 +191,29 @@ class LibrarySettingsSheet(
override val footer = null override val footer = null
override fun initModels() { override fun initModels() {
val sorting = preferences.librarySortingMode().get() val sorting = SortModeSetting.get(preferences, currentCategory)
val order = if (preferences.librarySortingAscending().get()) { val order = if (SortDirectionSetting.get(preferences, currentCategory) == SortDirectionSetting.ASCENDING) {
Item.MultiSort.SORT_ASC Item.MultiSort.SORT_ASC
} else { } else {
Item.MultiSort.SORT_DESC Item.MultiSort.SORT_DESC
} }
alphabetically.state = alphabetically.state =
if (sorting == LibrarySort.ALPHA) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.ALPHABETICAL) order else Item.MultiSort.SORT_NONE
lastRead.state = lastRead.state =
if (sorting == LibrarySort.LAST_READ) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.LAST_READ) order else Item.MultiSort.SORT_NONE
lastChecked.state = lastChecked.state =
if (sorting == LibrarySort.LAST_CHECKED) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.LAST_CHECKED) order else Item.MultiSort.SORT_NONE
unread.state = unread.state =
if (sorting == LibrarySort.UNREAD) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.UNREAD) order else Item.MultiSort.SORT_NONE
total.state = total.state =
if (sorting == LibrarySort.TOTAL) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.TOTAL_CHAPTERS) order else Item.MultiSort.SORT_NONE
latestChapter.state = latestChapter.state =
if (sorting == LibrarySort.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE
chapterFetchDate.state = chapterFetchDate.state =
if (sorting == LibrarySort.CHAPTER_FETCH_DATE) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.DATE_FETCHED) order else Item.MultiSort.SORT_NONE
dateAdded.state = dateAdded.state =
if (sorting == LibrarySort.DATE_ADDED) order else Item.MultiSort.SORT_NONE if (sorting == SortModeSetting.DATE_ADDED) order else Item.MultiSort.SORT_NONE
} }
override fun onItemClicked(item: Item) { override fun onItemClicked(item: Item) {
@ -219,23 +231,50 @@ class LibrarySettingsSheet(
else -> throw Exception("Unknown state") else -> throw Exception("Unknown state")
} }
preferences.librarySortingMode().set( setSortModePreference(item)
when (item) {
alphabetically -> LibrarySort.ALPHA setSortDirectionPrefernece(item)
lastRead -> LibrarySort.LAST_READ
lastChecked -> LibrarySort.LAST_CHECKED
unread -> LibrarySort.UNREAD
total -> LibrarySort.TOTAL
latestChapter -> LibrarySort.LATEST_CHAPTER
chapterFetchDate -> LibrarySort.CHAPTER_FETCH_DATE
dateAdded -> LibrarySort.DATE_ADDED
else -> throw Exception("Unknown sorting")
}
)
preferences.librarySortingAscending().set(item.state == Item.MultiSort.SORT_ASC)
item.group.items.forEach { adapter.notifyItemChanged(it) } item.group.items.forEach { adapter.notifyItemChanged(it) }
} }
private fun setSortDirectionPrefernece(item: Item.MultiStateGroup) {
val flag = if (item.state == Item.MultiSort.SORT_ASC) {
SortDirectionSetting.ASCENDING
} else {
SortDirectionSetting.DESCENDING
}
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
currentCategory?.sortDirection = flag.flag
db.insertCategory(currentCategory!!).executeAsBlocking()
} else {
preferences.librarySortingAscending().set(flag)
}
}
private fun setSortModePreference(item: Item) {
val flag = when (item) {
alphabetically -> SortModeSetting.ALPHABETICAL
lastRead -> SortModeSetting.LAST_READ
lastChecked -> SortModeSetting.LAST_CHECKED
unread -> SortModeSetting.UNREAD
total -> SortModeSetting.TOTAL_CHAPTERS
latestChapter -> SortModeSetting.LATEST_CHAPTER
chapterFetchDate -> SortModeSetting.DATE_FETCHED
dateAdded -> SortModeSetting.DATE_ADDED
else -> throw NotImplementedError("Unknown display mode")
}
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
currentCategory?.sortMode = flag.flag
db.insertCategory(currentCategory!!).executeAsBlocking()
} else {
preferences.librarySortingMode().set(flag)
}
}
} }
} }
@ -264,9 +303,9 @@ class LibrarySettingsSheet(
} }
// Gets user preference of currently selected display mode at current category // Gets user preference of currently selected display mode at current category
private fun getDisplayModePreference(): DisplayMode { private fun getDisplayModePreference(): DisplayModeSetting {
return if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) { return if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
DisplayMode.values()[currentCategory?.displayMode ?: 0] DisplayModeSetting.fromFlag(currentCategory?.displayMode)
} else { } else {
preferences.libraryDisplayMode().get() preferences.libraryDisplayMode().get()
} }
@ -300,33 +339,26 @@ class LibrarySettingsSheet(
} }
// Sets display group selections based on given mode // Sets display group selections based on given mode
fun setGroupSelections(mode: DisplayMode) { fun setGroupSelections(mode: DisplayModeSetting) {
compactGrid.checked = mode == DisplayMode.COMPACT_GRID compactGrid.checked = mode == DisplayModeSetting.COMPACT_GRID
comfortableGrid.checked = mode == DisplayMode.COMFORTABLE_GRID comfortableGrid.checked = mode == DisplayModeSetting.COMFORTABLE_GRID
list.checked = mode == DisplayMode.LIST list.checked = mode == DisplayModeSetting.LIST
} }
private fun setDisplayModePreference(item: Item) { private fun setDisplayModePreference(item: Item) {
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) { val flag = when (item) {
val flag = when (item) { compactGrid -> DisplayModeSetting.COMPACT_GRID
compactGrid -> Category.COMPACT_GRID comfortableGrid -> DisplayModeSetting.COMFORTABLE_GRID
comfortableGrid -> Category.COMFORTABLE_GRID list -> DisplayModeSetting.LIST
list -> Category.LIST else -> throw NotImplementedError("Unknown display mode")
else -> throw NotImplementedError("Unknown display mode") }
}
currentCategory?.displayMode = flag if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
currentCategory?.displayMode = flag.flag
db.insertCategory(currentCategory!!).executeAsBlocking() db.insertCategory(currentCategory!!).executeAsBlocking()
} else { } else {
preferences.libraryDisplayMode().set( preferences.libraryDisplayMode().set(flag)
when (item) {
compactGrid -> DisplayMode.COMPACT_GRID
comfortableGrid -> DisplayMode.COMFORTABLE_GRID
list -> DisplayMode.LIST
else -> throw NotImplementedError("Unknown display mode")
}
)
} }
} }
} }

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
@Deprecated("Deprecated in favor for SortModeSetting")
object LibrarySort { object LibrarySort {
const val ALPHA = 0 const val ALPHA = 0

View File

@ -0,0 +1,16 @@
package eu.kanade.tachiyomi.ui.library.setting
enum class DisplayModeSetting(val flag: Int) {
COMPACT_GRID(0b00000000),
COMFORTABLE_GRID(0b00000001),
LIST(0b00000010);
companion object {
const val MASK = 0b00000011
fun fromFlag(flag: Int?): DisplayModeSetting {
return values()
.find { mode -> mode.flag == flag } ?: COMPACT_GRID
}
}
}

View File

@ -0,0 +1,25 @@
package eu.kanade.tachiyomi.ui.library.setting
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
enum class SortDirectionSetting(val flag: Int) {
ASCENDING(0b01000000),
DESCENDING(0b00000000);
companion object {
const val MASK = 0b01000000
fun fromFlag(flag: Int?): SortDirectionSetting {
return values().find { mode -> mode.flag == flag } ?: ASCENDING
}
fun get(preferences: PreferencesHelper, category: Category?): SortDirectionSetting {
return if (preferences.categorisedDisplaySettings().get() && category != null && category.id != 0) {
fromFlag(category.sortDirection)
} else {
preferences.librarySortingAscending().get()
}
}
}
}

View File

@ -0,0 +1,32 @@
package eu.kanade.tachiyomi.ui.library.setting
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
enum class SortModeSetting(val flag: Int) {
ALPHABETICAL(0b00000000),
LAST_READ(0b00000100),
LAST_CHECKED(0b00001000),
UNREAD(0b00001100),
TOTAL_CHAPTERS(0b00010000),
LATEST_CHAPTER(0b00010100),
DATE_FETCHED(0b00011000),
DATE_ADDED(0b00011100);
companion object {
// Mask supports for more sorting flags if necessary
const val MASK = 0b00111100
fun fromFlag(flag: Int?): SortModeSetting {
return values().find { mode -> mode.flag == flag } ?: ALPHABETICAL
}
fun get(preferences: PreferencesHelper, category: Category?): SortModeSetting {
return if (preferences.categorisedDisplaySettings().get() && category != null && category.id != 0) {
fromFlag(category.sortMode)
} else {
preferences.librarySortingMode().get()
}
}
}
}

View File

@ -84,6 +84,8 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val didMigration = if (savedInstanceState == null) Migrations.upgrade(preferences) else false
binding = MainActivityBinding.inflate(layoutInflater) binding = MainActivityBinding.inflate(layoutInflater)
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079 // Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
@ -224,7 +226,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
preferences.incognitoMode().set(false) preferences.incognitoMode().set(false)
// Show changelog prompt on update // Show changelog prompt on update
if (Migrations.upgrade(preferences) && !BuildConfig.DEBUG) { if (didMigration && !BuildConfig.DEBUG) {
WhatsNewDialogController().showDialog(router) WhatsNewDialogController().showDialog(router)
} }
} }