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