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
This commit is contained in:
Fan Zhang
2016-12-09 13:04:24 -08:00
parent 1a71c05c7c
commit 1c118b5f2a
23 changed files with 465 additions and 173 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -16,18 +16,19 @@
<!-- Based off frameworks/base/core/res/res/layout/preference_material.xml <!-- Based off frameworks/base/core/res/res/layout/preference_material.xml
except that this has the negative margin on the image removed. --> 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/activatedBackgroundIndicator" android:background="?android:attr/selectableItemBackground"
android:clipToPadding="false"> android:clipToPadding="false">
<LinearLayout <LinearLayout
android:id="@id/icon_frame" android:id="@+id/icon_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="60dp" android:minWidth="60dp"
@@ -51,14 +52,16 @@
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingBottom="16dp"> android:paddingBottom="16dp">
<TextView android:id="@android:id/title" <TextView
android:id="@android:id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem" 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_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@android:id/title" android:layout_below="@android:id/title"
@@ -70,7 +73,8 @@
</RelativeLayout> </RelativeLayout>
<!-- Preference should place its actual preference widget here. --> <!-- 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_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"

View File

@@ -14,14 +14,32 @@
limitations under the License. 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" 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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -33,17 +51,20 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView android:id="@android:id/title" <TextView
android:layout_width="wrap_content" android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:paddingStart="16dp"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee" android:ellipsize="marquee"
android:fadingEdge="horizontal"/> android:fadingEdge="horizontal"/>
<!-- Preference should place its actual preference widget here. --> <!-- 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_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
@@ -56,32 +77,24 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="6dp"> android:layout_marginTop="6dp">
<ImageView <SeekBar
android:id="@android:id/icon" android:id="@*android:id/seekbar"
android:layout_gravity="center_vertical|start"
android:layout_width="24dp"
android:layout_height="24dp" />
<SeekBar android:id="@*android:id/seekbar"
android:layout_marginStart="24dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="match_parent" 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start" android:layout_gravity="center_vertical|start"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:layout_marginStart="24dp"
android:paddingStart="14dp"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="@android:style/TextAppearance.Material.Body1" android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>

View File

@@ -51,7 +51,6 @@
<dimen name="divider_height">3dip</dimen> <dimen name="divider_height">3dip</dimen>
<dimen name="divider_margin_top">6dip</dimen> <dimen name="divider_margin_top">6dip</dimen>
<dimen name="divider_margin_bottom">7dip</dimen> <dimen name="divider_margin_bottom">7dip</dimen>
<dimen name="vert_divider_width">1dip</dimen>
<!-- Size of icons in the top-level of settings --> <!-- Size of icons in the top-level of settings -->
<dimen name="header_icon_width">28dp</dimen> <dimen name="header_icon_width">28dp</dimen>

View File

@@ -93,22 +93,6 @@
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
</style> </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"> <style name="PreferenceHeaderPanelSinglePane">
<item name="android:layout_marginStart">0dp</item> <item name="android:layout_marginStart">0dp</item>
<item name="android:layout_marginEnd">0dp</item> <item name="android:layout_marginEnd">0dp</item>
@@ -156,18 +140,6 @@
<item name="android:scrollbarStyle">outsideOverlay</item> <item name="android:scrollbarStyle">outsideOverlay</item>
</style> </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 name="TextAppearance.SetupWizardDescription" parent="@android:style/TextAppearance.Material.Subhead">
</style> </style>
@@ -324,10 +296,6 @@
<!-- Scrollbar style OUTSIDE_OVERLAY --> <!-- Scrollbar style OUTSIDE_OVERLAY -->
<integer name="preference_scrollbar_style">33554432</integer> <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"> <style name="AppListSwitchPreference" parent="@*android:style/Preference.Material.DialogPreference">
<item name="android:widgetLayout">@*android:layout/preference_widget_switch</item> <item name="android:widgetLayout">@*android:layout/preference_widget_switch</item>
</style> </style>

View File

@@ -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>

View File

@@ -88,11 +88,16 @@
</style> </style>
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material"> <style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
<item name="android:preferenceStyle">@style/Preference</item> <!-- Parent path frameworks/support/v14/preference/res/values/themes.xml -->
<item name="android:editTextPreferenceStyle">@style/EditTextPreference</item> <item name="android:scrollbars">vertical</item>
<item name="dropdownPreferenceStyle">@style/Preference.DropDown.Material</item>
<item name="android:preferenceFragmentStyle">@style/PreferenceFragmentStyle</item>
<item name="apnPreferenceStyle">@style/ApnPreference</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>
<style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme"> <style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
@@ -124,6 +129,7 @@
<style name="Theme.Settings" parent="Theme.SettingsBase"> <style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item> <item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:listPreferredItemHeight">72dip</item>
<item name="*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item> <item name="*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
<item name="*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item> <item name="*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
<item name="*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item> <item name="*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>

