Fixed bottom sheets in recents/browse ignoring insets on lower devices

This commit is contained in:
Jays2Kings 2021-07-12 14:05:13 -04:00
parent 53ade52487
commit e0e6ffb6d8
2 changed files with 18 additions and 10 deletions

View File

@ -44,6 +44,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.recents.options.TabbedRecentsOptionsSheet import eu.kanade.tachiyomi.ui.recents.options.TabbedRecentsOptionsSheet
import eu.kanade.tachiyomi.ui.source.browse.ProgressItem import eu.kanade.tachiyomi.ui.source.browse.ProgressItem
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getBottomGestureInsets
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.spToPx import eu.kanade.tachiyomi.util.system.spToPx
import eu.kanade.tachiyomi.util.system.toInt import eu.kanade.tachiyomi.util.system.toInt
@ -172,6 +173,9 @@ class RecentsController(bundle: Bundle? = null) :
topMargin = headerHeight topMargin = headerHeight
bottomMargin = activityBinding?.bottomNav?.height ?: it.systemWindowInsetBottom bottomMargin = activityBinding?.bottomNav?.height ?: it.systemWindowInsetBottom
} }
if (activityBinding?.bottomNav == null) {
setBottomPadding()
}
}, },
onBottomNavUpdate = { onBottomNavUpdate = {
setBottomPadding() setBottomPadding()
@ -368,6 +372,8 @@ class RecentsController(bundle: Bundle? = null) :
} }
setPadding(binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true) setPadding(binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true)
requestFilePermissionsSafe(301, presenter.preferences) requestFilePermissionsSafe(301, presenter.preferences)
binding.downloadBottomSheet.root.sheetBehavior?.isGestureInsetBottomIgnored = true
} }
fun updateTitleAndMenu() { fun updateTitleAndMenu() {
@ -378,13 +384,11 @@ class RecentsController(bundle: Bundle? = null) :
} }
private fun setBottomPadding() { private fun setBottomPadding() {
val bottomBar = activityBinding?.bottomNav ?: return val bottomBar = activityBinding?.bottomNav
val pad = bottomBar.translationY - bottomBar.height val pad = bottomBar?.translationY?.minus(bottomBar.height) ?: 0f
val padding = max( val padding = max(
(-pad).toInt(), (-pad).toInt(),
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior.isExpanded()) 0 else { view?.rootWindowInsets?.getBottomGestureInsets() ?: 0
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
}
) )
binding.shadow2.translationY = pad binding.shadow2.translationY = pad
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.peekHeight = 48.spToPx + padding binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.peekHeight = 48.spToPx + padding

View File

@ -39,6 +39,7 @@ import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getBottomGestureInsets
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.spToPx import eu.kanade.tachiyomi.util.system.spToPx
@ -144,6 +145,9 @@ class BrowseController :
top = headerHeight, top = headerHeight,
bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx
) )
if (activityBinding?.bottomNav == null) {
setBottomPadding()
}
}, },
onBottomNavUpdate = { onBottomNavUpdate = {
setBottomPadding() setBottomPadding()
@ -163,6 +167,8 @@ class BrowseController :
requestFilePermissionsSafe(301, preferences) requestFilePermissionsSafe(301, preferences)
binding.bottomSheet.root.onCreate(this) binding.bottomSheet.root.onCreate(this)
binding.bottomSheet.root.sheetBehavior?.isGestureInsetBottomIgnored = true
binding.shadow.alpha = binding.shadow.alpha =
if (binding.bottomSheet.root.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f if (binding.bottomSheet.root.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f
@ -278,13 +284,11 @@ class BrowseController :
} }
private fun setBottomPadding() { private fun setBottomPadding() {
val bottomBar = activityBinding?.bottomNav ?: return val bottomBar = activityBinding?.bottomNav
val pad = bottomBar.translationY - bottomBar.height val pad = bottomBar?.translationY?.minus(bottomBar.height) ?: 0f
val padding = max( val padding = max(
(-pad).toInt(), (-pad).toInt(),
if (binding.bottomSheet.root.sheetBehavior.isExpanded()) 0 else { view?.rootWindowInsets?.getBottomGestureInsets() ?: 0
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
}
) )
binding.shadow2.translationY = pad binding.shadow2.translationY = pad
binding.bottomSheet.root.sheetBehavior?.peekHeight = 56.spToPx + padding binding.bottomSheet.root.sheetBehavior?.peekHeight = 56.spToPx + padding