- make lineitem aware of its state: clicable, enabled, expandable
- switch TimezonePicker to use paged list pattern
- make action bar span the full width, so the home/back button can be customized
- add checkbox line item type
- customize switch and seekbar
- many other UI tweaks
Test: manually tested
Change-Id: I0a1559630073a53bc798802d680ce28e1b120c3c
diff --git a/res/color/text_body_1.xml b/res/color/text_body_1.xml
new file mode 100644
index 0000000..0293e6f
--- /dev/null
+++ b/res/color/text_body_1.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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="@color/car_body1" />
+ <item android:state_enabled="false"
+ android:alpha="0.5"
+ android:color="@color/car_body1" />
+</selector>
\ No newline at end of file
diff --git a/res/color/text_body_2.xml b/res/color/text_body_2.xml
new file mode 100644
index 0000000..de1bc52
--- /dev/null
+++ b/res/color/text_body_2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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="@color/car_body2" />
+ <item android:state_enabled="false"
+ android:alpha="0.5"
+ android:color="@color/car_body2" />
+</selector>
\ No newline at end of file
diff --git a/res/drawable/ic_arrow_back.xml b/res/drawable/ic_arrow_back.xml
index 666d256..da6334f 100644
--- a/res/drawable/ic_arrow_back.xml
+++ b/res/drawable/ic_arrow_back.xml
@@ -18,14 +18,13 @@
~ does not provide a way to customize it. Here to center the icon in action bar, we make up
~ the margin by add the extra space in the icon itself -->
<vector
- android:height="@dimen/icon_size"
- android:width="@dimen/double_icon_size"
+ android:height="@dimen/stream_button_icon_size"
+ android:width="@dimen/stream_button_icon_size"
android:tint="@color/car_teal_700"
android:viewportHeight="24.0"
- android:viewportWidth="48.0"
+ android:viewportWidth="24.0"
xmlns:android="http://schemas.android.com/apk/res/android">
- <group
- android:translateX="12.0" >
- <path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
- </group>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>
diff --git a/res/drawable/ic_check_box.xml b/res/drawable/ic_check_box.xml
new file mode 100644
index 0000000..98b2869
--- /dev/null
+++ b/res/drawable/ic_check_box.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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:drawable="@drawable/ic_check_box_unchecked"
+ android:state_checked="false"/>
+ <item android:drawable="@drawable/ic_check_box_checked"
+ android:state_checked="true"/>
+ <item android:drawable="@drawable/ic_check_box_unchecked"/>
+</selector>
\ No newline at end of file
diff --git a/res/drawable/ic_check_box_checked.xml b/res/drawable/ic_check_box_checked.xml
new file mode 100644
index 0000000..b0b0dd0
--- /dev/null
+++ b/res/drawable/ic_check_box_checked.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright (C) 2017 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="@dimen/stream_button_icon_size"
+ android:height="@dimen/stream_button_icon_size"
+ android:tint="@color/car_teal_700"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/drawable/ic_check_box_unchecked.xml b/res/drawable/ic_check_box_unchecked.xml
new file mode 100644
index 0000000..fcfbace
--- /dev/null
+++ b/res/drawable/ic_check_box_unchecked.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright (C) 2017 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="@dimen/stream_button_icon_size"
+ android:height="@dimen/stream_button_icon_size"
+ android:tint="@color/car_tint"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/layout/action_bar.xml b/res/layout/action_bar.xml
index 7646ed3..9dc897f 100644
--- a/res/layout/action_bar.xml
+++ b/res/layout/action_bar.xml
@@ -19,11 +19,20 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/lens_header_height"
- android:gravity="end|center_vertical">
+ android:gravity="end|center_vertical" >
+ <FrameLayout
+ android:id="@+id/action_bar_icon_container"
+ android:layout_width="@dimen/side_margin"
+ android:layout_height="@dimen/lens_header_height"
+ android:layout_alignParentStart="true">
+ <ImageView
+ style="@style/SettingIcon.ActionBar"/>
+ </FrameLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/side_margin"
style="@style/CarTitle"
android:textColor="@color/car_teal_700"
android:layout_gravity="center_vertical"
diff --git a/res/layout/action_bar_with_button.xml b/res/layout/action_bar_with_button.xml
index e45cff8..1e14bfa 100644
--- a/res/layout/action_bar_with_button.xml
+++ b/res/layout/action_bar_with_button.xml
@@ -19,8 +19,16 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/lens_header_height"
- android:gravity="end|center_vertical">
+ android:gravity="center_vertical">
+ <FrameLayout
+ android:id="@+id/action_bar_icon_container"
+ android:layout_width="@dimen/side_margin"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true">
+ <ImageView
+ style="@style/SettingIcon.ActionBar"/>
+ </FrameLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
@@ -30,6 +38,7 @@
android:gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
+ android:layout_marginStart="@dimen/side_margin"
android:maxLines="1"
android:ellipsize="end"/>
@@ -37,6 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
+ android:layout_gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/action_button2"
diff --git a/res/layout/action_bar_with_toggle.xml b/res/layout/action_bar_with_toggle.xml
index bb0af6a..1b7e335 100644
--- a/res/layout/action_bar_with_toggle.xml
+++ b/res/layout/action_bar_with_toggle.xml
@@ -20,6 +20,15 @@
android:layout_height="@dimen/lens_header_height"
android:gravity="center_vertical" >
+ <FrameLayout
+ android:id="@+id/action_bar_icon_container"
+ android:layout_width="@dimen/side_margin"
+ android:layout_height="@dimen/lens_header_height"
+ android:layout_alignParentStart="true">
+ <ImageView
+ style="@style/SettingIcon.ActionBar"/>
+ </FrameLayout>
+
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
@@ -29,14 +38,14 @@
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
+ android:layout_marginStart="@dimen/side_margin"
android:maxLines="1"
android:ellipsize="end"/>
<Switch
android:id="@+id/toggle_switch"
android:background="@null"
- android:layout_width="@dimen/stream_button_icon_size"
- android:layout_height="@dimen/stream_button_icon_size"
+ style="@style/SettingSwitch"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/action_bar_end_widget_margin_end" />
diff --git a/res/layout/app_compat_activity.xml b/res/layout/app_compat_activity.xml
index 3569ac8..fa7b834 100644
--- a/res/layout/app_compat_activity.xml
+++ b/res/layout/app_compat_activity.xml
@@ -26,7 +26,11 @@
android:layout_width="match_parent"
android:layout_height="@dimen/lens_header_height"
app:theme="@style/ActionBarStyle.Car"
- app:contentInsetStart="@dimen/stream_content_keyline_1" />
+ app:contentInsetStart="0dp" />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height"
+ android:background="@color/car_list_divider"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/layout/checkbox_line_item.xml b/res/layout/checkbox_line_item.xml
new file mode 100644
index 0000000..11addd3
--- /dev/null
+++ b/res/layout/checkbox_line_item.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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:id="@+id/dashboard_tile"
+ style="@style/LineItem" >
+
+ <CheckBox
+ android:id="@+id/checkbox"
+ android:layout_width="@dimen/stream_button_icon_size"
+ android:layout_height="@dimen/stream_button_icon_size"
+ android:layout_marginStart="@dimen/stream_card_keyline_1"
+ android:button="@drawable/ic_check_box"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="@dimen/stream_card_keyline_3"
+ android:layout_marginEnd="@dimen/stream_card_keyline_3"
+ style="@style/CarBody2.SingleLine"
+ android:gravity="center_vertical"/>
+
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
+</RelativeLayout>
diff --git a/res/layout/icon_text_line_item.xml b/res/layout/icon_text_line_item.xml
index 0cc5262..773fb5f 100644
--- a/res/layout/icon_text_line_item.xml
+++ b/res/layout/icon_text_line_item.xml
@@ -22,6 +22,7 @@
android:id="@+id/icon"
android:layout_marginStart="@dimen/stream_card_keyline_1"
android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
style="@style/SettingIcon" />
<LinearLayout
android:layout_width="match_parent"
@@ -50,6 +51,13 @@
style="@style/SettingIcon"
android:layout_marginEnd="@dimen/stream_card_keyline_1"
android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
android:src="@drawable/ic_chevron_right"
- android:visibility="gone"/>
+ android:tint="@color/text_body_1"/>
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
</RelativeLayout>
diff --git a/res/layout/icon_toggle_line_item.xml b/res/layout/icon_toggle_line_item.xml
index 113c45d..08fce25 100644
--- a/res/layout/icon_toggle_line_item.xml
+++ b/res/layout/icon_toggle_line_item.xml
@@ -16,7 +16,6 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/dashboard_tile"
style="@style/LineItem" >
<ImageView
@@ -50,9 +49,14 @@
</LinearLayout>
<Switch
android:id="@+id/toggle_switch"
- style="@style/SettingIcon"
- android:layout_marginEnd="@dimen/stream_card_keyline_1"
+ style="@style/SettingSwitch"
android:layout_alignParentEnd="true"
- android:switchMinWidth="@dimen/stream_button_icon_size"
- android:visibility="gone"/>
+ android:layout_centerVertical="true"
+ android:layout_marginEnd="@dimen/stream_card_keyline_1" />
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
</RelativeLayout>
diff --git a/res/layout/icon_widget_line_item.xml b/res/layout/icon_widget_line_item.xml
index 2e47a0a..77be271 100644
--- a/res/layout/icon_widget_line_item.xml
+++ b/res/layout/icon_widget_line_item.xml
@@ -47,7 +47,14 @@
style="@style/SettingIcon"
android:layout_marginEnd="@dimen/stream_card_keyline_1"
android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
android:src="@drawable/ic_settings_gear"
android:background="@null"
android:visibility="gone" />
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
</RelativeLayout>
diff --git a/res/layout/seekbar_line_item.xml b/res/layout/seekbar_line_item.xml
index 88df404..770dde5 100644
--- a/res/layout/seekbar_line_item.xml
+++ b/res/layout/seekbar_line_item.xml
@@ -15,19 +15,31 @@
~ limitations under the License
-->
-<LinearLayout
+<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/LineItem"
- android:layout_marginStart="@dimen/stream_card_keyline_1"
- android:layout_marginEnd="@dimen/stream_card_keyline_3"
- android:orientation="vertical" >
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/CarBody2.SingleLine" />
- <SeekBar
- android:id="@+id/seekbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-</LinearLayout>
\ No newline at end of file
+ style="@style/LineItem" >
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_centerVertical="true"
+ android:layout_alignParentStart="true"
+ android:layout_marginStart="@dimen/stream_card_keyline_1"
+ android:layout_marginEnd="@dimen/stream_card_keyline_3" >
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/CarBody2.SingleLine" />
+ <SeekBar
+ android:id="@+id/seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/text_line_item.xml b/res/layout/text_line_item.xml
index 98f1d3b..f9bda63 100644
--- a/res/layout/text_line_item.xml
+++ b/res/layout/text_line_item.xml
@@ -15,20 +15,42 @@
~ limitations under the License
-->
-<LinearLayout
+<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/LineItem"
- android:layout_marginStart="@dimen/stream_card_keyline_1"
- android:orientation="vertical" >
- <TextView
- android:id="@+id/title"
+ style="@style/LineItem" >
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/CarBody1.SingleLine" />
- <TextView
- android:id="@+id/desc"
+ android:orientation="vertical"
+ android:layout_centerVertical="true"
+ android:gravity="center_vertical"
+ android:layout_alignParentStart="true"
+ android:layout_marginStart="@dimen/stream_card_keyline_1"
+ android:layout_marginEnd="@dimen/stream_card_keyline_3" >
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/CarBody1.SingleLine" />
+ <TextView
+ android:id="@+id/desc"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/CarBody2.SingleLine"
+ android:layout_marginTop="@dimen/double_line_text_margin" />
+ </LinearLayout>
+ <ImageView
+ android:id="@+id/right_chevron"
+ style="@style/SettingIcon"
+ android:layout_marginEnd="@dimen/stream_card_keyline_1"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:src="@drawable/ic_chevron_right"
+ android:tint="@color/text_body_1"/>
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/double_line_text_margin"
- style="@style/CarBody2.SingleLine" />
-</LinearLayout>
\ No newline at end of file
+ android:layout_height="@dimen/car_divider_height" />
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/toggle_line_item.xml b/res/layout/toggle_line_item.xml
index b103af2..abd09df 100644
--- a/res/layout/toggle_line_item.xml
+++ b/res/layout/toggle_line_item.xml
@@ -42,8 +42,14 @@
</LinearLayout>
<Switch
android:id="@+id/toggle_switch"
- style="@style/SettingIcon"
+ style="@style/SettingSwitch"
android:layout_alignParentEnd="true"
- android:layout_marginEnd="@dimen/stream_card_keyline_1"
- android:switchMinWidth="@dimen/stream_button_icon_size"/>
+ android:layout_centerVertical="true"
+ android:layout_marginEnd="@dimen/stream_card_keyline_1"/>
+ <View
+ android:id="@+id/line_item_divider"
+ android:layout_alignParentBottom="true"
+ android:background="@color/car_list_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_divider_height" />
</com.android.car.settings.common.InterceptTouchRelativeLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index adc0602..5e04b3f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -16,7 +16,7 @@
<resources>
- <dimen name="icon_size">56dp</dimen>
+ <dimen name="switch_end_padding">5dp</dimen>
<dimen name="double_icon_size">112dp</dimen>
<dimen name="line_item_height">128dp</dimen>
<dimen name="side_margin">148dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 545c90c..f0cc501 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -18,17 +18,17 @@
<style name="LineItem">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/line_item_height</item>
- <item name="android:layout_gravity">center_vertical</item>
- <item name="android:gravity">center_vertical</item>
</style>
<style name="CarBody1.SingleLine" parent="@style/CarBody1">
<item name="android:maxLines">1</item>
+ <item name="android:textColor">@color/text_body_1</item>
<item name="android:ellipsize">marquee</item>
</style>
<style name="CarBody2.SingleLine" parent="@style/CarBody2">
<item name="android:maxLines">1</item>
+ <item name="android:textColor">@color/text_body_2</item>
<item name="android:ellipsize">end</item>
</style>
@@ -43,7 +43,6 @@
</style>
<style name="ActionBarStyle.Car" parent="@style/Theme.AppCompat">
- <item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="actionBarSize">@dimen/lens_header_height</item>
</style>
@@ -59,4 +58,20 @@
<item name="android:gravity">center_vertical</item>
<item name="android:scaleType">fitCenter</item>
</style>
+
+ <style name="SettingIcon.ActionBar" parent="SettingIcon">
+ <item name="android:tint">@color/car_teal_700</item>
+ <item name="android:layout_gravity">center</item>
+ <item name="android:src">@drawable/ic_arrow_back</item>
+ </style>
+
+ <style name="SettingSwitch">
+ <item name="android:layout_width">@dimen/stream_button_icon_size</item>
+ <item name="android:layout_height">@dimen/stream_button_icon_size</item>
+ <item name="android:paddingEnd">@dimen/switch_end_padding</item>
+ <item name="android:scaleX">1.5</item>
+ <item name="android:scaleY">1.5</item>
+ <!--<item name="android:thumb">@drawable/ic_toggle_thumb</item>-->
+ <!--<item name="android:track">@drawable/ic_toggle_track</item>-->
+ </style>
</resources>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
deleted file mode 100644
index c295f95..0000000
--- a/res/xml/display_settings.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:title="@string/display_settings" >
-
- <SwitchPreference
- android:key="auto_brightness"
- android:title="@string/auto_brightness_title"
- android:summary="@string/auto_brightness_summary"/>
-
- <SeekBarPreference
- android:key="brightness"
- android:title="@string/brightness"
- android:max="255"
- app:min="0"
- app:showSeekBarValue="false"/>
-
-</PreferenceScreen>
diff --git a/src/com/android/car/settings/applications/ApplicationLineItem.java b/src/com/android/car/settings/applications/ApplicationLineItem.java
index c168290..3407d0c 100644
--- a/src/com/android/car/settings/applications/ApplicationLineItem.java
+++ b/src/com/android/car/settings/applications/ApplicationLineItem.java
@@ -66,6 +66,11 @@
@Override
public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isExpandable() {
return mClickable;
}
diff --git a/src/com/android/car/settings/applications/ApplicationPermissionLineItem.java b/src/com/android/car/settings/applications/ApplicationPermissionLineItem.java
index bd7298c..ee69037 100644
--- a/src/com/android/car/settings/applications/ApplicationPermissionLineItem.java
+++ b/src/com/android/car/settings/applications/ApplicationPermissionLineItem.java
@@ -73,7 +73,12 @@
@Override
public boolean isEnabled() {
- return false;
+ return true;
+ }
+
+ @Override
+ public boolean isExpandable() {
+ return true;
}
@Override
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java b/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
index 341f5d9..e814ddf 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
@@ -157,13 +157,19 @@
switch (viewType) {
case BONDED_DEVICE_HEADER_TYPE:
v = layoutInflater.inflate(R.layout.text_line_item, parent, false);
- ((TextView) v.findViewById(R.id.title)).setText(
+ v.setEnabled(false);
+ ((TextView) v.findViewById(R.id.desc)).setText(
R.string.bluetooth_preference_paired_devices);
+ v.findViewById(R.id.title).setVisibility(View.GONE);
+ v.findViewById(R.id.right_chevron).setVisibility(View.GONE);
break;
case AVAILABLE_DEVICE_HEADER_TYPE:
v = layoutInflater.inflate(R.layout.text_line_item, parent, false);
- ((TextView) v.findViewById(R.id.title)).setText(
+ v.setEnabled(false);
+ ((TextView) v.findViewById(R.id.desc)).setText(
R.string.bluetooth_preference_found_devices);
+ v.findViewById(R.id.title).setVisibility(View.GONE);
+ v.findViewById(R.id.right_chevron).setVisibility(View.GONE);
break;
default:
v = layoutInflater.inflate(R.layout.icon_widget_line_item, parent, false);
diff --git a/src/com/android/car/settings/bluetooth/BluetoothProfileLineItem.java b/src/com/android/car/settings/bluetooth/BluetoothProfileLineItem.java
index d6e5592..6f213f2 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothProfileLineItem.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothProfileLineItem.java
@@ -21,7 +21,7 @@
import android.content.Context;
import android.support.v7.widget.RecyclerView;
-import com.android.car.settings.common.ToggleLineItem;
+import com.android.car.settings.common.CheckBoxLineItem;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
@@ -32,10 +32,10 @@
/**
* Represents a line item for a Bluetooth mProfile.
*/
-public class BluetoothProfileLineItem extends ToggleLineItem {
+public class BluetoothProfileLineItem extends CheckBoxLineItem {
private final LocalBluetoothProfile mProfile;
private final CachedBluetoothDevice mCachedDevice;
- private ToggleLineItemViewHolder mViewHolder;
+ private CheckboxLineItemViewHolder mViewHolder;
private DataChangedListener mDataChangedListener;
public interface DataChangedListener {
@@ -75,14 +75,19 @@
}
@Override
- public void bindViewHolder(ToggleLineItemViewHolder holder) {
- super.bindViewHolder(holder);
- mViewHolder = holder;
+ public boolean isExpandable() {
+ return false;
}
@Override
- public CharSequence getDesc() {
- return null;
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public void bindViewHolder(CheckboxLineItemViewHolder holder) {
+ super.bindViewHolder(holder);
+ mViewHolder = holder;
}
@Override
diff --git a/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java b/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
index 4aac3b2..0579a96 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
@@ -28,6 +28,7 @@
import com.android.car.settings.common.BaseFragment;
import com.android.car.settings.R;
+import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.view.PagedListView;
import com.android.settingslib.bluetooth.BluetoothCallback;
@@ -87,7 +88,7 @@
}
mLocalAdapter = mLocalManager.getBluetoothAdapter();
- mDeviceListView.setDefaultItemDecoration(new PagedListView.Decoration(getContext()));
+ mDeviceListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
// Set this to light mode, since the scroll bar buttons always appear
// on top of a dark scrim.
mDeviceListView.setDarkMode();
diff --git a/src/com/android/car/settings/common/BaseFragment.java b/src/com/android/car/settings/common/BaseFragment.java
index 819f30c..9d225c5 100644
--- a/src/com/android/car/settings/common/BaseFragment.java
+++ b/src/com/android/car/settings/common/BaseFragment.java
@@ -107,12 +107,14 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setCustomView(mActionBarLayout);
actionBar.setDisplayShowCustomEnabled(true);
// make the toolbar take the whole width.
Toolbar toolbar=(Toolbar)actionBar.getCustomView().getParent();
toolbar.setPadding(0, 0, 0, 0);
+ getActivity().findViewById(R.id.action_bar_icon_container).setOnClickListener(
+ v -> mFragmentController.goBack());
((TextView) getActivity().findViewById(R.id.title)).setText(mTitleId);
}
}
diff --git a/src/com/android/car/settings/common/CarSettingActivity.java b/src/com/android/car/settings/common/CarSettingActivity.java
index f705ae3..88bb33b 100644
--- a/src/com/android/car/settings/common/CarSettingActivity.java
+++ b/src/com/android/car/settings/common/CarSettingActivity.java
@@ -71,16 +71,4 @@
super.onBackPressed();
}
}
-
- /**
- * Make home button as back button.
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- onBackPressed();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
}
diff --git a/src/com/android/car/settings/common/CheckBoxLineItem.java b/src/com/android/car/settings/common/CheckBoxLineItem.java
new file mode 100644
index 0000000..261fe81
--- /dev/null
+++ b/src/com/android/car/settings/common/CheckBoxLineItem.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package com.android.car.settings.common;
+
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import com.android.car.settings.R;
+
+/**
+ * Contains logic for a line item represents title text and a checkbox.
+ */
+public abstract class CheckBoxLineItem
+ extends TypedPagedListAdapter.LineItem<CheckBoxLineItem.CheckboxLineItemViewHolder> {
+ private final CharSequence mTitle;
+
+ private View.OnClickListener mOnClickListener = (v) -> {
+ CheckBox checkBox = v.findViewById(R.id.checkbox);
+ CheckBoxLineItem.this.onClick(checkBox.isChecked());
+ };
+
+ public CheckBoxLineItem(CharSequence title) {
+ mTitle = title;
+ }
+
+ public int getType() {
+ return CHECKBOX_TYPE;
+ }
+
+ public void bindViewHolder(CheckboxLineItemViewHolder viewHolder) {
+ viewHolder.titleView.setText(mTitle);
+ viewHolder.checkbox.setChecked(isChecked());
+ viewHolder.itemView.setOnClickListener(mOnClickListener);
+ }
+
+ public static class CheckboxLineItemViewHolder extends RecyclerView.ViewHolder {
+ final TextView titleView;
+ public final CheckBox checkbox;
+
+ public CheckboxLineItemViewHolder(View view) {
+ super(view);
+ titleView = view.findViewById(R.id.title);
+ checkbox = view.findViewById(R.id.checkbox);
+ }
+ }
+
+ public static RecyclerView.ViewHolder createViewHolder(ViewGroup parent) {
+ View v = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.checkbox_line_item, parent, false);
+ return new CheckboxLineItemViewHolder(v);
+ }
+
+ /**
+ * Called when any part of the line is clicked.
+ * @param isChecked the state of the switch widget at the time of click.
+ */
+ public abstract void onClick(boolean isChecked);
+
+ public abstract boolean isChecked();
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
+ public CharSequence getDesc() {
+ return null;
+ }
+}
diff --git a/src/com/android/car/settings/common/IconTextLineItem.java b/src/com/android/car/settings/common/IconTextLineItem.java
index 2c0f7c3..11a5d38 100644
--- a/src/com/android/car/settings/common/IconTextLineItem.java
+++ b/src/com/android/car/settings/common/IconTextLineItem.java
@@ -56,13 +56,10 @@
viewHolder.descView.setText(desc);
}
viewHolder.itemView.setOnClickListener(mOnClickListener);
- if (isEnabled()) {
- viewHolder.itemView.setEnabled(true);
- viewHolder.rightArrow.setVisibility(View.VISIBLE);
- } else {
- viewHolder.itemView.setEnabled(false);
- viewHolder.rightArrow.setVisibility(View.GONE);
- }
+ viewHolder.rightArrow.setVisibility(
+ isExpandable() ? View.VISIBLE : View.INVISIBLE);
+ viewHolder.dividerLine.setVisibility(
+ isClickable() && isEnabled() ? View.VISIBLE : View.INVISIBLE);
}
static class ViewHolder extends RecyclerView.ViewHolder {
@@ -70,6 +67,7 @@
final TextView descView;
final ImageView iconView;
final ImageView rightArrow;
+ public final View dividerLine;
public ViewHolder(View view) {
super(view);
@@ -77,6 +75,7 @@
titleView = (TextView) view.findViewById(R.id.title);
descView = (TextView) view.findViewById(R.id.desc);
rightArrow = (ImageView) view.findViewById(R.id.right_chevron);
+ dividerLine = view.findViewById(R.id.line_item_divider);
}
}
@@ -89,6 +88,4 @@
public abstract void setIcon(ImageView iconView);
public abstract void onClick();
-
- public abstract boolean isEnabled();
}
diff --git a/src/com/android/car/settings/common/IconToggleLineItem.java b/src/com/android/car/settings/common/IconToggleLineItem.java
index 83b82cd..73f5641 100644
--- a/src/com/android/car/settings/common/IconToggleLineItem.java
+++ b/src/com/android/car/settings/common/IconToggleLineItem.java
@@ -77,7 +77,6 @@
title = (TextView) itemView.findViewById(R.id.title);
summary = (TextView) itemView.findViewById(R.id.desc);
toggle = (Switch) itemView.findViewById(R.id.toggle_switch);
- toggle.setVisibility(View.VISIBLE);
}
@Override
@@ -106,4 +105,9 @@
public abstract boolean isChecked();
public abstract @DrawableRes int getIcon();
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
}
diff --git a/src/com/android/car/settings/common/ListSettingsFragment.java b/src/com/android/car/settings/common/ListSettingsFragment.java
index c20d52c..b1114e8 100644
--- a/src/com/android/car/settings/common/ListSettingsFragment.java
+++ b/src/com/android/car/settings/common/ListSettingsFragment.java
@@ -45,7 +45,7 @@
super.onActivityCreated(savedInstanceState);
mListView = (PagedListView) getView().findViewById(R.id.list);
- mListView.setDefaultItemDecoration(getDecoration());
+ mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
mListView.setDarkMode();
mPagedListAdapter = new TypedPagedListAdapter(getContext(), getLineItems());
mListView.setAdapter(mPagedListAdapter);
@@ -55,11 +55,4 @@
* Gets a List of LineItems to show up in this activity.
*/
public abstract ArrayList<TypedPagedListAdapter.LineItem> getLineItems();
-
- /**
- * Gets decoration for the list view.
- */
- protected PagedListView.Decoration getDecoration() {
- return new PagedListView.Decoration(getContext());
- }
}
diff --git a/src/com/android/car/settings/common/SeekbarLineItem.java b/src/com/android/car/settings/common/SeekbarLineItem.java
index 1140f02..69ee294 100644
--- a/src/com/android/car/settings/common/SeekbarLineItem.java
+++ b/src/com/android/car/settings/common/SeekbarLineItem.java
@@ -96,4 +96,14 @@
public abstract int getMaxSeekbarValue();
public abstract void onSeekbarChanged(int progress);
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
}
diff --git a/src/com/android/car/settings/common/SimpleIconLineItem.java b/src/com/android/car/settings/common/SimpleIconLineItem.java
index dcdc910..20b6f67 100644
--- a/src/com/android/car/settings/common/SimpleIconLineItem.java
+++ b/src/com/android/car/settings/common/SimpleIconLineItem.java
@@ -61,7 +61,7 @@
}
@Override
- public boolean isEnabled() {
+ public boolean isExpandable() {
return true;
}
diff --git a/src/com/android/car/settings/common/SimpleTextLineItem.java b/src/com/android/car/settings/common/SimpleTextLineItem.java
index d026410..4d59610 100644
--- a/src/com/android/car/settings/common/SimpleTextLineItem.java
+++ b/src/com/android/car/settings/common/SimpleTextLineItem.java
@@ -36,7 +36,7 @@
}
@Override
- public boolean isEnabled() {
+ public boolean isExpandable() {
return false;
}
diff --git a/src/com/android/car/settings/common/TextLineItem.java b/src/com/android/car/settings/common/TextLineItem.java
index f1227e9..683eca6 100644
--- a/src/com/android/car/settings/common/TextLineItem.java
+++ b/src/com/android/car/settings/common/TextLineItem.java
@@ -20,6 +20,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.TextView;
import com.android.car.settings.R;
@@ -46,16 +47,29 @@
viewHolder.descView.setText(getDesc());
viewHolder.itemView.setOnClickListener(mOnClickListener);
viewHolder.itemView.setEnabled(isEnabled());
+ viewHolder.titleView.setEnabled(isClickable() && isEnabled());
+ viewHolder.descView.setEnabled(isClickable() && isEnabled());
+ viewHolder.rightArrow.setEnabled(isEnabled());
+ viewHolder.rightArrow.setVisibility(
+ isExpandable() ? View.VISIBLE : View.INVISIBLE);
+ // set the dividerLine to INVISIBLE instead of GONE so the content of the line item
+ // don't need to shift.
+ viewHolder.dividerLine.setVisibility(
+ isClickable() && isEnabled() ? View.VISIBLE : View.INVISIBLE);
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public final TextView titleView;
public final TextView descView;
+ final ImageView rightArrow;
+ public final View dividerLine;
public ViewHolder(View view) {
super(view);
titleView = (TextView) view.findViewById(R.id.title);
descView = (TextView) view.findViewById(R.id.desc);
+ rightArrow = (ImageView) view.findViewById(R.id.right_chevron);
+ dividerLine = view.findViewById(R.id.line_item_divider);
}
}
@@ -66,6 +80,4 @@
}
public abstract void onClick();
-
- public abstract boolean isEnabled();
}
diff --git a/src/com/android/car/settings/common/ToggleLineItem.java b/src/com/android/car/settings/common/ToggleLineItem.java
index 857ee0f..78bee07 100644
--- a/src/com/android/car/settings/common/ToggleLineItem.java
+++ b/src/com/android/car/settings/common/ToggleLineItem.java
@@ -26,7 +26,7 @@
import com.android.car.settings.R;
/**
- * Contains logic for a line item represents title text, description text and a toggle widget.
+ * Contains logic for a line item represents title text, description text and a checkbox widget.
*/
public abstract class ToggleLineItem
extends TypedPagedListAdapter.LineItem<ToggleLineItem.ToggleLineItemViewHolder> {
@@ -84,4 +84,9 @@
public abstract void onClick(boolean isChecked);
public abstract boolean isChecked();
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
}
diff --git a/src/com/android/car/settings/common/TypedPagedListAdapter.java b/src/com/android/car/settings/common/TypedPagedListAdapter.java
index c92625f..3a42567 100644
--- a/src/com/android/car/settings/common/TypedPagedListAdapter.java
+++ b/src/com/android/car/settings/common/TypedPagedListAdapter.java
@@ -67,7 +67,8 @@
TOGGLE_TYPE,
ICON_TEXT_TYPE,
SEEKBAR_TYPE,
- ICON_TOGGLE_TYPE})
+ ICON_TOGGLE_TYPE,
+ CHECKBOX_TYPE})
public @interface LineItemType {}
// with one title and one description
@@ -85,12 +86,35 @@
// with one icon, title, description and a toggle.
static final int ICON_TOGGLE_TYPE = 5;
+ // with one icon, title and a checkbox.
+ static final int CHECKBOX_TYPE = 6;
+
@LineItemType
abstract int getType();
abstract void bindViewHolder(VH holder);
public abstract CharSequence getDesc();
+
+ /**
+ * Returns true if this item is ready to receive touch. If it's set to false,
+ * this item maybe not clickable or temporarily not functional.
+ */
+ public boolean isEnabled() {
+ return true;
+ }
+
+ /**
+ * Returns true if some component on this item can be clicked.
+ */
+ public boolean isClickable() {
+ return isExpandable();
+ }
+
+ /**
+ * Returns true if this item can launch another activity or fragment.
+ */
+ public abstract boolean isExpandable();
}
@Override
@@ -106,6 +130,8 @@
return SeekbarLineItem.createViewHolder(parent);
case LineItem.ICON_TOGGLE_TYPE:
return IconToggleLineItem.createViewHolder(parent);
+ case LineItem.CHECKBOX_TYPE:
+ return CheckBoxLineItem.createViewHolder(parent);
default:
throw new IllegalStateException("ViewType not supported: " + viewType);
}
diff --git a/src/com/android/car/settings/datetime/DateTimeToggleLineItem.java b/src/com/android/car/settings/datetime/DateTimeToggleLineItem.java
index b7453cb..1e8fc93 100644
--- a/src/com/android/car/settings/datetime/DateTimeToggleLineItem.java
+++ b/src/com/android/car/settings/datetime/DateTimeToggleLineItem.java
@@ -56,4 +56,9 @@
public CharSequence getDesc() {
return mDesc;
}
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
}
diff --git a/src/com/android/car/settings/datetime/SetDateLineItem.java b/src/com/android/car/settings/datetime/SetDateLineItem.java
index 2dfe0e8..8feed6b 100644
--- a/src/com/android/car/settings/datetime/SetDateLineItem.java
+++ b/src/com/android/car/settings/datetime/SetDateLineItem.java
@@ -51,6 +51,11 @@
}
@Override
+ public boolean isExpandable() {
+ return true;
+ }
+
+ @Override
public void onClick() {
mFragmentController.launchFragment(DatePickerFragment.getInstance());
}
diff --git a/src/com/android/car/settings/datetime/SetTimeLineItem.java b/src/com/android/car/settings/datetime/SetTimeLineItem.java
index 26fcf67..15bb9d2 100644
--- a/src/com/android/car/settings/datetime/SetTimeLineItem.java
+++ b/src/com/android/car/settings/datetime/SetTimeLineItem.java
@@ -52,6 +52,11 @@
}
@Override
+ public boolean isExpandable() {
+ return true;
+ }
+
+ @Override
public void onClick() {
mFragmentController.launchFragment(TimePickerFragment.getInstance());
}
diff --git a/src/com/android/car/settings/datetime/SetTimeZoneLineItem.java b/src/com/android/car/settings/datetime/SetTimeZoneLineItem.java
index 3e23c27..344f3ff 100644
--- a/src/com/android/car/settings/datetime/SetTimeZoneLineItem.java
+++ b/src/com/android/car/settings/datetime/SetTimeZoneLineItem.java
@@ -52,6 +52,16 @@
}
@Override
+ public boolean isExpandable() {
+ return false;
+ }
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
public void onClick() {
mFragmentController.launchFragment(TimeZonePickerFragment.getInstance());
}
diff --git a/src/com/android/car/settings/datetime/TimeFormatToggleLineItem.java b/src/com/android/car/settings/datetime/TimeFormatToggleLineItem.java
index 3f72c50..58430ad 100644
--- a/src/com/android/car/settings/datetime/TimeFormatToggleLineItem.java
+++ b/src/com/android/car/settings/datetime/TimeFormatToggleLineItem.java
@@ -78,4 +78,9 @@
return DateFormat.getTimeFormat(mContext)
.format(mTimeFormatDemoDate.getTime());
}
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
}
diff --git a/src/com/android/car/settings/datetime/TimeZoneLineItem.java b/src/com/android/car/settings/datetime/TimeZoneLineItem.java
new file mode 100644
index 0000000..7582734
--- /dev/null
+++ b/src/com/android/car/settings/datetime/TimeZoneLineItem.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package com.android.car.settings.datetime;
+
+import android.app.AlarmManager;
+import android.content.Context;
+import android.provider.Settings;
+
+import android.annotation.NonNull;
+import com.android.car.settings.R;
+import com.android.car.settings.common.TextLineItem;
+import com.android.settingslib.datetime.ZoneGetter;
+
+import java.util.Map;
+
+/**
+ * A LineItem that displays available time zone.
+ */
+class TimeZoneLineItem extends TextLineItem {
+ private final Context mContext;
+ private final TimeZoneChangeListener mListener;
+ private final Map<String, Object> mTimeZone;
+
+ public interface TimeZoneChangeListener {
+ void onTimeZoneChanged();
+ }
+
+ public TimeZoneLineItem(
+ Context context,
+ @NonNull TimeZoneChangeListener listener,
+ Map<String, Object> timeZone) {
+ super((CharSequence) timeZone.get(ZoneGetter.KEY_DISPLAYNAME));
+ mContext = context;
+ mListener = listener;
+ mTimeZone = timeZone;
+ }
+
+ @Override
+ public CharSequence getDesc() {
+ return (CharSequence) mTimeZone.get(ZoneGetter.KEY_GMT);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.AUTO_TIME_ZONE, 0) <= 0;
+ }
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
+ public void onClick() {
+ AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+ am.setTimeZone((String) mTimeZone.get(ZoneGetter.KEY_ID));
+ mListener.onTimeZoneChanged();
+ }
+}
diff --git a/src/com/android/car/settings/datetime/TimeZoneListAdapter.java b/src/com/android/car/settings/datetime/TimeZoneListAdapter.java
deleted file mode 100644
index db3b009..0000000
--- a/src/com/android/car/settings/datetime/TimeZoneListAdapter.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-package com.android.car.settings.datetime;
-
-import android.annotation.NonNull;
-import android.app.AlarmManager;
-import android.content.Context;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import com.android.car.settings.R;
-import com.android.car.view.PagedListView;
-import com.android.settingslib.datetime.ZoneGetter;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Renders Timezone to a view to be displayed as a row in a list, also sets the timezone to the
- * picked one.
- */
-public class TimeZoneListAdapter
- extends RecyclerView.Adapter<TimeZoneListAdapter.ViewHolder>
- implements PagedListView.ItemCap {
- private static final String TAG = "TimeZoneListAdapter";
-
- private final TimeZoneChangeListener mListener;
- private final Context mContext;
- private final List<Map<String, Object>> mZoneList;
-
- public TimeZoneListAdapter(@NonNull Context context,
- @NonNull TimeZoneChangeListener listener) {
- mContext = context;
- mListener = listener;
- mZoneList = ZoneGetter.getZonesList(mContext);
- }
-
- public boolean isEmpty() {
- return mZoneList.isEmpty();
- }
-
- public interface TimeZoneChangeListener {
- void onTimeZoneChanged();
- }
-
- public class ViewHolder extends RecyclerView.ViewHolder {
- private final TextView mTitle;
- private final TextView mDesc;
-
- public ViewHolder(View view) {
- super(view);
- mTitle = (TextView) view.findViewById(R.id.title);
- mDesc = (TextView) view.findViewById(R.id.desc);
- mDesc.setVisibility(View.VISIBLE);
- }
- }
-
- private class TimeZoneClickListener implements OnClickListener {
- private final int mPosition;
-
- public TimeZoneClickListener(int position) {
- mPosition = position;
- }
-
- @Override
- public void onClick(View v) {
- Map<String, Object> timeZone = mZoneList.get(mPosition);
- AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
- am.setTimeZone((String) timeZone.get(ZoneGetter.KEY_ID));
- mListener.onTimeZoneChanged();
- }
- };
-
- @Override
- public TimeZoneListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
- int viewType) {
- View v = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.text_line_item, parent, false);
- return new ViewHolder(v);
- }
-
- @Override
- public void onBindViewHolder(ViewHolder holder, int position) {
- Map<String, Object> timeZone = mZoneList.get(position);
- holder.mTitle.setText((String) timeZone.get(ZoneGetter.KEY_DISPLAYNAME));
- holder.mDesc.setText((String) timeZone.get(ZoneGetter.KEY_GMT));
- holder.itemView.setOnClickListener(new TimeZoneClickListener(position));
- }
-
- @Override
- public int getItemCount() {
- return mZoneList.size();
- }
-
- @Override
- public void setMaxItems(int maxItems) {
- // no limit in this list.
- }
-}
diff --git a/src/com/android/car/settings/datetime/TimeZonePickerFragment.java b/src/com/android/car/settings/datetime/TimeZonePickerFragment.java
index 846d665..3ab3581 100644
--- a/src/com/android/car/settings/datetime/TimeZonePickerFragment.java
+++ b/src/com/android/car/settings/datetime/TimeZonePickerFragment.java
@@ -20,36 +20,43 @@
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
-import com.android.car.settings.common.BaseFragment;
import com.android.car.settings.R;
+import com.android.car.settings.common.ListSettingsFragment;
+import com.android.car.settings.common.TypedPagedListAdapter;
import com.android.car.view.PagedListView;
+import com.android.settingslib.datetime.ZoneGetter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
/**
* Lists all time zone and its offset from GMT.
*/
-public class TimeZonePickerFragment extends BaseFragment implements
- TimeZoneListAdapter.TimeZoneChangeListener {
+public class TimeZonePickerFragment extends ListSettingsFragment implements
+ TimeZoneLineItem.TimeZoneChangeListener {
+ private List<Map<String, Object>> mZoneList;
public static TimeZonePickerFragment getInstance() {
TimeZonePickerFragment timeZonePickerFragment = new TimeZonePickerFragment();
- Bundle bundle = BaseFragment.getBundle();
+ Bundle bundle = ListSettingsFragment.getBundle();
bundle.putInt(EXTRA_TITLE_ID, R.string.date_time_set_timezone_title);
- bundle.putInt(EXTRA_LAYOUT, R.layout.list);
- bundle.putInt(EXTRA_ACTION_BAR_LAYOUT, R.layout.action_bar);
timeZonePickerFragment.setArguments(bundle);
return timeZonePickerFragment;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
+ mZoneList = ZoneGetter.getZonesList(getContext());
super.onActivityCreated(savedInstanceState);
+ }
- PagedListView listView = (PagedListView) getView().findViewById(R.id.list);
- listView.setDefaultItemDecoration(new PagedListView.Decoration(getContext()));
- listView.setDarkMode();
- TimeZoneListAdapter adapter = new TimeZoneListAdapter(
- getContext(), this /* TimeZoneChangeListener */);
- listView.setAdapter(adapter);
+ public ArrayList<TypedPagedListAdapter.LineItem> getLineItems() {
+ ArrayList<TypedPagedListAdapter.LineItem> lineItems = new ArrayList<>();
+ for (Map<String, Object> zone : mZoneList) {
+ lineItems.add(new TimeZoneLineItem(getContext(), this, zone));
+ }
+ return lineItems;
}
@Override
diff --git a/src/com/android/car/settings/display/AutoBrightnessLineItem.java b/src/com/android/car/settings/display/AutoBrightnessLineItem.java
index f025a64..66f3c13 100644
--- a/src/com/android/car/settings/display/AutoBrightnessLineItem.java
+++ b/src/com/android/car/settings/display/AutoBrightnessLineItem.java
@@ -63,8 +63,14 @@
holder.itemView.setEnabled(isEnabled());
}
+ @Override
public boolean isEnabled() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
}
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
}
diff --git a/src/com/android/car/settings/home/BluetoothLineItem.java b/src/com/android/car/settings/home/BluetoothLineItem.java
index 1c35798..bf16831 100644
--- a/src/com/android/car/settings/home/BluetoothLineItem.java
+++ b/src/com/android/car/settings/home/BluetoothLineItem.java
@@ -52,6 +52,16 @@
}
@Override
+ public boolean isExpandable() {
+ return false;
+ }
+
+ @Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
public void onClicked() {
mFragmentController.launchFragment(BluetoothSettingsFragment.getInstance());
}
diff --git a/src/com/android/car/settings/home/HomepageFragment.java b/src/com/android/car/settings/home/HomepageFragment.java
index d990237..d4f3cfa 100644
--- a/src/com/android/car/settings/home/HomepageFragment.java
+++ b/src/com/android/car/settings/home/HomepageFragment.java
@@ -23,6 +23,7 @@
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import android.view.View;
import com.android.car.settings.R;
import com.android.car.settings.applications.ApplicationSettingsFragment;
@@ -85,7 +86,7 @@
// Call super after the wifiLineItem and BluetoothLineItem are setup, because
// those are needed in super.onCreate().
super.onActivityCreated(savedInstanceState);
- ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+ getActivity().findViewById(R.id.action_bar_icon_container).setVisibility(View.GONE);
}
@Override
diff --git a/src/com/android/car/settings/home/WifiLineItem.java b/src/com/android/car/settings/home/WifiLineItem.java
index 1bc1a05..27618b9 100644
--- a/src/com/android/car/settings/home/WifiLineItem.java
+++ b/src/com/android/car/settings/home/WifiLineItem.java
@@ -67,6 +67,11 @@
}
@Override
+ public boolean isExpandable() {
+ return true;
+ }
+
+ @Override
public @DrawableRes int getIcon() {
return getIconRes(mCarWifiManager.getWifiState());
}
diff --git a/src/com/android/car/settings/sound/SoundSettingsFragment.java b/src/com/android/car/settings/sound/SoundSettingsFragment.java
index 6094224..03feb9a 100644
--- a/src/com/android/car/settings/sound/SoundSettingsFragment.java
+++ b/src/com/android/car/settings/sound/SoundSettingsFragment.java
@@ -29,6 +29,7 @@
import android.util.Log;
import com.android.car.settings.common.BaseFragment;
+import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.settings.common.TypedPagedListAdapter;
import com.android.car.settings.R;
import com.android.car.view.PagedListView;
@@ -112,8 +113,7 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = (PagedListView) getView().findViewById(R.id.list);
- mListView.setDefaultItemDecoration(
- new PagedListView.Decoration(getContext()));
+ mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
mListView.setDarkMode();
mPagedListAdapter = new TypedPagedListAdapter(getContext());
mListView.setAdapter(mPagedListAdapter);
diff --git a/src/com/android/car/settings/sound/VolumeLineItem.java b/src/com/android/car/settings/sound/VolumeLineItem.java
index 2df5e3e..6baf38b 100644
--- a/src/com/android/car/settings/sound/VolumeLineItem.java
+++ b/src/com/android/car/settings/sound/VolumeLineItem.java
@@ -108,6 +108,8 @@
Log.w(TAG, "CarAudiomanager not available, Car is not connected!");
return;
}
+ // the flag is a request to play sound, depend on implementation, it may not play
+ // anything, the listener in SoundSettings class will play audible feedback.
mCarAudioManager.setStreamVolume(streamType, progress, AudioManager.FLAG_PLAY_SOUND);
playAudioFeedback();
} catch (CarNotConnectedException e) {
diff --git a/src/com/android/car/settings/system/AboutSettingsFragment.java b/src/com/android/car/settings/system/AboutSettingsFragment.java
index a4976a2..e69513f 100644
--- a/src/com/android/car/settings/system/AboutSettingsFragment.java
+++ b/src/com/android/car/settings/system/AboutSettingsFragment.java
@@ -20,7 +20,6 @@
import android.os.Bundle;
import com.android.car.settings.common.ListSettingsFragment;
-import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.settings.common.SimpleTextLineItem;
import com.android.car.settings.common.TypedPagedListAdapter;
import com.android.car.settings.R;
@@ -58,9 +57,4 @@
getText(R.string.build_number), Build.DISPLAY));
return lineItems;
}
-
- @Override
- public PagedListView.Decoration getDecoration() {
- return new NoDividerItemDecoration(getContext());
- }
}
diff --git a/src/com/android/car/settings/system/AboutSystemLineItem.java b/src/com/android/car/settings/system/AboutSystemLineItem.java
index f8c4537..26195d7 100644
--- a/src/com/android/car/settings/system/AboutSystemLineItem.java
+++ b/src/com/android/car/settings/system/AboutSystemLineItem.java
@@ -44,7 +44,7 @@
}
@Override
- public boolean isEnabled() {
+ public boolean isExpandable() {
return true;
}
diff --git a/src/com/android/car/settings/system/LegalInfoLineItem.java b/src/com/android/car/settings/system/LegalInfoLineItem.java
index d5cb484..383adfd 100644
--- a/src/com/android/car/settings/system/LegalInfoLineItem.java
+++ b/src/com/android/car/settings/system/LegalInfoLineItem.java
@@ -46,6 +46,11 @@
}
@Override
+ public boolean isExpandable() {
+ return true;
+ }
+
+ @Override
public void onClick() {
// TODO: link to a legal info page.
}
diff --git a/src/com/android/car/settings/system/SystemUpdatesLineItem.java b/src/com/android/car/settings/system/SystemUpdatesLineItem.java
index f97dc24..1641cb0 100644
--- a/src/com/android/car/settings/system/SystemUpdatesLineItem.java
+++ b/src/com/android/car/settings/system/SystemUpdatesLineItem.java
@@ -47,6 +47,16 @@
}
@Override
+ public boolean isClickable() {
+ return true;
+ }
+
+ @Override
+ public boolean isExpandable() {
+ return false;
+ }
+
+ @Override
public void onClick() {
// TODO: trigger system OTA flow
}
diff --git a/src/com/android/car/settings/wifi/WifiSettingsFragment.java b/src/com/android/car/settings/wifi/WifiSettingsFragment.java
index 7021ec6..911d869 100644
--- a/src/com/android/car/settings/wifi/WifiSettingsFragment.java
+++ b/src/com/android/car/settings/wifi/WifiSettingsFragment.java
@@ -28,6 +28,7 @@
import com.android.car.settings.common.BaseFragment;
import com.android.car.settings.R;
+import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.view.PagedListView;
import com.android.settingslib.wifi.AccessPoint;
@@ -72,7 +73,7 @@
} else {
showMessage(R.string.wifi_disabled);
}
- mListView.setDefaultItemDecoration(new PagedListView.Decoration(getContext()));
+ mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
// Set this to light mode, since the scroll bar buttons always appear
// on top of a dark scrim.
mListView.setDarkMode();