OmniControl: make it scroll with header

Change-Id: I52a1e92d42d2f2756cdf283ee0b25cae415c7be2
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
deleted file mode 100644
index b8aa29d..0000000
--- a/.idea/deploymentTargetDropDown.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="deploymentTargetDropDown">
-    <targetSelectedWithDropDown>
-      <Target>
-        <type value="QUICK_BOOT_TARGET" />
-        <deviceKey>
-          <Key>
-            <type value="VIRTUAL_DEVICE_PATH" />
-            <value value="$USER_HOME$/.android/avd/Pixel_3a_API_31.avd" />
-          </Key>
-        </deviceKey>
-      </Target>
-    </targetSelectedWithDropDown>
-    <timeTargetWasSelectedWithDropDown value="2021-11-21T13:03:38.339749Z" />
-  </component>
-</project>
\ No newline at end of file
diff --git a/.idea/render.experimental.xml b/.idea/render.experimental.xml
new file mode 100644
index 0000000..8ec256a
--- /dev/null
+++ b/.idea/render.experimental.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RenderSettings">
+    <option name="showDecorations" value="true" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 1046e50..bd24cb3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -33,6 +33,11 @@
     kotlinOptions {
         jvmTarget = '1.8'
     }
+    sourceSets {
+        main {
+            res.srcDirs = ['src/main/res', 'src/main/res-private']
+        }
+    }
 }
 
 dependencies {
@@ -42,4 +47,7 @@
     implementation 'com.google.android.material:material:1.6.1'
     implementation 'androidx.preference:preference:1.2.0'
     implementation 'androidx.recyclerview:recyclerview:1.2.1'
+    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
+    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
+    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
 }
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f149f41..81146e4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -34,4 +34,4 @@
         </activity>
     </application>
 
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/app/src/main/java/org/omnirom/control/AbstractSettingsFragment.kt b/app/src/main/java/org/omnirom/control/AbstractSettingsFragment.kt
index 53cc3f0..bffe8da 100644
--- a/app/src/main/java/org/omnirom/control/AbstractSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/AbstractSettingsFragment.kt
@@ -18,6 +18,7 @@
 package org.omnirom.control
 
 import android.os.Bundle
+import android.view.View
 import androidx.appcompat.app.AppCompatActivity
 import androidx.preference.PreferenceFragmentCompat
 import org.omnirom.omnilib.preference.SecureCheckBoxPreference
@@ -44,12 +45,18 @@
 
     override fun onResume() {
         super.onResume()
-        (activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
-        (activity as? SettingsActivity)?.updateFragmentTitle(
-            getFragmentTitle(),
-            getFragmentSummary(),
-            getFragmentIcon(),
-            false
-        )
+        (activity as? AppCompatActivity)?.let {
+            it.supportActionBar?.setDisplayHomeAsUpEnabled(true)
+            it.supportActionBar?.show()
+        }
+        (activity as SettingsActivity)?.let {
+            it.toolbarPlaceHolder.visibility = View.GONE
+            it.updateFragmentTitle(
+                getFragmentTitle(),
+                getFragmentSummary(),
+                getFragmentIcon(),
+                false
+            )
+        }
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/AppListFragment.kt b/app/src/main/java/org/omnirom/control/AppListFragment.kt
index 9170d1c..c603d8f 100644
--- a/app/src/main/java/org/omnirom/control/AppListFragment.kt
+++ b/app/src/main/java/org/omnirom/control/AppListFragment.kt
@@ -126,7 +126,7 @@
         }
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         if (preference?.key != null) {
             var app: Application? = appManager.getAppOfPackage(preference.key)
             if (app != null) {
diff --git a/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt b/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
index 05ee9ba..c69ba4d 100644
--- a/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/BarsSettingsFragment.kt
@@ -53,7 +53,7 @@
         }
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
 
diff --git a/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
index 7f27eb4..962487a 100644
--- a/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
+++ b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
@@ -233,4 +233,4 @@
             mFastColorPref.updateColor();
         }
     }
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt b/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt
index 670f4f6..ba60c30 100644
--- a/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/ButtonSettingsFragment.kt
@@ -70,7 +70,7 @@
         }
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt b/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt
index 4a10cb5..5762e1a 100644
--- a/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/DialerSettingsFragment.kt
@@ -42,7 +42,7 @@
         setPreferencesFromResource(R.xml.dialer_settings_preferences, rootKey)
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
 }
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index 4330acc..1e9f4b5 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -223,16 +223,16 @@
         if (Utils.isAvailableApp(requireContext(), "org.omnirom.omniremote")) {
             val intent = Intent()
             intent.component = ComponentName(
-                    "org.omnirom.omniremote",
-                    "org.omnirom.omniremote.MainActivity"
+                "org.omnirom.omniremote",
+                "org.omnirom.omniremote.MainActivity"
             )
             gridItems.add(
-                    IntentGridItem(
-                            R.string.omni_remote_title,
-                            R.string.omni_remote_summary,
-                            R.drawable.ic_remote,
-                            intent
-                    )
+                IntentGridItem(
+                    R.string.omni_remote_title,
+                    R.string.omni_remote_summary,
+                    R.drawable.ic_remote,
+                    intent
+                )
             )
         }
         if (Utils.isAvailableApp(requireContext(), "org.omnirom.omnistore")) {
@@ -250,7 +250,11 @@
                 )
             )
         }
