mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 07:15:10 +01:00
parent
0755d2a169
commit
1eeacafd7b
@ -271,6 +271,8 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun filterOrder() = flowPrefs.getString("filter_order", "rudcmt")
|
fun filterOrder() = flowPrefs.getString("filter_order", "rudcmt")
|
||||||
|
|
||||||
|
fun hideHopper() = flowPrefs.getBoolean("hide_hopper", false)
|
||||||
|
|
||||||
// Tutorial preferences
|
// Tutorial preferences
|
||||||
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
||||||
|
|
||||||
|
@ -86,6 +86,9 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
|||||||
show_all.bindToPreference(preferences.showAllCategories()) {
|
show_all.bindToPreference(preferences.showAllCategories()) {
|
||||||
controller.presenter.getLibrary()
|
controller.presenter.getLibrary()
|
||||||
}
|
}
|
||||||
|
hide_hopper.bindToPreference(preferences.hideHopper()) {
|
||||||
|
controller.hideHopper(it)
|
||||||
|
}
|
||||||
uniform_grid.bindToPreference(preferences.uniformGrid()) {
|
uniform_grid.bindToPreference(preferences.uniformGrid()) {
|
||||||
controller.reattachAdapter()
|
controller.reattachAdapter()
|
||||||
}
|
}
|
||||||
@ -122,11 +125,15 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
|||||||
/**
|
/**
|
||||||
* Binds a checkbox or switch view with a boolean preference.
|
* Binds a checkbox or switch view with a boolean preference.
|
||||||
*/
|
*/
|
||||||
private fun CompoundButton.bindToPreference(pref: com.tfcporciuncula.flow.Preference<Boolean>, block: (() -> Unit)? = null) {
|
private fun CompoundButton.bindToPreference(
|
||||||
|
pref: com.tfcporciuncula.flow
|
||||||
|
.Preference<Boolean>,
|
||||||
|
block: ((Boolean) -> Unit)? = null
|
||||||
|
) {
|
||||||
isChecked = pref.get()
|
isChecked = pref.get()
|
||||||
setOnCheckedChangeListener { _, isChecked ->
|
setOnCheckedChangeListener { _, isChecked ->
|
||||||
pref.set(isChecked)
|
pref.set(isChecked)
|
||||||
block?.invoke()
|
block?.invoke(isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ import eu.kanade.tachiyomi.util.view.gone
|
|||||||
import eu.kanade.tachiyomi.util.view.hide
|
import eu.kanade.tachiyomi.util.view.hide
|
||||||
import eu.kanade.tachiyomi.util.view.isExpanded
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.isHidden
|
import eu.kanade.tachiyomi.util.view.isHidden
|
||||||
|
import eu.kanade.tachiyomi.util.view.isVisible
|
||||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
import eu.kanade.tachiyomi.util.view.setStyle
|
import eu.kanade.tachiyomi.util.view.setStyle
|
||||||
@ -347,6 +348,7 @@ class LibraryController(
|
|||||||
} else {
|
} else {
|
||||||
preferences.hopperGravity().get()
|
preferences.hopperGravity().get()
|
||||||
}
|
}
|
||||||
|
hideHopper(preferences.hideHopper().get())
|
||||||
category_hopper_frame.updateLayoutParams<CoordinatorLayout.LayoutParams> {
|
category_hopper_frame.updateLayoutParams<CoordinatorLayout.LayoutParams> {
|
||||||
anchorGravity = Gravity.TOP or when (gravityPref) {
|
anchorGravity = Gravity.TOP or when (gravityPref) {
|
||||||
0 -> Gravity.LEFT
|
0 -> Gravity.LEFT
|
||||||
@ -434,6 +436,11 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hideHopper(hide: Boolean) {
|
||||||
|
category_hopper_frame.visibleIf(!hide)
|
||||||
|
jumper_category_text.visibleIf(!hide)
|
||||||
|
}
|
||||||
|
|
||||||
private fun jumpToNextCategory(next: Boolean) {
|
private fun jumpToNextCategory(next: Boolean) {
|
||||||
val category = getVisibleHeader() ?: return
|
val category = getVisibleHeader() ?: return
|
||||||
if (presenter.showAllCategories) {
|
if (presenter.showAllCategories) {
|
||||||
@ -527,11 +534,19 @@ class LibraryController(
|
|||||||
return inflater.inflate(R.layout.library_list_controller, container, false)
|
return inflater.inflate(R.layout.library_list_controller, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun anchorView(): View? {
|
||||||
|
return if (category_hopper_frame.isVisible()) {
|
||||||
|
category_hopper_frame
|
||||||
|
} else {
|
||||||
|
filter_bottom_sheet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateLibrary(category: Category? = null) {
|
private fun updateLibrary(category: Category? = null) {
|
||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
LibraryUpdateService.start(view.context, category)
|
LibraryUpdateService.start(view.context, category)
|
||||||
snack = view.snack(R.string.updating_library) {
|
snack = view.snack(R.string.updating_library) {
|
||||||
anchorView = category_hopper_frame
|
anchorView = anchorView()
|
||||||
view.elevation = 15f.dpToPx
|
view.elevation = 15f.dpToPx
|
||||||
setAction(R.string.cancel) {
|
setAction(R.string.cancel) {
|
||||||
LibraryUpdateService.stop(context)
|
LibraryUpdateService.stop(context)
|
||||||
@ -642,7 +657,7 @@ class LibraryController(
|
|||||||
if (justStarted && freshStart) {
|
if (justStarted && freshStart) {
|
||||||
scrollToHeader(activeCategory)
|
scrollToHeader(activeCategory)
|
||||||
}
|
}
|
||||||
category_hopper_frame.visibleIf(!singleCategory)
|
category_hopper_frame.visibleIf(!singleCategory && !preferences.hideHopper().get())
|
||||||
filter_bottom_sheet.updateButtons(
|
filter_bottom_sheet.updateButtons(
|
||||||
showHideCategories = presenter.allCategories.size > 1,
|
showHideCategories = presenter.allCategories.size > 1,
|
||||||
showExpand = !singleCategory && presenter.showAllCategories
|
showExpand = !singleCategory && presenter.showAllCategories
|
||||||
@ -1024,7 +1039,7 @@ class LibraryController(
|
|||||||
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
||||||
adapter.moveItem(position, lastItemPosition!!)
|
adapter.moveItem(position, lastItemPosition!!)
|
||||||
snack = view?.snack(R.string.already_in_category) {
|
snack = view?.snack(R.string.already_in_category) {
|
||||||
anchorView = category_hopper_frame
|
anchorView = anchorView()
|
||||||
view.elevation = 15f.dpToPx
|
view.elevation = 15f.dpToPx
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -1048,7 +1063,7 @@ class LibraryController(
|
|||||||
snack = view?.snack(
|
snack = view?.snack(
|
||||||
resources!!.getString(R.string.moved_to_, category.name)
|
resources!!.getString(R.string.moved_to_, category.name)
|
||||||
) {
|
) {
|
||||||
anchorView = category_hopper_frame
|
anchorView = anchorView()
|
||||||
view.elevation = 15f.dpToPx
|
view.elevation = 15f.dpToPx
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
manga.category = category.id!!
|
manga.category = category.id!!
|
||||||
@ -1070,7 +1085,7 @@ class LibraryController(
|
|||||||
}, category.name
|
}, category.name
|
||||||
), Snackbar.LENGTH_LONG
|
), Snackbar.LENGTH_LONG
|
||||||
) {
|
) {
|
||||||
anchorView = category_hopper_frame
|
anchorView = anchorView()
|
||||||
view.elevation = 15f.dpToPx
|
view.elevation = 15f.dpToPx
|
||||||
setAction(R.string.cancel) {
|
setAction(R.string.cancel) {
|
||||||
LibraryUpdateService.stop(context)
|
LibraryUpdateService.stop(context)
|
||||||
@ -1246,7 +1261,7 @@ class LibraryController(
|
|||||||
snack = view?.snack(
|
snack = view?.snack(
|
||||||
activity?.getString(R.string.removed_from_library) ?: "", Snackbar.LENGTH_INDEFINITE
|
activity?.getString(R.string.removed_from_library) ?: "", Snackbar.LENGTH_INDEFINITE
|
||||||
) {
|
) {
|
||||||
anchorView = category_hopper_frame
|
anchorView = anchorView()
|
||||||
view.elevation = 15f.dpToPx
|
view.elevation = 15f.dpToPx
|
||||||
var undoing = false
|
var undoing = false
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
|
@ -189,6 +189,14 @@
|
|||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:text="@string/download_badge" />
|
android:text="@string/download_badge" />
|
||||||
|
|
||||||
|
<com.google.android.material.checkbox.MaterialCheckBox
|
||||||
|
android:id="@+id/hide_hopper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:text="@string/hide_category_hopper" />
|
||||||
|
|
||||||
<com.google.android.material.checkbox.MaterialCheckBox
|
<com.google.android.material.checkbox.MaterialCheckBox
|
||||||
android:id="@+id/hide_filters"
|
android:id="@+id/hide_filters"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -154,6 +154,7 @@
|
|||||||
<string name="show_count">Show count</string>
|
<string name="show_count">Show count</string>
|
||||||
<string name="tap_library_to_show_filters">Tap the Library icon to show filters</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="display_as">Display as</string>
|
||||||
|
<string name="hide_category_hopper">Hide category hopper</string>
|
||||||
<string name="more_library_settings">More library settings</string>
|
<string name="more_library_settings">More library settings</string>
|
||||||
|
|
||||||
<!-- Library update service notifications -->
|
<!-- Library update service notifications -->
|
||||||
|
Loading…
Reference in New Issue
Block a user