Browse Filters is now also a bottom sheet

Lets see how many more we can add (we're up to 6 if you're keeping score)
This commit is contained in:
Jay 2020-03-22 19:08:17 -04:00
parent ba30882291
commit 6a22c18fab
19 changed files with 318 additions and 161 deletions

View File

@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.GravityCompat
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -24,10 +23,10 @@ import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
@ -35,32 +34,28 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.connectivityManager import eu.kanade.tachiyomi.util.system.connectivityManager
import eu.kanade.tachiyomi.util.view.HeightTopWindowInsetsListener import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.marginBottom
import eu.kanade.tachiyomi.util.view.marginTop
import eu.kanade.tachiyomi.util.view.scrollViewWith import eu.kanade.tachiyomi.util.view.scrollViewWith
import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import eu.kanade.tachiyomi.widget.AutofitRecyclerView import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.catalogue_controller.* import kotlinx.android.synthetic.main.catalogue_controller.*
import rx.Observable import rx.Observable
import rx.Subscription import rx.Subscription
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
import timber.log.Timber import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.concurrent.TimeUnit
/** /**
* Controller to manage the catalogues available in the app. * Controller to manage the catalogues available in the app.
*/ */
open class BrowseCatalogueController(bundle: Bundle) : open class BrowseCatalogueController(bundle: Bundle) :
NucleusController<BrowseCataloguePresenter>(bundle), NucleusController<BrowseCataloguePresenter>(bundle),
SecondaryDrawerController,
FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener, FlexibleAdapter.OnItemLongClickListener,
FlexibleAdapter.EndlessScrollListener, FlexibleAdapter.EndlessScrollListener,
@ -148,8 +143,9 @@ open class BrowseCatalogueController(bundle: Bundle) :
setupRecycler(view) setupRecycler(view)
navView?.setFilters(presenter.filterItems) navView?.setFilters(presenter.filterItems)
scrollViewWith(recycler!!, true)
fab.visibleIf(presenter.sourceFilters.isNotEmpty())
fab.setOnClickListener { showFilters() }
progress?.visible() progress?.visible()
} }
@ -164,53 +160,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
super.onDestroyView(view) super.onDestroyView(view)
} }
override fun createSecondaryDrawer(drawer: androidx.drawerlayout.widget.DrawerLayout): ViewGroup? {
// Inflate and prepare drawer
val navView = drawer.inflate(R.layout.catalogue_drawer) as CatalogueNavigationView
this.navView = navView
navView.setFilters(presenter.filterItems)
drawer.setDrawerLockMode(androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END)
navView.onSearchClicked = {
val allDefault = presenter.sourceFilters == presenter.source.getFilterList()
showProgressBar()
adapter?.clear()
drawer.closeDrawer(GravityCompat.END)
presenter.setSourceFilter(if (allDefault) FilterList() else presenter.sourceFilters)
}
navView.onResetClicked = {
presenter.appliedFilters = FilterList()
val newFilters = presenter.source.getFilterList()
presenter.sourceFilters = newFilters
navView.setFilters(presenter.filterItems)
}
drawer.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
val statusScrim = navView.findViewById(R.id.status_bar_scrim) as View
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
val titleView = navView.findViewById(R.id.title_background) as View
val titleMarginTop = titleView.marginTop
navView.setOnApplyWindowInsetsListener { v, insets ->
navView.recycler.updatePaddingRelative(
bottom = navView.recycler.marginBottom + insets.systemWindowInsetBottom,
top = navView.recycler.marginTop + insets.systemWindowInsetTop
)
titleView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = titleMarginTop + insets.systemWindowInsetTop
}
insets
}
return navView
}
override fun cleanupSecondaryDrawer(drawer: androidx.drawerlayout.widget.DrawerLayout) {
navView = null
}
private fun setupRecycler(view: View) { private fun setupRecycler(view: View) {
numColumnsSubscription?.unsubscribe() numColumnsSubscription?.unsubscribe()
@ -252,8 +201,22 @@ open class BrowseCatalogueController(bundle: Bundle) :
recycler.setHasFixedSize(true) recycler.setHasFixedSize(true)
recycler.adapter = adapter recycler.adapter = adapter
scrollViewWith(recycler, true) { insets ->
fab.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = insets.systemWindowInsetBottom + 16.dpToPx
}
}
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
if (dy <= 0)
fab.extend()
else
fab.shrink()
}
})
catalogue_view.addView(recycler, 1) catalogue_view.addView(recycler, 1)
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
if (oldPosition != RecyclerView.NO_POSITION) { if (oldPosition != RecyclerView.NO_POSITION) {
recycler.layoutManager?.scrollToPosition(oldPosition) recycler.layoutManager?.scrollToPosition(oldPosition)
} }
@ -297,9 +260,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
} }
) )
// Setup filters button
menu.findItem(R.id.action_set_filter).isVisible = presenter.sourceFilters.isNotEmpty()
// Show next display mode // Show next display mode
menu.findItem(R.id.action_display_mode).apply { menu.findItem(R.id.action_display_mode).apply {
val icon = if (presenter.isListMode) val icon = if (presenter.isListMode)
@ -321,13 +281,63 @@ open class BrowseCatalogueController(bundle: Bundle) :
when (item.itemId) { when (item.itemId) {
R.id.action_search -> expandActionViewFromInteraction = true R.id.action_search -> expandActionViewFromInteraction = true
R.id.action_display_mode -> swapDisplayMode() R.id.action_display_mode -> swapDisplayMode()
// R.id.action_set_filter -> navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) }
R.id.action_open_in_web_view -> openInWebView() R.id.action_open_in_web_view -> openInWebView()
else -> return super.onOptionsItemSelected(item) else -> return super.onOptionsItemSelected(item)
} }
return true return true
} }
private fun showFilters() {
val sheet = CatalogueSearchSheet(activity!!)
sheet.setFilters(presenter.filterItems)
presenter.filtersChanged = false
val oldFilters = mutableListOf<Any?>()
for (i in presenter.sourceFilters) {
if (i is Filter.Group<*>) {
val subFilters = mutableListOf<Any?>()
for (j in i.state) {
subFilters.add((j as Filter<*>).state)
}
oldFilters.add(subFilters)
} else {
oldFilters.add(i.state)
}
}
sheet.onSearchClicked = {
var matches = true
for (i in presenter.sourceFilters.indices) {
val filter = oldFilters[i]
if (filter is List<*>) {
for (j in filter.indices) {
if (filter[j] !=
((presenter.sourceFilters[i] as Filter.Group<*>).state[j] as
Filter<*>).state) {
matches = false
break
}
}
} else if (oldFilters[i] != presenter.sourceFilters[i].state) {
matches = false
break
}
}
if (!matches) {
val allDefault = presenter.sourceFilters == presenter.source.getFilterList()
showProgressBar()
adapter?.clear()
presenter.setSourceFilter(if (allDefault) FilterList() else presenter.sourceFilters)
}
}
sheet.onResetClicked = {
presenter.appliedFilters = FilterList()
val newFilters = presenter.source.getFilterList()
presenter.sourceFilters = newFilters
sheet.setFilters(presenter.filterItems)
}
sheet.show()
}
private fun openInWebView() { private fun openInWebView() {
val source = presenter.source as? HttpSource ?: return val source = presenter.source as? HttpSource ?: return
val activity = activity ?: return val activity = activity ?: return

View File

@ -60,12 +60,15 @@ open class BrowseCataloguePresenter(
var query = "" var query = ""
private set private set
var filtersChanged = false
/** /**
* Modifiable list of filters. * Modifiable list of filters.
*/ */
var sourceFilters = FilterList() var sourceFilters = FilterList()
set(value) { set(value) {
field = value field = value
filtersChanged = true
filterItems = value.toItems() filterItems = value.toItems()
} }

View File

@ -7,9 +7,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.widget.SimpleNavigationView import eu.kanade.tachiyomi.widget.SimpleNavigationView
import kotlinx.android.synthetic.main.catalogue_drawer_content.view.*
class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
SimpleNavigationView(context, attrs) { SimpleNavigationView(context, attrs) {
@ -28,13 +26,13 @@ class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs:
val view = inflate(R.layout.catalogue_drawer_content) val view = inflate(R.layout.catalogue_drawer_content)
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler) ((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
addView(view) addView(view)
title.text = context.getString(R.string.source_search_options) // title.text = context.getString(R.string.source_search_options)
search_btn.setOnClickListener { onSearchClicked() } /*search_btn.setOnClickListener { onSearchClicked() }
reset_btn.setOnClickListener { onResetClicked() } reset_btn.setOnClickListener { onResetClicked() }
view.search_layout.setOnApplyWindowInsetsListener { v, insets -> view.search_layout.setOnApplyWindowInsetsListener { v, insets ->
view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
insets insets
} }*/
} }
fun setFilters(items: List<IFlexible<*>>) { fun setFilters(items: List<IFlexible<*>>) {

View File

@ -0,0 +1,119 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.app.Activity
import android.os.Build
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
import kotlinx.android.synthetic.main.catalogue_drawer_content.*
import uy.kohesive.injekt.injectLazy
class CatalogueSearchSheet(private val activity: Activity) :
BottomSheetDialog(activity, R.style.BottomSheetDialogThemeCovered) {
/**
* Preferences helper.
*/
private val preferences by injectLazy<PreferencesHelper>()
private var sheetBehavior: BottomSheetBehavior<*>
private var elevationAnimator: ValueAnimator? = null
var filterChanged = true
var isNotElevated = false
val adapter: FlexibleAdapter<IFlexible<*>> = FlexibleAdapter<IFlexible<*>>(null)
.setDisplayHeadersAtStartUp(true)
var onSearchClicked = {}
var onResetClicked = {}
init {
val view = activity.layoutInflater.inflate(R.layout.catalogue_drawer_content, null)
setContentView(view)
toolbar_title.text = context.getString(R.string.source_search_options)
dismiss_button.setOnClickListener { dismiss() }
reset_btn.setOnClickListener { onResetClicked() }
/*view.search_layout.setOnApplyWindowInsetsListener { v, insets ->
view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
insets
}*/
recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
recycler.clipToPadding = false
recycler.adapter = adapter
recycler.setHasFixedSize(true)
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
sheetBehavior.skipCollapsed = true
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
setEdgeToEdge(
activity, recycler, view, 50.dpToPx
)
// window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
// false
window?.navigationBarColor = activity.window.navigationBarColor
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme()
.getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0
) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) {}
override fun onStateChanged(p0: View, state: Int) {
if (state == BottomSheetBehavior.STATE_EXPANDED) {
sheetBehavior.skipCollapsed = true
}
}
})
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val atTop = !recycler.canScrollVertically(-1)
if (atTop != isNotElevated) {
elevationAnimator?.cancel()
isNotElevated = atTop
elevationAnimator?.cancel()
elevationAnimator = ObjectAnimator.ofFloat(
title_layout,
"elevation",
title_layout.elevation,
if (atTop) 0f else 10f.dpToPx
)
elevationAnimator?.duration = 100
elevationAnimator?.start()
}
}
})
}
override fun onStart() {
super.onStart()
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
}
override fun dismiss() {
super.dismiss()
if (filterChanged)
onSearchClicked()
}
fun setFilters(items: List<IFlexible<*>>) {
adapter.updateDataSet(items)
}
}

