From 3fa70dade3dc24c2394d9fa047c06379bda99b67 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 22 Nov 2020 15:13:12 -0500 Subject: [PATCH] Use ViewCompat for setting MainActivity inset paddings --- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index b2628da1b..d3174d649 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -9,6 +9,8 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.isVisible import androidx.core.view.marginBottom import androidx.core.view.updateLayoutParams @@ -90,15 +92,17 @@ class MainActivity : BaseActivity() { // Inset paddings when drawing edge-to-edge in Android 9+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - binding.bottomNav.setOnApplyWindowInsetsListener { view, insets -> - view.updatePadding(bottom = insets.systemWindowInsetBottom) + ViewCompat.setOnApplyWindowInsetsListener(binding.bottomNav) { view, insets -> + val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + view.updatePadding(bottom = systemInsets.bottom) insets } val initialFabBottomMargin = binding.rootFab.marginBottom - binding.rootFab.setOnApplyWindowInsetsListener { view, insets -> + ViewCompat.setOnApplyWindowInsetsListener(binding.rootFab) { view, insets -> + val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) view.updateLayoutParams { - bottomMargin = initialFabBottomMargin + insets.systemWindowInsetBottom + bottomMargin = initialFabBottomMargin + systemInsets.bottom } insets }