Always reserve space for preference icons.
This aligns text on preferences on the same screen when some of them
don't have icons.
- Use a custom layout for
preference
EditPreference
switch preference
VolumeSeekPreference
DialogPreferencei
Restricted*Preference
DropdownPreference
- Moved related style defs into a new file styles_preference.xml,
because current styles file is too large to read.
- Switch <PreferenceScreen ...> to <Preference ...> for a bunch of
regular preferences.
- Also removed some dead style.
Bug: 33430928
Test: runtest --path packages/apps/Settings/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
Change-Id: Ic9b75d3f133f2a83cd999297b8596253d4b10161
diff --git a/res/layout/preference_category_material_settings.xml b/res/layout/preference_category_material_settings.xml
new file mode 100644
index 0000000..13cefdb
--- /dev/null
+++ b/res/layout/preference_category_material_settings.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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.
+ -->
+
+<!-- Based off frameworks/base/core/res/res/layout/preference_category_material.xml
+ except that this supports icon -->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingTop="16dp">
+
+ <LinearLayout
+ android:id="@+id/icon_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="start|center_vertical"
+ android:orientation="horizontal">
+ <com.android.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxWidth="18dp"
+ android:maxHeight="18dp"/>
+ </LinearLayout>
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textColor="?android:attr/textColorPrimary"
+ android:paddingStart="60dp"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
+
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/preference_dropdown_material_settings.xml b/res/layout/preference_dropdown_material_settings.xml
new file mode 100644
index 0000000..ee4051d
--- /dev/null
+++ b/res/layout/preference_dropdown_material_settings.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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.
+ -->
+
+
+<!-- Based off frameworks/base/core/res/res/layout/preference_dropdown_material.xml
+ except that icon space in this layout is always reserved -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
+ android:clipToPadding="false">
+
+ <Spinner
+ android:id="@+id/spinner"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:visibility="invisible" />
+
+ <LinearLayout
+ android:id="@+id/icon_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="60dp"
+ android:gravity="start|center_vertical"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
+ <android.support.v7.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxWidth="48dp"
+ android:maxHeight="48dp" />
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp">
+
+ <TextView android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="@style/Preference_TextAppearanceMaterialSubhead"
+ android:ellipsize="marquee" />
+
+ <TextView android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignLeft="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="10" />
+
+ </RelativeLayout>
+
+ <!-- Preference should place its actual preference widget here. -->
+ <LinearLayout android:id="@android:id/widget_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="end|center_vertical"
+ android:paddingLeft="16dp"
+ android:orientation="vertical" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/preference_material_settings.xml b/res/layout/preference_material_settings.xml
index b8a00f2..ae108da 100644
--- a/res/layout/preference_material_settings.xml
+++ b/res/layout/preference_material_settings.xml
@@ -16,18 +16,19 @@
<!-- Based off frameworks/base/core/res/res/layout/preference_material.xml
except that this has the negative margin on the image removed. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:background="?android:attr/activatedBackgroundIndicator"
+ android:background="?android:attr/selectableItemBackground"
android:clipToPadding="false">
<LinearLayout
- android:id="@id/icon_frame"
+ android:id="@+id/icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="60dp"
@@ -41,7 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="48dp"
- android:maxHeight="48dp" />
+ android:maxHeight="48dp"/>
</LinearLayout>
<RelativeLayout
@@ -51,30 +52,33 @@
android:paddingTop="16dp"
android:paddingBottom="16dp">
- <TextView android:id="@android:id/title"
+ <TextView
+ android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem"
- android:ellipsize="marquee" />
+ android:ellipsize="marquee"/>
- <TextView android:id="@android:id/summary"
+ <TextView
+ android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
- android:maxLines="10" />
+ android:maxLines="10"/>
</RelativeLayout>
<!-- Preference should place its actual preference widget here. -->
- <LinearLayout android:id="@android:id/widget_frame"
+ <LinearLayout
+ android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end|center_vertical"
android:paddingStart="16dp"
- android:orientation="vertical" />
+ android:orientation="vertical"/>
</LinearLayout>
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index c5c7818..3eb0c97 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -14,14 +14,32 @@
limitations under the License.
-->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:clickable="false" >
+ android:clickable="false"
+ android:orientation="horizontal">
+
+ <LinearLayout
+ android:id="@+id/icon_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="44dp"
+ android:gravity="start|center_vertical"
+ android:orientation="horizontal"
+ android:paddingEnd="12dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp">
+ <com.android.internal.widget.PreferenceImageView
+ android:id="@android:id/icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"/>
+ </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@@ -31,24 +49,27 @@
android:layout_marginBottom="8dip">
<LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@android:id/title"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
+ android:paddingStart="16dp"
android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
+ android:fadingEdge="horizontal"/>
<!-- Preference should place its actual preference widget here. -->
- <LinearLayout android:id="@android:id/widget_frame"
+ <LinearLayout
+ android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end|center_vertical"
android:paddingStart="16dp"
- android:orientation="vertical" />
+ android:orientation="vertical"/>
</LinearLayout>
<FrameLayout
@@ -56,32 +77,24 @@
android:layout_height="wrap_content"
android:layout_marginTop="6dp">
- <ImageView
- android:id="@android:id/icon"
- android:layout_gravity="center_vertical|start"
- android:layout_width="24dp"
- android:layout_height="24dp" />
-
- <SeekBar android:id="@*android:id/seekbar"
- android:layout_marginStart="24dp"
+ <SeekBar
+ android:id="@*android:id/seekbar"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"/>
- <TextView android:id="@+id/suppression_text"
+ <TextView
+ android:id="@+id/suppression_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:textAlignment="viewStart"
- android:layout_marginStart="24dp"
- android:paddingStart="14dp"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary" />
+ android:textColor="?android:attr/textColorSecondary"/>
</FrameLayout>
-
</LinearLayout>
-</FrameLayout>
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 40f3f71..2931a98 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -51,7 +51,6 @@
<dimen name="divider_height">3dip</dimen>
<dimen name="divider_margin_top">6dip</dimen>
<dimen name="divider_margin_bottom">7dip</dimen>
- <dimen name="vert_divider_width">1dip</dimen>
<!-- Size of icons in the top-level of settings -->
<dimen name="header_icon_width">28dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a18fde3..f4b39d4 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -93,22 +93,6 @@
<item name="android:windowContentOverlay">@null</item>
</style>
- <style name="Preference">
- <item name="android:layout">@layout/preference_material_settings</item>
- </style>
-
- <style name="SyncSwitchPreference" parent="Preference">
- <item name="android:widgetLayout">@layout/preference_widget_sync_toggle</item>
- </style>
-
- <style name="EditTextPreference" parent="@*android:style/Preference.Material.DialogPreference.EditTextPreference">
- <item name="android:dialogLayout">@layout/preference_dialog_edittext</item>
- </style>
-
- <style name="PreferenceTheme" parent="@*android:style/PreferenceTheme">
- <item name="android:scrollbars">vertical</item>
- </style>
-
<style name="PreferenceHeaderPanelSinglePane">
<item name="android:layout_marginStart">0dp</item>
<item name="android:layout_marginEnd">0dp</item>
@@ -156,18 +140,6 @@
<item name="android:scrollbarStyle">outsideOverlay</item>
</style>
- <style name="PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
- <item name="android:layout">@layout/preference_list_fragment</item>
- </style>
-
- <style name="VertDivider">
- <item name="android:layout_width">@dimen/vert_divider_width</item>
- <item name="android:layout_height">fill_parent</item>
- <item name="android:background">@color/divider_color</item>
- <item name="android:focusable">false</item>
- <item name="android:clickable">false</item>
- </style>
-
<style name="TextAppearance.SetupWizardDescription" parent="@android:style/TextAppearance.Material.Subhead">
</style>
@@ -324,10 +296,6 @@
<!-- Scrollbar style OUTSIDE_OVERLAY -->
<integer name="preference_scrollbar_style">33554432</integer>
- <style name="ApnPreference">
- <item name="android:layout">@layout/apn_preference_layout</item>
- </style>
-
<style name="AppListSwitchPreference" parent="@*android:style/Preference.Material.DialogPreference">
<item name="android:widgetLayout">@*android:layout/preference_widget_switch</item>
</style>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
new file mode 100644
index 0000000..a504166
--- /dev/null
+++ b/res/values/styles_preference.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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.
+ -->
+
+<!-- This file only contains custom attribute and style definition for preferences -->
+<!-- Things unrelated to preference framework UI customization should go to other styles files -->
+<resources>
+ <style name="ApnPreference">
+ <item name="android:layout">@layout/apn_preference_layout</item>
+ </style>
+
+ <style name="EditTextPreference"
+ parent="@style/Preference.DialogPreference.EditTextPreference.Material">
+ <item name="android:layout">@layout/preference_material_settings</item>
+ <item name="android:dialogLayout">@layout/preference_dialog_edittext</item>
+ </style>
+
+ <style name="PreferenceFragmentStyle" parent="@*android:style/PreferenceFragment.Material">
+ <item name="android:layout">@layout/preference_list_fragment</item>
+ </style>
+
+ <style name="SettingsPreference">
+ <item name="android:layout">@layout/preference_material_settings</item>
+ </style>
+
+ <style name="SettingsDropdownPreference">
+ <item name="android:layout">@layout/preference_dropdown_material_settings</item>
+ </style>
+
+ <style name="SettingsDialogPreference" parent="SettingsPreference"/>
+
+ <style name="SettingsPreferenceCategory" parent="@style/Preference.Category.Material">
+ <item name="android:layout">@layout/preference_category_material_settings</item>
+ </style>
+
+ <style name="SettingsSwitchPreference" parent="SettingsPreference">
+ <item name="widgetLayout">@*android:layout/preference_widget_switch</item>
+ <item name="switchTextOn">@*android:string/capital_on</item>
+ <item name="switchTextOff">@*android:string/capital_off</item>
+ </style>
+
+ <style name="SyncSwitchPreference" parent="SettingsPreference">
+ <item name="android:widgetLayout">@layout/preference_widget_sync_toggle</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 6b765f7..edc1dbf 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -88,11 +88,16 @@
</style>
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
- <item name="android:preferenceStyle">@style/Preference</item>
- <item name="android:editTextPreferenceStyle">@style/EditTextPreference</item>
- <item name="dropdownPreferenceStyle">@style/Preference.DropDown.Material</item>
- <item name="android:preferenceFragmentStyle">@style/PreferenceFragmentStyle</item>
+ <!-- Parent path frameworks/support/v14/preference/res/values/themes.xml -->
+ <item name="android:scrollbars">vertical</item>
<item name="apnPreferenceStyle">@style/ApnPreference</item>
+ <item name="dialogPreferenceStyle">@style/SettingsDialogPreference</item>
+ <item name="dropdownPreferenceStyle">@style/SettingsDropdownPreference</item>
+ <item name="editTextPreferenceStyle">@style/EditTextPreference</item>
+ <item name="preferenceCategoryStyle">@style/SettingsPreferenceCategory</item>
+ <item name="preferenceFragmentStyle">@style/PreferenceFragmentStyle</item>
+ <item name="preferenceStyle">@style/SettingsPreference</item>
+ <item name="switchPreferenceStyle">@style/SettingsSwitchPreference</item>
</style>
<style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
@@ -124,6 +129,7 @@
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
+ <item name="android:listPreferredItemHeight">72dip</item>
<item name="*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
<item name="*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
<item name="*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
diff --git a/res/xml/about_legal.xml b/res/xml/about_legal.xml
index 48e81f4..596effe 100644
--- a/res/xml/about_legal.xml
+++ b/res/xml/about_legal.xml
@@ -15,7 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/legal_information">
+ android:title="@string/legal_information">
<!-- Note: The titles given here probably won't be used. Instead, we programmatically
fill the title with the label of the activity with the corresponding action.
@@ -23,38 +23,37 @@
list. -->
<!-- Copyright information -->
- <PreferenceScreen
+ <Preference
android:key="copyright"
android:title="@string/copyright_title">
- <intent android:action="android.settings.COPYRIGHT" />
- </PreferenceScreen>
+ <intent android:action="android.settings.COPYRIGHT"/>
+ </Preference>
<!-- License information -->
- <PreferenceScreen
+ <Preference
android:key="license"
android:title="@string/license_title">
- <intent android:action="android.settings.LICENSE" />
- </PreferenceScreen>
+ <intent android:action="android.settings.LICENSE"/>
+ </Preference>
<!-- Terms and conditions -->
- <PreferenceScreen
+ <Preference
android:key="terms"
android:title="@string/terms_title">
- <intent android:action="android.settings.TERMS" />
- </PreferenceScreen>
+ <intent android:action="android.settings.TERMS"/>
+ </Preference>
<!-- System WebView License information -->
- <PreferenceScreen
+ <Preference
android:key="webview_license"
android:title="@string/webview_license_title">
- <intent android:action="android.settings.WEBVIEW_LICENSE" />
- </PreferenceScreen>
+ <intent android:action="android.settings.WEBVIEW_LICENSE"/>
+ </Preference>
<Preference
android:key="wallpaper_attributions"
android:title="@string/wallpaper_attributions"
- android:summary="@string/wallpaper_attributions_values"
- />
+ android:summary="@string/wallpaper_attributions_values"/>
</PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 11cde5e..8bb54c6 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -15,7 +15,6 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/accessibility_settings"
android:persistent="true">
@@ -28,17 +27,17 @@
android:key="system_category"
android:title="@string/accessibility_system_title">
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" />
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title"/>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
android:key="font_size_preference_screen"
android:title="@string/title_font_size"/>
@@ -47,7 +46,7 @@
android:key="screen_zoom"
android:title="@string/screen_zoom_title"/>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
android:key="autoclick_preference_screen"
android:title="@string/accessibility_autoclick_preference_title"/>
@@ -82,12 +81,13 @@
android:summary="@string/accessibility_toggle_master_mono_summary"
android:persistent="false"/>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.ToggleGlobalGesturePreferenceFragment"
android:key="enable_global_gesture_preference_screen"
android:title="@string/accessibility_global_gesture_preference_title"/>
- <PreferenceScreen android:key="tts_settings_preference"
+ <Preference
+ android:key="tts_settings_preference"
android:fragment="com.android.settings.tts.TextToSpeechSettings"
android:title="@string/tts_settings_title"/>
@@ -107,7 +107,7 @@
android:title="@string/accessibility_display_inversion_preference_title"
android:summary="@string/accessibility_display_inversion_preference_subtitle"
android:persistent="false" />
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
android:key="daltonizer_preference_screen"
android:title="@string/accessibility_display_daltonizer_preference_title" />
diff --git a/res/xml/advanced_apps.xml b/res/xml/advanced_apps.xml
index 7e2e9cd..c17da05 100644
--- a/res/xml/advanced_apps.xml
+++ b/res/xml/advanced_apps.xml
@@ -29,11 +29,10 @@
<PreferenceCategory
android:title="@string/default_apps_title">
- <PreferenceScreen
+ <Preference
android:key="domain_urls"
android:title="@string/domain_urls_title"
- android:fragment="com.android.settings.applications.ManageDomainUrls">
- </PreferenceScreen>
+ android:fragment="com.android.settings.applications.ManageDomainUrls" />
<Preference
android:key="assist_and_voice_input"
diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml
index 932fa60..5da5326 100644
--- a/res/xml/app_default_settings.xml
+++ b/res/xml/app_default_settings.xml
@@ -64,8 +64,7 @@
<Preference
android:key="domain_urls"
android:title="@string/domain_urls_title"
- android:fragment="com.android.settings.applications.ManageDomainUrls">
- </Preference>
+ android:fragment="com.android.settings.applications.ManageDomainUrls"/>
<com.android.settings.WorkOnlyCategory
android:key="work_defaults"
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index e573bbd..34d48f1 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -43,7 +43,7 @@
android:summary="12:00am"
/>
- <PreferenceScreen
+ <Preference
android:fragment="com.android.settings.ZonePicker"
android:key="timezone"
android:title="@string/date_time_set_timezone"
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index d84b008..804ede9 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -22,7 +22,7 @@
android:title="@*android:string/bugreport_title"
android:dialogTitle="@*android:string/bugreport_title" />
- <PreferenceScreen
+ <Preference
android:key="local_backup_password"
android:title="@string/local_backup_password_title"
android:summary="@string/local_backup_password_summary_none"
@@ -31,7 +31,7 @@
android:action="android.settings.privacy.SET_FULL_BACKUP_PASSWORD"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.SetFullBackupPassword" />
- </PreferenceScreen>
+ </Preference>
<com.android.settingslib.RestrictedSwitchPreference
android:key="keep_screen_on"
@@ -57,13 +57,13 @@
android:summary="@string/oem_unlock_enable_summary"
settings:useAdditionalSummary="true"/>
- <PreferenceScreen
+ <Preference
android:key="running_apps"
android:title="@string/runningservices_settings_title"
android:summary="@string/runningservices_settings_summary"
android:fragment="com.android.settings.applications.RunningServices" />
- <PreferenceScreen
+ <Preference
android:key="convert_to_file_encryption"
android:title="@string/convert_to_file_encryption"
android:summary="@string/convert_to_file_encryption_enabled"
@@ -94,11 +94,11 @@
android:key="ota_disable_automatic_update"
android:title="@string/ota_disable_automatic_update" />
- <PreferenceScreen
+ <Preference
android:key="demo_mode"
android:title="@string/demo_mode">
<intent android:action="com.android.settings.action.DEMO_MODE" />
- </PreferenceScreen>
+ </Preference>
<PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category">
@@ -121,14 +121,14 @@
android:title="@string/bugreport_in_power"
android:summary="@string/bugreport_in_power_summary"/>
- <PreferenceScreen android:key="mock_location_app"
+ <Preference android:key="mock_location_app"
android:title="@string/mock_location_app" />
<SwitchPreference
android:key="debug_view_attributes"
android:title="@string/debug_view_attributes" />
- <PreferenceScreen android:key="debug_app"
+ <Preference android:key="debug_app"
android:title="@string/debug_app" />
<SwitchPreference
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 66cf8f4..cee2e70 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -19,56 +19,54 @@
android:title="@string/about_settings">
<!-- System update settings - launches activity -->
- <PreferenceScreen android:key="system_update_settings"
+ <Preference android:key="system_update_settings"
android:title="@string/system_update_settings_list_item_title"
android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen android:key="additional_system_update_settings"
+ <Preference android:key="additional_system_update_settings"
android:title="@string/additional_system_update_settings_list_item_title">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="@string/additional_system_update"
android:targetClass="@string/additional_system_update_menu" />
- </PreferenceScreen>
+ </Preference>
<!-- Device status - launches activity -->
- <PreferenceScreen android:key="status_info"
+ <Preference android:key="status_info"
android:title="@string/device_status"
android:summary="@string/device_status_summary"
- android:fragment="com.android.settings.deviceinfo.Status">
- </PreferenceScreen>
+ android:fragment="com.android.settings.deviceinfo.Status"/>
<!-- Manual -->
- <PreferenceScreen
+ <Preference
android:key="manual"
android:title="@string/manual">
<intent android:action="android.settings.SHOW_MANUAL" />
- </PreferenceScreen>
+ </Preference>
<!-- Legal Information -->
- <PreferenceScreen
+ <Preference
android:key="container"
android:title="@string/legal_information"
android:fragment="com.android.settings.LegalSettings" />
- <PreferenceScreen
+ <Preference
android:key="regulatory_info"
android:title="@string/regulatory_labels">
<intent android:action="android.settings.SHOW_REGULATORY_INFO" />
- </PreferenceScreen>
+ </Preference>
- <PreferenceScreen
+ <Preference
android:key="safety_info"
android:title="@string/safety_and_regulatory_info">
<intent android:action="android.settings.SHOW_SAFETY_AND_REGULATORY_INFO" />
- </PreferenceScreen>
+ </Preference>
<!-- Feedback on the device -->
- <PreferenceScreen android:key="device_feedback"
- android:title="@string/device_feedback">
- </PreferenceScreen>
+ <Preference android:key="device_feedback"
+ android:title="@string/device_feedback" />
<!-- Device hardware model -->
<com.android.settings.DividerPreference
@@ -89,12 +87,12 @@
android:summary="@string/device_info_default"/>
<!-- Security patch level -->
- <PreferenceScreen android:key="security_patch"
+ <Preference android:key="security_patch"
android:title="@string/security_patch"
android:summary="@string/device_info_default">
<intent android:action="android.intent.action.VIEW"
android:data="https://source.android.com/security/bulletin/" />
- </PreferenceScreen>
+ </Preference>
<!-- Device FCC equipment id -->
<com.android.settings.DividerPreference
diff --git a/res/xml/ia_display_settings.xml b/res/xml/ia_display_settings.xml
index 31b524a..756d551 100644
--- a/res/xml/ia_display_settings.xml
+++ b/res/xml/ia_display_settings.xml
@@ -61,7 +61,7 @@
settings:keywords="@string/keywords_display_auto_brightness"
android:summary="@string/auto_brightness_summary" />
- <PreferenceScreen
+ <Preference
android:key="font_size"
android:title="@string/title_font_size"
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
@@ -72,7 +72,7 @@
android:title="@string/screen_zoom_title"
settings:keywords="@string/screen_zoom_keywords" />
- <PreferenceScreen
+ <Preference
android:key="screensaver"
android:title="@string/screensaver_settings_title"
android:fragment="com.android.settings.DreamSettings" />
@@ -105,7 +105,7 @@
android:title="@string/tap_to_wake"
android:summary="@string/tap_to_wake_summary" />
- <PreferenceScreen
+ <Preference
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
settings:keywords="@string/keywords_display_cast_screen"
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index 68a867e..d724b74 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -114,7 +114,7 @@
android:persistent="false"
android:fragment="com.android.settings.TrustAgentSettings"/>
- <PreferenceScreen
+ <Preference
android:key="screen_pinning_settings"
android:title="@string/screen_pinning_title"
android:summary="@string/switch_off_text"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 227a650..c74d1f1 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -16,9 +16,9 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/sound_settings"
- android:key="sound_settings"
- settings:keywords="@string/keywords_sounds">
+ android:title="@string/sound_settings"
+ android:key="sound_settings"
+ settings:keywords="@string/keywords_sounds">
<!-- Media volume -->
<com.android.settings.notification.VolumeSeekBarPreference
@@ -87,7 +87,7 @@
android:key="cell_broadcast_settings"
android:title="@string/cell_broadcast_settings"
settings:useAdminDisabledSummary="true">
- <intent
+ <intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.cellbroadcastreceiver"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" />
@@ -101,7 +101,7 @@
android:fragment="com.android.settings.notification.OtherSoundSettings" />
<!-- Cast -->
- <PreferenceScreen
+ <Preference
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 41d96d6..1ae3380 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -254,7 +254,7 @@
private SwitchPreference mDebugViewAttributes;
private SwitchPreference mForceAllowOnExternal;
- private PreferenceScreen mPassword;
+ private Preference mPassword;
private String mDebugApp;
private Preference mDebugAppPref;
@@ -408,7 +408,7 @@
mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
- mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
+ mPassword = findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword);
if (!mUm.isAdminUser()) {
@@ -496,8 +496,7 @@
removePreferenceForProduction(hdcpChecking);
}
- PreferenceScreen convertFbePreference =
- (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
+ Preference convertFbePreference = findPreference(KEY_CONVERT_FBE);
try {
IBinder service = ServiceManager.getService("mount");
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index f0c77fc..af5b5cd 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -33,7 +33,6 @@
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -185,12 +184,12 @@
private SwitchPreference mToggleMasterMonoPreference;
private ListPreference mSelectLongPressTimeoutPreference;
private Preference mNoServicesMessagePreference;
- private PreferenceScreen mCaptioningPreferenceScreen;
- private PreferenceScreen mDisplayMagnificationPreferenceScreen;
- private PreferenceScreen mFontSizePreferenceScreen;
- private PreferenceScreen mAutoclickPreferenceScreen;
- private PreferenceScreen mGlobalGesturePreferenceScreen;
- private PreferenceScreen mDisplayDaltonizerPreferenceScreen;
+ private Preference mCaptioningPreferenceScreen;
+ private Preference mDisplayMagnificationPreferenceScreen;
+ private Preference mFontSizePreferenceScreen;
+ private Preference mAutoclickPreferenceScreen;
+ private Preference mGlobalGesturePreferenceScreen;
+ private Preference mDisplayDaltonizerPreferenceScreen;
private SwitchPreference mToggleInversionPreference;
private int mLongPressTimeoutDefault;
@@ -408,28 +407,24 @@
}
// Captioning.
- mCaptioningPreferenceScreen = (PreferenceScreen) findPreference(
- CAPTIONING_PREFERENCE_SCREEN);
+ mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
// Display magnification.
- mDisplayMagnificationPreferenceScreen = (PreferenceScreen) findPreference(
+ mDisplayMagnificationPreferenceScreen = findPreference(
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
// Font size.
- mFontSizePreferenceScreen = (PreferenceScreen) findPreference(
- FONT_SIZE_PREFERENCE_SCREEN);
+ mFontSizePreferenceScreen = findPreference(FONT_SIZE_PREFERENCE_SCREEN);
// Autoclick after pointer stops.
- mAutoclickPreferenceScreen = (PreferenceScreen) findPreference(
- AUTOCLICK_PREFERENCE_SCREEN);
+ mAutoclickPreferenceScreen = findPreference(AUTOCLICK_PREFERENCE_SCREEN);
// Display color adjustments.
- mDisplayDaltonizerPreferenceScreen = (PreferenceScreen) findPreference(
- DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
+ mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
// Global gesture.
- mGlobalGesturePreferenceScreen =
- (PreferenceScreen) findPreference(ENABLE_ACCESSIBILITY_GESTURE_PREFERENCE_SCREEN);
+ mGlobalGesturePreferenceScreen = findPreference(
+ ENABLE_ACCESSIBILITY_GESTURE_PREFERENCE_SCREEN);
final int longPressOnPowerBehavior = getActivity().getResources().getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior);
final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
@@ -468,7 +463,8 @@
for (int i = 0, count = installedServices.size(); i < count; ++i) {
AccessibilityServiceInfo info = installedServices.get(i);
- RestrictedPreference preference = new RestrictedPreference(getActivity());
+ RestrictedPreference preference =
+ new RestrictedPreference(mServicesCategory.getContext());
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
@@ -702,7 +698,7 @@
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
- List<SearchIndexableResource> indexables = new ArrayList<SearchIndexableResource>();
+ List<SearchIndexableResource> indexables = new ArrayList<>();
SearchIndexableResource indexable = new SearchIndexableResource(context);
indexable.xmlResId = R.xml.accessibility_settings;
indexables.add(indexable);
diff --git a/src/com/android/settings/display/ScreenZoomPreference.java b/src/com/android/settings/display/ScreenZoomPreference.java
index ee2ac95..07f61f8 100644
--- a/src/com/android/settings/display/ScreenZoomPreference.java
+++ b/src/com/android/settings/display/ScreenZoomPreference.java
@@ -16,23 +16,23 @@
package com.android.settings.display;
-import com.android.settingslib.display.DisplayDensityUtils;
-
import android.content.Context;
import android.support.v4.content.res.TypedArrayUtils;
-import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.AttributeSet;
+import com.android.settingslib.display.DisplayDensityUtils;
+
/**
* Preference for changing the density of the display on which the preference
* is visible.
*/
-public class ScreenZoomPreference extends PreferenceGroup {
+public class ScreenZoomPreference extends Preference {
public ScreenZoomPreference(Context context, AttributeSet attrs) {
super(context, attrs, TypedArrayUtils.getAttr(context,
- android.support.v7.preference.R.attr.preferenceScreenStyle,
- android.R.attr.preferenceScreenStyle));
+ android.support.v7.preference.R.attr.preferenceStyle,
+ android.R.attr.preferenceStyle));
if (TextUtils.isEmpty(getFragment())) {
setFragment("com.android.settings.display.ScreenZoomSettings");
@@ -49,9 +49,4 @@
setSummary(entries[currentIndex]);
}
}
-
- @Override
- protected boolean isOnSameScreenAsChildren() {
- return false;
- }
}
diff --git a/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java b/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java
new file mode 100644
index 0000000..15290b1
--- /dev/null
+++ b/tests/app/src/com/android/settings/dashboard/FirstIdViewMatcher.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 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.settings.dashboard;
+
+import android.content.res.Resources;
+import android.view.View;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+/***
+ * Matches on the first view with id if there are multiple views using the same Id.
+ */
+public class FirstIdViewMatcher {
+
+ public static Matcher<View> withFirstId(final int id) {
+ return new TypeSafeMatcher<View>() {
+ Resources resources = null;
+ private boolean mMatched;
+
+ public void describeTo(Description description) {
+ description.appendText(" is the first view that matches id.");
+ }
+
+ public boolean matchesSafely(View view) {
+ this.resources = view.getResources();
+ if (mMatched) {
+ return false;
+ } else {
+ mMatched |= id == view.getId();
+ return mMatched;
+ }
+ }
+ };
+ }
+}
diff --git a/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java b/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
new file mode 100644
index 0000000..b99f753e
--- /dev/null
+++ b/tests/app/src/com/android/settings/dashboard/PreferenceThemeTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 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.settings.dashboard;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static com.android.settings.dashboard.FirstIdViewMatcher.withFirstId;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class PreferenceThemeTest {
+
+ private Instrumentation mInstrumentation;
+ private Context mTargetContext;
+ private String mTargetPackage;
+
+ @Before
+ public void setUp() throws Exception {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mTargetContext = mInstrumentation.getTargetContext();
+ mTargetPackage = mTargetContext.getPackageName();
+ }
+
+ @Test
+ public void startPhoneStatus_preferenceIconSpaceReserved() throws InterruptedException {
+ launchPhoneStatus();
+ onView(withId(android.R.id.icon_frame)).check(doesNotExist());
+ onView(withFirstId(R.id.icon_container)).check(matches(isDisplayed()));
+ }
+
+ private void launchPhoneStatus() {
+ final Intent settingsIntent = new Intent("android.settings.DEVICE_INFO_SETTINGS")
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .setPackage(mTargetPackage)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ InstrumentationRegistry.getInstrumentation().startActivitySync(settingsIntent);
+ }
+}