mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 20:19:05 +01:00
[feature] add ability to set global filter/sort/display for Manga chapters (#3622)
* - [feature] add ability to set global filter/sort/display for Manga chapters * - move default chapter settings functionality to overflow menu - code clean up * - show confirmation dialog when user selects "Set as Default" option in Chapter Settings * - hide overflow menu in LibrarySettingsSheet * - apply default chapter settings if manga is added to Library from a Source's browsing screen Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
@@ -4,21 +4,49 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.databinding.CommonTabbedSheetBinding
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.SetChapterSettingsDialog
|
||||
import eu.kanade.tachiyomi.util.view.popupMenu
|
||||
|
||||
abstract class TabbedBottomSheetDialog(private val activity: Activity) : BottomSheetDialog(activity) {
|
||||
abstract class TabbedBottomSheetDialog(private val activity: Activity, private val manga: Manga? = null) : BottomSheetDialog(activity) {
|
||||
val binding: CommonTabbedSheetBinding = CommonTabbedSheetBinding.inflate(activity.layoutInflater)
|
||||
|
||||
init {
|
||||
val binding: CommonTabbedSheetBinding = CommonTabbedSheetBinding.inflate(activity.layoutInflater)
|
||||
|
||||
val adapter = LibrarySettingsSheetAdapter()
|
||||
binding.pager.offscreenPageLimit = 2
|
||||
binding.pager.adapter = adapter
|
||||
binding.tabs.setupWithViewPager(binding.pager)
|
||||
|
||||
// currently, we only need to show the overflow menu if this is a ChaptersSettingsSheet
|
||||
if (manga != null) {
|
||||
binding.menu.visibility = View.VISIBLE
|
||||
binding.menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
||||
} else {
|
||||
binding.menu.visibility = View.GONE
|
||||
}
|
||||
|
||||
setContentView(binding.root)
|
||||
}
|
||||
|
||||
private fun showPopupMenu(view: View) {
|
||||
view.popupMenu(
|
||||
R.menu.default_chapter_filter,
|
||||
{
|
||||
},
|
||||
{
|
||||
when (this.itemId) {
|
||||
R.id.save_as_default -> {
|
||||
manga?.let { SetChapterSettingsDialog(context, it).showDialog() }
|
||||
true
|
||||
}
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
abstract fun getTabViews(): List<View>
|
||||
|
||||
abstract fun getTabTitles(): List<Int>
|
||||
|
||||
Reference in New Issue
Block a user