Update MainSwitchBar to Material Next style.

Fix: 182255113
Test: Run robotest and see the ui
Change-Id: I2d407bb463a13ed986fe7fe3611e4c00c55284dd
diff --git a/packages/SettingsLib/MainSwitchPreference/Android.bp b/packages/SettingsLib/MainSwitchPreference/Android.bp
index 7b7496c..4ce854a 100644
--- a/packages/SettingsLib/MainSwitchPreference/Android.bp
+++ b/packages/SettingsLib/MainSwitchPreference/Android.bp
@@ -14,7 +14,7 @@
     resource_dirs: ["res"],
 
     static_libs: [
-          "androidx.preference_preference",
+        "androidx.preference_preference",
     ],
 
     sdk_version: "system_current",
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_disabled.xml
similarity index 60%
copy from packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
copy to packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_disabled.xml
index b29f459..b646f0a 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_disabled.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  Copyright (C) 2020 The Android Open Source Project
+  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.
@@ -15,12 +15,12 @@
   limitations under the License.
   -->
 
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/track_off_background" />
-  <item
-      android:width="13.33dp"
-      android:height="1.67dp"
-      android:left="21dp"
-      android:gravity="center"
-      android:drawable="@drawable/track_off_indicator" />
-</layer-list>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:attr/colorControlHighlight">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/state_off_color"/>
+            <corners android:radius="@dimen/switch_bar_radius"/>
+        </shape>
+    </item>
+</ripple>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_off.xml
similarity index 60%
copy from packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
copy to packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_off.xml
index b29f459..b646f0a 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_off.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  Copyright (C) 2020 The Android Open Source Project
+  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.
@@ -15,12 +15,12 @@
   limitations under the License.
   -->
 
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/track_off_background" />
-  <item
-      android:width="13.33dp"
-      android:height="1.67dp"
-      android:left="21dp"
-      android:gravity="center"
-      android:drawable="@drawable/track_off_indicator" />
-</layer-list>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:attr/colorControlHighlight">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/state_off_color"/>
+            <corners android:radius="@dimen/switch_bar_radius"/>
+        </shape>
+    </item>
+</ripple>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_on.xml
similarity index 60%
rename from packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
rename to packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_on.xml
index b29f459..afea8bd 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/switch_bar_bg_on.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  Copyright (C) 2020 The Android Open Source Project
+  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.
@@ -15,12 +15,12 @@
   limitations under the License.
   -->
 
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/track_off_background" />
-  <item
-      android:width="13.33dp"
-      android:height="1.67dp"
-      android:left="21dp"
-      android:gravity="center"
-      android:drawable="@drawable/track_off_indicator" />
-</layer-list>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="?android:attr/colorControlHighlight">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/state_on_color"/>
+            <corners android:radius="@dimen/switch_bar_radius"/>
+        </shape>
+    </item>
+</ripple>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_disabled.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_disabled.xml
new file mode 100644
index 0000000..9e6cfbd
--- /dev/null
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_disabled.xml
@@ -0,0 +1,33 @@
+<?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="@dimen/switch_thumb_margin"
+        android:left="@dimen/switch_thumb_margin"
+        android:right="@dimen/switch_thumb_margin"
+        android:bottom="@dimen/switch_thumb_margin">
+        <shape android:shape="oval">
+            <size
+                android:height="@dimen/switch_thumb_size"
+                android:width="@dimen/switch_thumb_size"/>
+            <solid
+                android:color="@color/state_off_color"
+                android:alpha="?android:attr/disabledAlpha"/>
+        </shape>
+    </item>
+</layer-list>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_off.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_off.xml
index 2be00b9..f6d8815 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_off.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_off.xml
@@ -16,16 +16,16 @@
   -->
 
 <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/thumb_off" />
