Merge "Change to use the expand button in support lib."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d629142a11
@@ -1,75 +0,0 @@
|
|||||||
<?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_material.xml -->
|
|
||||||
<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:gravity="center_vertical"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:clipToPadding="false">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/icon_frame"
|
|
||||||
style="@style/preference_icon_frame"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
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="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:textAppearance="?android:attr/textAppearanceListItem"
|
|
||||||
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_alignStart="@android:id/title"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:maxLines="1"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@@ -19,7 +19,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:key="apps_and_notification_screen"
|
android:key="apps_and_notification_screen"
|
||||||
android:title="@string/app_and_notification_dashboard_title">
|
android:title="@string/app_and_notification_dashboard_title"
|
||||||
|
settings:initialExpandedChildrenCount="4">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="recent_apps_category"
|
android:key="recent_apps_category"
|
||||||
|
@@ -1,83 +0,0 @@
|
|||||||
<?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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:title="@string/app_and_notification_dashboard_title"
|
|
||||||
android:key="apps_and_notification_screen"
|
|
||||||
settings:initialExpandedChildrenCount="4">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="recent_apps_category"
|
|
||||||
android:title="@string/recent_app_category_title"
|
|
||||||
android:order="-200">
|
|
||||||
<!-- Placeholder for a list of recent apps -->
|
|
||||||
|
|
||||||
<!-- See all apps button -->
|
|
||||||
<Preference
|
|
||||||
android:title="@string/applications_settings"
|
|
||||||
android:key="all_app_info"
|
|
||||||
android:order="20">
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.Settings$ManageApplicationsActivity">
|
|
||||||
<extra android:name="show_drawer_menu" android:value="true" />
|
|
||||||
</intent>
|
|
||||||
</Preference>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<!-- Empty category to draw divider -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="all_app_info_divider"
|
|
||||||
android:order="-190"/>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="manage_perms"
|
|
||||||
android:title="@string/app_permissions"
|
|
||||||
android:order="-130"
|
|
||||||
settings:keywords="@string/keywords_app_permissions">
|
|
||||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="dashboard_tile_placeholder"
|
|
||||||
android:order="10" />
|
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="app_and_notif_cell_broadcast_settings"
|
|
||||||
android:title="@string/cell_broadcast_settings"
|
|
||||||
android:order="15"
|
|
||||||
settings:useAdminDisabledSummary="true">
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.cellbroadcastreceiver"
|
|
||||||
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" />
|
|
||||||
</com.android.settingslib.RestrictedPreference>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="special_access"
|
|
||||||
android:title="@string/special_access"
|
|
||||||
android:order="20" >
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.Settings$SpecialAccessSettingsActivity" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -19,7 +19,8 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:key="display_settings_screen"
|
android:key="display_settings_screen"
|
||||||
android:title="@string/display_settings"
|
android:title="@string/display_settings"
|
||||||
settings:keywords="@string/keywords_display">
|
settings:keywords="@string/keywords_display"
|
||||||
|
settings:initialExpandedChildrenCount="4">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="brightness"
|
android:key="brightness"
|
||||||
|
@@ -1,128 +0,0 @@
|
|||||||
<?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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:title="@string/display_settings"
|
|
||||||
settings:keywords="@string/keywords_display"
|
|
||||||
android:key="display_settings_screen"
|
|
||||||
settings:initialExpandedChildrenCount="4">
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="brightness"
|
|
||||||
android:title="@string/brightness"
|
|
||||||
settings:keywords="@string/keywords_display_brightness_level">
|
|
||||||
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<com.android.settings.display.NightDisplayPreference
|
|
||||||
android:key="night_display"
|
|
||||||
android:title="@string/night_display_title"
|
|
||||||
android:fragment="com.android.settings.display.NightDisplaySettings"
|
|
||||||
android:widgetLayout="@null"
|
|
||||||
settings:widgetLayout="@null"
|
|
||||||
settings:keywords="@string/keywords_display_night_display" />
|
|
||||||
|
|
||||||
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="auto_brightness"
|
|
||||||
android:title="@string/auto_brightness_title"
|
|
||||||
settings:keywords="@string/keywords_display_auto_brightness"
|
|
||||||
android:summary="@string/auto_brightness_summary" />
|
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="wallpaper"
|
|
||||||
android:title="@string/wallpaper_settings_title"
|
|
||||||
settings:keywords="@string/keywords_display_wallpaper"
|
|
||||||
settings:useAdminDisabledSummary="true">
|
|
||||||
<intent
|
|
||||||
android:targetPackage="@string/config_wallpaper_picker_package"
|
|
||||||
android:targetClass="@string/config_wallpaper_picker_class" />
|
|
||||||
</com.android.settingslib.RestrictedPreference>
|
|
||||||
|
|
||||||
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
|
|
||||||
<com.android.settings.TimeoutListPreference
|
|
||||||
android:key="screen_timeout"
|
|
||||||
android:title="@string/screen_timeout"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:entries="@array/screen_timeout_entries"
|
|
||||||
android:entryValues="@array/screen_timeout_values" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="auto_rotate"
|
|
||||||
android:title="@string/accelerometer_title" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="color_mode"
|
|
||||||
android:title="@string/color_mode_title" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="font_size"
|
|
||||||
android:title="@string/title_font_size"
|
|
||||||
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
|
|
||||||
settings:keywords="@string/keywords_display_font_size" />
|
|
||||||
|
|
||||||
<com.android.settings.display.ScreenZoomPreference
|
|
||||||
android:key="screen_zoom"
|
|
||||||
android:title="@string/screen_zoom_title"
|
|
||||||
settings:keywords="@string/screen_zoom_keywords" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="screensaver"
|
|
||||||
android:title="@string/screensaver_settings_title"
|
|
||||||
android:fragment="com.android.settings.dream.DreamSettings" />
|
|
||||||
|
|
||||||
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
|
|
||||||
<Preference
|
|
||||||
android:key="ambient_display"
|
|
||||||
android:title="@string/ambient_display_screen_title"
|
|
||||||
android:fragment="com.android.settings.display.AmbientDisplaySettings" />
|
|
||||||
|
|
||||||
<!-- Hide night mode for now
|
|
||||||
<ListPreference
|
|
||||||
android:key="night_mode"
|
|
||||||
android:title="@string/night_mode_title"
|
|
||||||
settings:keywords="@string/keywords_display_night_mode"
|
|
||||||
android:summary="@string/night_mode_summary"
|
|
||||||
android:entries="@array/night_mode_entries"
|
|
||||||
android:entryValues="@array/night_mode_values" /> -->
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="camera_gesture"
|
|
||||||
android:title="@string/camera_gesture_title"
|
|
||||||
android:summary="@string/camera_gesture_desc" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="lift_to_wake"
|
|
||||||
android:title="@string/lift_to_wake_title" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="tap_to_wake"
|
|
||||||
android:title="@string/tap_to_wake"
|
|
||||||
android:summary="@string/tap_to_wake_summary" />
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="theme"
|
|
||||||
android:title="@string/device_theme"
|
|
||||||
android:summary="@string/summary_placeholder" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="vr_display_pref"
|
|
||||||
android:title="@string/display_vr_pref_title"
|
|
||||||
android:fragment="com.android.settings.display.VrDisplayPreferencePicker" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:key="installed_app_detail_settings_screen"
|
||||||
|
app:initialExpandedChildrenCount="6">
|
||||||
|
|
||||||
<com.android.settings.applications.LayoutPreference
|
<com.android.settings.applications.LayoutPreference
|
||||||
android:key="header_view"
|
android:key="header_view"
|
||||||
|
@@ -19,7 +19,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:key="language_and_input_settings_screen"
|
android:key="language_and_input_settings_screen"
|
||||||
android:title="@string/language_settings" >
|
android:title="@string/language_settings"
|
||||||
|
settings:initialExpandedChildrenCount="3" >
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="phone_language"
|
android:key="phone_language"
|
||||||
|
@@ -1,95 +0,0 @@
|
|||||||
<?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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:title="@string/language_settings"
|
|
||||||
android:key="language_and_input_settings_screen"
|
|
||||||
settings:initialExpandedChildrenCount="3" >
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="phone_language"
|
|
||||||
android:title="@string/phone_language"
|
|
||||||
android:icon="@drawable/ic_translate_24dp"
|
|
||||||
android:fragment="com.android.settings.localepicker.LocaleListEditor"/>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="keyboards_category"
|
|
||||||
android:title="@string/keyboard_and_input_methods_category">
|
|
||||||
<Preference
|
|
||||||
android:key="virtual_keyboard_pref"
|
|
||||||
android:title="@string/virtual_keyboard_category"
|
|
||||||
android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment"/>
|
|
||||||
<Preference
|
|
||||||
android:key="physical_keyboard_pref"
|
|
||||||
android:title="@string/physical_keyboard_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="input_assistance_category"
|
|
||||||
android:title="@string/input_assistance">
|
|
||||||
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
|
|
||||||
<!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
|
|
||||||
See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
|
|
||||||
<Preference
|
|
||||||
android:key="spellcheckers_settings"
|
|
||||||
android:title="@string/spellcheckers_settings_title"
|
|
||||||
android:persistent="false"
|
|
||||||
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
|
|
||||||
|
|
||||||
<com.android.settings.widget.GearPreference
|
|
||||||
android:key="default_autofill"
|
|
||||||
android:title="@string/autofill_app"
|
|
||||||
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
|
|
||||||
settings:keywords="@string/autofill_keywords" />
|
|
||||||
|
|
||||||
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
|
||||||
<Preference
|
|
||||||
android:key="key_user_dictionary_settings"
|
|
||||||
android:title="@string/user_dict_settings_title"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="pointer_and_tts_category">
|
|
||||||
|
|
||||||
<com.android.settings.PointerSpeedPreference
|
|
||||||
android:key="pointer_speed"
|
|
||||||
android:title="@string/pointer_speed"
|
|
||||||
android:dialogTitle="@string/pointer_speed"/>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="tts_settings_summary"
|
|
||||||
android:title="@string/tts_settings_title"
|
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="game_controller_settings_category"
|
|
||||||
android:title="@string/game_controller_settings_category">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_input_devices"
|
|
||||||
android:title="@string/vibrate_input_devices"
|
|
||||||
android:summary="@string/vibrate_input_devices_summary" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -14,7 +14,11 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen
|
||||||
android:title="@string/security_settings_title">
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
|
android:key="security_dashboard_page"
|
||||||
|
android:title="@string/security_settings_title"
|
||||||
|
settings:initialExpandedChildrenCount="9">
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2017 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:key="security_dashboard_page"
|
|
||||||
android:title="@string/security_settings_title"
|
|
||||||
settings:initialExpandedChildrenCount="9">
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -19,59 +19,62 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:title="@string/sound_settings"
|
android:title="@string/sound_settings"
|
||||||
android:key="sound_settings"
|
android:key="sound_settings"
|
||||||
settings:keywords="@string/keywords_sounds">
|
settings:keywords="@string/keywords_sounds"
|
||||||
|
settings:initialExpandedChildrenCount="6">
|
||||||
|
|
||||||
<PreferenceCategory
|
<!-- Media volume -->
|
||||||
android:key="sound_settings_primary_items_category"
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:order="-100">
|
android:key="media_volume"
|
||||||
<!-- Media volume -->
|
android:icon="@*android:drawable/ic_audio_media"
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
android:title="@string/media_volume_option_title"
|
||||||
android:key="media_volume"
|
android:order="-106"/>
|
||||||
android:icon="@*android:drawable/ic_audio_media"
|
|
||||||
android:title="@string/media_volume_option_title" />
|
|
||||||
|
|
||||||
<!-- Alarm volume -->
|
<!-- Alarm volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:key="alarm_volume"
|
android:key="alarm_volume"
|
||||||
android:icon="@*android:drawable/ic_audio_alarm"
|
android:icon="@*android:drawable/ic_audio_alarm"
|
||||||
android:title="@string/alarm_volume_option_title" />
|
android:title="@string/alarm_volume_option_title"
|
||||||
|
android:order="-105"/>
|
||||||
|
|
||||||
<!-- Ring volume -->
|
<!-- Ring volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:key="ring_volume"
|
android:key="ring_volume"
|
||||||
android:icon="@*android:drawable/ic_audio_ring_notif"
|
android:icon="@*android:drawable/ic_audio_ring_notif"
|
||||||
android:title="@string/ring_volume_option_title" />
|
android:title="@string/ring_volume_option_title"
|
||||||
|
android:order="-104"/>
|
||||||
|
|
||||||
<!-- Notification volume -->
|
<!-- Notification volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
android:key="notification_volume"
|
android:key="notification_volume"
|
||||||
android:icon="@*android:drawable/ic_audio_ring_notif"
|
android:icon="@*android:drawable/ic_audio_ring_notif"
|
||||||
android:title="@string/notification_volume_option_title" />
|
android:title="@string/notification_volume_option_title"
|
||||||
|
android:order="-103"/>
|
||||||
|
|
||||||
<!-- Also vibrate for calls -->
|
<!-- Also vibrate for calls -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="vibrate_when_ringing"
|
android:key="vibrate_when_ringing"
|
||||||
android:title="@string/vibrate_when_ringing_title" />
|
android:title="@string/vibrate_when_ringing_title"
|
||||||
|
android:order="-102"/>
|
||||||
|
|
||||||
<!-- Interruptions -->
|
<!-- Interruptions -->
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="zen_mode"
|
android:key="zen_mode"
|
||||||
android:title="@string/zen_mode_settings_title"
|
android:title="@string/zen_mode_settings_title"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
|
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
|
||||||
android:fragment="com.android.settings.notification.ZenModeSettings"
|
android:fragment="com.android.settings.notification.ZenModeSettings"
|
||||||
settings:allowDividerAbove="true" />
|
settings:allowDividerAbove="true"
|
||||||
|
android:order="-101"/>
|
||||||
|
|
||||||
<!-- Phone ringtone -->
|
<!-- Phone ringtone -->
|
||||||
<com.android.settings.DefaultRingtonePreference
|
<com.android.settings.DefaultRingtonePreference
|
||||||
android:key="ringtone"
|
android:key="ringtone"
|
||||||
android:title="@string/ringtone_title"
|
android:title="@string/ringtone_title"
|
||||||
android:dialogTitle="@string/ringtone_title"
|
android:dialogTitle="@string/ringtone_title"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:ringtoneType="ringtone"
|
android:ringtoneType="ringtone"
|
||||||
settings:allowDividerAbove="true" />
|
settings:allowDividerAbove="true"
|
||||||
|
android:order="-100"/>
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<!-- Default notification ringtone -->
|
<!-- Default notification ringtone -->
|
||||||
<com.android.settings.DefaultRingtonePreference
|
<com.android.settings.DefaultRingtonePreference
|
||||||
|
@@ -1,195 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2017 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
|
||||||
android:title="@string/sound_settings"
|
|
||||||
android:key="sound_settings"
|
|
||||||
settings:keywords="@string/keywords_sounds"
|
|
||||||
settings:initialExpandedChildrenCount="6">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:order="-100">
|
|
||||||
<!-- Media volume -->
|
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
|
||||||
android:key="media_volume"
|
|
||||||
android:icon="@*android:drawable/ic_audio_media"
|
|
||||||
android:title="@string/media_volume_option_title" />
|
|
||||||
|
|
||||||
<!-- Alarm volume -->
|
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
|
||||||
android:key="alarm_volume"
|
|
||||||
android:icon="@*android:drawable/ic_audio_alarm"
|
|
||||||
android:title="@string/alarm_volume_option_title" />
|
|
||||||
|
|
||||||
<!-- Ring volume -->
|
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
|
||||||
android:key="ring_volume"
|
|
||||||
android:icon="@*android:drawable/ic_audio_ring_notif"
|
|
||||||
android:title="@string/ring_volume_option_title" />
|
|
||||||
|
|
||||||
<!-- Notification volume -->
|
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
|
||||||
android:key="notification_volume"
|
|
||||||
android:icon="@*android:drawable/ic_audio_ring_notif"
|
|
||||||
android:title="@string/notification_volume_option_title" />
|
|
||||||
|
|
||||||
<!-- Also vibrate for calls -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_when_ringing"
|
|
||||||
android:title="@string/vibrate_when_ringing_title" />
|
|
||||||
|
|
||||||
<!-- Interruptions -->
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="zen_mode"
|
|
||||||
android:title="@string/zen_mode_settings_title"
|
|
||||||
settings:useAdminDisabledSummary="true"
|
|
||||||
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
|
|
||||||
android:fragment="com.android.settings.notification.ZenModeSettings"
|
|
||||||
settings:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
<!-- Phone ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="ringtone"
|
|
||||||
android:title="@string/ringtone_title"
|
|
||||||
android:dialogTitle="@string/ringtone_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:ringtoneType="ringtone"
|
|
||||||
settings:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
<!-- Default notification ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="notification_ringtone"
|
|
||||||
android:title="@string/notification_ringtone_title"
|
|
||||||
android:dialogTitle="@string/notification_ringtone_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:ringtoneType="notification" />
|
|
||||||
|
|
||||||
<!-- Default alarm ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="alarm_ringtone"
|
|
||||||
android:title="@string/alarm_ringtone_title"
|
|
||||||
android:dialogTitle="@string/alarm_ringtone_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:persistent="false"
|
|
||||||
android:ringtoneType="alarm" />
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<!-- Other sounds -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:title="@string/other_sound_category_preference_title"
|
|
||||||
android:order="-50">
|
|
||||||
|
|
||||||
<!-- Dial pad tones -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="dial_pad_tones"
|
|
||||||
android:title="@string/dial_pad_tones_title" />
|
|
||||||
|
|
||||||
<!-- Screen locking sounds -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="screen_locking_sounds"
|
|
||||||
android:title="@string/screen_locking_sounds_title" />
|
|
||||||
|
|
||||||
<!-- Charging sounds -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="charging_sounds"
|
|
||||||
android:title="@string/charging_sounds_title" />
|
|
||||||
|
|
||||||
<!-- Docking sounds -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="docking_sounds"
|
|
||||||
android:title="@string/docking_sounds_title" />
|
|
||||||
|
|
||||||
<!-- Touch sounds -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="touch_sounds"
|
|
||||||
android:title="@string/touch_sounds_title" />
|
|
||||||
|
|
||||||
<!-- Vibrate on touch -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_on_touch"
|
|
||||||
android:title="@string/vibrate_on_touch_title" />
|
|
||||||
|
|
||||||
<!-- Dock speaker plays -->
|
|
||||||
<DropDownPreference
|
|
||||||
android:key="dock_audio_media"
|
|
||||||
android:title="@string/dock_audio_media_title"
|
|
||||||
android:summary="%s" />
|
|
||||||
|
|
||||||
<!-- Boot sounds -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="boot_sounds"
|
|
||||||
android:title="@string/boot_sounds_title" />
|
|
||||||
|
|
||||||
<!-- Emergency tone -->
|
|
||||||
<DropDownPreference
|
|
||||||
android:key="emergency_tone"
|
|
||||||
android:title="@string/emergency_tone_title"
|
|
||||||
android:summary="%s" />
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
|
||||||
android:key="cell_broadcast_settings"
|
|
||||||
android:title="@string/cell_broadcast_settings"
|
|
||||||
settings:useAdminDisabledSummary="true"
|
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
android:order="-1">
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.cellbroadcastreceiver"
|
|
||||||
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" />
|
|
||||||
</com.android.settingslib.RestrictedPreference>
|
|
||||||
|
|
||||||
<com.android.settings.widget.WorkOnlyCategory
|
|
||||||
android:key="sound_work_settings_section"
|
|
||||||
android:title="@string/sound_work_settings"
|
|
||||||
android:order="100">
|
|
||||||
|
|
||||||
<!-- Use the same sounds of the work profile -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="work_use_personal_sounds"
|
|
||||||
android:title="@string/work_use_personal_sounds_title"
|
|
||||||
android:summary="@string/work_use_personal_sounds_summary"
|
|
||||||
android:disableDependentsState="true" />
|
|
||||||
|
|
||||||
<!-- Work phone ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="work_ringtone"
|
|
||||||
android:title="@string/work_ringtone_title"
|
|
||||||
android:dialogTitle="@string/work_alarm_ringtone_title"
|
|
||||||
android:ringtoneType="ringtone"
|
|
||||||
android:dependency="work_use_personal_sounds" />
|
|
||||||
|
|
||||||
<!-- Default work notification ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="work_notification_ringtone"
|
|
||||||
android:title="@string/work_notification_ringtone_title"
|
|
||||||
android:dialogTitle="@string/work_alarm_ringtone_title"
|
|
||||||
android:ringtoneType="notification"
|
|
||||||
android:dependency="work_use_personal_sounds" />
|
|
||||||
|
|
||||||
<!-- Default work alarm ringtone -->
|
|
||||||
<com.android.settings.DefaultRingtonePreference
|
|
||||||
android:key="work_alarm_ringtone"
|
|
||||||
android:title="@string/work_alarm_ringtone_title"
|
|
||||||
android:dialogTitle="@string/work_alarm_ringtone_title"
|
|
||||||
android:persistent="false"
|
|
||||||
android:ringtoneType="alarm"
|
|
||||||
android:dependency="work_use_personal_sounds" />
|
|
||||||
|
|
||||||
</com.android.settings.widget.WorkOnlyCategory>
|
|
||||||
</PreferenceScreen>
|
|
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="system_dashboard_screen"
|
android:key="system_dashboard_screen"
|
||||||
android:title="@string/header_category_system">
|
android:title="@string/header_category_system"
|
||||||
|
settings:initialExpandedChildrenCount="4">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_settings"
|
android:key="gesture_settings"
|
||||||
|
@@ -65,16 +65,9 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
mProgressiveDisclosureMixin.setTileLimit(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return mProgressiveDisclosureMixin.isEnabled()
|
return R.xml.display_settings;
|
||||||
? R.xml.display_settings : R.xml.display_settings_new_advance_button;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -58,7 +58,6 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo;
|
import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo;
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
||||||
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
|
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
|
||||||
@@ -275,11 +274,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
if (root != null) {
|
if (root != null) {
|
||||||
root.removeAll();
|
root.removeAll();
|
||||||
}
|
}
|
||||||
if (ProgressiveDisclosureMixin.isV2Enabled()) {
|
addPreferencesFromResource(R.xml.security_settings);
|
||||||
addPreferencesFromResource(R.xml.security_settings_advanced_button);
|
|
||||||
} else {
|
|
||||||
addPreferencesFromResource(R.xml.security_settings);
|
|
||||||
}
|
|
||||||
root = getPreferenceScreen();
|
root = getPreferenceScreen();
|
||||||
|
|
||||||
// Add category for security status
|
// Add category for security status
|
||||||
|
@@ -47,12 +47,6 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
mProgressiveDisclosureMixin.setTileLimit(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getHelpResource() {
|
protected int getHelpResource() {
|
||||||
return R.string.help_url_apps_and_notifications;
|
return R.string.help_url_apps_and_notifications;
|
||||||
@@ -60,8 +54,7 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return mProgressiveDisclosureMixin.isEnabled()
|
return R.xml.app_and_notification;
|
||||||
? R.xml.app_and_notification : R.xml.app_and_notification_new_advance_button;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -17,7 +17,6 @@ package com.android.settings.dashboard;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import com.android.settingslib.drawer.DashboardCategory;
|
import com.android.settingslib.drawer.DashboardCategory;
|
||||||
@@ -79,12 +78,6 @@ public interface DashboardFeatureProvider {
|
|||||||
void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
|
void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
|
||||||
Tile tile, String key, int baseOrder);
|
Tile tile, String key, int baseOrder);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a {@link ProgressiveDisclosureMixin} for specified fragment.
|
|
||||||
*/
|
|
||||||
ProgressiveDisclosureMixin getProgressiveDisclosureMixin(Context context,
|
|
||||||
DashboardFragment fragment, Bundle args);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns additional intent filter action for dashboard tiles
|
* Returns additional intent filter action for dashboard tiles
|
||||||
*/
|
*/
|
||||||
|
@@ -188,16 +188,6 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProgressiveDisclosureMixin getProgressiveDisclosureMixin(Context context,
|
|
||||||
DashboardFragment fragment, Bundle args) {
|
|
||||||
boolean keepExpanded = false;
|
|
||||||
if (args != null) {
|
|
||||||
keepExpanded = args.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY) != null;
|
|
||||||
}
|
|
||||||
return new ProgressiveDisclosureMixin(context, fragment, keepExpanded);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExtraIntentAction() {
|
public String getExtraIntentAction() {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -58,7 +58,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
new ArrayMap<>();
|
new ArrayMap<>();
|
||||||
private final Set<String> mDashboardTilePrefKeys = new ArraySet<>();
|
private final Set<String> mDashboardTilePrefKeys = new ArraySet<>();
|
||||||
|
|
||||||
protected ProgressiveDisclosureMixin mProgressiveDisclosureMixin;
|
|
||||||
protected DashboardFeatureProvider mDashboardFeatureProvider;
|
protected DashboardFeatureProvider mDashboardFeatureProvider;
|
||||||
private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
|
private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
|
||||||
private boolean mListeningToCategoryChange;
|
private boolean mListeningToCategoryChange;
|
||||||
@@ -69,9 +68,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
mDashboardFeatureProvider =
|
mDashboardFeatureProvider =
|
||||||
FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
|
FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
|
||||||
mProgressiveDisclosureMixin = mDashboardFeatureProvider
|
|
||||||
.getProgressiveDisclosureMixin(context, this, getArguments());
|
|
||||||
getLifecycle().addObserver(mProgressiveDisclosureMixin);
|
|
||||||
|
|
||||||
List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
|
List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
|
||||||
if (controllers == null) {
|
if (controllers == null) {
|
||||||
@@ -140,8 +136,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void notifySummaryChanged(Tile tile) {
|
public void notifySummaryChanged(Tile tile) {
|
||||||
final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
|
final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
|
||||||
final Preference pref = mProgressiveDisclosureMixin.findPreference(
|
final Preference pref = getPreferenceScreen().findPreference(key);
|
||||||
getPreferenceScreen(), key);
|
|
||||||
if (pref == null) {
|
if (pref == null) {
|
||||||
Log.d(getLogTag(),
|
Log.d(getLogTag(),
|
||||||
String.format("Can't find pref by key %s, skipping update summary %s/%s",
|
String.format("Can't find pref by key %s, skipping update summary %s/%s",
|
||||||
@@ -267,7 +262,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
final String key = controller.getPreferenceKey();
|
final String key = controller.getPreferenceKey();
|
||||||
|
|
||||||
final Preference preference = mProgressiveDisclosureMixin.findPreference(screen, key);
|
final Preference preference = screen.findPreference(key);
|
||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s",
|
Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s",
|
||||||
key, controller.getClass().getSimpleName()));
|
key, controller.getClass().getSimpleName()));
|
||||||
@@ -290,7 +285,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
// Add resource based tiles.
|
// Add resource based tiles.
|
||||||
displayResourceTiles();
|
displayResourceTiles();
|
||||||
mProgressiveDisclosureMixin.collapse(getPreferenceScreen());
|
|
||||||
|
|
||||||
refreshDashboardTiles(TAG);
|
refreshDashboardTiles(TAG);
|
||||||
}
|
}
|
||||||
@@ -342,8 +336,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
if (mDashboardTilePrefKeys.contains(key)) {
|
if (mDashboardTilePrefKeys.contains(key)) {
|
||||||
// Have the key already, will rebind.
|
// Have the key already, will rebind.
|
||||||
final Preference preference = mProgressiveDisclosureMixin.findPreference(
|
final Preference preference = screen.findPreference(key);
|
||||||
screen, key);
|
|
||||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
||||||
preference, tile, key, mPlaceholderPreferenceController.getOrder());
|
preference, tile, key, mPlaceholderPreferenceController.getOrder());
|
||||||
} else {
|
} else {
|
||||||
@@ -351,7 +344,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
final Preference pref = new Preference(getPrefContext());
|
final Preference pref = new Preference(getPrefContext());
|
||||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
||||||
pref, tile, key, mPlaceholderPreferenceController.getOrder());
|
pref, tile, key, mPlaceholderPreferenceController.getOrder());
|
||||||
mProgressiveDisclosureMixin.addPreference(screen, pref);
|
screen.addPreference(pref);
|
||||||
mDashboardTilePrefKeys.add(key);
|
mDashboardTilePrefKeys.add(key);
|
||||||
}
|
}
|
||||||
remove.remove(key);
|
remove.remove(key);
|
||||||
@@ -359,7 +352,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
// Finally remove tiles that are gone.
|
// Finally remove tiles that are gone.
|
||||||
for (String key : remove) {
|
for (String key : remove) {
|
||||||
mDashboardTilePrefKeys.remove(key);
|
mDashboardTilePrefKeys.remove(key);
|
||||||
mProgressiveDisclosureMixin.removePreference(screen, key);
|
final Preference preference = screen.findPreference(key);
|
||||||
|
if (preference != null) {
|
||||||
|
screen.removePreference(preference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mSummaryLoader.setListening(true);
|
mSummaryLoader.setListening(true);
|
||||||
}
|
}
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.Context;
|
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
public class ExpandPreference extends Preference {
|
|
||||||
|
|
||||||
public ExpandPreference(Context context, AttributeSet attrs,
|
|
||||||
int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpandPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpandPreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpandPreference(Context context) {
|
|
||||||
super(context);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
setLayoutResource(R.layout.expand_preference);
|
|
||||||
setIcon(R.drawable.ic_arrow_down_24dp);
|
|
||||||
setTitle(R.string.advanced_section_header);
|
|
||||||
setOrder(999);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
|
||||||
super.onBindViewHolder(holder);
|
|
||||||
holder.setDividerAllowedAbove(false);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,282 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.VisibleForTesting;
|
|
||||||
import android.support.v14.preference.PreferenceFragment;
|
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.instrumentation.Instrumentable;
|
|
||||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|
||||||
import com.android.settingslib.core.lifecycle.events.OnCreate;
|
|
||||||
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickListener,
|
|
||||||
LifecycleObserver, OnCreate, OnSaveInstanceState {
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String FEATURE_FLAG_NEW_ADVANCE_BUTTON = "new_settings_advance_button";
|
|
||||||
private static final String TAG = "ProgressiveDisclosure";
|
|
||||||
private static final String STATE_USER_EXPANDED = "state_user_expanded";
|
|
||||||
private static final int DEFAULT_TILE_LIMIT = 300;
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
// Collapsed preference sorted by order.
|
|
||||||
private final List<Preference> mCollapsedPrefs = new ArrayList<>();
|
|
||||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
|
||||||
private final PreferenceFragment mFragment;
|
|
||||||
private /* final */ ExpandPreference mExpandButton;
|
|
||||||
|
|
||||||
private int mTileLimit = DEFAULT_TILE_LIMIT;
|
|
||||||
private boolean mUserExpanded;
|
|
||||||
|
|
||||||
public ProgressiveDisclosureMixin(Context context,
|
|
||||||
PreferenceFragment fragment, boolean keepExpanded) {
|
|
||||||
mContext = context;
|
|
||||||
mFragment = fragment;
|
|
||||||
mExpandButton = new ExpandPreference(context);
|
|
||||||
mExpandButton.setOnPreferenceClickListener(this);
|
|
||||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
|
||||||
mUserExpanded = keepExpanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
mUserExpanded = savedInstanceState.getBoolean(STATE_USER_EXPANDED, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
outState.putBoolean(STATE_USER_EXPANDED, mUserExpanded);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
if (preference instanceof ExpandPreference) {
|
|
||||||
final PreferenceScreen screen = mFragment.getPreferenceScreen();
|
|
||||||
if (screen != null) {
|
|
||||||
screen.removePreference(preference);
|
|
||||||
for (Preference pref : mCollapsedPrefs) {
|
|
||||||
screen.addPreference(pref);
|
|
||||||
}
|
|
||||||
mCollapsedPrefs.clear();
|
|
||||||
mUserExpanded = true;
|
|
||||||
final int metricsCategory;
|
|
||||||
if (mFragment instanceof Instrumentable) {
|
|
||||||
metricsCategory = ((Instrumentable) mFragment).getMetricsCategory();
|
|
||||||
} else {
|
|
||||||
metricsCategory = MetricsProto.MetricsEvent.VIEW_UNKNOWN;
|
|
||||||
}
|
|
||||||
mMetricsFeatureProvider.actionWithSource(mContext, metricsCategory,
|
|
||||||
MetricsProto.MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return !isV2Enabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isV2Enabled() {
|
|
||||||
return FeatureFlagUtils.isEnabled(FEATURE_FLAG_NEW_ADVANCE_BUTTON);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the threshold to start collapsing preferences when there are too many.
|
|
||||||
*/
|
|
||||||
public void setTileLimit(int limit) {
|
|
||||||
if (isEnabled()) {
|
|
||||||
mTileLimit = limit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the controller is in collapsed state.
|
|
||||||
*/
|
|
||||||
public boolean isCollapsed() {
|
|
||||||
return !mCollapsedPrefs.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the screen should be collapsed.
|
|
||||||
*/
|
|
||||||
public boolean shouldCollapse(PreferenceScreen screen) {
|
|
||||||
return !mUserExpanded && screen.getPreferenceCount() > mTileLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collapse extra preferences and show a "More" button
|
|
||||||
*/
|
|
||||||
public void collapse(PreferenceScreen screen) {
|
|
||||||
final int itemCount = screen.getPreferenceCount();
|
|
||||||
if (!shouldCollapse(screen)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!mCollapsedPrefs.isEmpty()) {
|
|
||||||
Log.w(TAG, "collapsed list should ALWAYS BE EMPTY before collapsing!");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = itemCount - 1; i >= mTileLimit; i--) {
|
|
||||||
final Preference preference = screen.getPreference(i);
|
|
||||||
addToCollapsedList(preference);
|
|
||||||
screen.removePreference(preference);
|
|
||||||
}
|
|
||||||
screen.addPreference(mExpandButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds preference to screen. If there are too many preference on screen, adds it to
|
|
||||||
* collapsed list instead.
|
|
||||||
*/
|
|
||||||
public void addPreference(PreferenceScreen screen, Preference pref) {
|
|
||||||
// Either add to screen, or to collapsed list.
|
|
||||||
if (isCollapsed()) {
|
|
||||||
// insert the preference to right position.
|
|
||||||
final int lastPreferenceIndex = screen.getPreferenceCount() - 2;
|
|
||||||
if (lastPreferenceIndex >= 0) {
|
|
||||||
final Preference lastPreference = screen.getPreference(lastPreferenceIndex);
|
|
||||||
if (lastPreference.getOrder() > pref.getOrder()) {
|
|
||||||
// insert to screen and move the last pref to collapsed list.
|
|
||||||
screen.removePreference(lastPreference);
|
|
||||||
screen.addPreference(pref);
|
|
||||||
addToCollapsedList(lastPreference);
|
|
||||||
} else {
|
|
||||||
// Insert to collapsed list.
|
|
||||||
addToCollapsedList(pref);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Couldn't find last preference on screen, just add to collapsed list.
|
|
||||||
addToCollapsedList(pref);
|
|
||||||
}
|
|
||||||
} else if (shouldCollapse(screen)) {
|
|
||||||
// About to have too many tiles on scree, collapse and add pref to collapsed list.
|
|
||||||
screen.addPreference(pref);
|
|
||||||
collapse(screen);
|
|
||||||
} else {
|
|
||||||
// No need to collapse, add to screen directly.
|
|
||||||
screen.addPreference(pref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes preference. If the preference is on screen, remove it from screen. If the
|
|
||||||
* preference is in collapsed list, remove it from list.
|
|
||||||
*/
|
|
||||||
public void removePreference(PreferenceScreen screen, String key) {
|
|
||||||
// Try removing from screen.
|
|
||||||
final Preference preference = screen.findPreference(key);
|
|
||||||
if (preference != null) {
|
|
||||||
screen.removePreference(preference);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Didn't find on screen, try removing from collapsed list.
|
|
||||||
for (int i = 0; i < mCollapsedPrefs.size(); i++) {
|
|
||||||
final Preference pref = mCollapsedPrefs.get(i);
|
|
||||||
if (TextUtils.equals(key, pref.getKey())) {
|
|
||||||
mCollapsedPrefs.remove(pref);
|
|
||||||
if (mCollapsedPrefs.isEmpty()) {
|
|
||||||
// Removed last element, remove expand button too.
|
|
||||||
screen.removePreference(mExpandButton);
|
|
||||||
} else {
|
|
||||||
updateExpandButtonSummary();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds preference by key, either from screen or from collapsed list.
|
|
||||||
*/
|
|
||||||
public Preference findPreference(PreferenceScreen screen, CharSequence key) {
|
|
||||||
Preference preference = screen.findPreference(key);
|
|
||||||
if (preference != null) {
|
|
||||||
return preference;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < mCollapsedPrefs.size(); i++) {
|
|
||||||
final Preference pref = mCollapsedPrefs.get(i);
|
|
||||||
if (TextUtils.equals(key, pref.getKey())) {
|
|
||||||
return pref;
|
|
||||||
}
|
|
||||||
if (pref instanceof PreferenceGroup) {
|
|
||||||
final Preference returnedPreference = ((PreferenceGroup) pref).findPreference(key);
|
|
||||||
if (returnedPreference != null) {
|
|
||||||
return returnedPreference;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Cannot find preference with key " + key);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add preference to collapsed list.
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
|
||||||
void addToCollapsedList(Preference preference) {
|
|
||||||
// Insert preference based on it's order.
|
|
||||||
int insertionIndex = Collections.binarySearch(mCollapsedPrefs, preference);
|
|
||||||
if (insertionIndex < 0) {
|
|
||||||
insertionIndex = insertionIndex * -1 - 1;
|
|
||||||
}
|
|
||||||
mCollapsedPrefs.add(insertionIndex, preference);
|
|
||||||
updateExpandButtonSummary();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
List<Preference> getCollapsedPrefs() {
|
|
||||||
return mCollapsedPrefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
void updateExpandButtonSummary() {
|
|
||||||
final int size = mCollapsedPrefs.size();
|
|
||||||
if (size == 0) {
|
|
||||||
mExpandButton.setSummary(null);
|
|
||||||
} else if (size == 1) {
|
|
||||||
mExpandButton.setSummary(mCollapsedPrefs.get(0).getTitle());
|
|
||||||
} else {
|
|
||||||
CharSequence summary = mCollapsedPrefs.get(0).getTitle();
|
|
||||||
for (int i = 1; i < size; i++) {
|
|
||||||
final CharSequence nextSummary = mCollapsedPrefs.get(i).getTitle();
|
|
||||||
if (!TextUtils.isEmpty(nextSummary)) {
|
|
||||||
summary = mContext.getString(R.string.join_many_items_middle, summary,
|
|
||||||
nextSummary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mExpandButton.setSummary(summary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -64,13 +64,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
mProgressiveDisclosureMixin.setTileLimit(2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -86,8 +79,7 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return mProgressiveDisclosureMixin.isEnabled()
|
return R.xml.language_and_input;
|
||||||
? R.xml.language_and_input : R.xml.language_and_input_new_advance_button;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -54,12 +54,6 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
|
|
||||||
private RingtonePreference mRequestPreference;
|
private RingtonePreference mRequestPreference;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
mProgressiveDisclosureMixin.setTileLimit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.SOUND;
|
return MetricsEvent.SOUND;
|
||||||
@@ -109,8 +103,7 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return mProgressiveDisclosureMixin.isEnabled()
|
return R.xml.sound_settings;
|
||||||
? R.xml.sound_settings : R.xml.sound_settings_new_advance_button;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,6 +23,7 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkScoreManager;
|
import android.net.NetworkScoreManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
@@ -60,8 +61,8 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onAttach(context);
|
super.onCreate(icicle);
|
||||||
int tileLimit = 1;
|
int tileLimit = 1;
|
||||||
if (mWifiWakeupPreferenceController.isAvailable()) {
|
if (mWifiWakeupPreferenceController.isAvailable()) {
|
||||||
tileLimit++;
|
tileLimit++;
|
||||||
@@ -69,7 +70,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
if (mUseOpenWifiPreferenceController.isAvailable()) {
|
if (mUseOpenWifiPreferenceController.isAvailable()) {
|
||||||
tileLimit++;
|
tileLimit++;
|
||||||
}
|
}
|
||||||
mProgressiveDisclosureMixin.setTileLimit(tileLimit);
|
getPreferenceScreen().setInitialExpandedChildrenCount(tileLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -6,7 +6,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowPowerManagerWrapper;
|
import com.android.settings.testutils.shadow.ShadowPowerManagerWrapper;
|
||||||
@@ -30,8 +29,6 @@ public class DisplaySettingsTest {
|
|||||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final DisplaySettings fragment = new DisplaySettings();
|
final DisplaySettings fragment = new DisplaySettings();
|
||||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
|
||||||
mock(ProgressiveDisclosureMixin.class));
|
|
||||||
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||||
fragment.getPreferenceScreenResId());
|
fragment.getPreferenceScreenResId());
|
||||||
final List<String> preferenceKeys = new ArrayList<>();
|
final List<String> preferenceKeys = new ArrayList<>();
|
||||||
|
@@ -20,7 +20,6 @@ import android.content.Context;
|
|||||||
|
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
@@ -51,8 +50,6 @@ public class AppAndNotificationDashboardFragmentTest {
|
|||||||
final List<String> niks = AppAndNotificationDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
final List<String> niks = AppAndNotificationDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getNonIndexableKeys(context);
|
.getNonIndexableKeys(context);
|
||||||
AppAndNotificationDashboardFragment fragment = new AppAndNotificationDashboardFragment();
|
AppAndNotificationDashboardFragment fragment = new AppAndNotificationDashboardFragment();
|
||||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
|
||||||
mock(ProgressiveDisclosureMixin.class));
|
|
||||||
final int xmlId = fragment.getPreferenceScreenResId();
|
final int xmlId = fragment.getPreferenceScreenResId();
|
||||||
|
|
||||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||||
|
@@ -67,8 +67,6 @@ public class DashboardFragmentTest {
|
|||||||
private DashboardCategory mDashboardCategory;
|
private DashboardCategory mDashboardCategory;
|
||||||
@Mock
|
@Mock
|
||||||
private FakeFeatureFactory mFakeFeatureFactory;
|
private FakeFeatureFactory mFakeFeatureFactory;
|
||||||
@Mock
|
|
||||||
private ProgressiveDisclosureMixin mDisclosureMixin;
|
|
||||||
private TestFragment mTestFragment;
|
private TestFragment mTestFragment;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -79,9 +77,6 @@ public class DashboardFragmentTest {
|
|||||||
mDashboardCategory.tiles = new ArrayList<>();
|
mDashboardCategory.tiles = new ArrayList<>();
|
||||||
mDashboardCategory.tiles.add(new Tile());
|
mDashboardCategory.tiles.add(new Tile());
|
||||||
mTestFragment = new TestFragment(ShadowApplication.getInstance().getApplicationContext());
|
mTestFragment = new TestFragment(ShadowApplication.getInstance().getApplicationContext());
|
||||||
when(mFakeFeatureFactory.dashboardFeatureProvider.getProgressiveDisclosureMixin(
|
|
||||||
nullable(Context.class), eq(mTestFragment), nullable(Bundle.class)))
|
|
||||||
.thenReturn(mDisclosureMixin);
|
|
||||||
when(mFakeFeatureFactory.dashboardFeatureProvider
|
when(mFakeFeatureFactory.dashboardFeatureProvider
|
||||||
.getTilesForCategory(nullable(String.class)))
|
.getTilesForCategory(nullable(String.class)))
|
||||||
.thenReturn(mDashboardCategory);
|
.thenReturn(mDashboardCategory);
|
||||||
@@ -110,8 +105,7 @@ public class DashboardFragmentTest {
|
|||||||
.thenReturn("test_key");
|
.thenReturn("test_key");
|
||||||
mTestFragment.onCreatePreferences(new Bundle(), "rootKey");
|
mTestFragment.onCreatePreferences(new Bundle(), "rootKey");
|
||||||
|
|
||||||
verify(mDisclosureMixin).addPreference(nullable(PreferenceScreen.class),
|
verify(mTestFragment.mScreen).addPreference(nullable(Preference.class));
|
||||||
nullable(Preference.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -1,381 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.Context;
|
|
||||||
import android.support.v14.preference.PreferenceFragment;
|
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.support.v7.preference.PreferenceManager;
|
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settings.TestConfig;
|
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static android.util.FeatureFlagUtils.FFLAG_PREFIX;
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.nullable;
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.anyInt;
|
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
|
||||||
shadows = {SettingsShadowSystemProperties.class})
|
|
||||||
public class ProgressiveDisclosureTest {
|
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private Context mContext;
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private PreferenceFragment mPreferenceFragment;
|
|
||||||
@Mock
|
|
||||||
private ExpandPreference mExpandButton;
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private Context mAppContext;
|
|
||||||
private Preference mPreference;
|
|
||||||
private ProgressiveDisclosureMixin mMixin;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
FakeFeatureFactory.setupForTest(mContext);
|
|
||||||
mScreen = mPreferenceFragment.getPreferenceScreen();
|
|
||||||
mAppContext = ShadowApplication.getInstance().getApplicationContext();
|
|
||||||
mMixin = new ProgressiveDisclosureMixin(mAppContext,
|
|
||||||
mPreferenceFragment, false /* keepExpanded */);
|
|
||||||
ReflectionHelpers.setField(mMixin, "mExpandButton", mExpandButton);
|
|
||||||
mPreference = new Preference(mAppContext);
|
|
||||||
mPreference.setKey("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
SettingsShadowSystemProperties.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void systemPropertySetForNewAdvancedButtonFeature_verifyIsDisabled() {
|
|
||||||
SettingsShadowSystemProperties.set(
|
|
||||||
FFLAG_PREFIX + ProgressiveDisclosureMixin.FEATURE_FLAG_NEW_ADVANCE_BUTTON, "true");
|
|
||||||
assertThat(mMixin.isEnabled()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void systemPropertyNotSet_verifyIsDisabled() {
|
|
||||||
SettingsShadowSystemProperties.set(
|
|
||||||
FFLAG_PREFIX + ProgressiveDisclosureMixin.FEATURE_FLAG_NEW_ADVANCE_BUTTON, "false");
|
|
||||||
assertThat(mMixin.isEnabled()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldNotCollapse_lessPreferenceThanLimit() {
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(5);
|
|
||||||
|
|
||||||
mMixin.setTileLimit(10);
|
|
||||||
|
|
||||||
assertThat(mMixin.shouldCollapse(mScreen)).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldNotCollapse_preferenceCountSameAsThreshold() {
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(5);
|
|
||||||
|
|
||||||
mMixin.setTileLimit(5);
|
|
||||||
|
|
||||||
assertThat(mMixin.shouldCollapse(mScreen)).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldNotCollapse_whenStartAsExpanded() {
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(5);
|
|
||||||
|
|
||||||
mMixin = new ProgressiveDisclosureMixin(mAppContext,
|
|
||||||
mPreferenceFragment, true /* keepExpanded */);
|
|
||||||
mMixin.setTileLimit(10);
|
|
||||||
|
|
||||||
assertThat(mMixin.shouldCollapse(mScreen)).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldCollapse_morePreferenceThanLimit() {
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(5);
|
|
||||||
mMixin.setTileLimit(3);
|
|
||||||
|
|
||||||
assertThat(mMixin.shouldCollapse(mScreen)).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findPreference_prefInCollapsedList_shouldFindIt() {
|
|
||||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(null);
|
|
||||||
mMixin.addToCollapsedList(mPreference);
|
|
||||||
|
|
||||||
Preference pref = mMixin.findPreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
assertThat(pref).isNotNull();
|
|
||||||
assertThat(pref).isSameAs(mPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findPreference_prefOnScreen_shouldFindIt() {
|
|
||||||
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
|
|
||||||
|
|
||||||
Preference pref = mMixin.findPreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
assertThat(pref).isNotNull();
|
|
||||||
assertThat(pref).isSameAs(mPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findPreference_prefNotInCollapsedListOrScreen_shouldNotFindIt() {
|
|
||||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(null);
|
|
||||||
Preference pref = mMixin.findPreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
assertThat(pref).isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findPreference_prefRemovedFromCollapsedList_shouldNotFindIt() {
|
|
||||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(null);
|
|
||||||
mMixin.addToCollapsedList(mPreference);
|
|
||||||
mMixin.removePreference(mPreferenceFragment.getPreferenceScreen(), mPreference.getKey());
|
|
||||||
|
|
||||||
Preference pref = mMixin.findPreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
assertThat(pref).isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findPreference_nestedPrefInCollapsedList_shouldFindIt() {
|
|
||||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(null);
|
|
||||||
final PreferenceScreen prefGroup = spy(new PreferenceScreen(mAppContext, null));
|
|
||||||
when(prefGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
|
|
||||||
final Preference preference = mock(Preference.class);
|
|
||||||
when(preference.getKey()).thenReturn("TestKey");
|
|
||||||
prefGroup.addPreference(preference);
|
|
||||||
mMixin.addToCollapsedList(prefGroup);
|
|
||||||
|
|
||||||
Preference pref = mMixin.findPreference(mScreen, "TestKey");
|
|
||||||
|
|
||||||
assertThat(pref).isNotNull();
|
|
||||||
assertThat(pref).isSameAs(preference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void removePreference_shouldRemoveOnScreenPreference() {
|
|
||||||
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
|
|
||||||
|
|
||||||
mMixin.removePreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
verify(mScreen).removePreference(mPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void removeLastPreference_shouldRemoveExpandButtonToo() {
|
|
||||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(null);
|
|
||||||
mMixin.addToCollapsedList(mPreference);
|
|
||||||
// Collapsed
|
|
||||||
assertThat(mMixin.isCollapsed()).isTrue();
|
|
||||||
|
|
||||||
mMixin.removePreference(mScreen, mPreference.getKey());
|
|
||||||
|
|
||||||
// Removing expand button
|
|
||||||
verify(mScreen).removePreference(any(Preference.class));
|
|
||||||
// No longer collapsed
|
|
||||||
assertThat(mMixin.isCollapsed()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void collapse_shouldDoNothingIfNotCollapsible() {
|
|
||||||
final PreferenceScreen screen = mPreferenceFragment.getPreferenceScreen();
|
|
||||||
when(screen.getPreferenceCount()).thenReturn(5);
|
|
||||||
mMixin.setTileLimit(15);
|
|
||||||
|
|
||||||
mMixin.collapse(screen);
|
|
||||||
assertThat(mMixin.isCollapsed()).isFalse();
|
|
||||||
verify(mExpandButton, never()).setSummary(nullable(String.class));
|
|
||||||
verify(screen, never()).addPreference(any(Preference.class));
|
|
||||||
verify(screen, never()).removePreference(any(Preference.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void collapse_shouldRemovePrefAndAddExpandButton() {
|
|
||||||
final PreferenceScreen screen = mPreferenceFragment.getPreferenceScreen();
|
|
||||||
when(screen.getPreferenceCount()).thenReturn(5);
|
|
||||||
when(screen.getPreference(anyInt())).thenReturn(mPreference);
|
|
||||||
mMixin.setTileLimit(2);
|
|
||||||
|
|
||||||
mMixin.collapse(screen);
|
|
||||||
|
|
||||||
assertThat(mMixin.isCollapsed()).isTrue();
|
|
||||||
verify(mExpandButton, atLeastOnce()).setSummary(nullable(String.class));
|
|
||||||
verify(screen).addPreference(any(ExpandPreference.class));
|
|
||||||
verify(screen, times(3)).removePreference(any(Preference.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addToCollapsedList_shouldAddInOrder() {
|
|
||||||
final Preference pref1 = new Preference(mAppContext);
|
|
||||||
final Preference pref2 = new Preference(mAppContext);
|
|
||||||
pref1.setOrder(10);
|
|
||||||
pref2.setOrder(20);
|
|
||||||
|
|
||||||
// Pref1 has lower order than pref2, but add pref2 first. The collapsed list should maintain
|
|
||||||
// items in increasing order.
|
|
||||||
mMixin.addToCollapsedList(pref2);
|
|
||||||
mMixin.addToCollapsedList(pref1);
|
|
||||||
|
|
||||||
List<Preference> collapsedList = mMixin.getCollapsedPrefs();
|
|
||||||
assertThat(collapsedList.get(0)).isSameAs(pref1);
|
|
||||||
assertThat(collapsedList.get(1)).isSameAs(pref2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addPreferenceWhenCollapsed_noPrefOnScreen_shouldAddToList() {
|
|
||||||
// Add something to collapsed list so we are in collapsed state.
|
|
||||||
mMixin.addToCollapsedList(new Preference(mAppContext));
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().size()).isEqualTo(1);
|
|
||||||
|
|
||||||
// Just 1 preference on screen: the more button
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(1);
|
|
||||||
final Preference toBeAdded = new Preference(mAppContext);
|
|
||||||
toBeAdded.setOrder(100);
|
|
||||||
mMixin.addPreference(mScreen, toBeAdded);
|
|
||||||
|
|
||||||
// Should have 2 prefs in collapsed list now
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().size()).isEqualTo(2);
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().get(0)).isSameAs(toBeAdded);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addPreferenceWhenCollapsed_prefOrderLessThanLastOnScreen_shouldAddToScreen() {
|
|
||||||
final Preference lastPref = new Preference(mAppContext);
|
|
||||||
lastPref.setOrder(100);
|
|
||||||
// Add something to collapsed list so we are in collapsed state.
|
|
||||||
mMixin.addToCollapsedList(new Preference(mAppContext));
|
|
||||||
verify(mExpandButton).setSummary(nullable(String.class));
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().size()).isEqualTo(1);
|
|
||||||
|
|
||||||
// 3 prefs on screen, 2 are real and the last one is more button.
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(3);
|
|
||||||
when(mScreen.getPreference(1)).thenReturn(lastPref);
|
|
||||||
|
|
||||||
final Preference toBeAdded = new Preference(mAppContext);
|
|
||||||
toBeAdded.setOrder(50);
|
|
||||||
mMixin.addPreference(mScreen, toBeAdded);
|
|
||||||
|
|
||||||
verify(mScreen).removePreference(lastPref);
|
|
||||||
verify(mScreen).addPreference(toBeAdded);
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().get(0)).isSameAs(lastPref);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addPreferenceWhenCollapsed_prefOrderMoreThanLastOnScreen_shouldAddToList() {
|
|
||||||
final Preference lastPref = new Preference(mAppContext);
|
|
||||||
lastPref.setOrder(100);
|
|
||||||
// Add something to collapsed list so we are in collapsed state.
|
|
||||||
mMixin.addToCollapsedList(new Preference(mAppContext));
|
|
||||||
verify(mExpandButton).setSummary(nullable(String.class));
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().size()).isEqualTo(1);
|
|
||||||
|
|
||||||
// 3 prefs on screen, 2 are real and the last one is more button.
|
|
||||||
when(mScreen.getPreferenceCount()).thenReturn(3);
|
|
||||||
when(mScreen.getPreference(1)).thenReturn(lastPref);
|
|
||||||
|
|
||||||
final Preference toBeAdded = new Preference(mAppContext);
|
|
||||||
toBeAdded.setOrder(200);
|
|
||||||
mMixin.addPreference(mScreen, toBeAdded);
|
|
||||||
|
|
||||||
verify(mScreen, never()).removePreference(any(Preference.class));
|
|
||||||
verify(mScreen, never()).addPreference(any(Preference.class));
|
|
||||||
verify(mExpandButton, times(2)).setSummary(nullable(String.class));
|
|
||||||
assertThat(mMixin.getCollapsedPrefs().get(0)).isSameAs(toBeAdded);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateExpandSummary_noPref_noSummary() {
|
|
||||||
mMixin.updateExpandButtonSummary();
|
|
||||||
|
|
||||||
verify(mExpandButton).setSummary(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateExpandSummary_doNotIncludeEmptyPrefTitle() {
|
|
||||||
final Preference pref1 = new Preference(mAppContext);
|
|
||||||
pref1.setTitle("1");
|
|
||||||
final Preference pref2 = new Preference(mAppContext);
|
|
||||||
pref2.setTitle(null);
|
|
||||||
final Preference pref3 = new Preference(mAppContext);
|
|
||||||
pref3.setTitle("3");
|
|
||||||
final Preference pref4 = new Preference(mAppContext);
|
|
||||||
pref4.setTitle("");
|
|
||||||
|
|
||||||
mMixin.addToCollapsedList(pref1);
|
|
||||||
mMixin.addToCollapsedList(pref2);
|
|
||||||
mMixin.addToCollapsedList(pref3);
|
|
||||||
mMixin.addToCollapsedList(pref4);
|
|
||||||
|
|
||||||
verify(mExpandButton).setSummary("1, 3");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateExapndSummary_singlePref_expandSummarySameAsPrefTitle() {
|
|
||||||
final String TEST = "test";
|
|
||||||
final Preference pref = new Preference(mAppContext);
|
|
||||||
pref.setTitle(TEST);
|
|
||||||
|
|
||||||
mMixin.addToCollapsedList(pref);
|
|
||||||
verify(mExpandButton).setSummary(TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateExapndSummary_multiPrefs_useCombinedPrefTitleAsSummary() {
|
|
||||||
final String TEST1 = "test1";
|
|
||||||
final String TEST2 = "test2";
|
|
||||||
final Preference pref1 = new Preference(mAppContext);
|
|
||||||
pref1.setTitle(TEST1);
|
|
||||||
final Preference pref2 = new Preference(mAppContext);
|
|
||||||
pref2.setTitle(TEST2);
|
|
||||||
|
|
||||||
mMixin.addToCollapsedList(pref1);
|
|
||||||
mMixin.addToCollapsedList(pref2);
|
|
||||||
|
|
||||||
verify(mExpandButton)
|
|
||||||
.setSummary(mAppContext.getString(R.string.join_many_items_middle, TEST1, TEST2));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -43,7 +43,6 @@ import android.view.textservice.TextServicesManager;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
@@ -103,9 +102,6 @@ public class LanguageAndInputSettingsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPreferenceScreenResId() {
|
public void testGetPreferenceScreenResId() {
|
||||||
ProgressiveDisclosureMixin progessiveMixin = mock(ProgressiveDisclosureMixin.class);
|
|
||||||
when(progessiveMixin.isEnabled()).thenReturn(true);
|
|
||||||
ReflectionHelpers.setField(mFragment, "mProgressiveDisclosureMixin", progessiveMixin);
|
|
||||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_input);
|
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +169,6 @@ public class LanguageAndInputSettingsTest {
|
|||||||
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
|
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getNonIndexableKeys(context);
|
.getNonIndexableKeys(context);
|
||||||
LanguageAndInputSettings settings = new LanguageAndInputSettings();
|
LanguageAndInputSettings settings = new LanguageAndInputSettings();
|
||||||
ReflectionHelpers.setField(settings, "mProgressiveDisclosureMixin",
|
|
||||||
mock(ProgressiveDisclosureMixin.class));
|
|
||||||
final int xmlId = settings.getPreferenceScreenResId();
|
final int xmlId = settings.getPreferenceScreenResId();
|
||||||
|
|
||||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||||
@@ -186,8 +180,6 @@ public class LanguageAndInputSettingsTest {
|
|||||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
|
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
|
||||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
|
||||||
mock(ProgressiveDisclosureMixin.class));
|
|
||||||
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||||
fragment.getPreferenceScreenResId());
|
fragment.getPreferenceScreenResId());
|
||||||
final List<String> preferenceKeys = new ArrayList<>();
|
final List<String> preferenceKeys = new ArrayList<>();
|
||||||
|
@@ -21,7 +21,6 @@ import android.content.Context;
|
|||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
@@ -62,8 +61,6 @@ public class SoundSettingsTest {
|
|||||||
final List<String> niks = SoundSettings.SEARCH_INDEX_DATA_PROVIDER
|
final List<String> niks = SoundSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getNonIndexableKeys(context);
|
.getNonIndexableKeys(context);
|
||||||
SoundSettings settings = new SoundSettings();
|
SoundSettings settings = new SoundSettings();
|
||||||
ReflectionHelpers.setField(settings, "mProgressiveDisclosureMixin",
|
|
||||||
mock(ProgressiveDisclosureMixin.class));
|
|
||||||
final int xmlId = settings.getPreferenceScreenResId();
|
final int xmlId = settings.getPreferenceScreenResId();
|
||||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||||
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
|
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||||
|
Reference in New Issue
Block a user