mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 06:31:47 +01:00
Using a helper to get the toolbar height
since there's 2, one of them might be hidden and have a height of 0
This commit is contained in:
parent
798c93b44b
commit
f473e46c92
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.databinding.DownloadBottomSheetBinding
|
||||
import eu.kanade.tachiyomi.ui.extension.ExtensionDividerItemDecoration
|
||||
import eu.kanade.tachiyomi.ui.recents.RecentsController
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
import eu.kanade.tachiyomi.util.view.collapse
|
||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.view.expand
|
||||
@ -21,6 +20,7 @@ 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.toolbarHeight
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
|
||||
class DownloadBottomSheet @JvmOverloads constructor(
|
||||
@ -74,7 +74,7 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
||||
binding.recyclerLayout.doOnApplyWindowInsets { v, windowInsets, _ ->
|
||||
v.updateLayoutParams<MarginLayoutParams> {
|
||||
topMargin = windowInsets.systemWindowInsetTop +
|
||||
(controller.activityBinding?.toolbar?.height ?: headerHeight) -
|
||||
(controller.toolbarHeight ?: headerHeight) -
|
||||
binding.sheetLayout.height
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
|
||||
open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceListener {
|
||||
|
||||
@ -129,6 +130,9 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
||||
extraViewForUndo = extraViewToCheck
|
||||
}
|
||||
|
||||
val toolbarHeight: Int
|
||||
get() = max(binding.toolbar.height, binding.cardFrame.height)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// Create a webview before extensions do or else they will break night mode theme
|
||||
// https://stackoverflow.com/questions/54191883
|
||||
|
@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.math.max
|
||||
|
||||
class OverflowDialog(activity: MainActivity) : Dialog(activity, R.style.OverflowDialogTheme) {
|
||||
|
||||
@ -77,7 +76,7 @@ class OverflowDialog(activity: MainActivity) : Dialog(activity, R.style.Overflow
|
||||
}
|
||||
|
||||
binding.overflowCardView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = max(activity.binding.toolbar.height, activity.binding.cardFrame.height) - 2.dpToPx
|
||||
topMargin = activity.toolbarHeight - 2.dpToPx
|
||||
}
|
||||
window?.let { window ->
|
||||
window.navigationBarColor = Color.TRANSPARENT
|
||||
|
@ -51,6 +51,7 @@ import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||
import eu.kanade.tachiyomi.util.view.setStyle
|
||||
import eu.kanade.tachiyomi.util.view.smoothScrollToTop
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.toolbarHeight
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
@ -151,7 +152,7 @@ class RecentsController(bundle: Bundle? = null) :
|
||||
afterInsets = {
|
||||
headerHeight = it.systemWindowInsetTop + appBarHeight + 48.dpToPx
|
||||
binding.fakeAppBar.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
height = it.systemWindowInsetTop + (activityBinding?.toolbar?.height ?: appBarHeight)
|
||||
height = it.systemWindowInsetTop + (toolbarHeight ?: appBarHeight)
|
||||
}
|
||||
binding.recycler.updatePaddingRelative(
|
||||
bottom = activityBinding?.bottomNav?.height ?: 0
|
||||
|
@ -21,13 +21,12 @@ import eu.kanade.tachiyomi.ui.main.SearchActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.util.addOrRemoveToFavorites
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.toolbarHeight
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* This controller shows and manages the different search result in global search.
|
||||
@ -182,7 +181,7 @@ open class GlobalSearchController(
|
||||
adapter = GlobalSearchAdapter(this)
|
||||
|
||||
binding.recycler.updatePaddingRelative(
|
||||
top = max(activityBinding?.toolbar?.height ?: 0, (activityBinding?.cardToolbar?.height ?: 0)) +
|
||||
top = (toolbarHeight ?: 0) +
|
||||
(activity?.window?.decorView?.rootWindowInsets?.systemWindowInsetTop ?: 0)
|
||||
)
|
||||
|
||||
|
@ -90,13 +90,13 @@ fun Controller.liftAppbarWith(recycler: RecyclerView, padView: Boolean = false)
|
||||
val attrsArray = intArrayOf(R.attr.actionBarSize)
|
||||
val array = recycler.context.obtainStyledAttributes(attrsArray)
|
||||
var appBarHeight = (
|
||||
if (activityBinding?.toolbar?.height ?: 0 > 0) activityBinding!!.toolbar.height
|
||||
if (toolbarHeight ?: 0 > 0) toolbarHeight!!
|
||||
else array.getDimensionPixelSize(0, 0)
|
||||
)
|
||||
array.recycle()
|
||||
activityBinding!!.toolbar.post {
|
||||
if (activityBinding!!.toolbar.height > 0) {
|
||||
appBarHeight = activityBinding!!.toolbar.height
|
||||
if (toolbarHeight!! > 0) {
|
||||
appBarHeight = toolbarHeight!!
|
||||
recycler.requestApplyInsets()
|
||||
}
|
||||
}
|
||||
@ -174,14 +174,14 @@ fun Controller.scrollViewWith(
|
||||
val attrsArray = intArrayOf(R.attr.actionBarSize)
|
||||
val array = recycler.context.obtainStyledAttributes(attrsArray)
|
||||
var appBarHeight = (
|
||||
if (activityBinding?.toolbar?.height ?: 0 > 0) activityBinding!!.toolbar.height
|
||||
if (toolbarHeight ?: 0 > 0) toolbarHeight!!
|
||||
else array.getDimensionPixelSize(0, 0)
|
||||
) + if (includeTabView) tabBarHeight else 0
|
||||
array.recycle()
|
||||
swipeRefreshLayout?.setDistanceToTriggerSync(150.dpToPx)
|
||||
activityBinding!!.toolbar.post {
|
||||
if (activityBinding!!.toolbar.height > 0) {
|
||||
appBarHeight = activityBinding!!.toolbar.height + if (includeTabView) tabBarHeight else 0
|
||||
if (toolbarHeight!! > 0) {
|
||||
appBarHeight = toolbarHeight!! + if (includeTabView) tabBarHeight else 0
|
||||
recycler.requestApplyInsets()
|
||||
}
|
||||
}
|
||||
@ -460,3 +460,6 @@ fun Controller.openInBrowser(url: String) {
|
||||
|
||||
val Controller.activityBinding: MainActivityBinding?
|
||||
get() = (activity as? MainActivity)?.binding
|
||||
|
||||
val Controller.toolbarHeight: Int?
|
||||
get() = (activity as? MainActivity)?.toolbarHeight
|
||||
|
Loading…
Reference in New Issue
Block a user