From 2106751ea4d5d778bc8bd60d008669663666837a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=8B=E9=A1=B5?= <31466456+canyie@users.noreply.github.com> Date: Fri, 3 Jun 2022 18:21:56 +0800 Subject: [PATCH] Fix SnackBar shows behind window insets --- .../com/topjohnwu/magisk/arch/BaseFragment.kt | 1 + .../com/topjohnwu/magisk/ui/MainActivity.kt | 5 +++ .../topjohnwu/magisk/ui/log/LogFragment.kt | 3 ++ .../magisk/ui/settings/SettingsFragment.kt | 1 + .../main/res/layout/fragment_settings_md2.xml | 39 ++++++++++++------- .../main/res/layout/include_log_superuser.xml | 6 +++ 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt index 227dee6f6..7891a4ed9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseFragment.kt @@ -20,6 +20,7 @@ abstract class BaseFragment : Fragment(), ViewModelHo protected abstract val layoutRes: Int private val navigation get() = activity?.navigation + open val snackbarView: View? get() = null open val snackbarAnchorView: View? get() = null override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt index 38b75b851..32d9baaa0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt @@ -36,6 +36,11 @@ class MainActivity : BaseMainActivity() { override val layoutRes = R.layout.activity_main_md2 override val viewModel by viewModel() override val navHostId: Int = R.id.main_nav_host + override val snackbarView: View + get() { + val fragmentOverride = currentFragment?.snackbarView + return fragmentOverride ?: super.snackbarView + } override val snackbarAnchorView: View? get() { val fragmentAnchor = currentFragment?.snackbarAnchorView diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt index afc6f6ce5..d20fb7c11 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt @@ -20,6 +20,9 @@ class LogFragment : BaseFragment() { override val layoutRes = R.layout.fragment_log_md2 override val viewModel by viewModel() + override val snackbarView: View? + get() = if (isMagiskLogVisible) binding.logFilterSuperuser.snackbarContainer + else super.snackbarView override val snackbarAnchorView get() = binding.logFilterToggle private var actionSave: MenuItem? = null diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt index 2da40183d..a41f7b72f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt @@ -14,6 +14,7 @@ class SettingsFragment : BaseFragment() { override val layoutRes = R.layout.fragment_settings_md2 override val viewModel by viewModel() + override val snackbarView: View get() = binding.snackbarContainer override fun onStart() { super.onStart() diff --git a/app/src/main/res/layout/fragment_settings_md2.xml b/app/src/main/res/layout/fragment_settings_md2.xml index c28e319ee..c06570d00 100644 --- a/app/src/main/res/layout/fragment_settings_md2.xml +++ b/app/src/main/res/layout/fragment_settings_md2.xml @@ -13,20 +13,31 @@ - + android:layout_height="match_parent"> + + + + + diff --git a/app/src/main/res/layout/include_log_superuser.xml b/app/src/main/res/layout/include_log_superuser.xml index e62903c2d..29585642e 100644 --- a/app/src/main/res/layout/include_log_superuser.xml +++ b/app/src/main/res/layout/include_log_superuser.xml @@ -43,6 +43,12 @@ + +