From 6cccdf44596dabb63ed4bc5378d0c81d52eff180 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 23 Feb 2020 21:32:56 -0800 Subject: [PATCH] New categories now default to title sorting in D&D/single list mode --- .../data/database/mappers/CategoryTypeMapping.kt | 15 ++++++++++----- .../tachiyomi/ui/category/CategoryPresenter.kt | 1 + .../ui/setting/SettingsGeneralController.kt | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt index 718a42f4b0..d70d659877 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt @@ -60,12 +60,17 @@ class CategoryGetResolver : DefaultGetResolver() { flags = cursor.getInt(cursor.getColumnIndex(COL_FLAGS)) val orderString = cursor.getString(cursor.getColumnIndex(COL_MANGA_ORDER)) - if (orderString?.firstOrNull()?.isLetter() == true) { - mangaSort = orderString.first() - mangaOrder = emptyList() + when { + orderString.isNullOrBlank() -> { + mangaSort = 'a' + mangaOrder = emptyList() + } + orderString.firstOrNull()?.isLetter() == true -> { + mangaSort = orderString.first() + mangaOrder = emptyList() + } + else -> mangaOrder = orderString.split("/")?.mapNotNull { it.toLongOrNull() } } - else - mangaOrder = orderString?.split("/")?.mapNotNull { it.toLongOrNull() } ?: emptyList() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt index ea01818513..d21ff188dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryPresenter.kt @@ -72,6 +72,7 @@ class CategoryPresenter( // Insert into database. + cat.mangaSort = 'a' db.insertCategory(cat).executeAsBlocking() val cats = db.getCategories().executeAsBlocking() val newCat = cats.find { it.name == name } ?: return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 97b3eef4a5..e0a2903546 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -50,7 +50,7 @@ class SettingsGeneralController : SettingsController() { R.string.system_theme, R.string.sysyem_white_theme, R.string.system_amoled_theme, R.string .system_darkblue_theme) entryValues = listOf(1, 8, 2, 3, 4, 5, 9, 6, 7) - defaultValue = 8 + defaultValue = 9 onChange { activity?.recreate()