View File

@@ -23,38 +23,37 @@
list. --> list. -->
<!-- Copyright information --> <!-- Copyright information -->
<PreferenceScreen <Preference
android:key="copyright" android:key="copyright"
android:title="@string/copyright_title"> android:title="@string/copyright_title">
<intent android:action="android.settings.COPYRIGHT"/> <intent android:action="android.settings.COPYRIGHT"/>
</PreferenceScreen> </Preference>
<!-- License information --> <!-- License information -->
<PreferenceScreen <Preference
android:key="license" android:key="license"
android:title="@string/license_title"> android:title="@string/license_title">
<intent android:action="android.settings.LICENSE"/> <intent android:action="android.settings.LICENSE"/>
</PreferenceScreen> </Preference>
<!-- Terms and conditions --> <!-- Terms and conditions -->
<PreferenceScreen <Preference
android:key="terms" android:key="terms"
android:title="@string/terms_title"> android:title="@string/terms_title">
<intent android:action="android.settings.TERMS"/> <intent android:action="android.settings.TERMS"/>
</PreferenceScreen> </Preference>
<!-- System WebView License information --> <!-- System WebView License information -->
<PreferenceScreen <Preference
android:key="webview_license" android:key="webview_license"
android:title="@string/webview_license_title"> android:title="@string/webview_license_title">
<intent android:action="android.settings.WEBVIEW_LICENSE"/> <intent android:action="android.settings.WEBVIEW_LICENSE"/>
</PreferenceScreen> </Preference>
<Preference <Preference
android:key="wallpaper_attributions" android:key="wallpaper_attributions"
android:title="@string/wallpaper_attributions" android:title="@string/wallpaper_attributions"
android:summary="@string/wallpaper_attributions_values" android:summary="@string/wallpaper_attributions_values"/>
/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -15,7 +15,6 @@
--> -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <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:title="@string/accessibility_settings"
android:persistent="true"> android:persistent="true">
@@ -28,17 +27,17 @@
android:key="system_category" android:key="system_category"
android:title="@string/accessibility_system_title"> android:title="@string/accessibility_system_title">
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment" android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
android:key="captioning_preference_screen" android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" /> android:title="@string/accessibility_captioning_title" />
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_preference_screen" android:key="screen_magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title"/> android:title="@string/accessibility_screen_magnification_title"/>
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
android:key="font_size_preference_screen" android:key="font_size_preference_screen"
android:title="@string/title_font_size"/> android:title="@string/title_font_size"/>
@@ -47,7 +46,7 @@
android:key="screen_zoom" android:key="screen_zoom"
android:title="@string/screen_zoom_title"/> android:title="@string/screen_zoom_title"/>
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
android:key="autoclick_preference_screen" android:key="autoclick_preference_screen"
android:title="@string/accessibility_autoclick_preference_title"/> android:title="@string/accessibility_autoclick_preference_title"/>
@@ -82,12 +81,13 @@
android:summary="@string/accessibility_toggle_master_mono_summary" android:summary="@string/accessibility_toggle_master_mono_summary"
android:persistent="false"/> android:persistent="false"/>
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.ToggleGlobalGesturePreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleGlobalGesturePreferenceFragment"
android:key="enable_global_gesture_preference_screen" android:key="enable_global_gesture_preference_screen"
android:title="@string/accessibility_global_gesture_preference_title"/> 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:fragment="com.android.settings.tts.TextToSpeechSettings"
android:title="@string/tts_settings_title"/> android:title="@string/tts_settings_title"/>
@@ -107,7 +107,7 @@
android:title="@string/accessibility_display_inversion_preference_title" android:title="@string/accessibility_display_inversion_preference_title"
android:summary="@string/accessibility_display_inversion_preference_subtitle" android:summary="@string/accessibility_display_inversion_preference_subtitle"
android:persistent="false" /> android:persistent="false" />
<PreferenceScreen <Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
android:key="daltonizer_preference_screen" android:key="daltonizer_preference_screen"
android:title="@string/accessibility_display_daltonizer_preference_title" /> android:title="@string/accessibility_display_daltonizer_preference_title" />