-    </shape>
-
-  </item>
+    <item
+        android:top="@dimen/switch_thumb_margin"
+        android:left="@dimen/switch_thumb_margin"
+        android:right="@dimen/switch_thumb_margin"
+        android:bottom="@dimen/switch_thumb_margin">
+        <shape android:shape="oval">
+            <size
+                android:height="@dimen/switch_thumb_size"
+                android:width="@dimen/switch_thumb_size"/>
+            <solid android:color="@color/state_off_color"/>
+        </shape>
+    </item>
 </layer-list>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_on.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_on.xml
index e85eb42..61230b5 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_on.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_on.xml
@@ -16,16 +16,16 @@
   -->
 
 <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="?android:attr/colorAccent" />
-    </shape>
-
-  </item>
+    <item
+        android:top="@dimen/switch_thumb_margin"
+        android:left="@dimen/switch_thumb_margin"
+        android:right="@dimen/switch_thumb_margin"
+        android:bottom="@dimen/switch_thumb_margin">
+        <shape android:shape="oval">
+            <size
+                android:height="@dimen/switch_thumb_size"
+                android:width="@dimen/switch_thumb_size"/>
+            <solid android:color="@color/state_on_color"/>
+        </shape>
+    </item>
 </layer-list>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_selector.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_selector.xml
index 8cc9bb3..a541eaa 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_selector.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/thumb_selector.xml
@@ -16,6 +16,7 @@
   -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/thumb_on" android:state_checked="true" />
-  <item android:drawable="@drawable/thumb_off" android:state_checked="false" />
+    <item android:drawable="@drawable/thumb_on" android:state_checked="true"/>
+    <item android:drawable="@drawable/thumb_off" android:state_checked="false"/>
+    <item android:drawable="@drawable/thumb_disabled" android:state_enabled="false"/>
 </selector>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_disabled_background.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_disabled_background.xml
new file mode 100644
index 0000000..b6c7313
--- /dev/null
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_disabled_background.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="@dimen/switch_track_width"
+    android:height="@dimen/switch_track_height">
+    <solid
+        android:color="@color/track_off_color"
+        android:alpha="?android:attr/disabledAlpha"/>
+    <corners android:radius="@dimen/switch_track_radius"/>
+</shape>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_background.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_background.xml
index c838654..f2c11b6 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_background.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_background.xml
@@ -15,20 +15,10 @@
   limitations under the License.
   -->
 
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="52dp"
-    android:height="28dp"
-    android:viewportWidth="52"
-    android:viewportHeight="28">
-
-  <group>
-    <clip-path
-        android:pathData="M14 0H38C45.732 0 52 6.26801 52 14C52 21.732 45.732 28 38 28H14C6.26801 28 0 21.732 0 14C0 6.26801 6.26801 0 14 0Z" />
-
-    <path
-        android:pathData="M0 0V28H52V0"
-        android:fillColor="@color/track_off" />
-  </group>
-
-</vector>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    android:width="@dimen/switch_track_width"
+    android:height="@dimen/switch_track_height">
+    <solid android:color="@color/track_off_color"/>
+    <corners android:radius="@dimen/switch_track_radius"/>
+</shape>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_indicator.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_indicator.xml
deleted file mode 100644
index 6cc6224..0000000
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_off_indicator.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2020 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.
-  -->
-
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="13.33dp"
-    android:height="1.67dp"
-    android:viewportWidth="13.33"
-    android:viewportHeight="1.67">
-
-  <group>
-    <clip-path
-        android:pathData="M0 0H13.3333V1.66667H0V0Z" />
-
-    <path
-        android:pathData="M0 0V1.66667H13.3333V0"
-        android:fillColor="@android:color/white" />
-  </group>
-
-</vector>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on.xml
deleted file mode 100644
index cf24112..0000000
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2020 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:drawable="@drawable/track_on_background" />
-  <item
-      android:width="13.19dp"
-      android:height="10.06dp"
-      android:gravity="center"
-      android:right="21dp"
-      android:drawable="@drawable/track_on_indicator" />
-</layer-list>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_background.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_background.xml
index bb1a7ef..9246462 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_background.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_background.xml
@@ -15,22 +15,10 @@
   limitations under the License.
   -->
 
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="52dp"
-    android:height="28dp"
-    android:viewportWidth="52"
-    android:viewportHeight="28"
-    android:tint="@*android:color/switch_track_material">
-
-  <group>
-    <clip-path
-        android:pathData="M14 0H38C45.732 0 52 6.26801 52 14C52 21.732 45.732 28 38 28H14C6.26801 28 0 21.732 0 14C0 6.26801 6.26801 0 14 0Z" />
-
-    <path
-        android:pathData="M0 0V28H52V0"
-        android:fillColor="@*android:color/white_disabled_material" />
-
-  </group>
-
-</vector>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    android:width="@dimen/switch_track_width"
+    android:height="@dimen/switch_track_height">
+    <solid android:color="@color/track_on_color"/>
+    <corners android:radius="@dimen/switch_track_radius"/>
+</shape>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_indicator.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_indicator.xml
deleted file mode 100644
index 2281d04..0000000
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_on_indicator.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2020 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.
-  -->
-
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="13.19dp"
-    android:height="10.06dp"
-    android:viewportWidth="13.19"
-    android:viewportHeight="10.06">
-
-  <group>
-    <path
-        android:pathData="M4.75012 8.12738L1.62262 4.99988L0.557617 6.05738L4.75012 10.2499L13.7501 1.24988L12.6926 0.192383L4.75012 8.12738Z"
-        android:fillColor="@android:color/white" />
-  </group>
-
-</vector>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_selector.xml b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_selector.xml
index 5c699be..50a03b9 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/drawable/track_selector.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/drawable/track_selector.xml
@@ -16,6 +16,7 @@
   -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/track_on" android:state_checked="true" />
