refactor PagedList view:
- add attr for divider/no divider decoration
- left scroll width setable
enlarge switch to meet UX spec
change seekbar to meet ux spec
Test: run manually
Change-Id: I3454240d8efe334cec7678855489f9f9f9782397
diff --git a/res/drawable/ic_seekbar_thumb.xml b/res/drawable/ic_seekbar_thumb.xml
new file mode 100644
index 0000000..72871be
--- /dev/null
+++ b/res/drawable/ic_seekbar_thumb.xml
@@ -0,0 +1,28 @@
+<?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
+ -->
+
+<shape
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval">
+ <solid android:color="@color/car_teal_700" />
+ <size
+ android:width="20dp"
+ android:height="20dp" />
+ <stroke
+ android:width="1dp"
+ android:color="@color/car_teal_700" />
+</shape>
diff --git a/res/drawable/ic_seekbar_track.xml b/res/drawable/ic_seekbar_track.xml
new file mode 100644
index 0000000..d862f5a
--- /dev/null
+++ b/res/drawable/ic_seekbar_track.xml
@@ -0,0 +1,38 @@
+<?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
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Use android provided id, as seekbar is expecting that -->
+ <item android:id="@android:id/background">
+ <shape android:shape="line">
+ <corners
+ android:radius="@dimen/seekbar_track_corner"/>
+ <stroke
+ android:width="@dimen/seekbar_track_height"
+ android:color="@color/car_grey_300" />
+ </shape>
+ </item>
+ <item android:id="@android:id/progress">
+ <clip>
+ <shape android:shape="line">
+ <stroke
+ android:width="@dimen/seekbar_track_height"
+ android:color="@color/car_teal_700" />
+ </shape>
+ </clip>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/bluetooth_details.xml b/res/layout/bluetooth_details.xml
index 75fbffa..6c31f60 100644
--- a/res/layout/bluetooth_details.xml
+++ b/res/layout/bluetooth_details.xml
@@ -39,6 +39,7 @@
<com.android.car.view.PagedListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
+ style="@style/SettingPagedList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
diff --git a/res/layout/bluetooth_list.xml b/res/layout/bluetooth_list.xml
index 3c5b89c..31d1071 100644
--- a/res/layout/bluetooth_list.xml
+++ b/res/layout/bluetooth_list.xml
@@ -32,6 +32,7 @@
android:layout_height="match_parent">
<com.android.car.view.PagedListView
android:id="@+id/list"
+ style="@style/SettingPagedList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/side_margin" />
diff --git a/res/layout/list.xml b/res/layout/list.xml
index 8a967e4..6029a3f 100644
--- a/res/layout/list.xml
+++ b/res/layout/list.xml
@@ -17,10 +17,9 @@
<com.android.car.view.PagedListView
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list"
android:layout_marginEnd="@dimen/side_margin"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:usedInDrawer="true"
+ style="@style/SettingPagedList"
/>
diff --git a/res/layout/seekbar_line_item.xml b/res/layout/seekbar_line_item.xml
index 770dde5..7457643 100644
--- a/res/layout/seekbar_line_item.xml
+++ b/res/layout/seekbar_line_item.xml
@@ -27,14 +27,17 @@
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" />
+ 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"/>
+ android:paddingTop="@dimen/seekbar_padding_top"
+ android:id="@+id/seekbar"
+ android:progressDrawable="@drawable/ic_seekbar_track"
+ android:thumb="@drawable/ic_seekbar_thumb"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:id="@+id/line_item_divider"
diff --git a/res/layout/single_text_line_item.xml b/res/layout/single_text_line_item.xml
new file mode 100644
index 0000000..f5602bf
--- /dev/null
+++ b/res/layout/single_text_line_item.xml
@@ -0,0 +1,37 @@
+<?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"
+ style="@style/LineItem" >
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ 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"
+ style="@style/CarBody2.SingleLine" />
+ <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/wifi_list.xml b/res/layout/wifi_list.xml
index ee1cffb..fe7f7c6 100644
--- a/res/layout/wifi_list.xml
+++ b/res/layout/wifi_list.xml
@@ -33,6 +33,7 @@
android:layout_marginEnd="@dimen/side_margin" >
<com.android.car.view.PagedListView
android:id="@+id/list"
+ style="@style/SettingPagedList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5e04b3f..8ad53a6 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -16,6 +16,9 @@
<resources>
+ <dimen name="seekbar_track_height">6dp</dimen>
+ <dimen name="seekbar_track_corner">3dp</dimen>
+ <dimen name="seekbar_padding_top">10dp</dimen>
<dimen name="switch_end_padding">5dp</dimen>
<dimen name="double_icon_size">112dp</dimen>
<dimen name="line_item_height">128dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index f0cc501..bc02fc2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -71,7 +71,11 @@
<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>
+
+ <style name="SettingPagedList">
+ <item name="scrollbarContainerWidth">@dimen/side_margin</item>
+ <item name="showDivider">false</item>
+ <item name="usedInDrawer">true</item>
</style>
</resources>
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDetailFragment.java b/src/com/android/car/settings/bluetooth/BluetoothDetailFragment.java
index 508412d..6a37a72 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDetailFragment.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDetailFragment.java
@@ -26,7 +26,6 @@
import com.android.car.settings.common.BaseFragment;
import com.android.car.settings.R;
-import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.settings.common.TypedPagedListAdapter;
import com.android.car.view.PagedListView;
@@ -82,7 +81,6 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = (PagedListView) getView().findViewById(R.id.list);
- mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
mListView.setDarkMode();
if (mDevice == null) {
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java b/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
index e814ddf..f8ef05d 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDeviceListAdapter.java
@@ -156,20 +156,16 @@
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
switch (viewType) {
case BONDED_DEVICE_HEADER_TYPE:
- v = layoutInflater.inflate(R.layout.text_line_item, parent, false);
+ v = layoutInflater.inflate(R.layout.single_text_line_item, parent, false);
v.setEnabled(false);
- ((TextView) v.findViewById(R.id.desc)).setText(
+ ((TextView) v.findViewById(R.id.title)).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);
+ v = layoutInflater.inflate(R.layout.single_text_line_item, parent, false);
v.setEnabled(false);
- ((TextView) v.findViewById(R.id.desc)).setText(
+ ((TextView) v.findViewById(R.id.title)).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/BluetoothSettingsFragment.java b/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
index 0579a96..3c39fa3 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothSettingsFragment.java
@@ -28,7 +28,6 @@
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;
@@ -88,7 +87,6 @@
}
mLocalAdapter = mLocalManager.getBluetoothAdapter();
- 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/ListSettingsFragment.java b/src/com/android/car/settings/common/ListSettingsFragment.java
index b1114e8..97b03e1 100644
--- a/src/com/android/car/settings/common/ListSettingsFragment.java
+++ b/src/com/android/car/settings/common/ListSettingsFragment.java
@@ -45,7 +45,6 @@
super.onActivityCreated(savedInstanceState);
mListView = (PagedListView) getView().findViewById(R.id.list);
- mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
mListView.setDarkMode();
mPagedListAdapter = new TypedPagedListAdapter(getContext(), getLineItems());
mListView.setAdapter(mPagedListAdapter);
diff --git a/src/com/android/car/settings/common/NoDividerItemDecoration.java b/src/com/android/car/settings/common/NoDividerItemDecoration.java
deleted file mode 100644
index ba7661b..0000000
--- a/src/com/android/car/settings/common/NoDividerItemDecoration.java
+++ /dev/null
@@ -1,35 +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.common;
-
-import android.support.v7.widget.RecyclerView;
-import android.content.Context;
-import android.graphics.Canvas;
-import com.android.car.view.PagedListView;
-
-/**
- * Default {@link com.android.car.view.PagedListView.Decoration} for the {@link PagedListView}
- * that removes the dividing lines between items.
- */
-public class NoDividerItemDecoration extends PagedListView.Decoration {
- public NoDividerItemDecoration(Context context) {
- super(context);
- }
-
- @Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {}
-}
diff --git a/src/com/android/car/settings/sound/SoundSettingsFragment.java b/src/com/android/car/settings/sound/SoundSettingsFragment.java
index 03feb9a..199e647 100644
--- a/src/com/android/car/settings/sound/SoundSettingsFragment.java
+++ b/src/com/android/car/settings/sound/SoundSettingsFragment.java
@@ -29,7 +29,6 @@
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;
@@ -113,7 +112,6 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = (PagedListView) getView().findViewById(R.id.list);
- mListView.setDefaultItemDecoration(new NoDividerItemDecoration(getContext()));
mListView.setDarkMode();
mPagedListAdapter = new TypedPagedListAdapter(getContext());
mListView.setAdapter(mPagedListAdapter);
diff --git a/src/com/android/car/settings/wifi/WifiSettingsFragment.java b/src/com/android/car/settings/wifi/WifiSettingsFragment.java
index 911d869..d7a2a4f 100644
--- a/src/com/android/car/settings/wifi/WifiSettingsFragment.java
+++ b/src/com/android/car/settings/wifi/WifiSettingsFragment.java
@@ -28,7 +28,6 @@
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;
@@ -73,7 +72,6 @@
} else {
showMessage(R.string.wifi_disabled);
}
- 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();