-        if (Utils.isAvailableApp(requireContext(), "org.omnirom.omnistoreinstaller") && !Utils.isAvailableApp(requireContext(), "org.omnirom.omnistore")) {
+        if (Utils.isAvailableApp(
+                requireContext(),
+                "org.omnirom.omnistoreinstaller"
+            ) && !Utils.isAvailableApp(requireContext(), "org.omnirom.omnistore")
+        ) {
             val intent = Intent()
             intent.component = ComponentName(
                 "org.omnirom.omnistoreinstaller",
@@ -283,13 +287,20 @@
 
     override fun onResume() {
         super.onResume()
-        (activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(false)
-        (activity as? SettingsActivity)?.updateFragmentTitle(
-            resources.getString(R.string.app_name),
-            "",
-            0,
-            true
-        )
+        (activity as? AppCompatActivity)?.let {
+            it.supportActionBar?.setDisplayHomeAsUpEnabled(false)
+            it.supportActionBar?.hide()
+        }
+        (activity as SettingsActivity)?.let {
+            it.toolbarPlaceHolder.visibility = View.VISIBLE
+            it.updateFragmentTitle(
+                resources.getString(R.string.app_name),
+                "",
+                0,
+                true
+            )
+        }
+
         createGridItems()
         gridItemsAdapter.notifyDataSetChanged()
     }
diff --git a/app/src/main/java/org/omnirom/control/LockscreenSettingsFragment.kt b/app/src/main/java/org/omnirom/control/LockscreenSettingsFragment.kt
index 70a8803..97928d1 100644
--- a/app/src/main/java/org/omnirom/control/LockscreenSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/LockscreenSettingsFragment.kt
@@ -45,7 +45,7 @@
         }
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt b/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
index 9d72993..7c6b2e8 100644
--- a/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/MoreSettingsFragment.kt
@@ -39,7 +39,7 @@
         setPreferencesFromResource(R.xml.more_settings_preferences, rootKey)
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/OverlaysFragment.kt b/app/src/main/java/org/omnirom/control/OverlaysFragment.kt
index 88b32d8..9b3d0ab 100644
--- a/app/src/main/java/org/omnirom/control/OverlaysFragment.kt
+++ b/app/src/main/java/org/omnirom/control/OverlaysFragment.kt
@@ -476,13 +476,19 @@
 
     override fun onResume() {
         super.onResume()
-        (activity as? AppCompatActivity)?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
-        (activity as? SettingsActivity)?.updateFragmentTitle(
-            getFragmentTitle(),
-            getFragmentSummary(),
-            getFragmentIcon(),
-            false
-        )
+        (activity as? AppCompatActivity)?.let {
+            it.supportActionBar?.setDisplayHomeAsUpEnabled(true)
+            it.supportActionBar?.show()
+        }
+        (activity as SettingsActivity)?.let {
+            it.toolbarPlaceHolder.visibility = View.GONE
+            it.updateFragmentTitle(
+                getFragmentTitle(),
+                getFragmentSummary(),
+                getFragmentIcon(),
+                false
+            )
+        }
     }
 
     override fun onCreateView(
diff --git a/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt b/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
index bb4ce2e..8a9e678 100644
--- a/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
+++ b/app/src/main/java/org/omnirom/control/QSSettingsFragment.kt
@@ -97,7 +97,7 @@
         }
     }
 
-    override fun onPreferenceTreeClick(preference: Preference?): Boolean {
+    override fun onPreferenceTreeClick(preference: Preference): Boolean {
         return super.onPreferenceTreeClick(preference)
     }
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/omnirom/control/SettingsActivity.kt b/app/src/main/java/org/omnirom/control/SettingsActivity.kt
index 5e1e4b7..0e70ebe 100644
--- a/app/src/main/java/org/omnirom/control/SettingsActivity.kt
+++ b/app/src/main/java/org/omnirom/control/SettingsActivity.kt
@@ -25,6 +25,7 @@
 import android.widget.TextView
 import androidx.appcompat.app.AppCompatActivity
 import androidx.appcompat.widget.Toolbar
+import androidx.core.view.WindowCompat
 import androidx.fragment.app.Fragment
 
 
@@ -32,10 +33,17 @@
 
     private val CURRENT_FRAGMENT = "current_fragment"
 
+    lateinit var toolbarPlaceHolder: View
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+
+        WindowCompat.setDecorFitsSystemWindows(window, false)
+
         setContentView(R.layout.settings_activity)
 
+        toolbarPlaceHolder = findViewById(R.id.toolbar_placeholder)
+
         var fragment: Fragment = GridViewFragment()
         if (savedInstanceState != null) {
             val savedFragment =
diff --git a/app/src/main/java/org/omnirom/control/widget/ExpandableHeightGridView.kt b/app/src/main/java/org/omnirom/control/widget/ExpandableHeightGridView.kt
new file mode 100644
index 0000000..06190be
--- /dev/null
+++ b/app/src/main/java/org/omnirom/control/widget/ExpandableHeightGridView.kt
@@ -0,0 +1,19 @@
+package org.omnirom.control.widget
+
+import android.content.Context
+import android.util.AttributeSet
+import android.widget.GridView
+
+class ExpandableHeightGridView @JvmOverloads constructor(
+    context: Context,
+    attrs: AttributeSet? = null,
+    defStyleAttr: Int = 0
+) : GridView(context, attrs) {
+
+    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+        val expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
+            MeasureSpec.AT_MOST)
+        super.onMeasure(widthMeasureSpec, expandSpec)
+        layoutParams.height = measuredHeight
+    }
+}
diff --git a/app/src/main/res-private/color-v31/omni_settings_switch_thumb_color.xml b/app/src/main/res-private/color-v31/omni_settings_switch_thumb_color.xml
new file mode 100644
index 0000000..0a8cdd9
--- /dev/null
+++ b/app/src/main/res-private/color-v31/omni_settings_switch_thumb_color.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Disabled status of thumb -->
+    <item android:state_enabled="false"
+        android:color="@color/omni_settings_thumb_disabled_color" />
+    <!-- Toggle off status of thumb -->
+    <item android:state_checked="false"
+        android:color="@color/omni_settings_thumb_off_color" />
+    <!-- Enabled or toggle on status of thumb -->
+    <item android:color="@color/omni_settings_state_on_color" />
+</selector>
diff --git a/app/src/main/res-private/color-v31/omni_settings_switch_track_color.xml b/app/src/main/res-private/color-v31/omni_settings_switch_track_color.xml
new file mode 100644
index 0000000..92561d9
--- /dev/null
+++ b/app/src/main/res-private/color-v31/omni_settings_switch_track_color.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Disabled status of thumb -->
+    <item android:state_enabled="false"
+        android:color="@color/omni_settings_track_off_color"
+        android:alpha="?android:attr/disabledAlpha" />
+    <!-- Toggle off status of thumb -->
+    <item android:state_checked="false"
+        android:color="@color/omni_settings_track_off_color" />
+    <!-- Enabled or toggle on status of thumb -->
+    <item android:color="@color/omni_settings_track_on_color" />
+</selector>
diff --git a/app/src/main/res-private/color-v31/omni_settings_switch_track_off.xml b/app/src/main/res-private/color-v31/omni_settings_switch_track_off.xml
new file mode 100644
index 0000000..762bb31
--- /dev/null
+++ b/app/src/main/res-private/color-v31/omni_settings_switch_track_off.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@android:color/system_neutral2_500" android:lStar="45" />
+</selector>
\ No newline at end of file
diff --git a/app/src/main/res-private/color-v31/omni_settings_switch_track_on.xml b/app/src/main/res-private/color-v31/omni_settings_switch_track_on.xml
new file mode 100644
index 0000000..81ddf29
--- /dev/null
+++ b/app/src/main/res-private/color-v31/omni_settings_switch_track_on.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2021 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+  -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@android:color/system_accent2_500" android:lStar="51" />
+</selector>
\ No newline at end of file
diff --git a/app/src/main/res-private/drawable-v31/omni_settings_switch_thumb.xml b/app/src/main/res-private/drawable-v31/omni_settings_switch_thumb.xml
new file mode 100644
index 0000000..9074d89
--- /dev/null
+++ b/app/src/main/res-private/drawable-v31/omni_settings_switch_thumb.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:top="4dp"
+        android:left="4dp"
+        android:right="4dp"
+        android:bottom="4dp">
+        <shape android:shape="oval" >
+            <size android:height="20dp" android:width="20dp" />
+            <solid android:color="@color/omni_settings_switch_thumb_color" />
+        </shape>
+    </item>
+</layer-list>
\ No newline at end of file
diff --git a/app/src/main/res-private/drawable-v31/omni_settings_switch_track.xml b/app/src/main/res-private/drawable-v31/omni_settings_switch_track.xml
new file mode 100644
index 0000000..532c254
--- /dev/null
+++ b/app/src/main/res-private/drawable-v31/omni_settings_switch_track.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<shape
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    android:width="52dp"
+    android:height="28dp">
+
+    <solid android:color="@color/omni_settings_switch_track_color" />
+    <corners android:radius="35dp" />
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res-private/values-night-v31/colors.xml b/app/src/main/res-private/values-night-v31/colors.xml
new file mode 100644
index 0000000..400bc84
--- /dev/null
+++ b/app/src/main/res-private/values-night-v31/colors.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <!-- Material next thumb disable color-->
+    <color name="omni_settings_thumb_disabled_color">@android:color/system_neutral1_700</color>
+
+    <!-- Material next thumb off color-->
+    <color name="omni_settings_thumb_off_color">@android:color/system_neutral1_400</color>
+
+    <!-- Material next track on color-->
+    <color name="omni_settings_track_on_color">@color/omni_settings_switch_track_on</color>
+
+    <!-- Material next track off color-->
+    <color name="omni_settings_track_off_color">@android:color/system_neutral1_700</color>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res-private/values-v31/colors.xml b/app/src/main/res-private/values-v31/colors.xml
new file mode 100644
index 0000000..be1de09
--- /dev/null
+++ b/app/src/main/res-private/values-v31/colors.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>    
+    <color name="omni_settings_state_on_color">@android:color/system_accent1_100</color>
+
+    <!-- Material next state off color-->
+    <color name="omni_settings_state_off_color">@android:color/system_accent2_100</color>
+
+    <!-- Material next thumb disable color-->
+    <color name="omni_settings_thumb_disabled_color">@android:color/system_neutral2_100</color>
+
+    <!-- Material next thumb off color-->
+    <color name="omni_settings_thumb_off_color">@android:color/system_neutral2_300</color>
+
+    <!-- Material next track on color-->
+    <color name="omni_settings_track_on_color">@android:color/system_accent1_600</color>
+
+    <!-- Material next track off color-->
+    <color name="omni_settings_track_off_color">@color/omni_settings_switch_track_off</color>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res-private/values-v31/config.xml b/app/src/main/res-private/values-v31/config.xml
new file mode 100644
index 0000000..f5db48c
--- /dev/null
+++ b/app/src/main/res-private/values-v31/config.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <bool name="omni_settings_icon_space_reserved">false</bool>
+    <bool name="omni_settings_config_allow_divider">false</bool>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res-private/values-v31/dimens.xml b/app/src/main/res-private/values-v31/dimens.xml
new file mode 100644
index 0000000..9b85225
--- /dev/null
+++ b/app/src/main/res-private/values-v31/dimens.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <dimen name="omni_pref_title_text_size">18sp</dimen>
+</resources>
diff --git a/app/src/main/res-private/values-v31/styles_preference.xml b/app/src/main/res-private/values-v31/styles_preference.xml
new file mode 100644
index 0000000..a460fb4
--- /dev/null
+++ b/app/src/main/res-private/values-v31/styles_preference.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="Omni.PreferenceTheme" parent="@style/PreferenceThemeOverlay">
+        <item name="preferenceCategoryStyle">@style/Omni.CategoryStyle</item>
+        <item name="preferenceCategoryTitleTextAppearance">@style/Omni.CategoryTitle</item>
+        <item name="preferenceScreenStyle">@style/Omni.PreferenceScreenStyle</item>
+        <item name="preferenceStyle">@style/Omni.PreferenceStyle</item>
+        <item name="switchPreferenceStyle">@style/Omni.SwitchPreferenceStyle</item>
+        <item name="dropdownPreferenceStyle">@style/Omni.DropDownPreferenceStyle</item>
+        <item name="dialogPreferenceStyle">@style/Omni.DialogPreferenceStyle</item>
+        <item name="editTextPreferenceStyle">@style/Omni.EditTextPreferenceStyle</item>
+        <item name="checkBoxPreferenceStyle">@style/Omni.CheckboxPreferenceStyle</item>
+    </style>
+
+    <style name="Omni.CategoryStyle" parent="@style/Preference.Category.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+        <item name="allowDividerAbove">@bool/omni_settings_config_allow_divider</item>
+        <item name="allowDividerBelow">@bool/omni_settings_config_allow_divider</item>
+    </style>
+
+    <style name="Omni.PreferenceStyle" parent="@style/Preference.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.PreferenceScreenStyle"
+        parent="@style/Preference.PreferenceScreen.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.SwitchPreferenceStyle"
+        parent="@style/Preference.SwitchPreference.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.CheckboxPreferenceStyle"
+        parent="@style/Preference.CheckBoxPreference.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.DropDownPreferenceStyle"
+        parent="@style/Preference.DropDown.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.DialogPreferenceStyle"
+        parent="@style/Preference.DialogPreference.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+    </style>
+
+    <style name="Omni.EditTextPreferenceStyle"
+        parent="@style/Preference.DialogPreference.EditTextPreference.Material">
+        <item name="iconSpaceReserved">@bool/omni_settings_icon_space_reserved</item>
+        <item name="allowDividerAbove">@bool/omni_settings_config_allow_divider</item>
+        <item name="allowDividerBelow">@bool/omni_settings_config_allow_divider</item>
+    </style>
+
+    <style name="Omni.SwitchStyle"
+        parent="@android:style/Widget.Material.CompoundButton.Switch">
+        <item name="android:switchMinWidth">52dp</item>
+        <item name="android:thumb">@drawable/omni_settings_switch_thumb</item>
+        <item name="android:track">@drawable/omni_settings_switch_track</item>
+    </style>
+
+    <style name="Omni.PreferenceTitle"
+        parent="@style/TextAppearance.Material3.BodyMedium">
+        <item name="android:textSize">@dimen/omni_pref_title_text_size</item>
+    </style>
+
+    <style name="Omni.CategoryTitle" parent="@android:style/TextAppearance.Material.Body2">
+    </style>
+</resources>
diff --git a/app/src/main/res/layout/grid_fragment.xml b/app/src/main/res/layout/grid_fragment.xml
index 055c473..67ade28 100644
--- a/app/src/main/res/layout/grid_fragment.xml
+++ b/app/src/main/res/layout/grid_fragment.xml
@@ -1,10 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-<GridView xmlns:android="http://schemas.android.com/apk/res/android"
+<org.omnirom.control.widget.ExpandableHeightGridView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/grid_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:gravity="center"
-    android:horizontalSpacing="@dimen/grid_view_spacing"
-    android:verticalSpacing="@dimen/grid_view_spacing"
     android:numColumns="@integer/grid_view_columns"
     android:stretchMode="columnWidth"/>
diff --git a/app/src/main/res/layout/settings_activity.xml b/app/src/main/res/layout/settings_activity.xml
index d5492cb..3a89086 100644
--- a/app/src/main/res/layout/settings_activity.xml
+++ b/app/src/main/res/layout/settings_activity.xml
@@ -1,68 +1,98 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical">
+    tools:context=".SettingsActivity">
 
-    <androidx.appcompat.widget.Toolbar
-        android:id="@+id/toolbar"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
-
-    <LinearLayout
+    <com.google.android.material.appbar.AppBarLayout
+        android:id="@+id/app_bar_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
-        android:layout_marginStart="@dimen/fragment_side_margin"
-        android:layout_marginEnd="@dimen/fragment_side_margin"
-        android:orientation="horizontal">
-
-        <ImageView
-            android:id="@+id/fragment_icon"
-            android:layout_width="@dimen/grid_item_icon_size"
-            android:layout_height="@dimen/grid_item_icon_size"
-            android:layout_gravity="center_vertical"
-            android:layout_marginStart="@dimen/fragment_icon_margin_start" />
+        android:fitsSystemWindows="true" >
 
         <LinearLayout
-            android:layout_width="0dp"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_gravity="start|center_vertical"
-            android:layout_marginStart="@dimen/fragment_icon_margin_start"
-            android:layout_weight="1"
+            android:orientation="vertical"/>
+
+        <com.google.android.material.appbar.MaterialToolbar
+            android:id="@+id/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/toolbar_placeholder_height"/>
+
+    </com.google.android.material.appbar.AppBarLayout>
+
+    <androidx.core.widget.NestedScrollView
+        android:id="@+id/scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginStart="@dimen/fragment_side_margin"
+            android:layout_marginEnd="@dimen/fragment_side_margin"
+            android:paddingBottom="@dimen/bottom_placeholder_height"
             android:orientation="vertical">
 
-            <TextView
-                android:id="@+id/fragment_title"
+            <Space
+                android:id="@+id/toolbar_placeholder"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:ellipsize="end"
-                android:gravity="center_vertical"
-                android:maxLines="1"
-                android:textAppearance="@style/Theme.OmniControl.GridItem.TitleTextStyle"
-                tools:text="aaaa" />
+                android:layout_height="@dimen/toolbar_placeholder_height"/>
 
-            <TextView
-                android:id="@+id/fragment_summary"
+            <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:ellipsize="end"
-                android:gravity="center_vertical"
-                android:maxLines="1"
-                android:textAppearance="@style/Theme.OmniControl.GridItem.SummaryTextStyle"
-                android:textColor="?android:attr/textColorSecondary"
-                tools:text="vvvv" />
+                android:layout_marginStart="@dimen/fragment_icon_margin_start"
+                android:layout_marginEnd="@dimen/fragment_icon_margin_start"
+                android:layout_marginBottom="@dimen/fragment_icon_margin_start"
+                android:orientation="horizontal">
+
+                <ImageView
+                    android:id="@+id/fragment_icon"
+                    android:layout_width="@dimen/grid_item_icon_size"
+                    android:layout_height="@dimen/grid_item_icon_size"
+                    android:layout_gravity="center_vertical"
+                    android:layout_marginEnd="@dimen/fragment_icon_margin_start"/>
+
+                <LinearLayout
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="start|center_vertical"
+                    android:layout_weight="1"
+                    android:orientation="vertical">
+
+                    <TextView
+                        android:id="@+id/fragment_title"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="end"
+                        android:gravity="center_vertical"
+                        android:maxLines="1"
+                        android:textAppearance="@style/Theme.OmniControl.GridItem.TitleTextStyle"
+                        tools:text="aaaa" />
+
+                    <TextView
+                        android:id="@+id/fragment_summary"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:ellipsize="end"
+                        android:gravity="center_vertical"
+                        android:maxLines="1"
+                        android:textAppearance="@style/Theme.OmniControl.GridItem.SummaryTextStyle"
+                        android:textColor="?android:attr/textColorSecondary"
+                        tools:text="vvvv" />
+
+                </LinearLayout>
+            </LinearLayout>
+
+            <FrameLayout
+                android:id="@+id/settings"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent" />
 
         </LinearLayout>
-    </LinearLayout>
-
-    <FrameLayout
-        android:id="@+id/settings"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_marginStart="@dimen/fragment_side_margin"
-        android:layout_marginTop="20dp"
-        android:layout_marginEnd="@dimen/fragment_side_margin"
-        android:layout_weight="1" />
-
-</LinearLayout>
+    </androidx.core.widget.NestedScrollView>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml
index ce8c2f5..3126217 100644
--- a/app/src/main/res/values-land/dimens.xml
+++ b/app/src/main/res/values-land/dimens.xml
@@ -5,4 +5,5 @@
     <dimen name="color_item_column_width">@dimen/color_item_column_height</dimen>
     <dimen name="color_item_container_width">@dimen/color_item_container_height</dimen>
     <dimen name="overlay_fragment_side_margin">20dp</dimen>
+    <dimen name="toolbar_placeholder_height">60dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index ffcc2c7..037fa81 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -3,5 +3,4 @@
     <color name="colorPrimary">@android:color/system_accent1_100</color>
     <color name="overlay_item_background">@android:color/system_neutral1_800</color>
     <color name="overlay_blocker_color">#10ffffff</color>
-    <color name="windowBackground">@android:color/system_neutral1_900</color>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c69970e..e09d1b9 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,5 +3,4 @@
     <color name="colorPrimary">@android:color/system_accent1_600</color>
     <color name="overlay_item_background">@android:color/system_neutral1_0</color>
     <color name="overlay_blocker_color">#10000000</color>
-    <color name="windowBackground">@android:color/system_neutral1_50</color>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 5375713..825dc10 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -3,8 +3,7 @@
     <dimen name="applist_icon_size">108dp</dimen>
     <dimen name="grid_item_corner_radius">16dp</dimen>
     <dimen name="fragment_side_margin">10dp</dimen>
-    <dimen name="grid_item_border">10dp</dimen>
-    <dimen name="grid_view_spacing">8dp</dimen>
+    <dimen name="grid_item_border">16dp</dimen>
     <dimen name="fragment_icon_margin_start">16dp</dimen>
     <dimen name="grid_item_icon_size">32dp</dimen>
     <dimen name="grid_icon_margin_start">0dp</dimen>
@@ -28,4 +27,7 @@
     <dimen name="summary_text_size">14sp</dimen>
     <dimen name="pref_title_text_size">18sp</dimen>
     <dimen name="root_title_text_size">32sp</dimen>
+    <dimen name="toolbar_placeholder_height">105dp</dimen>
+    <dimen name="bottom_placeholder_height">60dp</dimen>
+    <dimen name="grid_item_margin_start">16dp</dimen>
 </resources>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index ee8b266..ee5af62 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -7,10 +7,10 @@
         <item name="android:windowLightStatusBar">?attr/isLightTheme</item>
         <item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
         <item name="android:windowSplashScreenIconBackgroundColor">@color/ic_launcher_background</item>
-        <item name="android:windowBackground">@color/windowBackground</item>
         <item name="preferenceTheme">@style/Omni.PreferenceTheme</item>
         <item name="android:switchStyle">@style/Omni.SwitchStyle</item>
         <item name="android:textAppearanceListItem">@style/Omni.PreferenceTitle</item>
+        <item name="dialogCornerRadius">8dp</item>
     </style>
 
     <style name="Theme.OmniControl.TitleTextStyle" parent="TextAppearance.Material3.BodyMedium">