View File

@@ -29,11 +29,10 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/default_apps_title"> android:title="@string/default_apps_title">
<PreferenceScreen <Preference
android:key="domain_urls" android:key="domain_urls"
android:title="@string/domain_urls_title" android:title="@string/domain_urls_title"
android:fragment="com.android.settings.applications.ManageDomainUrls"> android:fragment="com.android.settings.applications.ManageDomainUrls" />
</PreferenceScreen>
<Preference <Preference
android:key="assist_and_voice_input" android:key="assist_and_voice_input"

View File

@@ -64,8 +64,7 @@
<Preference <Preference
android:key="domain_urls" android:key="domain_urls"
android:title="@string/domain_urls_title" android:title="@string/domain_urls_title"
android:fragment="com.android.settings.applications.ManageDomainUrls"> android:fragment="com.android.settings.applications.ManageDomainUrls"/>
</Preference>
<com.android.settings.WorkOnlyCategory <com.android.settings.WorkOnlyCategory
android:key="work_defaults" android:key="work_defaults"

View File

@@ -43,7 +43,7 @@
android:summary="12:00am" android:summary="12:00am"
/> />
<PreferenceScreen <Preference
android:fragment="com.android.settings.ZonePicker" android:fragment="com.android.settings.ZonePicker"
android:key="timezone" android:key="timezone"
android:title="@string/date_time_set_timezone" android:title="@string/date_time_set_timezone"

View File

@@ -22,7 +22,7 @@
android:title="@*android:string/bugreport_title" android:title="@*android:string/bugreport_title"
android:dialogTitle="@*android:string/bugreport_title" /> android:dialogTitle="@*android:string/bugreport_title" />
<PreferenceScreen <Preference
android:key="local_backup_password" android:key="local_backup_password"
android:title="@string/local_backup_password_title" android:title="@string/local_backup_password_title"
android:summary="@string/local_backup_password_summary_none" android:summary="@string/local_backup_password_summary_none"
@@ -31,7 +31,7 @@
android:action="android.settings.privacy.SET_FULL_BACKUP_PASSWORD" android:action="android.settings.privacy.SET_FULL_BACKUP_PASSWORD"
android:targetPackage="com.android.settings" android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.SetFullBackupPassword" /> android:targetClass="com.android.settings.SetFullBackupPassword" />
</PreferenceScreen> </Preference>
<com.android.settingslib.RestrictedSwitchPreference <com.android.settingslib.RestrictedSwitchPreference
android:key="keep_screen_on" android:key="keep_screen_on"
@@ -57,13 +57,13 @@
android:summary="@string/oem_unlock_enable_summary" android:summary="@string/oem_unlock_enable_summary"
settings:useAdditionalSummary="true"/> settings:useAdditionalSummary="true"/>
<PreferenceScreen <Preference
android:key="running_apps" android:key="running_apps"
android:title="@string/runningservices_settings_title" android:title="@string/runningservices_settings_title"
android:summary="@string/runningservices_settings_summary" android:summary="@string/runningservices_settings_summary"
android:fragment="com.android.settings.applications.RunningServices" /> android:fragment="com.android.settings.applications.RunningServices" />
<PreferenceScreen <Preference
android:key="convert_to_file_encryption" android:key="convert_to_file_encryption"
android:title="@string/convert_to_file_encryption" android:title="@string/convert_to_file_encryption"
android:summary="@string/convert_to_file_encryption_enabled" android:summary="@string/convert_to_file_encryption_enabled"
@@ -94,11 +94,11 @@
android:key="ota_disable_automatic_update" android:key="ota_disable_automatic_update"
android:title="@string/ota_disable_automatic_update" /> android:title="@string/ota_disable_automatic_update" />
<PreferenceScreen <Preference
android:key="demo_mode" android:key="demo_mode"
android:title="@string/demo_mode"> android:title="@string/demo_mode">
<intent android:action="com.android.settings.action.DEMO_MODE" /> <intent android:action="com.android.settings.action.DEMO_MODE" />
</PreferenceScreen> </Preference>
<PreferenceCategory android:key="debug_debugging_category" <PreferenceCategory android:key="debug_debugging_category"
android:title="@string/debug_debugging_category"> android:title="@string/debug_debugging_category">
@@ -121,14 +121,14 @@
android:title="@string/bugreport_in_power" android:title="@string/bugreport_in_power"
android:summary="@string/bugreport_in_power_summary"/> 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" /> android:title="@string/mock_location_app" />
<SwitchPreference <SwitchPreference
android:key="debug_view_attributes" android:key="debug_view_attributes"
android:title="@string/debug_view_attributes" /> android:title="@string/debug_view_attributes" />
<PreferenceScreen android:key="debug_app" <Preference android:key="debug_app"
android:title="@string/debug_app" /> android:title="@string/debug_app" />
<SwitchPreference <SwitchPreference

