Merge "Add Preference themes to Car overlay."
diff --git a/car_product/overlay/frameworks/base/core/res/res/color/car_switch.xml b/car_product/overlay/frameworks/base/core/res/res/color/car_switch.xml
new file mode 100644
index 0000000..ebf3841
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/color/car_switch.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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="?attr/colorControlActivated"
+        android:state_checked="true"/>
+    <item
+        android:color="?attr/colorSwitchThumbNormal"/>
+</selector>
diff --git a/car_product/overlay/frameworks/base/core/res/res/color/primary_text.xml b/car_product/overlay/frameworks/base/core/res/res/color/primary_text.xml
new file mode 100644
index 0000000..6caf472
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/color/primary_text.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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:alpha="0.5"
+        android:color="@color/car_body1"
+        android:state_enabled="false"/>
+    <item android:color="@color/car_body1"/>
+</selector>
diff --git a/car_product/overlay/frameworks/base/core/res/res/drawable/car_checkbox.xml b/car_product/overlay/frameworks/base/core/res/res/drawable/car_checkbox.xml
new file mode 100644
index 0000000..00e3a19
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/drawable/car_checkbox.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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:width="@dimen/car_primary_icon_size"
+        android:height="@dimen/car_primary_icon_size"
+        android:drawable="@drawable/btn_check_material_anim"/>
+</layer-list>
diff --git a/car_product/overlay/frameworks/base/core/res/res/drawable/car_switch_thumb.xml b/car_product/overlay/frameworks/base/core/res/res/drawable/car_switch_thumb.xml
new file mode 100644
index 0000000..03efc18
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/drawable/car_switch_thumb.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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="oval">
+    <solid android:color="@color/car_switch"/>
+    <size
+        android:width="@dimen/car_seekbar_thumb_size"
+        android:height="@dimen/car_seekbar_thumb_size"/>
+</shape>
diff --git a/car_product/overlay/frameworks/base/core/res/res/layout/car_preference.xml b/car_product/overlay/frameworks/base/core/res/res/layout/car_preference.xml
new file mode 100644
index 0000000..899fe6a
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/layout/car_preference.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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.
+-->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="?attr/selectableItemBackground"
+    android:focusable="true"
+    android:minHeight="?attr/listPreferredItemHeightSmall"
+    android:paddingEnd="?attr/listPreferredItemPaddingEnd"
+    android:paddingStart="?attr/listPreferredItemPaddingStart">
+
+    <com.android.internal.widget.PreferenceImageView
+        android:id="@id/icon"
+        android:layout_width="@dimen/car_primary_icon_size"
+        android:layout_height="@dimen/car_primary_icon_size"
+        android:layout_alignParentStart="true"
+        android:layout_centerVertical="true"
+        android:layout_marginBottom="@dimen/car_padding_2"
+        android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
+        android:layout_marginTop="@dimen/car_padding_2"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_marginBottom="@dimen/car_padding_2"
+        android:layout_marginTop="@dimen/car_padding_2"
+        android:layout_toEndOf="@id/icon"
+        android:layout_toStartOf="@id/widget_frame"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ellipsize="end"
+            android:singleLine="true"
+            android:textAppearance="?attr/textAppearanceListItem"/>
+
+        <TextView
+            android:id="@id/summary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?attr/textAppearanceListItemSecondary"/>
+
+    </LinearLayout>
+
+    <!-- Preference should place its actual preference widget here. -->
+    <FrameLayout
+        android:id="@id/widget_frame"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentEnd="true"
+        android:layout_centerVertical="true"/>
+
+</RelativeLayout>
diff --git a/car_product/overlay/frameworks/base/core/res/res/layout/car_preference_category.xml b/car_product/overlay/frameworks/base/core/res/res/layout/car_preference_category.xml
new file mode 100644
index 0000000..6bc0306
--- /dev/null
+++ b/car_product/overlay/frameworks/base/core/res/res/layout/car_preference_category.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 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.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="?attr/selectableItemBackground"
+    android:focusable="true"
+    android:gravity="center_vertical"
+    android:minHeight="@dimen/car_card_header_height"
+    android:orientation="horizontal"
+    android:paddingEnd="?attr/listPreferredItemPaddingEnd"
+    android:paddingStart="?attr/listPreferredItemPaddingStart">
+
+    <com.android.internal.widget.PreferenceImageView
+        android:id="@id/icon"
+        android:layout_width="@dimen/car_primary_icon_size"
+        android:layout_height="@dimen/car_primary_icon_size"
+        android:layout_gravity="center_vertical"
+        android:layout_marginBottom="@dimen/car_padding_2"
+        android:layout_marginEnd="?attr/listPreferredItemPaddingEnd"
+        android:layout_marginTop="@dimen/car_padding_2"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="@dimen/car_padding_2"
+        android:layout_marginTop="@dimen/car_padding_2"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@id/title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:fontFamily="sans-serif-medium"
+            android:textAlignment="viewStart"
+            android:textAppearance="?attr/textAppearanceSmall"
+            android:textColor="?attr/colorAccent"/>
+
+        <TextView
+            android:id="@id/summary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ellipsize="end"
+            android:singleLine="true"
+            android:textColor="?attr/textColorSecondary"/>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values-h1752dp/dimens.xml b/car_product/overlay/frameworks/base/core/res/res/values-h1752dp/dimens.xml
index f975711..da38586 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values-h1752dp/dimens.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values-h1752dp/dimens.xml
@@ -15,6 +15,9 @@
 -->
 
 <resources>
+    <!-- Application Bar -->
+    <dimen name="car_app_bar_height">112dp</dimen>
+
     <!-- Text size for car -->
     <dimen name="car_title2_size">32sp</dimen>
     <dimen name="car_body1_size">32sp</dimen>
@@ -32,4 +35,7 @@
     <dimen name="car_keyline_2">108dp</dimen>
     <dimen name="car_keyline_3">152dp</dimen>
     <dimen name="car_keyline_4">182dp</dimen>
+
+    <!-- Minimum height of list items. -->
+    <dimen name="car_single_line_list_item_height">128dp</dimen>
 </resources>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values-h600dp/dimens.xml b/car_product/overlay/frameworks/base/core/res/res/values-h600dp/dimens.xml
index b659bef..ba726d9 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values-h600dp/dimens.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values-h600dp/dimens.xml
@@ -14,6 +14,9 @@
 limitations under the License.
 -->
 <resources>
+    <!-- Application Bar -->
+    <dimen name="car_app_bar_height">96dp</dimen>
+
     <!-- Size of notification text titles (see TextAppearance.StatusBar.EventContent.Title) -->
     <dimen name="notification_title_text_size">40sp</dimen>
 
@@ -36,4 +39,7 @@
 
     <!-- The size of the media actions in the media notification. -->
     <dimen name="media_notification_action_button_size">56dp</dimen>
+
+    <!-- Minimum height of list items. -->
+    <dimen name="car_single_line_list_item_height">116dp</dimen>
 </resources>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values-w1280dp/dimens.xml b/car_product/overlay/frameworks/base/core/res/res/values-w1280dp/dimens.xml
index 2e2f851..de9bc8b 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values-w1280dp/dimens.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values-w1280dp/dimens.xml
@@ -19,4 +19,5 @@
     <dimen name="car_keyline_2">108dp</dimen>
     <dimen name="car_keyline_3">128dp</dimen>
     <dimen name="car_keyline_4">168dp</dimen>
+    <dimen name="car_margin">148dp</dimen>
 </resources>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values-w1920dp/dimens.xml b/car_product/overlay/frameworks/base/core/res/res/values-w1920dp/dimens.xml
index 389f162..7a0f7a5 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values-w1920dp/dimens.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values-w1920dp/dimens.xml
@@ -16,4 +16,5 @@
 
 <resources>
     <dimen name="car_keyline_4">184dp</dimen>