-  <item android:drawable="@drawable/track_off" android:state_checked="false" />
+    <item android:drawable="@drawable/track_on_background" android:state_checked="true"/>
+    <item android:drawable="@drawable/track_off_background" android:state_checked="false"/>
+    <item android:drawable="@drawable/track_disabled_background" android:state_enabled="false"/>
 </selector>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/main_switch_bar.xml
index 3ce9421..9ccf63a 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/layout-v31/main_switch_bar.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/layout-v31/main_switch_bar.xml
@@ -19,6 +19,10 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
+    android:paddingRight="?android:attr/listPreferredItemPaddingRight"
     android:background="?android:attr/colorBackground"
     android:orientation="vertical">
 
@@ -27,7 +31,6 @@
         android:minHeight="@dimen/min_switch_bar_height"
         android:layout_height="wrap_content"
         android:layout_width="match_parent"
-        android:background="?android:attr/selectableItemBackground"
         android:paddingLeft="@dimen/switchbar_margin_start"
         android:paddingRight="@dimen/switchbar_margin_end">
 
@@ -41,7 +44,6 @@
             android:maxLines="2"
             android:ellipsize="end"
             android:textAppearance="?android:attr/textAppearanceListItem"
-            android:textAlignment="viewStart"
             style="@style/MainSwitchText" />
 
         <ImageView
@@ -58,18 +60,13 @@
         <Switch
             android:id="@android:id/switch_widget"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_height="48dp"
             android:layout_gravity="center_vertical"
             android:track="@drawable/track_selector"
             android:thumb="@drawable/thumb_selector"
             android:theme="@style/Settings.MainSwitch"/>
     </LinearLayout>
 
-    <View
-        android:id="@+id/below_divider"
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="?android:attr/listDivider" />
 </LinearLayout>
 
 
diff --git a/packages/SettingsLib/MainSwitchPreference/res/layout/main_switch_bar.xml b/packages/SettingsLib/MainSwitchPreference/res/layout/main_switch_bar.xml
index 5dc3209..ac82733 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/layout/main_switch_bar.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/layout/main_switch_bar.xml
@@ -54,4 +54,3 @@
         android:theme="@style/Widget.SwitchBar.Switch"/>
 </LinearLayout>
 