View File

@@ -19,56 +19,54 @@
android:title="@string/about_settings"> android:title="@string/about_settings">
<!-- System update settings - launches activity --> <!-- 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:title="@string/system_update_settings_list_item_title"
android:summary="@string/system_update_settings_list_item_summary"> android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" /> <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"> android:title="@string/additional_system_update_settings_list_item_title">
<intent android:action="android.intent.action.MAIN" <intent android:action="android.intent.action.MAIN"
android:targetPackage="@string/additional_system_update" android:targetPackage="@string/additional_system_update"
android:targetClass="@string/additional_system_update_menu" /> android:targetClass="@string/additional_system_update_menu" />
</PreferenceScreen> </Preference>
<!-- Device status - launches activity --> <!-- Device status - launches activity -->
<PreferenceScreen android:key="status_info" <Preference android:key="status_info"
android:title="@string/device_status" android:title="@string/device_status"
android:summary="@string/device_status_summary" android:summary="@string/device_status_summary"
android:fragment="com.android.settings.deviceinfo.Status"> android:fragment="com.android.settings.deviceinfo.Status"/>
</PreferenceScreen>
<!-- Manual --> <!-- Manual -->
<PreferenceScreen <Preference
android:key="manual" android:key="manual"
android:title="@string/manual"> android:title="@string/manual">
<intent android:action="android.settings.SHOW_MANUAL" /> <intent android:action="android.settings.SHOW_MANUAL" />
</PreferenceScreen> </Preference>
<!-- Legal Information --> <!-- Legal Information -->
<PreferenceScreen <Preference
android:key="container" android:key="container"
android:title="@string/legal_information" android:title="@string/legal_information"
android:fragment="com.android.settings.LegalSettings" /> android:fragment="com.android.settings.LegalSettings" />
<PreferenceScreen <Preference
android:key="regulatory_info" android:key="regulatory_info"
android:title="@string/regulatory_labels"> android:title="@string/regulatory_labels">
<intent android:action="android.settings.SHOW_REGULATORY_INFO" /> <intent android:action="android.settings.SHOW_REGULATORY_INFO" />
</PreferenceScreen> </Preference>
<PreferenceScreen <Preference
android:key="safety_info" android:key="safety_info"
android:title="@string/safety_and_regulatory_info"> android:title="@string/safety_and_regulatory_info">
<intent android:action="android.settings.SHOW_SAFETY_AND_REGULATORY_INFO" /> <intent android:action="android.settings.SHOW_SAFETY_AND_REGULATORY_INFO" />
</PreferenceScreen> </Preference>
<!-- Feedback on the device --> <!-- Feedback on the device -->
<PreferenceScreen android:key="device_feedback" <Preference android:key="device_feedback"
android:title="@string/device_feedback"> android:title="@string/device_feedback" />
</PreferenceScreen>
<!-- Device hardware model --> <!-- Device hardware model -->
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
@@ -89,12 +87,12 @@
android:summary="@string/device_info_default"/> android:summary="@string/device_info_default"/>
<!-- Security patch level --> <!-- Security patch level -->
<PreferenceScreen android:key="security_patch" <Preference android:key="security_patch"
android:title="@string/security_patch" android:title="@string/security_patch"
android:summary="@string/device_info_default"> android:summary="@string/device_info_default">
<intent android:action="android.intent.action.VIEW" <intent android:action="android.intent.action.VIEW"
android:data="https://source.android.com/security/bulletin/" /> android:data="https://source.android.com/security/bulletin/" />
</PreferenceScreen> </Preference>
<!-- Device FCC equipment id --> <!-- Device FCC equipment id -->
<com.android.settings.DividerPreference <com.android.settings.DividerPreference

View File

