mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 10:39:08 +01:00
Fixes to filter sheet in landscape
This commit is contained in:
parent
fe7bd2a7bb
commit
4d094105a9
@ -121,8 +121,6 @@ open class LibraryController(
|
|||||||
|
|
||||||
val stopRefreshRelay: PublishRelay<Boolean> = PublishRelay.create()
|
val stopRefreshRelay: PublishRelay<Boolean> = PublishRelay.create()
|
||||||
|
|
||||||
protected var phoneLandscape = false
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of manga per row in grid mode.
|
* Number of manga per row in grid mode.
|
||||||
*/
|
*/
|
||||||
@ -194,12 +192,6 @@ open class LibraryController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val config = resources?.configuration
|
|
||||||
phoneLandscape =
|
|
||||||
(config?.orientation == Configuration.ORIENTATION_LANDSCAPE && (config.screenLayout.and(
|
|
||||||
Configuration.SCREENLAYOUT_SIZE_MASK
|
|
||||||
)) < Configuration.SCREENLAYOUT_SIZE_LARGE)
|
|
||||||
|
|
||||||
presenter.onRestore()
|
presenter.onRestore()
|
||||||
val library = presenter.getAllManga()
|
val library = presenter.getAllManga()
|
||||||
if (library != null) presenter.updateViewBlocking()
|
if (library != null) presenter.updateViewBlocking()
|
||||||
|
@ -113,11 +113,8 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
// pad the recycler if the filter bottom sheet is visible
|
// pad the recycler if the filter bottom sheet is visible
|
||||||
if (!phoneLandscape) {
|
val height = view.context.resources.getDimensionPixelSize(R.dimen.rounder_radius) + 4.dpToPx
|
||||||
val height =
|
recycler.updatePaddingRelative(bottom = height)
|
||||||
view.context.resources.getDimensionPixelSize(R.dimen.rounder_radius) + 4.dpToPx
|
|
||||||
recycler.updatePaddingRelative(bottom = height)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent?) {
|
override fun onTouchEvent(event: MotionEvent?) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.ui.library.filter
|
package eu.kanade.tachiyomi.ui.library.filter
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -16,7 +15,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
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.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
@ -70,27 +68,20 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
|
|
||||||
var onGroupClicked: (Int) -> Unit = { _ -> }
|
var onGroupClicked: (Int) -> Unit = { _ -> }
|
||||||
var pager: View? = null
|
var pager: View? = null
|
||||||
var phoneLandscape = false
|
|
||||||
|
|
||||||
fun onCreate(pagerView: View) {
|
fun onCreate(pagerView: View) {
|
||||||
clearButton = clear_button
|
clearButton = clear_button
|
||||||
filter_layout.removeView(clearButton)
|
filter_layout.removeView(clearButton)
|
||||||
sheetBehavior = BottomSheetBehavior.from(this)
|
sheetBehavior = BottomSheetBehavior.from(this)
|
||||||
phoneLandscape = (isLandscape() && !isTablet())
|
|
||||||
sheetBehavior?.isHideable = true
|
sheetBehavior?.isHideable = true
|
||||||
sheetBehavior?.skipCollapsed = phoneLandscape
|
|
||||||
pager = pagerView
|
pager = pagerView
|
||||||
val shadow2: View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
|
val shadow2: View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
|
||||||
val shadow: View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
|
val shadow: View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
|
||||||
if (phoneLandscape) {
|
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
}
|
|
||||||
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
top_bar.alpha = 1 - max(0f, progress)
|
top_bar.alpha = 1 - max(0f, progress)
|
||||||
shadow2.alpha = (1 - max(0f, progress)) * 0.25f
|
shadow2.alpha = (1 - max(0f, progress)) * 0.25f
|
||||||
if (phoneLandscape) shadow.alpha = progress
|
shadow.alpha = 1 + min(0f, progress)
|
||||||
else shadow.alpha = 1 + min(0f, progress)
|
|
||||||
updateRootPadding(progress)
|
updateRootPadding(progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,15 +92,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
}
|
}
|
||||||
updateRootPadding(when (sheetBehavior?.state) {
|
|
||||||
BottomSheetBehavior.STATE_HIDDEN -> -1f
|
|
||||||
BottomSheetBehavior.STATE_EXPANDED -> 1f
|
|
||||||
else -> 0f
|
|
||||||
})
|
|
||||||
shadow.alpha = if (sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN) 0f else 1f
|
|
||||||
if (phoneLandscape && shadow2.visibility != View.GONE) {
|
|
||||||
shadow2.gone()
|
|
||||||
}
|
|
||||||
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
|
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
|
||||||
hide_filters.setOnCheckedChangeListener { _, isChecked ->
|
hide_filters.setOnCheckedChangeListener { _, isChecked ->
|
||||||
preferences.hideFiltersAtStart().set(isChecked)
|
preferences.hideFiltersAtStart().set(isChecked)
|
||||||
@ -122,6 +104,14 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
if (activeFilters && sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN &&
|
if (activeFilters && sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN &&
|
||||||
sheetBehavior?.skipCollapsed == false)
|
sheetBehavior?.skipCollapsed == false)
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
|
||||||
|
updateRootPadding(when (sheetBehavior?.state) {
|
||||||
|
BottomSheetBehavior.STATE_HIDDEN -> -1f
|
||||||
|
BottomSheetBehavior.STATE_EXPANDED -> 1f
|
||||||
|
else -> 0f
|
||||||
|
})
|
||||||
|
shadow.alpha = if (sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN) 0f else 1f
|
||||||
|
|
||||||
createTags()
|
createTags()
|
||||||
clearButton.setOnClickListener { clearFilters() }
|
clearButton.setOnClickListener { clearFilters() }
|
||||||
}
|
}
|
||||||
@ -134,8 +124,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
}
|
}
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
top_bar.alpha = 0f
|
top_bar.alpha = 0f
|
||||||
if (phoneLandscape)
|
|
||||||
shadow?.alpha = 1f
|
|
||||||
}
|
}
|
||||||
if (state == BottomSheetBehavior.STATE_HIDDEN) {
|
if (state == BottomSheetBehavior.STATE_HIDDEN) {
|
||||||
reSortViews()
|
reSortViews()
|
||||||
@ -150,15 +138,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
stateChanged(sheetBehavior.state)
|
stateChanged(sheetBehavior.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isLandscape(): Boolean {
|
|
||||||
return context.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isTablet(): Boolean {
|
|
||||||
return (context.resources.configuration.screenLayout and Configuration
|
|
||||||
.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateRootPadding(progress: Float? = null) {
|
fun updateRootPadding(progress: Float? = null) {
|
||||||
val minHeight = sheetBehavior?.peekHeight ?: 0
|
val minHeight = sheetBehavior?.peekHeight ?: 0
|
||||||
val maxHeight = height
|
val maxHeight = height
|
||||||
@ -333,6 +312,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
filterItems.remove(trackers!!)
|
filterItems.remove(trackers!!)
|
||||||
reSortViews()
|
reSortViews()
|
||||||
onGroupClicked(ACTION_FILTER)
|
onGroupClicked(ACTION_FILTER)
|
||||||
|
sheetBehavior?.isHideable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reSortViews() {
|
private fun reSortViews() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user