-
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values-night/colors.xml b/packages/SettingsLib/MainSwitchPreference/res/values-night/colors.xml
index e54569e..7457285 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values-night/colors.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values-night/colors.xml
@@ -15,11 +15,10 @@
   limitations under the License.
   -->
 
-<resources>
-
-    <color name="thumb_off">#BFFFFFFF</color>
-    <color name="track_off">@*android:color/material_grey_600</color>
-
+<resources xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
     <color name="switchbar_switch_track_tint">#82000000</color>
     <color name="switchbar_switch_thumb_tint">@android:color/black</color>
+
+    <!-- Material next track on color-->
+    <color name="track_on_color">?androidprv:attr/colorSurfaceHighlight</color>
 </resources>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values/colors.xml b/packages/SettingsLib/MainSwitchPreference/res/values/colors.xml
index b5a73b1..ea7bfd4 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values/colors.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values/colors.xml
@@ -15,12 +15,20 @@
   limitations under the License.
   -->
 
-<resources>
-
-    <color name="thumb_off">#BFFFFFFF</color>
-    <color name="track_off">@*android:color/material_grey_600</color>
-
+<resources xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
     <color name="switchbar_background_color">@*android:color/material_grey_600</color>
     <color name="switchbar_switch_track_tint">#BFFFFFFF</color>
     <color name="switchbar_switch_thumb_tint">@android:color/white</color>
+
+    <!-- Material next state on color-->
+    <color name="state_on_color">?androidprv:attr/colorAccentPrimary</color>
+
+    <!-- Material next state off color-->
+    <color name="state_off_color">?androidprv:attr/colorAccentSecondary</color>
+
+    <!-- Material next track on color-->
+    <color name="track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
+
+    <!-- Material next track off color-->
+    <color name="track_off_color">?androidprv:attr/colorAccentSecondaryVariant</color>
 </resources>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml b/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
index c471bcd..67886bc 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values/dimens.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Size of layout margin left -->
-    <dimen name="switchbar_margin_start">22dp</dimen>
+    <dimen name="switchbar_margin_start">24dp</dimen>
 
     <!-- Size of layout margin right -->
     <dimen name="switchbar_margin_end">16dp</dimen>
@@ -35,6 +35,24 @@
     <!-- Restricted icon in switch bar -->
     <dimen name="restricted_icon_margin_end">16dp</dimen>
 
+    <!-- Radius of switch bar -->
+    <dimen name="switch_bar_radius">28dp</dimen>
+
+    <!-- Margin of switch thumb -->
+    <dimen name="switch_thumb_margin">4dp</dimen>
+
+    <!-- Size of switch thumb -->
+    <dimen name="switch_thumb_size">20dp</dimen>
+
+    <!-- Width of switch track -->
+    <dimen name="switch_track_width">52dp</dimen>
+
+    <!-- Height of switch track -->
+    <dimen name="switch_track_height">28dp</dimen>
+
+    <!-- Radius of switch track -->
+    <dimen name="switch_track_radius">35dp</dimen>
+
     <!-- SwitchBar sub settings margin start / end -->
     <dimen name="switchbar_subsettings_margin_start">72dp</dimen>
     <dimen name="switchbar_subsettings_margin_end">16dp</dimen>
diff --git a/packages/SettingsLib/MainSwitchPreference/res/values/styles.xml b/packages/SettingsLib/MainSwitchPreference/res/values/styles.xml
index e058097..5867695 100644
--- a/packages/SettingsLib/MainSwitchPreference/res/values/styles.xml
+++ b/packages/SettingsLib/MainSwitchPreference/res/values/styles.xml
@@ -19,6 +19,8 @@
 
     <style name="MainSwitchText">
         <item name="android:textSize">20sp</item>
+        <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+        <item name="android:textColor">@android:color/black</item>
     </style>
 
     <style name="Settings.MainSwitch" parent="@android:style/Widget.Material.CompoundButton.Switch">
diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
index 2be3f0d..7913e0a 100644
--- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
+++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.util.AttributeSet;
@@ -50,6 +51,10 @@
 
     protected TextView mTextView;
     protected Switch mSwitch;
+    private Drawable mBackgroundOn;
+    private Drawable mBackgroundOff;
+    private Drawable mBackgroundDisabled;
+    private View mFrameView;
 
     public MainSwitchBar(Context context) {
         this(context, null);
@@ -81,8 +86,12 @@
         setFocusable(true);
         setClickable(true);
 
+        mFrameView = findViewById(R.id.frame);
         mTextView = (TextView) findViewById(R.id.switch_text);
         mSwitch = (Switch) findViewById(android.R.id.switch_widget);
+        mBackgroundOn = getContext().getDrawable(R.drawable.switch_bar_bg_on);
+        mBackgroundOff = getContext().getDrawable(R.drawable.switch_bar_bg_off);
+        mBackgroundDisabled = getContext().getDrawable(R.drawable.switch_bar_bg_disabled);
 
         addOnSwitchChangeListener((switchView, isChecked) -> setChecked(isChecked));
 
@@ -194,21 +203,31 @@
         super.setEnabled(enabled);
         mTextView.setEnabled(enabled);
         mSwitch.setEnabled(enabled);
+
+        if (BuildCompat.isAtLeastS()) {
+            if (enabled) {
+                mFrameView.setBackground(isChecked() ? mBackgroundOn : mBackgroundOff);
+            } else {
+                mFrameView.setBackground(mBackgroundDisabled);
+            }
+        }
     }
 
     private void propagateChecked(boolean isChecked) {
+        setBackground(isChecked);
+
         final int count = mSwitchChangeListeners.size();
         for (int n = 0; n < count; n++) {
             mSwitchChangeListeners.get(n).onSwitchChanged(mSwitch, isChecked);
         }
     }
 
-    private void setBackground(boolean checked) {
-        if (BuildCompat.isAtLeastS()) {
-            return;
+    private void setBackground(boolean isChecked) {
+        if (!BuildCompat.isAtLeastS()) {
+            setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
+        } else {
+            mFrameView.setBackground(isChecked ? mBackgroundOn : mBackgroundOff);
         }
-
-        setBackgroundColor(checked ? mBackgroundActivatedColor : mBackgroundColor);
     }
 
     static class SavedState extends BaseSavedState {
@@ -273,6 +292,7 @@
 
         mSwitch.setChecked(ss.mChecked);
         setChecked(ss.mChecked);
+        setBackground(ss.mChecked);
         setVisibility(ss.mVisible ? View.VISIBLE : View.GONE);
         mSwitch.setOnCheckedChangeListener(ss.mVisible ? this : null);
 
diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchPreference.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchPreference.java
index 1f7f8d4..cafc703 100644
--- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchPreference.java
+++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchPreference.java
@@ -63,7 +63,7 @@
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
 
-        holder.setDividerAllowedAbove(true);
+        holder.setDividerAllowedAbove(false);
         holder.setDividerAllowedBelow(false);
 
         mMainSwitchBar = (MainSwitchBar) holder.findViewById(R.id.main_switch_bar);
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/MainSwitchPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/MainSwitchPreferenceTest.java
index 2e77aca..12f329d 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/MainSwitchPreferenceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/MainSwitchPreferenceTest.java
@@ -59,15 +59,6 @@
     }
 
     @Test
-    public void shouldAllowDividerBelow() {
-        mPreference.onBindViewHolder(mHolder);
-
-        View divider = mRootView.findViewById(R.id.below_divider);
-
-        assertThat(divider.getVisibility()).isEqualTo(View.VISIBLE);
-    }
-
-    @Test
     public void updateStatus_shouldMatchTheStatus() {
         mPreference.onBindViewHolder(mHolder);
         mPreference.updateStatus(true);