@@ -61,7 +61,7 @@
settings:keywords="@string/keywords_display_auto_brightness" settings:keywords="@string/keywords_display_auto_brightness"
android:summary="@string/auto_brightness_summary" /> android:summary="@string/auto_brightness_summary" />
<PreferenceScreen <Preference
android:key="font_size" android:key="font_size"
android:title="@string/title_font_size" android:title="@string/title_font_size"
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment" android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
@@ -72,7 +72,7 @@
android:title="@string/screen_zoom_title" android:title="@string/screen_zoom_title"
settings:keywords="@string/screen_zoom_keywords" /> settings:keywords="@string/screen_zoom_keywords" />
<PreferenceScreen <Preference
android:key="screensaver" android:key="screensaver"
android:title="@string/screensaver_settings_title" android:title="@string/screensaver_settings_title"
android:fragment="com.android.settings.DreamSettings" /> android:fragment="com.android.settings.DreamSettings" />
@@ -105,7 +105,7 @@
android:title="@string/tap_to_wake" android:title="@string/tap_to_wake"
android:summary="@string/tap_to_wake_summary" /> android:summary="@string/tap_to_wake_summary" />
<PreferenceScreen <Preference
android:key="wifi_display" android:key="wifi_display"
android:title="@string/wifi_display_settings_title" android:title="@string/wifi_display_settings_title"
settings:keywords="@string/keywords_display_cast_screen" settings:keywords="@string/keywords_display_cast_screen"

View File

@@ -114,7 +114,7 @@
android:persistent="false" android:persistent="false"
android:fragment="com.android.settings.TrustAgentSettings"/> android:fragment="com.android.settings.TrustAgentSettings"/>
<PreferenceScreen <Preference
android:key="screen_pinning_settings" android:key="screen_pinning_settings"
android:title="@string/screen_pinning_title" android:title="@string/screen_pinning_title"
android:summary="@string/switch_off_text" android:summary="@string/switch_off_text"

View File

@@ -101,7 +101,7 @@
android:fragment="com.android.settings.notification.OtherSoundSettings" /> android:fragment="com.android.settings.notification.OtherSoundSettings" />
<!-- Cast --> <!-- Cast -->
<PreferenceScreen <Preference
android:key="wifi_display" android:key="wifi_display"
android:title="@string/wifi_display_settings_title" android:title="@string/wifi_display_settings_title"
android:fragment="com.android.settings.wfd.WifiDisplaySettings" /> android:fragment="com.android.settings.wfd.WifiDisplaySettings" />

View File

