Added "more library settings" button to library display sheet

Categories setting item now says "add categories" if none are made
This commit is contained in:
Jay 2020-05-07 15:29:04 -04:00
parent aa8195c48f
commit 41d1aaa02c
4 changed files with 19 additions and 6 deletions

View File

@ -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()
}
}
/**

View File

@ -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) {

View File

@ -180,6 +180,13 @@
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:text="@string/start_with_filters_hidden" />
<com.google.android.material.button.MaterialButton
android:id="@+id/more_settings"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/more_library_settings"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -78,7 +78,7 @@
<string name="confirm_category_deletion_message">Manga in this category will moved into the
default category.</string>
<string name="already_in_category">Manga already in category</string>
<string name="add_category">Add category</string>
<string name="add_categories">Add categories</string>
<string name="edit_categories">Edit categories</string>
<string name="manage_category">Manage category</string>
<string name="rename_category">Rename category</string>
@ -152,6 +152,7 @@
<string name="show_count">Show count</string>
<string name="tap_library_to_show_filters">Tap the Library icon to show filters</string>
<string name="display_as">Display as</string>
<string name="more_library_settings">More library settings</string>
<!-- Library update service notifications -->
<string name="new_chapters_found">New chapters found</string>