mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 00:51:47 +01:00
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:
parent
ba30882291
commit
6a22c18fab
@ -9,7 +9,6 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
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.preference.PreferencesHelper
|
||||
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.online.HttpSource
|
||||
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.catalogue.CatalogueController
|
||||
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.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
||||
import eu.kanade.tachiyomi.util.view.HeightTopWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
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.snack
|
||||
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.visibleIf
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.android.synthetic.main.catalogue_controller.*
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Controller to manage the catalogues available in the app.
|
||||
*/
|
||||
open class BrowseCatalogueController(bundle: Bundle) :
|
||||
NucleusController<BrowseCataloguePresenter>(bundle),
|
||||
SecondaryDrawerController,
|
||||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
FlexibleAdapter.EndlessScrollListener,
|
||||
@ -148,8 +143,9 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
setupRecycler(view)
|
||||
|
||||
navView?.setFilters(presenter.filterItems)
|
||||
scrollViewWith(recycler!!, true)
|
||||
|
||||
fab.visibleIf(presenter.sourceFilters.isNotEmpty())
|
||||
fab.setOnClickListener { showFilters() }
|
||||
progress?.visible()
|
||||
}
|
||||
|
||||
@ -164,53 +160,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
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) {
|
||||
numColumnsSubscription?.unsubscribe()
|
||||
|
||||
@ -252,8 +201,22 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
recycler.setHasFixedSize(true)
|
||||
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)
|
||||
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||
if (oldPosition != RecyclerView.NO_POSITION) {
|
||||
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
|
||||
menu.findItem(R.id.action_display_mode).apply {
|
||||
val icon = if (presenter.isListMode)
|
||||
@ -321,13 +281,63 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
||||
when (item.itemId) {
|
||||
R.id.action_search -> expandActionViewFromInteraction = true
|
||||
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()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
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() {
|
||||
val source = presenter.source as? HttpSource ?: return
|
||||
val activity = activity ?: return
|
||||
|
@ -60,12 +60,15 @@ open class BrowseCataloguePresenter(
|
||||
var query = ""
|
||||
private set
|
||||
|
||||
var filtersChanged = false
|
||||
|
||||
/**
|
||||
* Modifiable list of filters.
|
||||
*/
|
||||
var sourceFilters = FilterList()
|
||||
set(value) {
|
||||
field = value
|
||||
filtersChanged = true
|
||||
filterItems = value.toItems()
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.view.inflate
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.widget.SimpleNavigationView
|
||||
import kotlinx.android.synthetic.main.catalogue_drawer_content.view.*
|
||||
|
||||
class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
SimpleNavigationView(context, attrs) {
|
||||
@ -28,13 +26,13 @@ class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs:
|
||||
val view = inflate(R.layout.catalogue_drawer_content)
|
||||
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
|
||||
addView(view)
|
||||
title.text = context.getString(R.string.source_search_options)
|
||||
search_btn.setOnClickListener { onSearchClicked() }
|
||||
// title.text = context.getString(R.string.source_search_options)
|
||||
/*search_btn.setOnClickListener { onSearchClicked() }
|
||||
reset_btn.setOnClickListener { onResetClicked() }
|
||||
view.search_layout.setOnApplyWindowInsetsListener { v, insets ->
|
||||
view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||
insets
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
fun setFilters(items: List<IFlexible<*>>) {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@ package eu.kanade.tachiyomi.ui.catalogue.latest
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.ViewGroup
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
|
||||
@ -25,13 +23,5 @@ class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.display_bottom_sheet.*
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class DisplayBottomSheet(private val controller: LibraryController) : BottomSheetDialog
|
||||
(controller.activity!!, R.style.BottomSheetDialogTheme) {
|
||||
(controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
|
||||
|
||||
val activity = controller.activity!!
|
||||
|
||||
@ -37,9 +37,10 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
||||
setContentView(view)
|
||||
|
||||
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
|
||||
sheetBehavior.peekHeight = 220.dpToPx + height
|
||||
window?.navigationBarColor = activity.window.navigationBarColor
|
||||
|
||||
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, progress: Float) { }
|
||||
|
@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf
|
||||
import kotlinx.android.synthetic.main.chapter_sort_bottom_sheet.*
|
||||
|
||||
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
||||
(controller.activity!!, R.style.BottomSheetDialogTheme) {
|
||||
(controller.activity!!, R.style.BottomSheetDialogThemeCovered) {
|
||||
|
||||
val activity = controller.activity!!
|
||||
|
||||
@ -30,9 +30,10 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
|
||||
setContentView(view)
|
||||
|
||||
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
|
||||
sheetBehavior.peekHeight = 380.dpToPx + height
|
||||
window?.navigationBarColor = activity.window.navigationBarColor
|
||||
|
||||
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, progress: Float) { }
|
||||
|
@ -40,7 +40,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : Bott
|
||||
setContentView(view)
|
||||
|
||||
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
|
||||
sheetBehavior.peekHeight = 380.dpToPx + height
|
||||
|
||||
|
@ -62,7 +62,7 @@ class MigrationBottomSheetDialog(
|
||||
params3.endToEnd = -1
|
||||
extra_search_param.layoutParams = params3
|
||||
}
|
||||
setEdgeToEdge(activity, constraint_layout, view, false)
|
||||
setEdgeToEdge(activity, constraint_layout, view)
|
||||
setBottomEdge(
|
||||
if (activity.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) extra_search_param_text
|
||||
else skip_step, activity
|
||||
|
@ -54,7 +54,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog
|
||||
val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null)
|
||||
setContentView(view)
|
||||
|
||||
setEdgeToEdge(activity, constraint_layout, view, true)
|
||||
setEdgeToEdge(activity, constraint_layout, view, 0)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||
preferences.readerTheme().getOrDefault() == 0 &&
|
||||
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
||||
|
@ -32,7 +32,7 @@ class ReaderPageSheet(
|
||||
|
||||
init {
|
||||
setContentView(view)
|
||||
setEdgeToEdge(activity, view, view, false)
|
||||
setEdgeToEdge(activity, view, view)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||
Injekt.get<PreferencesHelper>().readerTheme().getOrDefault() == 0 &&
|
||||
activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 &&
|
||||
|
@ -52,7 +52,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
|
||||
activity,
|
||||
constraint_layout,
|
||||
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()
|
||||
.getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0
|
||||
|
@ -398,7 +398,7 @@ fun BottomSheetDialog.setEdgeToEdge(
|
||||
activity: Activity,
|
||||
layout: View,
|
||||
contentView: View,
|
||||
setTopMargin: Boolean
|
||||
setTopMargin: Int = -1
|
||||
) {
|
||||
window?.setBackgroundDrawable(null)
|
||||
val currentNightMode =
|
||||
@ -425,12 +425,22 @@ fun BottomSheetDialog.setEdgeToEdge(
|
||||
}
|
||||
window?.findViewById<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
|
||||
false
|
||||
contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
if (setTopMargin) topMargin =
|
||||
activity.window.decorView.rootWindowInsets.systemWindowInsetTop
|
||||
leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft
|
||||
rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight
|
||||
contentView.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
/*contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
if (setTopMargin > -1) topMargin =
|
||||
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) {
|
||||
|
8
app/src/main/res/drawable/bg_bottom_sheet_secondary.xml
Normal file
8
app/src/main/res/drawable/bg_bottom_sheet_secondary.xml
Normal 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>
|
@ -2,6 +2,7 @@
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/catalouge_layout"
|
||||
android:layout_height="match_parent">
|
||||
@ -23,4 +24,18 @@
|
||||
|
||||
</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>
|
||||
|
@ -1,75 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/bg_bottom_sheet_primary"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_background"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/listPreferredItemHeightSmall"
|
||||
android:background="?colorPrimary"
|
||||
android:elevation="2dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingEnd">
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:clipToPadding="false"
|
||||
android:fitsSystemWindows="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/title_layout"
|
||||
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_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="Title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textColor="?attr/actionBarTintColor"/>
|
||||
android:textColor="?actionBarTintColor"
|
||||
android:textSize="20sp"
|
||||
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>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3"
|
||||
android:layout_gravity="top"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/divider"/>
|
||||
|
||||
<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>
|
||||
<ImageView
|
||||
android:id="@+id/dismiss_button"
|
||||
style="@style/Theme.Widget.CustomImageButton"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:src="@drawable/ic_expand_more_white_24dp"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
|
7
app/src/main/res/layout/catalogue_search_sheet.xml
Normal file
7
app/src/main/res/layout/catalogue_search_sheet.xml
Normal 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>
|
@ -10,12 +10,6 @@
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
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
|
||||
android:id="@+id/action_display_mode"
|
||||
android:title="@string/action_display_mode"
|
||||
|
@ -213,6 +213,13 @@
|
||||
<item name="android:colorBackground">@android:color/transparent</item>
|
||||
</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-->
|
||||
<!--==============-->
|
||||
|
Loading…
Reference in New Issue
Block a user