From 41d1aaa02c7356d9e2b9f5362854dedd91dfc878 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 7 May 2020 15:29:04 -0400 Subject: [PATCH] Added "more library settings" button to library display sheet Categories setting item now says "add categories" if none are made --- .../kanade/tachiyomi/ui/library/DisplayBottomSheet.kt | 11 ++++++++--- .../tachiyomi/ui/setting/SettingsLibraryController.kt | 4 ++-- app/src/main/res/layout/display_bottom_sheet.xml | 7 +++++++ app/src/main/res/values/strings.xml | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt index 0bb3e8f0ba..84eaa82cf7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt @@ -12,12 +12,14 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault +import eu.kanade.tachiyomi.ui.setting.SettingsLibraryController import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.expand import eu.kanade.tachiyomi.util.view.isCollapsed import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.visibleIf +import eu.kanade.tachiyomi.util.view.withFadeTransaction import kotlinx.android.synthetic.main.display_bottom_sheet.* import uy.kohesive.injekt.injectLazy @@ -66,7 +68,7 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) initGeneralPreferences() - setBottomEdge(hide_filters, activity) + setBottomEdge(display_layout, activity) close_button.setOnClickListener { dismiss() } settings_scroll_view.viewTreeObserver.addOnGlobalLayoutListener { val isScrollable = @@ -79,8 +81,7 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee private fun initGeneralPreferences() { display_group.bindToPreference(preferences.libraryLayout()) { controller.reattachAdapter() - if (sheetBehavior.isCollapsed()) - dismiss() + if (sheetBehavior.isCollapsed()) dismiss() } uniform_grid.bindToPreference(preferences.uniformGrid()) { controller.reattachAdapter() @@ -98,6 +99,10 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee controller.reattachAdapter() } hide_filters.bindToPreference(preferences.hideFiltersAtStart()) + more_settings.setOnClickListener { + controller.router.pushController(SettingsLibraryController().withFadeTransaction()) + dismiss() + } } /** 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 576a19e8e6..1c62574bf1 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 @@ -34,9 +34,9 @@ class SettingsLibraryController : SettingsController() { preferenceCategory { titleRes = R.string.categories preference { - titleRes = R.string.edit_categories val catCount = db.getCategories().executeAsBlocking().size - summary = context.resources.getQuantityString(R.plurals.category, catCount, catCount) + titleRes = if (catCount > 0) R.string.edit_categories else R.string.add_categories + if (catCount > 0) summary = context.resources.getQuantityString(R.plurals.category, catCount, catCount) onClick { router.pushController(CategoryController().withFadeTransaction()) } } intListPreference(activity) { diff --git a/app/src/main/res/layout/display_bottom_sheet.xml b/app/src/main/res/layout/display_bottom_sheet.xml index bb518eb1b0..353207fc37 100644 --- a/app/src/main/res/layout/display_bottom_sheet.xml +++ b/app/src/main/res/layout/display_bottom_sheet.xml @@ -180,6 +180,13 @@ android:layout_marginStart="12dp" android:layout_marginEnd="12dp" android:text="@string/start_with_filters_hidden" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01a62e8e5d..7557e4e7cd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -78,7 +78,7 @@ Manga in this category will moved into the default category. Manga already in category - Add category + Add categories Edit categories Manage category Rename category @@ -152,6 +152,7 @@ Show count Tap the Library icon to show filters Display as + More library settings New chapters found