View File

@ -2,8 +2,6 @@ package eu.kanade.tachiyomi.ui.catalogue.latest
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.ViewGroup
import androidx.drawerlayout.widget.DrawerLayout
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
@ -25,13 +23,5 @@ class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle
override fun onPrepareOptionsMenu(menu: Menu) { override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu) super.onPrepareOptionsMenu(menu)
menu.findItem(R.id.action_search).isVisible = false menu.findItem(R.id.action_search).isVisible = false
menu.findItem(R.id.action_set_filter).isVisible = false
}
override fun createSecondaryDrawer(drawer: androidx.drawerlayout.widget.DrawerLayout): ViewGroup? {
return null
}
override fun cleanupSecondaryDrawer(drawer: androidx.drawerlayout.widget.DrawerLayout) {
} }
} }

View File

@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.display_bottom_sheet.*
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class DisplayBottomSheet(private val controller: LibraryController) : BottomSheetDialog class DisplayBottomSheet(private val controller: LibraryController) : BottomSheetDialog
(controller.activity!!, R.style.BottomSheetDialogTheme) { (controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
val activity = controller.activity!! val activity = controller.activity!!
@ -37,9 +37,10 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
setContentView(view) setContentView(view)
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
setEdgeToEdge(activity, bottom_sheet, view, false) setEdgeToEdge(activity, bottom_sheet, view)
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
sheetBehavior.peekHeight = 220.dpToPx + height sheetBehavior.peekHeight = 220.dpToPx + height
window?.navigationBarColor = activity.window.navigationBarColor
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) { } override fun onSlide(bottomSheet: View, progress: Float) { }

View File

@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.* import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.*
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
(controller.activity!!, R.style.BottomSheetDialogTheme) { (controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
val activity = controller.activity!! val activity = controller.activity!!
@ -30,9 +30,10 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
setContentView(view) setContentView(view)
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
setEdgeToEdge(activity, bottom_sheet, view, false) setEdgeToEdge(activity, bottom_sheet, view)
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
sheetBehavior.peekHeight = 380.dpToPx + height sheetBehavior.peekHeight = 380.dpToPx + height
window?.navigationBarColor = activity.window.navigationBarColor
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) { } override fun onSlide(bottomSheet: View, progress: Float) { }

View File

@ -40,7 +40,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : Bott
setContentView(view) setContentView(view)
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
setEdgeToEdge(activity, display_bottom_sheet, view, false) setEdgeToEdge(activity, display_bottom_sheet, view)
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
sheetBehavior.peekHeight = 380.dpToPx + height sheetBehavior.peekHeight = 380.dpToPx + height

View File

@ -62,7 +62,7 @@ class MigrationBottomSheetDialog(
params3.endToEnd = -1 params3.endToEnd = -1
extra_search_param.layoutParams = params3 extra_search_param.layoutParams = params3
} }
setEdgeToEdge(activity, constraint_layout, view, false) setEdgeToEdge(activity, constraint_layout, view)
setBottomEdge( setBottomEdge(
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) extra_search_param_text if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) extra_search_param_text
else skip_step, activity else skip_step, activity

View File

@ -54,7 +54,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog
val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null) val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null)
setContentView(view) setContentView(view)
setEdgeToEdge(activity, constraint_layout, view, true) setEdgeToEdge(activity, constraint_layout, view, 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
preferences.readerTheme().getOrDefault() == 0 && preferences.readerTheme().getOrDefault() == 0 &&
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&

View File

@ -32,7 +32,7 @@ class ReaderPageSheet(
init { init {
setContentView(view) setContentView(view)
setEdgeToEdge(activity, view, view, false) setEdgeToEdge(activity, view, view)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
Injekt.get<PreferencesHelper>().readerTheme().getOrDefault() == 0 && Injekt.get<PreferencesHelper>().readerTheme().getOrDefault() == 0 &&
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&

View File

@ -52,7 +52,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
activity, activity,
constraint_layout, constraint_layout,
scroll, scroll,
context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE if (context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
0 else -1
) )
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme()
.getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0 .getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0

View File

@ -398,7 +398,7 @@ fun BottomSheetDialog.setEdgeToEdge(
activity: Activity, activity: Activity,
layout: View, layout: View,
contentView: View, contentView: View,
setTopMargin: Boolean setTopMargin: Int = -1
) { ) {
window?.setBackgroundDrawable(null) window?.setBackgroundDrawable(null)
val currentNightMode = val currentNightMode =
@ -425,12 +425,22 @@ fun BottomSheetDialog.setEdgeToEdge(
} }
window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows = window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
false false
contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> { contentView.systemUiVisibility =
if (setTopMargin) topMargin = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
activity.window.decorView.rootWindowInsets.systemWindowInsetTop /*contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft if (setTopMargin > -1) topMargin =
rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight activity.window.decorView.rootWindowInsets.systemWindowInsetTop + setTopMargin
}*/
if (setTopMargin > 0) (contentView.parent as View).updateLayoutParams<ViewGroup.MarginLayoutParams> {
height =
activity.window.decorView.height - activity.window.decorView.rootWindowInsets.systemWindowInsetTop - setTopMargin
// activity.window.decorView.rootWindowInsets.systemWindowInsetTop // + setTopMargin
} }
else if (setTopMargin == 0) contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetTop
}
contentView.requestLayout()
} }
fun setBottomEdge(view: View, activity: Activity) { fun setBottomEdge(view: View, activity: Activity) {

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
<solid android:color="?android:attr/statusBarColor" />
</shape>

View File

@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:id="@+id/catalouge_layout" android:id="@+id/catalouge_layout"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -23,4 +24,18 @@
</LinearLayout> </LinearLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
app:backgroundTint="?colorAccent"
android:text="@string/action_filter"
android:layout_gravity="bottom|end"
app:icon="@drawable/ic_filter_list_white_24dp"
app:iconTint="@color/md_white_1000"
android:textColor="@color/md_white_1000"
android:textAllCaps="false"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:layout_height="wrap_content"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,75 +1,68 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true" android:background="@drawable/bg_bottom_sheet_primary"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/title_background" android:id="@+id/recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall" android:layout_height="match_parent"
android:background="?colorPrimary" android:layout_marginTop="?attr/actionBarSize"
android:elevation="2dp" android:clipToPadding="false"
android:gravity="center_vertical" android:fitsSystemWindows="true" />
android:orientation="horizontal"
android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
<TextView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/title" android:id="@+id/title_layout"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:background="@drawable/bg_bottom_sheet_primary"
android:clickable="true"
android:elevation="0dp"
android:focusable="true"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/reset_btn"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/action_reset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_gravity="center"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
tools:text="Title" android:textColor="?actionBarTintColor"
android:textAppearance="@style/TextAppearance.AppCompat.Body2" android:textSize="20sp"
android:textColor="?attr/actionBarTintColor"/> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Title Text" />
</LinearLayout> <ImageView
android:id="@+id/dismiss_button"
<FrameLayout style="@style/Theme.Widget.CustomImageButton"
android:layout_width="match_parent" android:layout_width="30dp"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_weight="3" android:layout_gravity="end"
android:layout_gravity="top"/> android:layout_marginEnd="12dp"
android:src="@drawable/ic_expand_more_white_24dp"
<View android:tint="?android:attr/textColorPrimary"
android:id="@+id/divider" app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_height="1dp" app:layout_constraintTop_toTopOf="parent" />
android:background="?android:attr/divider"/> </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="8dp"
tools:paddingBottom="20dp">
<Button
android:id="@+id/reset_btn"
style="@style/Theme.Widget.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_reset"/>
<Button
android:id="@+id/search_btn"
style="@style/Theme.Widget.Button.Colored"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:layout_weight="1"
android:text="@string/action_search"/>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.kanade.tachiyomi.ui.catalogue.browse.CatalogueSearchSheet xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/diplay_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent">
</eu.kanade.tachiyomi.ui.catalogue.browse.CatalogueSearchSheet>

View File

@ -10,12 +10,6 @@
app:actionViewClass="androidx.appcompat.widget.SearchView" app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|ifRoom" /> app:showAsAction="collapseActionView|ifRoom" />
<item
android:id="@+id/action_set_filter"
android:icon="@drawable/ic_filter_list_white_24dp"
android:title="@string/action_set_filter"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_display_mode" android:id="@+id/action_display_mode"
android:title="@string/action_display_mode" android:title="@string/action_display_mode"

View File

@ -213,6 +213,13 @@
<item name="android:colorBackground">@android:color/transparent</item> <item name="android:colorBackground">@android:color/transparent</item>
</style> </style>
<style name="BottomSheetDialogThemeCovered"
parent="@style/Theme.MaterialComponents.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="android:colorBackground">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<!--==============--> <!--==============-->
<!--Widgets.Button--> <!--Widgets.Button-->
<!--==============--> <!--==============-->