Browse Source

ui: Handle navbar insets properly

Peter Cai 1 year ago
parent
commit
42942c2816

+ 3 - 6
app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt

@@ -49,12 +49,9 @@ class SettingsFragment: PreferenceFragmentCompat() {
             ?.bindBooleanFlow(preferenceRepository.disableSafeguardFlow, PreferenceKeys.DISABLE_SAFEGUARD_REMOVABLE_ESIM)
     }
 
-    override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
-    ): View {
-        return super.onCreateView(inflater, container, savedInstanceState).also(::setupRootViewInsets)
+    override fun onStart() {
+        super.onStart()
+        setupRootViewInsets(requireView().requireViewById(androidx.preference.R.id.recycler_view))
     }
 
     private fun CheckBoxPreference.bindBooleanFlow(flow: Flow<Boolean>, key: Preferences.Key<Boolean>) {

+ 4 - 3
app-common/src/main/java/im/angry/openeuicc/util/UiUtils.kt

@@ -56,15 +56,16 @@ fun AppCompatActivity.setupToolbarInsets() {
     }
 }
 
-fun setupRootViewInsets(view: View) {
+fun setupRootViewInsets(view: ViewGroup) {
+    // Disable clipToPadding to make sure content actually display
+    view.clipToPadding = false
     ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
         val bars = insets.getInsets(
             WindowInsetsCompat.Type.systemBars()
                     or WindowInsetsCompat.Type.displayCutout()
         )
 
-        // Don't set padding bottom because we do want scrolling root views to extend into nav bar
-        v.updatePadding(bars.left, v.paddingTop, bars.right, v.paddingBottom)
+        v.updatePadding(bars.left, v.paddingTop, bars.right, bars.bottom)
 
         WindowInsetsCompat.CONSUMED
     }