Pad bottom of settings list view with bottom system insets

This change allows for a transparent navigation bar in the settings Material next redesign.

Test: Bottom of settings not cut off by bottom navigation bar
Bug: 187732263
Change-Id: I237011003ca0c3760c0fbdbb2865ef90c19d7b81
diff --git a/res/layout/settings_activity.xml b/res/layout/settings_activity.xml
index c70d5bf..5edd2df 100644
--- a/res/layout/settings_activity.xml
+++ b/res/layout/settings_activity.xml
@@ -18,7 +18,8 @@
     android:id="@+id/content_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:fitsSystemWindows="true">
 
     <Toolbar
         android:id="@+id/action_bar"
diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
index e2a69ff..8fe42ac 100644
--- a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
+++ b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
@@ -152,6 +152,17 @@
                 filterPreferences(query, mPreferenceScreen);
             }
         });
+
+        View listView = getListView();
+        final int bottomPadding = listView.getPaddingBottom();
+        listView.setOnApplyWindowInsetsListener((v, insets) -> {
+            v.setPadding(
+                    v.getPaddingLeft(),
+                    v.getPaddingTop(),
+                    v.getPaddingRight(),
+                    bottomPadding + insets.getSystemWindowInsetBottom());
+            return insets.consumeSystemWindowInsets();
+        });
     }
 
     @Override
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 05927ef..d754ed2 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -24,9 +24,11 @@
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.text.TextUtils;
+import android.view.View;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
+import androidx.core.view.WindowCompat;
 import androidx.fragment.app.DialogFragment;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
@@ -82,6 +84,7 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.settings_activity);
         setActionBar(findViewById(R.id.action_bar));
+        WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
 
         if (savedInstanceState == null) {
             Intent intent = getIntent();
@@ -199,6 +202,21 @@
         }
 
         @Override
+        public void onViewCreated(View view, Bundle savedInstanceState) {
+            super.onViewCreated(view, savedInstanceState);
+            View listView = getListView();
+            final int bottomPadding = listView.getPaddingBottom();
+            listView.setOnApplyWindowInsetsListener((v, insets) -> {
+                v.setPadding(
+                        v.getPaddingLeft(),
+                        v.getPaddingTop(),
+                        v.getPaddingRight(),
+                        bottomPadding + insets.getSystemWindowInsetBottom());
+                return insets.consumeSystemWindowInsets();
+            });
+        }
+
+        @Override
         public void onSaveInstanceState(Bundle outState) {
             super.onSaveInstanceState(outState);
             outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mPreferenceHighlighted);