mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 15:21:51 +01:00
Using helper functions for bottom sheet methods
This commit is contained in:
parent
c0eb0b62c7
commit
3c56dc6cba
@ -13,7 +13,13 @@ import eu.kanade.tachiyomi.data.download.model.Download
|
|||||||
import eu.kanade.tachiyomi.ui.extension.ExtensionDividerItemDecoration
|
import eu.kanade.tachiyomi.ui.extension.ExtensionDividerItemDecoration
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentsController
|
import eu.kanade.tachiyomi.ui.recents.RecentsController
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.hide
|
||||||
|
import eu.kanade.tachiyomi.util.view.isCollapsed
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
|
import eu.kanade.tachiyomi.util.view.isHidden
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import kotlinx.android.synthetic.main.download_bottom_sheet.view.*
|
import kotlinx.android.synthetic.main.download_bottom_sheet.view.*
|
||||||
|
|
||||||
@ -65,17 +71,17 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sheet_layout.setOnClickListener {
|
sheet_layout.setOnClickListener {
|
||||||
if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) {
|
if (!sheetBehavior.isExpanded()) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior?.expand()
|
||||||
} else {
|
} else {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update()
|
update()
|
||||||
setInformationView()
|
setInformationView()
|
||||||
if (!controller.hasQueue()) {
|
if (!controller.hasQueue()) {
|
||||||
sheetBehavior?.isHideable = true
|
sheetBehavior?.isHideable = true
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
sheetBehavior?.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,9 +211,9 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
|
|
||||||
fun dismiss() {
|
fun dismiss() {
|
||||||
if (sheetBehavior?.isHideable == true) {
|
if (sheetBehavior?.isHideable == true) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
sheetBehavior?.hide()
|
||||||
} else {
|
} else {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,13 +221,11 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
val hasQueue = presenter.downloadQueue.isNotEmpty()
|
val hasQueue = presenter.downloadQueue.isNotEmpty()
|
||||||
if (hasQueue) {
|
if (hasQueue) {
|
||||||
sheetBehavior?.skipCollapsed = !hasQueue
|
sheetBehavior?.skipCollapsed = !hasQueue
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN) sheetBehavior?.state =
|
if (sheetBehavior.isHidden()) sheetBehavior?.collapse()
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
} else {
|
} else {
|
||||||
sheetBehavior?.isHideable = !hasQueue
|
sheetBehavior?.isHideable = !hasQueue
|
||||||
sheetBehavior?.skipCollapsed = !hasQueue
|
sheetBehavior?.skipCollapsed = !hasQueue
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) sheetBehavior?.state =
|
if (sheetBehavior.isCollapsed()) sheetBehavior?.hide()
|
||||||
BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
}
|
}
|
||||||
controller.setPadding(!hasQueue)
|
controller.setPadding(!hasQueue)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
|||||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
import eu.kanade.tachiyomi.ui.source.SourceController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
import kotlinx.android.synthetic.main.extensions_bottom_sheet.view.*
|
import kotlinx.android.synthetic.main.extensions_bottom_sheet.view.*
|
||||||
@ -72,11 +75,11 @@ ExtensionAdapter.OnButtonClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sheet_layout.setOnClickListener {
|
sheet_layout.setOnClickListener {
|
||||||
if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) {
|
if (!sheetBehavior.isExpanded()) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior?.expand()
|
||||||
fetchOnlineExtensionsIfNeeded()
|
fetchOnlineExtensionsIfNeeded()
|
||||||
} else {
|
} else {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
presenter.getExtensionUpdateCount()
|
presenter.getExtensionUpdateCount()
|
||||||
|
@ -13,6 +13,8 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
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.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.isCollapsed
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
@ -55,7 +57,7 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
sheetBehavior.skipCollapsed = true
|
sheetBehavior.skipCollapsed = true
|
||||||
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +79,7 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
|||||||
private fun initGeneralPreferences() {
|
private fun initGeneralPreferences() {
|
||||||
display_group.bindToPreference(preferences.libraryLayout()) {
|
display_group.bindToPreference(preferences.libraryLayout()) {
|
||||||
controller.reattachAdapter()
|
controller.reattachAdapter()
|
||||||
if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED)
|
if (sheetBehavior.isCollapsed())
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
uniform_grid.bindToPreference(preferences.uniformGrid()) {
|
uniform_grid.bindToPreference(preferences.uniformGrid()) {
|
||||||
|
@ -28,7 +28,6 @@ import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
|||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.github.florent37.viewtooltip.ViewTooltip
|
import com.github.florent37.viewtooltip.ViewTooltip
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|
||||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
@ -61,9 +60,13 @@ import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
|||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.getItemView
|
import eu.kanade.tachiyomi.util.view.getItemView
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
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.isHidden
|
||||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||||
import eu.kanade.tachiyomi.util.view.setBackground
|
import eu.kanade.tachiyomi.util.view.setBackground
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
@ -161,10 +164,10 @@ class LibraryController(
|
|||||||
val notAtTop = recycler.canScrollVertically(-1)
|
val notAtTop = recycler.canScrollVertically(-1)
|
||||||
if (notAtTop != elevate) elevateFunc(notAtTop)
|
if (notAtTop != elevate) elevateFunc(notAtTop)
|
||||||
val order = getCategoryOrder()
|
val order = getCategoryOrder()
|
||||||
if (filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_HIDDEN) {
|
if (!filter_bottom_sheet.sheetBehavior.isHidden()) {
|
||||||
scrollDistance += abs(dy)
|
scrollDistance += abs(dy)
|
||||||
if (scrollDistance > scrollDistanceTilHidden) {
|
if (scrollDistance > scrollDistanceTilHidden) {
|
||||||
filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
filter_bottom_sheet.sheetBehavior?.hide()
|
||||||
scrollDistance = 0f
|
scrollDistance = 0f
|
||||||
}
|
}
|
||||||
} else scrollDistance = 0f
|
} else scrollDistance = 0f
|
||||||
@ -1009,9 +1012,8 @@ class LibraryController(
|
|||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
closeTip()
|
closeTip()
|
||||||
when {
|
when {
|
||||||
filter_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> filter_bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior.isHidden() -> filter_bottom_sheet.sheetBehavior?.collapse()
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
!filter_bottom_sheet.sheetBehavior.isExpanded() -> filter_bottom_sheet.sheetBehavior?.expand()
|
||||||
filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
else -> DisplayBottomSheet(this).show()
|
else -> DisplayBottomSheet(this).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1019,22 +1021,17 @@ class LibraryController(
|
|||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
closeTip()
|
closeTip()
|
||||||
when {
|
when {
|
||||||
filter_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> filter_bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior.isHidden() -> filter_bottom_sheet.sheetBehavior?.collapse()
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
!filter_bottom_sheet.sheetBehavior.isExpanded() -> filter_bottom_sheet.sheetBehavior?.expand()
|
||||||
filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> filter_bottom_sheet.sheetBehavior?.state =
|
else -> filter_bottom_sheet.sheetBehavior?.hide()
|
||||||
BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
filter_bottom_sheet.sheetBehavior?.isHideable == true -> filter_bottom_sheet.sheetBehavior?.state =
|
|
||||||
BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
else -> filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sheetIsExpanded(): Boolean = false
|
override fun sheetIsExpanded(): Boolean = false
|
||||||
|
|
||||||
override fun handleSheetBack(): Boolean {
|
override fun handleSheetBack(): Boolean {
|
||||||
val sheetBehavior = BottomSheetBehavior.from(filter_bottom_sheet)
|
if (filter_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
if (sheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED && sheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
|
filter_bottom_sheet.sheetBehavior?.collapse()
|
||||||
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -15,7 +15,11 @@ 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.collapse
|
||||||
|
import eu.kanade.tachiyomi.util.view.hide
|
||||||
import eu.kanade.tachiyomi.util.view.inflate
|
import eu.kanade.tachiyomi.util.view.inflate
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
|
import eu.kanade.tachiyomi.util.view.isHidden
|
||||||
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
|
||||||
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
|
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
|
||||||
@ -92,7 +96,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
if (preferences.hideFiltersAtStart().getOrDefault()) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
sheetBehavior?.hide()
|
||||||
}
|
}
|
||||||
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
|
hide_filters.isChecked = preferences.hideFiltersAtStart().getOrDefault()
|
||||||
hide_filters.setOnCheckedChangeListener { _, isChecked ->
|
hide_filters.setOnCheckedChangeListener { _, isChecked ->
|
||||||
@ -105,9 +109,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
}
|
}
|
||||||
|
|
||||||
val activeFilters = hasActiveFiltersFromPref()
|
val activeFilters = hasActiveFiltersFromPref()
|
||||||
if (activeFilters && sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN &&
|
if (activeFilters && sheetBehavior.isHidden() && sheetBehavior?.skipCollapsed == false)
|
||||||
sheetBehavior?.skipCollapsed == false)
|
sheetBehavior?.collapse()
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
|
|
||||||
post {
|
post {
|
||||||
updateRootPadding(
|
updateRootPadding(
|
||||||
@ -117,7 +120,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
else -> 0f
|
else -> 0f
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
shadow.alpha = if (sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN) 0f else 1f
|
shadow.alpha = if (sheetBehavior.isHidden()) 0f else 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
createTags()
|
createTags()
|
||||||
@ -151,7 +154,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
val minHeight = sheetBehavior?.peekHeight ?: 0
|
val minHeight = sheetBehavior?.peekHeight ?: 0
|
||||||
val maxHeight = height
|
val maxHeight = height
|
||||||
val trueProgress = progress
|
val trueProgress = progress
|
||||||
?: if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
?: if (sheetBehavior.isExpanded()) 1f else 0f
|
||||||
val percent = (trueProgress * 100).roundToInt()
|
val percent = (trueProgress * 100).roundToInt()
|
||||||
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
||||||
val height = context.resources.getDimensionPixelSize(R.dimen.rounder_radius)
|
val height = context.resources.getDimensionPixelSize(R.dimen.rounder_radius)
|
||||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
|||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcedureConfig
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.marginBottom
|
import eu.kanade.tachiyomi.util.view.marginBottom
|
||||||
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.updatePaddingRelative
|
||||||
@ -81,7 +82,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
|||||||
)
|
)
|
||||||
if (bottomSheet != null) {
|
if (bottomSheet != null) {
|
||||||
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet)
|
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet)
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.expand()
|
||||||
behavior.skipCollapsed = true
|
behavior.skipCollapsed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,11 @@ import eu.kanade.tachiyomi.util.system.hasSideNavBar
|
|||||||
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
|
import eu.kanade.tachiyomi.util.view.hide
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
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.updatePaddingRelative
|
||||||
@ -272,8 +275,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
bottomSheet?.show()
|
bottomSheet?.show()
|
||||||
if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (chapters_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
chapters_bottom_sheet.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -283,8 +286,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
* delegated to the presenter.
|
* delegated to the presenter.
|
||||||
*/
|
*/
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (chapters_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
chapters_bottom_sheet.sheetBehavior?.collapse()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
presenter.onBackPressed()
|
presenter.onBackPressed()
|
||||||
@ -336,8 +339,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
// Set initial visibility
|
// Set initial visibility
|
||||||
setMenuVisibility(menuVisible)
|
setMenuVisibility(menuVisible)
|
||||||
chapters_bottom_sheet.sheetBehavior?.isHideable = !menuVisible
|
chapters_bottom_sheet.sheetBehavior?.isHideable = !menuVisible
|
||||||
if (!menuVisible) chapters_bottom_sheet.sheetBehavior?.state =
|
if (!menuVisible) chapters_bottom_sheet.sheetBehavior?.hide()
|
||||||
BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
val peek = chapters_bottom_sheet.sheetBehavior?.peekHeight ?: 30.dpToPx
|
val peek = chapters_bottom_sheet.sheetBehavior?.peekHeight ?: 30.dpToPx
|
||||||
reader_layout.doOnApplyWindowInsets { v, insets, _ ->
|
reader_layout.doOnApplyWindowInsets { v, insets, _ ->
|
||||||
sheetManageNavColor = when {
|
sheetManageNavColor = when {
|
||||||
@ -386,11 +388,11 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
systemUi?.show()
|
systemUi?.show()
|
||||||
appbar.visible()
|
appbar.visible()
|
||||||
|
|
||||||
if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (chapters_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
chapters_bottom_sheet.sheetBehavior?.isHideable = false
|
chapters_bottom_sheet.sheetBehavior?.isHideable = false
|
||||||
}
|
}
|
||||||
if (chapters_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED && sheetManageNavColor) {
|
if (!chapters_bottom_sheet.sheetBehavior.isExpanded() && sheetManageNavColor) {
|
||||||
window.navigationBarColor = Color.TRANSPARENT // getResourceColor(R.attr.colorPrimaryDark)
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
if (animate) {
|
if (animate) {
|
||||||
if (!menuStickyVisible) {
|
if (!menuStickyVisible) {
|
||||||
@ -402,7 +404,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
})
|
})
|
||||||
appbar.startAnimation(toolbarAnimation)
|
appbar.startAnimation(toolbarAnimation)
|
||||||
}
|
}
|
||||||
BottomSheetBehavior.from(chapters_bottom_sheet).state = BottomSheetBehavior.STATE_COLLAPSED
|
chapters_bottom_sheet.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
systemUi?.hide()
|
systemUi?.hide()
|
||||||
@ -416,8 +418,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
})
|
})
|
||||||
appbar.startAnimation(toolbarAnimation)
|
appbar.startAnimation(toolbarAnimation)
|
||||||
BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true
|
BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true
|
||||||
BottomSheetBehavior.from(chapters_bottom_sheet).state =
|
chapters_bottom_sheet.sheetBehavior?.hide()
|
||||||
BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
} else {
|
} else {
|
||||||
appbar.gone()
|
appbar.gone()
|
||||||
}
|
}
|
||||||
@ -553,8 +554,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
if (config?.showNewChapter == false) {
|
if (config?.showNewChapter == false) {
|
||||||
systemUi?.show()
|
systemUi?.show()
|
||||||
}
|
}
|
||||||
} else if (chapters_bottom_sheet.shouldCollaspe && chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
} else if (chapters_bottom_sheet.shouldCollaspe && chapters_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
chapters_bottom_sheet.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
if (chapters_bottom_sheet.selectedChapterId != page.chapter.chapter.id) {
|
if (chapters_bottom_sheet.selectedChapterId != page.chapter.chapter.id) {
|
||||||
chapters_bottom_sheet.refreshList()
|
chapters_bottom_sheet.refreshList()
|
||||||
@ -572,8 +573,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
|
|||||||
*/
|
*/
|
||||||
fun onPageLongTap(page: ReaderPage) {
|
fun onPageLongTap(page: ReaderPage) {
|
||||||
ReaderPageSheet(this, page).show()
|
ReaderPageSheet(this, page).show()
|
||||||
if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (chapters_bottom_sheet.sheetBehavior.isExpanded()) {
|
||||||
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
chapters_bottom_sheet.sheetBehavior?.collapse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import kotlinx.android.synthetic.main.reader_chapters_sheet.view.*
|
import kotlinx.android.synthetic.main.reader_chapters_sheet.view.*
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -39,18 +42,15 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(this)
|
sheetBehavior = BottomSheetBehavior.from(this)
|
||||||
chapters_button.setOnClickListener {
|
chapters_button.setOnClickListener {
|
||||||
if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (sheetBehavior.isExpanded()) {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior?.collapse()
|
||||||
} else {
|
} else {
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
chapter_recycler.alpha = when (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
chapter_recycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f
|
||||||
true -> 1f
|
|
||||||
false -> 0f
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
@ -112,7 +112,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
|||||||
})
|
})
|
||||||
|
|
||||||
backgroundTintList = ColorStateList.valueOf(
|
backgroundTintList = ColorStateList.valueOf(
|
||||||
if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) primary
|
if (!sheetBehavior.isExpanded()) primary
|
||||||
else fullPrimary
|
else fullPrimary
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ 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.util.lang.plusAssign
|
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||||
import eu.kanade.tachiyomi.util.system.hasSideNavBar
|
import eu.kanade.tachiyomi.util.system.hasSideNavBar
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
||||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||||
@ -157,7 +158,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
sheetBehavior?.skipCollapsed = true
|
sheetBehavior?.skipCollapsed = true
|
||||||
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
override fun onDetachedFromWindow() {
|
||||||
|
@ -39,6 +39,8 @@ import eu.kanade.tachiyomi.ui.recently_read.RemoveHistoryDialog
|
|||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.requestPermissionsSafe
|
import eu.kanade.tachiyomi.util.view.requestPermissionsSafe
|
||||||
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
|
||||||
@ -201,7 +203,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (showingDownloads) {
|
if (showingDownloads) {
|
||||||
dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
dl_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
|
setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
|
||||||
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
||||||
@ -431,16 +433,15 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
|
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
if (dl_bottom_sheet.sheetBehavior?.isHideable == false || hasQueue())
|
if (dl_bottom_sheet.sheetBehavior?.isHideable == false || hasQueue())
|
||||||
dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
dl_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (showingDownloads) dl_bottom_sheet.dismiss()
|
if (showingDownloads) dl_bottom_sheet.dismiss()
|
||||||
else dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
else dl_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sheetIsExpanded(): Boolean = dl_bottom_sheet.sheetBehavior?.state ==
|
override fun sheetIsExpanded(): Boolean = dl_bottom_sheet.sheetBehavior.isExpanded()
|
||||||
BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
|
|
||||||
override fun expandSearch() {
|
override fun expandSearch() {
|
||||||
if (showingDownloads) {
|
if (showingDownloads) {
|
||||||
|
@ -33,6 +33,10 @@ import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
|||||||
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
|
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
|
||||||
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
|
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.isCollapsed
|
||||||
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.requestPermissionsSafe
|
import eu.kanade.tachiyomi.util.view.requestPermissionsSafe
|
||||||
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
|
||||||
@ -169,28 +173,27 @@ class SourceController : NucleusController<SourcePresenter>(),
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (showingExtensions) {
|
if (showingExtensions) {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
ext_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
ext_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
if (!ext_bottom_sheet.sheetBehavior.isCollapsed()) {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
ext_bottom_sheet.sheetBehavior?.collapse()
|
||||||
} else {
|
} else {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
ext_bottom_sheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sheetIsExpanded(): Boolean = ext_bottom_sheet.sheetBehavior?.state ==
|
override fun sheetIsExpanded(): Boolean = ext_bottom_sheet.sheetBehavior.isExpanded()
|
||||||
BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
|
|
||||||
override fun handleSheetBack(): Boolean {
|
override fun handleSheetBack(): Boolean {
|
||||||
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
if (!ext_bottom_sheet.sheetBehavior.isCollapsed()) {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
ext_bottom_sheet.sheetBehavior?.collapse()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -279,8 +282,7 @@ class SourceController : NucleusController<SourcePresenter>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun expandSearch() {
|
override fun expandSearch() {
|
||||||
if (showingExtensions)
|
if (showingExtensions) ext_bottom_sheet.sheetBehavior?.collapse()
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
else activity?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
else activity?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
||||||
import kotlinx.android.synthetic.main.source_filter_sheet.*
|
import kotlinx.android.synthetic.main.source_filter_sheet.*
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -51,7 +52,7 @@ class SourceSearchSheet(activity: Activity) :
|
|||||||
|
|
||||||
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
||||||
sheetBehavior.skipCollapsed = true
|
sheetBehavior.skipCollapsed = true
|
||||||
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
sheetBehavior.expand()
|
||||||
setEdgeToEdge(
|
setEdgeToEdge(
|
||||||
activity, view, 50.dpToPx
|
activity, view, 50.dpToPx
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package eu.kanade.tachiyomi.util.view
|
||||||
|
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN
|
||||||
|
|
||||||
|
fun BottomSheetBehavior<*>.hide() {
|
||||||
|
state = STATE_HIDDEN
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BottomSheetBehavior<*>.collapse() {
|
||||||
|
state = STATE_COLLAPSED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BottomSheetBehavior<*>.expand() {
|
||||||
|
state = STATE_EXPANDED
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BottomSheetBehavior<*>?.isExpanded() = this?.state == STATE_EXPANDED
|
||||||
|
fun BottomSheetBehavior<*>?.isCollapsed() = this?.state == STATE_COLLAPSED
|
||||||
|
fun BottomSheetBehavior<*>?.isHidden() = this?.state == STATE_HIDDEN
|
@ -3,13 +3,11 @@ package eu.kanade.tachiyomi.util.view
|
|||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.math.MathUtils
|
import androidx.core.math.MathUtils
|
||||||
@ -57,7 +55,6 @@ fun Controller.setOnQueryTextChangeListener(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
|
||||||
fun Controller.scrollViewWith(
|
fun Controller.scrollViewWith(
|
||||||
recycler: RecyclerView,
|
recycler: RecyclerView,
|
||||||
padBottom: Boolean = false,
|
padBottom: Boolean = false,
|
||||||
@ -81,11 +78,10 @@ fun Controller.scrollViewWith(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val randomTag = Random.nextLong()
|
val randomTag = Random.nextLong()
|
||||||
var headerHeight = 0
|
|
||||||
var lastY = 0f
|
var lastY = 0f
|
||||||
var fakeToolbarView: View? = null
|
var fakeToolbarView: View? = null
|
||||||
recycler.doOnApplyWindowInsets { view, insets, _ ->
|
recycler.doOnApplyWindowInsets { view, insets, _ ->
|
||||||
headerHeight = insets.systemWindowInsetTop + appBarHeight
|
val headerHeight = insets.systemWindowInsetTop + appBarHeight
|
||||||
if (!customPadding) view.updatePaddingRelative(
|
if (!customPadding) view.updatePaddingRelative(
|
||||||
top = headerHeight,
|
top = headerHeight,
|
||||||
bottom = if (padBottom) insets.systemWindowInsetBottom else view.paddingBottom
|
bottom = if (padBottom) insets.systemWindowInsetBottom else view.paddingBottom
|
||||||
|
Loading…
Reference in New Issue
Block a user