From 4fdb4f14a84d6852742c7d670023e671a46606e5 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 May 2020 10:33:49 -0400 Subject: [PATCH] Move categories up in library settings --- .../ui/setting/SettingsLibraryController.kt | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 3044355e9..ef306ec96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -44,6 +44,9 @@ class SettingsLibraryController : SettingsController() { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { titleRes = R.string.pref_category_library + val dbCategories = db.getCategories().executeAsBlocking() + val categories = listOf(Category.createDefault()) + dbCategories + preferenceCategory { titleRes = R.string.pref_category_display @@ -74,8 +77,40 @@ class SettingsLibraryController : SettingsController() { } } - val dbCategories = db.getCategories().executeAsBlocking() - val categories = listOf(Category.createDefault()) + dbCategories + preferenceCategory { + titleRes = R.string.pref_category_library_categories + + preference { + titleRes = R.string.action_edit_categories + + val catCount = dbCategories.size + summary = context.resources.getQuantityString(R.plurals.num_categories, catCount, catCount) + + onClick { + router.pushController(CategoryController().withFadeTransaction()) + } + } + + intListPreference { + key = Keys.defaultCategory + titleRes = R.string.default_category + + entries = arrayOf(context.getString(R.string.default_category_summary)) + + categories.map { it.name }.toTypedArray() + entryValues = arrayOf("-1") + categories.map { it.id.toString() }.toTypedArray() + defaultValue = "-1" + + val selectedCategory = categories.find { it.id == preferences.defaultCategory() } + summary = selectedCategory?.name + ?: context.getString(R.string.default_category_summary) + onChange { newValue -> + summary = categories.find { + it.id == (newValue as String).toInt() + }?.name ?: context.getString(R.string.default_category_summary) + true + } + } + } preferenceCategory { titleRes = R.string.pref_category_library_update @@ -170,41 +205,6 @@ class SettingsLibraryController : SettingsController() { defaultValue = false } } - - preferenceCategory { - titleRes = R.string.pref_category_library_categories - - preference { - titleRes = R.string.action_edit_categories - - val catCount = dbCategories.size - summary = context.resources.getQuantityString(R.plurals.num_categories, catCount, catCount) - - onClick { - router.pushController(CategoryController().withFadeTransaction()) - } - } - - intListPreference { - key = Keys.defaultCategory - titleRes = R.string.default_category - - entries = arrayOf(context.getString(R.string.default_category_summary)) + - categories.map { it.name }.toTypedArray() - entryValues = arrayOf("-1") + categories.map { it.id.toString() }.toTypedArray() - defaultValue = "-1" - - val selectedCategory = categories.find { it.id == preferences.defaultCategory() } - summary = selectedCategory?.name - ?: context.getString(R.string.default_category_summary) - onChange { newValue -> - summary = categories.find { - it.id == (newValue as String).toInt() - }?.name ?: context.getString(R.string.default_category_summary) - true - } - } - } } class LibraryColumnsDialog : DialogController() {