Implement fixes to achieve Polestar styles
Bug: 140031856
Test: Manual on device
Change-Id: I2d2bd5afc1c5c28048086dee384a66fa64aa4f5a
diff --git a/car-ui-lib/generate_rros.mk b/car-ui-lib/generate_rros.mk
index 7e93c36..2334e0f 100644
--- a/car-ui-lib/generate_rros.mk
+++ b/car-ui-lib/generate_rros.mk
@@ -27,6 +27,7 @@
LOCAL_PACKAGE_NAME := $$(rro_package_name)
LOCAL_CERTIFICATE := platform
LOCAL_SDK_VERSION := current
+ LOCAL_USE_AAPT2 := true
gen := $$(call intermediates-dir-for,ETC,$$(rro_package_name))/AndroidManifest.xml
$$(gen): $(LOCAL_PATH)/AndroidManifest.xml
diff --git a/car-ui-lib/res/drawable/car_ui_preference_switch_text_track.xml b/car-ui-lib/res/drawable/car_ui_preference_switch_text_track.xml
new file mode 100644
index 0000000..bc5a14a
--- /dev/null
+++ b/car-ui-lib/res/drawable/car_ui_preference_switch_text_track.xml
@@ -0,0 +1,56 @@
+<?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"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item>
+ <!-- Shape used to set the size of the overlay drawable -->
+ <shape
+ android:shape="rectangle"
+ android:tint="@android:color/transparent">
+ <size
+ android:width="@dimen/car_ui_preference_switch_width"
+ android:height="@dimen/car_ui_preference_switch_height"/>
+ </shape>
+ </item>
+ <item
+ android:gravity="center"
+ android:top="0dp"
+ android:bottom="0dp"
+ android:right="0dp"
+ android:left="@dimen/car_ui_preference_switch_width_half">
+ <drawable
+ class="com.android.car.ui.drawable.CarUiTextDrawable"
+ app:text="@string/car_ui_preference_switch_on"
+ app:textColor="@color/car_ui_preference_switch_track_text_color"
+ app:textSize="@dimen/car_ui_preference_switch_text_size">
+ </drawable>
+ </item>
+ <item
+ android:gravity="center"
+ android:top="0dp"
+ android:bottom="0dp"
+ android:left="0dp"
+ android:right="@dimen/car_ui_preference_switch_width_half">
+ <drawable
+ class="com.android.car.ui.drawable.CarUiTextDrawable"
+ app:text="@string/car_ui_preference_switch_off"
+ app:textColor="@color/car_ui_preference_switch_track_text_color"
+ app:textSize="@dimen/car_ui_preference_switch_text_size">
+ </drawable>
+ </item>
+</layer-list>
diff --git a/car-ui-lib/res/drawable/car_ui_recyclerview_divider.xml b/car-ui-lib/res/drawable/car_ui_recyclerview_divider.xml
index bddaae3..7683148 100644
--- a/car-ui-lib/res/drawable/car_ui_recyclerview_divider.xml
+++ b/car-ui-lib/res/drawable/car_ui_recyclerview_divider.xml
@@ -17,6 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <size android:height="0dp" />
- <solid android:color="@android:color/transparent" />
+ <size android:height="@dimen/car_ui_recyclerview_divider_height" />
+ <solid android:color="@color/car_ui_recyclerview_divider_color" />
</shape>
diff --git a/car-ui-lib/res/layout-port/car_ui_toolbar.xml b/car-ui-lib/res/layout-port/car_ui_toolbar.xml
index 8361ed2..16014dc 100644
--- a/car-ui-lib/res/layout-port/car_ui_toolbar.xml
+++ b/car-ui-lib/res/layout-port/car_ui_toolbar.xml
@@ -77,6 +77,7 @@
android:id="@+id/row_separator"
android:layout_width="match_parent"
android:layout_height="0.01dp"
+ style="@style/Widget.CarUi.Toolbar.SeparatorView"
app:layout_constraintTop_toBottomOf="@id/row_separator_guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
@@ -110,6 +111,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/car_ui_toolbar_title_margin_start"
+ android:singleLine="true"
style="@style/TextAppearance.CarUi.Widget.Toolbar.Title"
app:layout_constraintTop_toTopOf="@id/toolbar_top_guideline"
app:layout_constraintBottom_toTopOf="@id/row_separator"
@@ -179,6 +181,7 @@
android:id="@+id/bottom_styleable"
android:layout_width="match_parent"
android:layout_height="0.01dp"
+ style="@style/Widget.CarUi.Toolbar.BottomView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
diff --git a/car-ui-lib/res/layout/car_ui_preference_chevron.xml b/car-ui-lib/res/layout/car_ui_preference_chevron.xml
index 6dfba0c..efeaddb 100644
--- a/car-ui-lib/res/layout/car_ui_preference_chevron.xml
+++ b/car-ui-lib/res/layout/car_ui_preference_chevron.xml
@@ -18,4 +18,4 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:src="@drawable/car_ui_preference_icon_chevron_drawable"/>
\ No newline at end of file
+ android:src="@drawable/car_ui_preference_icon_chevron"/>
\ No newline at end of file
diff --git a/car-ui-lib/res/layout/car_ui_preference_fragment.xml b/car-ui-lib/res/layout/car_ui_preference_fragment.xml
index 75dd6d0..1f3fb9a 100644
--- a/car-ui-lib/res/layout/car_ui_preference_fragment.xml
+++ b/car-ui-lib/res/layout/car_ui_preference_fragment.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:background="@drawable/car_ui_activity_background">
<FrameLayout
android:id="@android:id/list_container"
@@ -29,7 +30,7 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:scrollbars="none"/>
+ app:enableDivider="true"/>
</FrameLayout>
<com.android.car.ui.toolbar.Toolbar
diff --git a/car-ui-lib/res/layout/car_ui_search_view.xml b/car-ui-lib/res/layout/car_ui_search_view.xml
index 3c47ad7..6878d6a 100644
--- a/car-ui-lib/res/layout/car_ui_search_view.xml
+++ b/car-ui-lib/res/layout/car_ui_search_view.xml
@@ -19,6 +19,23 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
+ <EditText
+ android:id="@+id/search_bar"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:paddingStart="@dimen/car_ui_touch_target_width"
+ android:paddingEnd="@dimen/car_ui_touch_target_width"
+ android:hint="@string/car_ui_toolbar_default_search_hint"
+ android:textColorHint="@color/car_ui_toolbar_search_hint_text_color"
+ android:inputType="text"
+ android:singleLine="true"
+ android:imeOptions="actionSearch"
+ style="@style/Widget.CarUi.Toolbar.Search.EditText"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
<FrameLayout
android:layout_width="@dimen/car_ui_touch_target_width"
android:layout_height="@dimen/car_ui_touch_target_height"
@@ -34,22 +51,6 @@
android:scaleType="fitCenter"/>
</FrameLayout>
- <EditText
- android:id="@+id/search_bar"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:paddingStart="@dimen/car_ui_touch_target_width"
- android:paddingEnd="@dimen/car_ui_touch_target_width"
- android:hint="@string/car_ui_toolbar_default_search_hint"
- android:textColorHint="@color/car_ui_toolbar_search_hint_text_color"
- android:inputType="text"
- android:singleLine="true"
- android:imeOptions="actionSearch"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"/>
-
<FrameLayout
android:id="@+id/search_close"
android:layout_width="@dimen/car_ui_touch_target_width"
diff --git a/car-ui-lib/res/layout/car_ui_toolbar.xml b/car-ui-lib/res/layout/car_ui_toolbar.xml
index f1b2fdc..870424c 100644
--- a/car-ui-lib/res/layout/car_ui_toolbar.xml
+++ b/car-ui-lib/res/layout/car_ui_toolbar.xml
@@ -97,6 +97,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/car_ui_toolbar_title_margin_start"
+ android:singleLine="true"
style="@style/TextAppearance.CarUi.Widget.Toolbar.Title"
app:layout_constraintTop_toTopOf="@id/toolbar_top_guideline"
app:layout_constraintBottom_toTopOf="@id/toolbar_bottom_guideline"
@@ -166,10 +167,21 @@
<!-- can't use 0dp for layout_height or the constraintlayout effect kicks in -->
<View
+ android:id="@+id/row_separator"
+ android:layout_width="match_parent"
+ android:layout_height="0.01dp"
+ style="@style/Widget.CarUi.Toolbar.SeparatorView"
+ app:layout_constraintTop_toBottomOf="@id/toolbar_top_guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
+ <!-- can't use 0dp for layout_height or the constraintlayout effect kicks in -->
+ <View
android:id="@+id/bottom_styleable"
android:layout_width="match_parent"
android:layout_height="0.01dp"
- app:layout_constraintBottom_toBottomOf="parent"
+ style="@style/Widget.CarUi.Toolbar.BottomView"
+ app:layout_constraintTop_toBottomOf="@+id/row_separator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/car-ui-lib/res/values/attrs.xml b/car-ui-lib/res/values/attrs.xml
index 933223a..7195f17 100644
--- a/car-ui-lib/res/values/attrs.xml
+++ b/car-ui-lib/res/values/attrs.xml
@@ -63,8 +63,19 @@
</attr>
</declare-styleable>
- <declare-styleable name="CarUiRecyclerViewTheme">
- <attr name="carUiRecyclerViewStyle" format="reference" />
+ <!-- Theme attribute to specify a default style for all CarUiRecyclerViews -->
+ <attr name="carUiRecyclerViewStyle" format="reference" />
+
+ <!-- TODO: Replace this with the Android default text styleable -->
+ <declare-styleable name="CarUiTextDrawable">
+ <!-- Text to be rendered by the drawable -->
+ <attr name="text" format="string" />
+ <!-- Font size -->
+ <attr name="textSize" format="dimension" />
+ <!-- Text color -->
+ <attr name="textColor" format="color" />
+ <!-- Type face to use -->
+ <attr name="typeface" format="string" />
</declare-styleable>
<attr name="state_ux_restricted" format="boolean" />
diff --git a/car-ui-lib/res/values/bools.xml b/car-ui-lib/res/values/bools.xml
index d970184..2e59118 100644
--- a/car-ui-lib/res/values/bools.xml
+++ b/car-ui-lib/res/values/bools.xml
@@ -30,5 +30,6 @@
<bool name="car_ui_preference_category_allow_divider_below">false</bool>
<bool name="car_ui_preference_switch_toggle_show_animation">true</bool>
+ <bool name="car_ui_preference_switch_toggle_use_text_track">false</bool>
<bool name="car_ui_preference_show_chevron">false</bool>
</resources>
diff --git a/car-ui-lib/res/values/colors.xml b/car-ui-lib/res/values/colors.xml
index 2b5480f..8a70ba6 100644
--- a/car-ui-lib/res/values/colors.xml
+++ b/car-ui-lib/res/values/colors.xml
@@ -16,6 +16,8 @@
<resources>
<!-- General -->
+ <!-- Background color to use on full screen activities -->
+ <color name="car_ui_activity_background_color">#000000</color>
<!-- Main text color (titles, text body, etc.) -->
<color name="car_ui_primary_text_color">#FFFFFFFF</color>
<!-- Text color used in subtitles or other secondary text blocks -->
@@ -32,22 +34,27 @@
<!-- Toolbar -->
+ <!-- Color used on the navigation icon -->
+ <color name="car_ui_nav_icon_color">@color/car_ui_primary_text_color</color>
<!-- Text color applied to the hint displayed inside the search box -->
<color name="car_ui_toolbar_search_hint_text_color">#33FFFFFF</color>
- <!-- Toolbar background color -->
- <color name="car_ui_toolbar_background_color">#E0000000</color>
+ <!-- Menu item colors -->
<color name="car_ui_toolbar_menu_item_icon_deactivated_color">@color/car_ui_primary_text_color</color>
<color name="car_ui_toolbar_menu_item_icon_disabled_color">@color/car_ui_secondary_text_color</color>
<color name="car_ui_toolbar_menu_item_icon_restricted_color">@color/car_ui_secondary_text_color</color>
<color name="car_ui_toolbar_menu_item_icon_activated_color">#FF000000</color>
+ <!-- Menu item background colors -->
<color name="car_ui_toolbar_menu_item_icon_background_deactivated_color">@android:color/transparent</color>
<color name="car_ui_toolbar_menu_item_icon_background_disabled_color">@color/car_ui_toolbar_menu_item_icon_disabled_color</color>
<color name="car_ui_toolbar_menu_item_icon_background_restricted_color">@color/car_ui_toolbar_menu_item_icon_restricted_color</color>
<color name="car_ui_toolbar_menu_item_icon_background_activated_color">@color/car_ui_primary_text_color</color>
- <!-- Car UI Recycler View -->
- <!-- The color of the scroll bar indicator in the CarUiRecyclerView. -->
+ <!-- Recycler View -->
+
+ <!-- Color of the scroll bar indicator in the CarUiRecyclerView. -->
<color name="car_ui_scrollbar_thumb">#99ffffff</color>
+ <!-- Color of the divider views between CarUiRecyclerView items -->
+ <color name="car_ui_recyclerview_divider_color">@android:color/transparent</color>
<!-- Preferences -->
@@ -55,7 +62,6 @@
<color name="car_ui_preference_summary_text_color">#ffdadce0</color>
<color name="car_ui_preference_title_text_color">@android:color/white</color>
<color name="car_ui_preference_edit_text_dialog_message_text_color">#ffdadce0</color>
-
<color name="car_ui_preference_icon_color">@android:color/white</color>
-
+ <color name="car_ui_preference_switch_track_text_color">@android:color/white</color>
</resources>
diff --git a/car-ui-lib/res/values/dimens.xml b/car-ui-lib/res/values/dimens.xml
index ddb0067..5e7d7e6 100644
--- a/car-ui-lib/res/values/dimens.xml
+++ b/car-ui-lib/res/values/dimens.xml
@@ -45,7 +45,7 @@
<!-- Tab icon height (if icons are enabled) -->
<dimen name="car_ui_tab_icon_height">36dp</dimen>
- <!-- Car toolbar -->
+ <!-- Toolbar -->
<dimen name="car_ui_toolbar_row_height">96dp</dimen>
<dimen name="car_ui_toolbar_first_row_height">@dimen/car_ui_toolbar_row_height</dimen>
<dimen name="car_ui_toolbar_second_row_height">@dimen/car_ui_toolbar_row_height</dimen>
@@ -64,6 +64,9 @@
<!-- Internal artifacts. Do not overlay -->
<item name="wrap_content" format="integer" type="dimen">-2</item>
+ <!-- CarUiRecyclerView -->
+ <dimen name="car_ui_recyclerview_divider_height">0dp</dimen>
+
<!-- Default Scroll Bar for CarUiRecyclerView -->
<dimen name="car_ui_scrollbar_button_size">@dimen/car_ui_touch_target_width</dimen>
<dimen name="car_ui_scrollbar_thumb_width">7dp</dimen>
@@ -105,6 +108,11 @@
<dimen name="car_ui_preference_edit_text_dialog_text_margin_start">24dp</dimen>
<dimen name="car_ui_preference_edit_text_dialog_text_margin_end">24dp</dimen>
+ <dimen name="car_ui_preference_switch_text_size">30sp</dimen>
+ <dimen name="car_ui_preference_switch_width">288dp</dimen>
+ <dimen name="car_ui_preference_switch_width_half">144dp</dimen>
+ <dimen name="car_ui_preference_switch_height">101dp</dimen>
+
<!-- Alert dialog -->
<dimen name="car_ui_dialog_edittext_height">50dp</dimen>
diff --git a/car-ui-lib/res/values/drawables.xml b/car-ui-lib/res/values/drawables.xml
new file mode 100644
index 0000000..caf3418
--- /dev/null
+++ b/car-ui-lib/res/values/drawables.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Copyright (C) 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.
+-->
+<resources>
+ <!-- General -->
+
+ <!-- Background drawable to use on full screen activities -->
+ <drawable name="car_ui_activity_background">@color/car_ui_activity_background_color</drawable>
+
+ <!-- Toolbar background color -->
+ <drawable name="car_ui_toolbar_background">#E0000000</drawable>
+
+</resources>
diff --git a/car-ui-lib/res/values/strings.xml b/car-ui-lib/res/values/strings.xml
index 5249ad4..34b8898 100644
--- a/car-ui-lib/res/values/strings.xml
+++ b/car-ui-lib/res/values/strings.xml
@@ -31,6 +31,10 @@
<string name="car_ui_dialog_preference_positive">Ok</string>
<!-- Negative option for a preference dialog. [CHAR_LIMIT=30] -->
<string name="car_ui_dialog_preference_negative">Cancel</string>
+ <!-- Text to show when a preference switch is on. [CHAR_LIMIT=30] -->
+ <string name="car_ui_preference_switch_on">On</string>
+ <!-- Text to show when a preference switch is off. [CHAR_LIMIT=30] -->
+ <string name="car_ui_preference_switch_off">Off</string>
<!-- Font family to use for preference category titles. [CHAR_LIMIT=NONE] -->
<string name="car_ui_preference_category_title_font_family" translatable="false">sans-serif-medium</string>
diff --git a/car-ui-lib/res/values/styles.xml b/car-ui-lib/res/values/styles.xml
index 3b89f9c..0a5bf88 100644
--- a/car-ui-lib/res/values/styles.xml
+++ b/car-ui-lib/res/values/styles.xml
@@ -25,15 +25,32 @@
<style name="Widget.CarUi.Toolbar"/>
<style name="Widget.CarUi.Toolbar.NavIcon">
- <item name="android:tint">@color/car_ui_primary_text_color</item>
+ <item name="android:tint">@color/car_ui_nav_icon_color</item>
<item name="android:src">@drawable/car_ui_icon_arrow_back</item>
</style>
<style name="Widget.CarUi.Toolbar.TextButton" parent="Widget.CarUi.Button.Borderless.Colored"/>
+ <!-- Style applied to the decoration view between toolbar rows -->
+ <style name="Widget.CarUi.Toolbar.SeparatorView">
+ <item name="android:height">0.01dp</item>
+ <item name="android:background">@android:color/transparent</item>
+ </style>
+
+ <!-- Style applied to the decoration view below the toolbar -->
+ <style name="Widget.CarUi.Toolbar.BottomView">
+ <item name="android:height">0.01dp</item>
+ <item name="android:background">@android:color/transparent</item>
+ </style>
+
+ <!-- Style applied to the edit box inside the toolbar search area -->
+ <style name="Widget.CarUi.Toolbar.Search.EditText"
+ parent="android:Widget.DeviceDefault.EditText"/>
+
<style name="Widget.CarUi.CarUiRecyclerView">
<item name="android:scrollbars">vertical</item>
</style>
+
<style name="Widget.CarUi.CarUiRecyclerView.NestedRecyclerView">
<item name="android:scrollbars">none</item>
</style>
@@ -87,6 +104,8 @@
<style name="Preference.CarUi.SwitchPreference">
<item name="android:widgetLayout">@layout/car_ui_preference_widget_switch</item>
+ <item name="android:switchTextOn">@string/car_ui_preference_switch_on</item>
+ <item name="android:switchTextOff">@string/car_ui_preference_switch_off</item>
</style>
<style name="PreferenceFragment.CarUi">
diff --git a/car-ui-lib/res/values/themes.xml b/car-ui-lib/res/values/themes.xml
index 728009b..6574a31 100644
--- a/car-ui-lib/res/values/themes.xml
+++ b/car-ui-lib/res/values/themes.xml
@@ -197,6 +197,9 @@
<item name="listChoiceIndicatorMultipleAnimated">?android:attr/listChoiceIndicatorMultiple</item>
<item name="preferenceTheme">@style/CarUiPreferenceTheme</item>
+
+ <!-- Used by CarUiRecyclerView -->
+ <item name="carUiRecyclerViewStyle">@style/Widget.CarUi.CarUiRecyclerView</item>
</style>
<style name="CarUiPreferenceTheme">
diff --git a/car-ui-lib/res/values/values.xml b/car-ui-lib/res/values/values.xml
index a33f167..2eb4d70 100644
--- a/car-ui-lib/res/values/values.xml
+++ b/car-ui-lib/res/values/values.xml
@@ -16,8 +16,15 @@
-->
<resources>
+ <!-- Toolbar -->
+
+ <!-- Whether tabs should use flex layout or not -->
<bool name="car_ui_tab_flexible_layout">false</bool>
+ <!-- Layout to be used for toolbar tabs -->
<item name="car_ui_tab_item_layout" type="layout">@layout/car_ui_tab_item</item>
- <item name="car_ui_preference_icon_chevron_drawable" type="drawable">@null</item>
+ <!-- Preferences -->
+
+ <!-- Overlayable drawable to use for the preference chevron -->
+ <item name="car_ui_preference_icon_chevron" type="drawable">@null</item>
</resources>
diff --git a/car-ui-lib/src/com/android/car/ui/drawable/CarUiTextDrawable.java b/car-ui-lib/src/com/android/car/ui/drawable/CarUiTextDrawable.java
new file mode 100644
index 0000000..0587cf9
--- /dev/null
+++ b/car-ui-lib/src/com/android/car/ui/drawable/CarUiTextDrawable.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 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.
+ */
+package com.android.car.ui.drawable;
+
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.text.TextPaint;
+import android.util.AttributeSet;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.car.ui.R;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
+/**
+ * A drawable to renders a given text. It can be used as part of a compound
+ * drawable as follows:
+ *
+ * <pre>
+ * {@code
+ * <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ * ...
+ * <item
+ * <drawable
+ * class="com.android.car.ui.drawable.CarUiTextDrawable"
+ * app:text="Some text"
+ * app:textSize="30sp">
+ * </drawable>
+ * </item>
+ * ...
+ * </layer-list>
+ * }
+ * </pre>
+ *
+ * <b>Important: This class is referenced by reflection from overlays. DO NOT
+ * RENAME, REMOVE OR MOVE TO ANOTHER PACKAGE, otherwise the overlays would
+ * cause the target application to crash.</b>
+ */
+public class CarUiTextDrawable extends Drawable {
+ private TextPaint mPaint = new TextPaint();
+ private Rect mTextBounds = new Rect(); // Minimum bounds of the text only.
+
+ // Attributes initialized during inflation
+ private @Nullable String mText;
+ private Typeface mTypeface = Typeface.DEFAULT;
+ private float mTextSize = 10;
+ private int mTextColor = Color.WHITE;
+
+ /** Text sample used to measure font height */
+ private static final String TEXT_HEIGHT_SAMPLE = "Ag";
+
+ /** Constructor available to include this drawable by code */
+ public CarUiTextDrawable(@Nullable String text,
+ Typeface typeface,
+ float textSize,
+ int textColor) {
+ mText = text;
+ mTypeface = typeface;
+ mTextSize = textSize;
+ mTextColor = textColor;
+ refreshTextBoundsAndInvalidate();
+ }
+
+ /** Constructor invoked by XML inflator */
+ public CarUiTextDrawable() {
+ // To be used during inflation.
+ }
+
+ /** Updates the text rendered by this drawable */
+ public void setText(@Nullable String text) {
+ this.mText = text;
+ refreshTextBoundsAndInvalidate();
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mTextBounds.height();
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return mTextBounds.width();
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ Rect bounds = getBounds();
+ if (bounds.isEmpty() || mPaint.getAlpha() == 0) {
+ return;
+ }
+
+ // Draw text.
+ if (mText != null) {
+ canvas.drawText(mText,
+ bounds.centerX(),
+ bounds.centerY() + (mTextBounds.height() / 2.0f),
+ mPaint);
+ }
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ final int old = mPaint.getAlpha();
+ if (alpha != old) {
+ mPaint.setAlpha(alpha);
+ invalidateSelf();
+ }
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter cf) {
+ mPaint.setColorFilter(cf);
+ invalidateSelf();
+ }
+
+ @Override
+ public int getOpacity() {
+ return mPaint.bgColor != 0 ? PixelFormat.OPAQUE : PixelFormat.TRANSPARENT;
+ }
+
+ /**
+ * Call this to re-measure the text when properties that may affect the
+ * textBounds are changed.
+ */
+ private void refreshTextBoundsAndInvalidate() {
+ mPaint.setTypeface(mTypeface);
+ mPaint.setTextSize(mTextSize);
+ mPaint.setColor(mTextColor);
+ mPaint.setTextAlign(Paint.Align.CENTER);
+ mPaint.setAntiAlias(true);
+ mPaint.setDither(true);
+ calculateTextBounds(mPaint, mText, mTextBounds);
+ invalidateSelf();
+ }
+
+ /**
+ * Calculate the bounds of the given text.
+ *
+ * The textBounds are different from the drawable bounds: the textBounds is
+ * is strictly a subset, and measures the minimum bounding box necessary to
+ * draw the text. The left and right of the textBounds are used to calculate
+ * the intrinsic width and intrinsic height.
+ *
+ * Text height is calculated based on a fixed sample text (to avoid height
+ * changing every time a different text is rendered)
+ */
+ private void calculateTextBounds(TextPaint paint, @Nullable String text, Rect outBounds) {
+ outBounds.setEmpty();
+ paint.getTextBounds(TEXT_HEIGHT_SAMPLE, 0, TEXT_HEIGHT_SAMPLE.length(), outBounds);
+
+ if (text != null) {
+ // Save the top and bottom bounds of the sample text.
+ int top = outBounds.top;
+ int bottom = outBounds.bottom;
+
+ // Get the actual text bounds.
+ paint.getTextBounds(text, 0, text.length(), outBounds);
+
+ // Replace top and bottom with sample text bounds. We only care about left
+ // and right.
+ outBounds.top = top;
+ outBounds.bottom = bottom;
+ } else {
+ outBounds.left = 0;
+ outBounds.right = 0;
+ }
+ }
+
+ private @NonNull TypedArray themedObtainAttributes(@NonNull Resources res,
+ @Nullable Resources.Theme theme,
+ @NonNull AttributeSet set,
+ @NonNull int[] attrs) {
+ if (theme == null) {
+ return res.obtainAttributes(set, attrs);
+ }
+ return theme.obtainStyledAttributes(set, attrs, 0, 0);
+ }
+
+ @Override
+ public void inflate(@NonNull Resources r, @NonNull XmlPullParser parser,
+ @NonNull AttributeSet attrs, @Nullable Resources.Theme theme)
+ throws XmlPullParserException, IOException {
+ final TypedArray a = themedObtainAttributes(r, theme, attrs, R.styleable.CarUiTextDrawable);
+ mText = a.getString(R.styleable.CarUiTextDrawable_text);
+ mTypeface = Typeface.create(a.getString(R.styleable.CarUiTextDrawable_typeface),
+ Typeface.NORMAL);
+ mTextSize = a.getDimension(R.styleable.CarUiTextDrawable_textSize, 10);
+ mTextColor = a.getColor(R.styleable.CarUiTextDrawable_textColor,
+ r.getColor(R.color.car_ui_primary_text_color, theme));
+ a.recycle();
+ refreshTextBoundsAndInvalidate();
+ super.inflate(r, parser, attrs, theme);
+ }
+}
diff --git a/car-ui-lib/src/com/android/car/ui/preference/PreferenceFragment.java b/car-ui-lib/src/com/android/car/ui/preference/PreferenceFragment.java
index fb28add..d1525ce 100644
--- a/car-ui-lib/src/com/android/car/ui/preference/PreferenceFragment.java
+++ b/car-ui-lib/src/com/android/car/ui/preference/PreferenceFragment.java
@@ -57,6 +57,7 @@
toolbar.registerToolbarHeightChangeListener(height -> {
recyclerView.setPadding(0, height, 0, 0);
});
+ toolbar.setTitle(getPreferenceScreen().getTitle());
}
/**
diff --git a/car-ui-lib/src/com/android/car/ui/preference/PreferenceSwitchWidget.java b/car-ui-lib/src/com/android/car/ui/preference/PreferenceSwitchWidget.java
index e15a351..bd67a00 100644
--- a/car-ui-lib/src/com/android/car/ui/preference/PreferenceSwitchWidget.java
+++ b/car-ui-lib/src/com/android/car/ui/preference/PreferenceSwitchWidget.java
@@ -37,7 +37,7 @@
public PreferenceSwitchWidget(Context context, AttributeSet attrs) {
super(context, attrs);
- mContext = context;
+ init(context);
}
public PreferenceSwitchWidget(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -54,6 +54,11 @@
private void init(Context context) {
mEnableAnimation = context.getResources().getBoolean(
R.bool.car_ui_preference_switch_toggle_show_animation);
+ boolean textBackground = context.getResources().getBoolean(
+ R.bool.car_ui_preference_switch_toggle_use_text_track);
+ if (textBackground) {
+ setTrackDrawable(context.getDrawable(R.drawable.car_ui_preference_switch_text_track));
+ }
}
@Override
diff --git a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
index 759e0a8..fa43696 100644
--- a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
+++ b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
@@ -220,11 +220,11 @@
}
public CarUiRecyclerView(@NonNull Context context) {
- this(context, null, 0);
+ this(context, null);
}
public CarUiRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
+ this(context, attrs, R.attr.carUiRecyclerViewStyle);
}
public CarUiRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
@@ -237,10 +237,11 @@
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
- TypedArray a =
- context.obtainStyledAttributes(
- attrs, R.styleable.CarUiRecyclerView, defStyleAttr,
- R.style.Widget_CarUi_CarUiRecyclerView);
+ TypedArray a = context.obtainStyledAttributes(
+ attrs,
+ R.styleable.CarUiRecyclerView,
+ defStyleAttr,
+ R.style.Widget_CarUi_CarUiRecyclerView);
mScrollBarEnabled = context.getResources().getBoolean(R.bool.car_ui_scrollbar_enable);
mFullyInitialized = false;
diff --git a/car-ui-lib/src/com/android/car/ui/toolbar/Toolbar.java b/car-ui-lib/src/com/android/car/ui/toolbar/Toolbar.java
index 7546b67..a028dcc 100644
--- a/car-ui-lib/src/com/android/car/ui/toolbar/Toolbar.java
+++ b/car-ui-lib/src/com/android/car/ui/toolbar/Toolbar.java
@@ -496,7 +496,7 @@
/** Show/hide the background. When hidden, the toolbar is completely transparent. */
public void setBackgroundShown(boolean shown) {
if (shown) {
- super.setBackground(getContext().getDrawable(R.color.car_ui_toolbar_background_color));
+ super.setBackground(getContext().getDrawable(R.drawable.car_ui_toolbar_background));
} else {
super.setBackground(null);
}
diff --git a/car-ui-lib/tests/paintbooth/res/drawable/ic_settings_wifi.xml b/car-ui-lib/tests/paintbooth/res/drawable/ic_settings_wifi.xml
new file mode 100644
index 0000000..9a09d70
--- /dev/null
+++ b/car-ui-lib/tests/paintbooth/res/drawable/ic_settings_wifi.xml
@@ -0,0 +1,27 @@
+<!--
+ ~ 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.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="64dp"
+ android:height="64dp"
+ android:viewportWidth="64"
+ android:viewportHeight="64">
+ <path
+ android:pathData="M36.87,39.05a7,7 0,1 1,-9.901 9.9,7 7,0 0,1 9.901,-9.9zM14.243,26.323c9.763,-9.764 25.593,-9.764 35.355,0M53.84,22.08C41.735,9.972 22.106,9.972 10,22.08M18.486,30.565c7.42,-7.42 19.449,-7.42 26.869,0M22.728,34.808c5.077,-5.077 13.308,-5.077 18.385,0"
+ android:strokeWidth="2"
+ android:fillColor="#00000000"
+ android:fillType="evenOdd"
+ android:strokeColor="#FFF"/>
+</vector>
diff --git a/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity.xml b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity.xml
index 243e0e7..330c781 100644
--- a/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity.xml
+++ b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_activity.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2019 The Android Open Source Project
+ ~ 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.
@@ -12,15 +12,15 @@
~ 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
+ ~ limitations under the License.
-->
-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:background="@drawable/car_ui_activity_background">
<com.android.car.ui.toolbar.Toolbar
android:id="@+id/toolbar"
@@ -33,6 +33,6 @@
<com.android.car.ui.recyclerview.CarUiRecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
diff --git a/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_list_item.xml b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_list_item.xml
index be6952c..a9d45ad 100644
--- a/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_list_item.xml
+++ b/car-ui-lib/tests/paintbooth/res/layout/car_ui_recycler_view_list_item.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2018 The Android Open Source Project
+ ~ 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.
@@ -12,9 +12,8 @@
~ 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
+ ~ limitations under the License.
-->
-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
diff --git a/car-ui-lib/tests/paintbooth/res/layout/dialogs_activity.xml b/car-ui-lib/tests/paintbooth/res/layout/dialogs_activity.xml
index db9e384..378a355 100644
--- a/car-ui-lib/tests/paintbooth/res/layout/dialogs_activity.xml
+++ b/car-ui-lib/tests/paintbooth/res/layout/dialogs_activity.xml
@@ -14,51 +14,50 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<androidx.constraintlayout.widget.ConstraintLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dialog_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/dialog_activity_background_color">
+ android:background="@drawable/car_ui_activity_background">
<com.android.car.ui.toolbar.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
- app:title="@string/app_name"
- app:state="subpage"/>
+ app:state="subpage"
+ app:title="@string/app_name" />
<Button
android:id="@+id/show_dialog_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog"
- app:layout_constraintBottom_toTopOf="@+id/show_dialog_only_positive_bt"
+ app:layout_constraintTop_toBottomOf="@+id/toolbar"
+ app:layout_constraintBottom_toTopOf="@+id/show_dialog_with_textbox"
app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
+ app:layout_constraintRight_toRightOf="parent"/>
<Button
android:id="@+id/show_dialog_with_textbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog with edit text box"
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_bt"
app:layout_constraintBottom_toTopOf="@+id/show_dialog_only_positive_bt"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_bt"/>
+ app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/show_dialog_only_positive_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog with only positive button"
- app:layout_constraintBottom_toTopOf="@+id/show_dialog_with_checkbox_bt"
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_textbox"
+ app:layout_constraintBottom_toTopOf="@+id/show_dialog_with_no_button_set"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_textbox"/>
+ app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/show_dialog_with_no_button_set"
@@ -68,7 +67,7 @@
app:layout_constraintBottom_toTopOf="@+id/show_dialog_with_checkbox_bt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_only_positive_bt"/>
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_only_positive_bt" />
<Button
android:id="@+id/show_dialog_with_checkbox_bt"
@@ -78,7 +77,7 @@
app:layout_constraintBottom_toTopOf="@+id/show_dialog_without_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_no_button_set"/>
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_no_button_set" />
<Button
android:id="@+id/show_dialog_without_title"
@@ -88,7 +87,7 @@
app:layout_constraintBottom_toTopOf="@+id/show_toast"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_checkbox_bt"/>
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_with_checkbox_bt" />
<Button
android:id="@+id/show_toast"
@@ -98,6 +97,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/show_dialog_without_title"/>
+ app:layout_constraintTop_toBottomOf="@+id/show_dialog_without_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/car-ui-lib/tests/paintbooth/res/layout/grid_car_ui_recycler_view_activity.xml b/car-ui-lib/tests/paintbooth/res/layout/grid_car_ui_recycler_view_activity.xml
index 2472b5b..b472d06 100644
--- a/car-ui-lib/tests/paintbooth/res/layout/grid_car_ui_recycler_view_activity.xml
+++ b/car-ui-lib/tests/paintbooth/res/layout/grid_car_ui_recycler_view_activity.xml
@@ -1,9 +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.
+ -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:background="@drawable/car_ui_activity_background">
<com.android.car.ui.toolbar.Toolbar
android:id="@+id/toolbar"
diff --git a/car-ui-lib/tests/paintbooth/res/layout/main_activity.xml b/car-ui-lib/tests/paintbooth/res/layout/main_activity.xml
index c0c2e07..6642b20 100644
--- a/car-ui-lib/tests/paintbooth/res/layout/main_activity.xml
+++ b/car-ui-lib/tests/paintbooth/res/layout/main_activity.xml
@@ -20,7 +20,7 @@
android:id="@+id/home"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/dialog_activity_background_color">
+ android:background="@drawable/car_ui_activity_background">
<com.android.car.ui.toolbar.Toolbar
android:id="@+id/toolbar"
diff --git a/car-ui-lib/tests/paintbooth/res/values/arrays.xml b/car-ui-lib/tests/paintbooth/res/values/arrays.xml
index 1a22073..6d4c2c4 100644
--- a/car-ui-lib/tests/paintbooth/res/values/arrays.xml
+++ b/car-ui-lib/tests/paintbooth/res/values/arrays.xml
@@ -1,4 +1,19 @@
<?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.
+ -->
<resources>
<!-- Used for the entries in a list preference [CHAR_LIMIT=NONE]-->
diff --git a/car-ui-lib/tests/paintbooth/res/values/strings.xml b/car-ui-lib/tests/paintbooth/res/values/strings.xml
index 91dbac2..e1c8ca8 100644
--- a/car-ui-lib/tests/paintbooth/res/values/strings.xml
+++ b/car-ui-lib/tests/paintbooth/res/values/strings.xml
@@ -20,6 +20,10 @@
<!-- Strings for Preference Samples -->
<eat-comment/>
+
+ <!-- Preferences page title [CHAR_LIMIT=NONE] -->
+ <string name="preferences_screen_title">Settings</string>
+
<!--This section is for basic attributes -->
<eat-comment/>
<!-- Category title for basic preferences [CHAR_LIMIT=NONE]-->
@@ -44,6 +48,9 @@
<!-- Summary of a single line title preference [CHAR_LIMIT=NONE]-->
<string name="summary_single_line_title_preference">This title will be ellipsized instead of wrapping to another line</string>
+ <!-- Title of a single line title preference without summary [CHAR_LIMIT=NONE]-->
+ <string name="title_single_line_no_summary">Single line preference - no summary</string>
+
<!--This section is for preferences that contain a widget in their layout -->
<eat-comment/>
<!-- Category title for preferences with widgets [CHAR_LIMIT=NONE]-->
@@ -123,4 +130,5 @@
<string name="title_copyable_preference">Copyable preference</string>
<!-- Summary of a copyable preference [CHAR_LIMIT=NONE]-->
<string name="summary_copyable_preference">Long press on this preference to copy its summary</string>
+ <string name="preference_title">Settings</string>
</resources>
diff --git a/car-ui-lib/tests/paintbooth/res/xml/preference_overlays.xml b/car-ui-lib/tests/paintbooth/res/xml/preference_overlays.xml
index 4184558..27ef049 100644
--- a/car-ui-lib/tests/paintbooth/res/xml/preference_overlays.xml
+++ b/car-ui-lib/tests/paintbooth/res/xml/preference_overlays.xml
@@ -15,6 +15,6 @@
~ limitations under the License.
-->
<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ app:title="Overlays">
</PreferenceScreen>
\ No newline at end of file
diff --git a/car-ui-lib/tests/paintbooth/res/xml/preference_samples.xml b/car-ui-lib/tests/paintbooth/res/xml/preference_samples.xml
index 60e092e..7086931 100644
--- a/car-ui-lib/tests/paintbooth/res/xml/preference_samples.xml
+++ b/car-ui-lib/tests/paintbooth/res/xml/preference_samples.xml
@@ -16,7 +16,8 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ app:title="@string/preferences_screen_title">
<PreferenceCategory
android:title="@string/basic_preferences">
@@ -35,13 +36,18 @@
android:key="icon"
android:title="@string/title_icon_preference"
android:summary="@string/summary_icon_preference"
- android:icon="@android:drawable/ic_menu_camera"/>
+ android:icon="@drawable/ic_settings_wifi"/>
<Preference
android:key="single_line_title"
android:title="@string/title_single_line_title_preference"
android:summary="@string/summary_single_line_title_preference"
app:singleLineTitle="true"/>
+
+ <Preference
+ android:key="single_line_no_summary"
+ android:title="@string/title_single_line_no_summary"
+ app:singleLineTitle="true"/>
</PreferenceCategory>
<PreferenceCategory
@@ -57,7 +63,7 @@
android:title="@string/title_switch_preference"
android:summary="@string/summary_switch_preference"/>
- <DropDownPreference
+ <com.android.car.ui.preference.CarUiDropDownPreference
android:key="dropdown"
android:title="@string/title_dropdown_preference"
android:entries="@array/entries"
@@ -74,13 +80,13 @@
<PreferenceCategory
android:title="@string/dialogs">
- <EditTextPreference
+ <com.android.car.ui.preference.CarUiEditTextPreference
android:key="edittext"
android:title="@string/title_edittext_preference"
app:useSimpleSummaryProvider="true"
android:dialogTitle="@string/dialog_title_edittext_preference"/>
- <ListPreference
+ <com.android.car.ui.preference.CarUiListPreference
android:key="list"
android:title="@string/title_list_preference"
app:useSimpleSummaryProvider="true"
@@ -88,7 +94,7 @@
android:entryValues="@array/entry_values"
android:dialogTitle="@string/dialog_title_list_preference"/>
- <MultiSelectListPreference
+ <com.android.car.ui.preference.CarUiMultiSelectListPreference
android:key="multi_select_list"
android:title="@string/title_multi_list_preference"
android:summary="@string/summary_multi_list_preference"
@@ -102,19 +108,19 @@
android:title="@string/advanced_attributes"
app:initialExpandedChildrenCount="1">
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="expandable"
android:title="@string/title_expandable_preference"
android:summary="@string/summary_expandable_preference"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:title="@string/title_intent_preference"
android:summary="@string/summary_intent_preference">
<intent android:action="android.intent.action.VIEW"
android:data="http://www.android.com"/>
- </Preference>
+ </com.android.car.ui.preference.CarUiPreference>
<SwitchPreference
android:key="parent"
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/OverlayActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/OverlayActivity.java
index 5300ece..2b37cd9 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/OverlayActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/OverlayActivity.java
@@ -27,9 +27,10 @@
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
-import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
+import com.android.car.ui.preference.PreferenceFragment;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -56,7 +57,7 @@
}
/** PreferenceFragmentCompat that sets the preference hierarchy from XML */
- public static class OverlayFragment extends PreferenceFragmentCompat {
+ public static class OverlayFragment extends PreferenceFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiRecyclerViewActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiRecyclerViewActivity.java
index 4daae3b..a05b39d 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiRecyclerViewActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiRecyclerViewActivity.java
@@ -31,7 +31,7 @@
*/
public class CarUiRecyclerViewActivity extends Activity {
private final ArrayList<String> mData = new ArrayList<>();
- private final int mDataToGenerate = 15;
+ private final int mDataToGenerate = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
index e3d1004..928f4d7 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/GridCarUiRecyclerViewActivity.java
@@ -27,7 +27,7 @@
/** Activity that shows GridCarUiRecyclerView example with dummy data. */
public class GridCarUiRecyclerViewActivity extends Activity {
private final ArrayList<String> mData = new ArrayList<>();
- private final int mDataToGenerate = 50;
+ private final int mDataToGenerate = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/preferences/PreferenceActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/preferences/PreferenceActivity.java
index d63b110..33da5a0 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/preferences/PreferenceActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/preferences/PreferenceActivity.java
@@ -38,15 +38,8 @@
}
}
- @Override
- public boolean onSupportNavigateUp() {
- onBackPressed();
- return true;
- }
-
/** PreferenceFragment that sets the preference hierarchy from XML */
public static class DemoFragment extends PreferenceFragment {
-
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource