From ef166dd712626c0cbb7cab964f5505210326cb24 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 13 Jul 2021 19:26:42 -0400 Subject: [PATCH] Fix insets in landscape for browse and recents --- .../tachiyomi/ui/recents/RecentsController.kt | 17 ++++++++++++----- .../tachiyomi/ui/source/BrowseController.kt | 7 +++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index ad5718d65e..1242f4a1cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -10,6 +10,7 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import android.view.WindowInsets import androidx.appcompat.widget.SearchView import androidx.core.graphics.ColorUtils import androidx.core.view.isVisible @@ -402,6 +403,7 @@ class RecentsController(bundle: Bundle? = null) : binding.downloadBottomSheet.downloadFab.updateLayoutParams { bottomMargin = max(-pad.toInt(), view?.rootWindowInsets?.systemWindowInsetBottom ?: 0) + 16.dpToPx } + setPadding(binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true) } fun setRefreshing(refresh: Boolean) { @@ -429,11 +431,16 @@ class RecentsController(bundle: Bundle? = null) : return false } - fun setPadding(sheetIsHidden: Boolean) { - binding.recycler.updatePaddingRelative(bottom = if (sheetIsHidden) 0 else 20.dpToPx) - binding.recycler.updateLayoutParams { - bottomMargin = if (sheetIsHidden) 0 else 30.dpToPx - } + fun setPadding(sheetIsHidden: Boolean, insets: WindowInsets? = null) { + val peekHeight = binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.peekHeight ?: 0 + val cInsets = insets ?: view?.rootWindowInsets ?: return + binding.recycler.updatePaddingRelative( + bottom = if (sheetIsHidden) { + activityBinding?.bottomNav?.height ?: cInsets.systemWindowInsetBottom + } else { + peekHeight + } + ) } override fun onActivityResumed(activity: Activity) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt index fd2782e594..eed9a156f0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt @@ -143,7 +143,7 @@ class BrowseController : headerHeight = it.systemWindowInsetTop + appBarHeight binding.sourceRecycler.updatePaddingRelative( top = headerHeight, - bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx + bottom = (activityBinding?.bottomNav?.height ?: it.getBottomGestureInsets()) + 58.spToPx ) if (activityBinding?.bottomNav == null) { setBottomPadding() @@ -299,7 +299,10 @@ class BrowseController : bottomMargin = -pad.toInt() } binding.sourceRecycler.updatePaddingRelative( - bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx + bottom = ( + activityBinding?.bottomNav?.height + ?: view?.rootWindowInsets?.getBottomGestureInsets() ?: 0 + ) + 58.spToPx ) }