@@ -254,7 +254,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private SwitchPreference mDebugViewAttributes; private SwitchPreference mDebugViewAttributes;
private SwitchPreference mForceAllowOnExternal; private SwitchPreference mForceAllowOnExternal;
private PreferenceScreen mPassword; private Preference mPassword;
private String mDebugApp; private String mDebugApp;
private Preference mDebugAppPref; private Preference mDebugAppPref;
@@ -408,7 +408,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES); mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY); mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD); mPassword = findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword); mAllPrefs.add(mPassword);
if (!mUm.isAdminUser()) { if (!mUm.isAdminUser()) {
@@ -496,8 +496,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
removePreferenceForProduction(hdcpChecking); removePreferenceForProduction(hdcpChecking);
} }
PreferenceScreen convertFbePreference = Preference convertFbePreference = findPreference(KEY_CONVERT_FBE);
(PreferenceScreen) findPreference(KEY_CONVERT_FBE);
try { try {
IBinder service = ServiceManager.getService("mount"); IBinder service = ServiceManager.getService("mount");

View File

@@ -33,7 +33,6 @@ import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.KeyCharacterMap; import android.view.KeyCharacterMap;
import android.view.KeyEvent; import android.view.KeyEvent;
@@ -185,12 +184,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
private SwitchPreference mToggleMasterMonoPreference; private SwitchPreference mToggleMasterMonoPreference;
private ListPreference mSelectLongPressTimeoutPreference; private ListPreference mSelectLongPressTimeoutPreference;
private Preference mNoServicesMessagePreference; private Preference mNoServicesMessagePreference;
private PreferenceScreen mCaptioningPreferenceScreen; private Preference mCaptioningPreferenceScreen;
private PreferenceScreen mDisplayMagnificationPreferenceScreen; private Preference mDisplayMagnificationPreferenceScreen;
private PreferenceScreen mFontSizePreferenceScreen; private Preference mFontSizePreferenceScreen;
private PreferenceScreen mAutoclickPreferenceScreen; private Preference mAutoclickPreferenceScreen;
private PreferenceScreen mGlobalGesturePreferenceScreen; private Preference mGlobalGesturePreferenceScreen;
private PreferenceScreen mDisplayDaltonizerPreferenceScreen; private Preference mDisplayDaltonizerPreferenceScreen;
private SwitchPreference mToggleInversionPreference; private SwitchPreference mToggleInversionPreference;
private int mLongPressTimeoutDefault; private int mLongPressTimeoutDefault;
@@ -408,28 +407,24 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
} }
// Captioning. // Captioning.
mCaptioningPreferenceScreen = (PreferenceScreen) findPreference( mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
CAPTIONING_PREFERENCE_SCREEN);
// Display magnification. // Display magnification.
mDisplayMagnificationPreferenceScreen = (PreferenceScreen) findPreference( mDisplayMagnificationPreferenceScreen = findPreference(
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN); DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
// Font size. // Font size.
mFontSizePreferenceScreen = (PreferenceScreen) findPreference( mFontSizePreferenceScreen = findPreference(FONT_SIZE_PREFERENCE_SCREEN);
FONT_SIZE_PREFERENCE_SCREEN);
// Autoclick after pointer stops. // Autoclick after pointer stops.
mAutoclickPreferenceScreen = (PreferenceScreen) findPreference( mAutoclickPreferenceScreen = findPreference(AUTOCLICK_PREFERENCE_SCREEN);
AUTOCLICK_PREFERENCE_SCREEN);
// Display color adjustments. // Display color adjustments.
mDisplayDaltonizerPreferenceScreen = (PreferenceScreen) findPreference( mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
// Global gesture. // Global gesture.
mGlobalGesturePreferenceScreen = mGlobalGesturePreferenceScreen = findPreference(
(PreferenceScreen) findPreference(ENABLE_ACCESSIBILITY_GESTURE_PREFERENCE_SCREEN); ENABLE_ACCESSIBILITY_GESTURE_PREFERENCE_SCREEN);
final int longPressOnPowerBehavior = getActivity().getResources().getInteger( final int longPressOnPowerBehavior = getActivity().getResources().getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior); com.android.internal.R.integer.config_longPressOnPowerBehavior);
final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
@@ -468,7 +463,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
for (int i = 0, count = installedServices.size(); i < count; ++i) { for (int i = 0, count = installedServices.size(); i < count; ++i) {
AccessibilityServiceInfo info = installedServices.get(i); AccessibilityServiceInfo info = installedServices.get(i);
RestrictedPreference preference = new RestrictedPreference(getActivity()); RestrictedPreference preference =
new RestrictedPreference(mServicesCategory.getContext());
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString(); String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo; ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
@@ -702,7 +698,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
@Override @Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) { boolean enabled) {
List<SearchIndexableResource> indexables = new ArrayList<SearchIndexableResource>(); List<SearchIndexableResource> indexables = new ArrayList<>();
SearchIndexableResource indexable = new SearchIndexableResource(context); SearchIndexableResource indexable = new SearchIndexableResource(context);
indexable.xmlResId = R.xml.accessibility_settings; indexable.xmlResId = R.xml.accessibility_settings;
indexables.add(indexable); indexables.add(indexable);

View File

@@ -16,23 +16,23 @@
package com.android.settings.display; package com.android.settings.display;
import com.android.settingslib.display.DisplayDensityUtils;
import android.content.Context; import android.content.Context;
import android.support.v4.content.res.TypedArrayUtils; 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.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import com.android.settingslib.display.DisplayDensityUtils;
/** /**
* Preference for changing the density of the display on which the preference * Preference for changing the density of the display on which the preference
* is visible. * is visible.
*/ */
public class ScreenZoomPreference extends PreferenceGroup { public class ScreenZoomPreference extends Preference {
public ScreenZoomPreference(Context context, AttributeSet attrs) { public ScreenZoomPreference(Context context, AttributeSet attrs) {
super(context, attrs, TypedArrayUtils.getAttr(context, super(context, attrs, TypedArrayUtils.getAttr(context,
android.support.v7.preference.R.attr.preferenceScreenStyle, android.support.v7.preference.R.attr.preferenceStyle,
android.R.attr.preferenceScreenStyle)); android.R.attr.preferenceStyle));
if (TextUtils.isEmpty(getFragment())) { if (TextUtils.isEmpty(getFragment())) {
setFragment("com.android.settings.display.ScreenZoomSettings"); setFragment("com.android.settings.display.ScreenZoomSettings");
@@ -49,9 +49,4 @@ public class ScreenZoomPreference extends PreferenceGroup {
setSummary(entries[currentIndex]); setSummary(entries[currentIndex]);
} }
} }
@Override
protected boolean isOnSameScreenAsChildren() {
return false;
}
} }

View File

@@ -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;
}
}
};
}
}

View File

@@ -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);
}
}