+    <dimen name="car_margin">192dp</dimen>
 </resources>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values/styles_device_default.xml b/car_product/overlay/frameworks/base/core/res/res/values/styles_device_default.xml
index 32783b9..443996f 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values/styles_device_default.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values/styles_device_default.xml
@@ -84,10 +84,19 @@
         <item name="paddingEnd">@dimen/car_button_horizontal_padding</item>
     </style>
 
-     <style name="Widget.DeviceDefault.ProgressBar.Horizontal" parent="Widget.Material.ProgressBar.Horizontal">
-         <item name="minHeight">@dimen/car_progress_bar_height</item>
-         <item name="maxHeight">@dimen/car_progress_bar_height</item>
-     </style>
+    <style name="Widget.DeviceDefault.CompoundButton.CheckBox" parent="Widget.Material.CompoundButton.CheckBox">
+        <item name="button">@drawable/car_checkbox</item>
+    </style>
+
+    <style name="Widget.DeviceDefault.CompoundButton.Switch" parent="Widget.Material.CompoundButton.Switch">
+        <item name="thumb">@drawable/car_switch_thumb</item>
+        <item name="switchMinWidth">@dimen/car_primary_icon_size</item>
+    </style>
+
+    <style name="Widget.DeviceDefault.ProgressBar.Horizontal" parent="Widget.Material.ProgressBar.Horizontal">
+        <item name="minHeight">@dimen/car_progress_bar_height</item>
+        <item name="maxHeight">@dimen/car_progress_bar_height</item>
+    </style>
 
     <style name="Widget.DeviceDefault.SeekBar" parent="Widget.Material.SeekBar">
         <item name="progressDrawable">@drawable/car_seekbar_track</item>
@@ -98,4 +107,24 @@
         <item name="textSize">@dimen/car_body3_size</item>
     </style>
 
+    <!-- Preference Styles -->
+    <style name="Preference.DeviceDefault" parent="Preference.Material">
+        <item name="layout">@layout/car_preference</item>
+    </style>
+    <style name="Preference.DeviceDefault.Category" parent="Preference.Material.Category">
+        <item name="layout">@layout/car_preference_category</item>
+    </style>
+    <style name="Preference.DeviceDefault.CheckBoxPreference" parent="Preference.Material.CheckBoxPreference">
+        <item name="layout">@layout/car_preference</item>
+    </style>
+    <style name="Preference.DeviceDefault.DialogPreference" parent="Preference.Material.DialogPreference">
+        <item name="layout">@layout/car_preference</item>
+    </style>
+    <style name="Preference.DeviceDefault.DialogPreference.EditTextPreference" parent="Preference.Material.DialogPreference.EditTextPreference">
+        <item name="layout">@layout/car_preference</item>
+    </style>
+    <style name="Preference.DeviceDefault.SwitchPreference" parent="Preference.Material.SwitchPreference">
+        <item name="layout">@layout/car_preference</item>
+    </style>
+
 </resources>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values/themes_device_defaults.xml b/car_product/overlay/frameworks/base/core/res/res/values/themes_device_defaults.xml
index 23a56b5..4f2e0fe 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values/themes_device_defaults.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values/themes_device_defaults.xml
@@ -33,8 +33,9 @@
         <item name="colorPrimaryDark">@color/primary_device_default_dark</item>
         <item name="colorForeground">@color/car_card_light</item>
         <item name="editTextColor">@color/car_body1</item>
+        <item name="listPreferredItemHeightSmall">@dimen/car_single_line_list_item_height</item>
         <item name="textColorHint">@color/car_body2</item>
-        <item name="textColorPrimary">@color/car_body1</item>
+        <item name="textColorPrimary">@color/primary_text</item>
         <item name="textColorSecondary">@color/car_body2</item>
         <item name="textColorHint">@color/car_grey_400</item>
         <item name="toastFrameBackground">@drawable/toast_frame</item>