Add a new feature flag for the expand button in support lib.
- check the feature flag to determine whether to use the existing progressive disclosure mixin or use the expand button in the support library. - add corresponding preference xml files that add the new preference group attribute to use with the expand button in the support lib. Bug: 63985174 Test: make RunSettingsRoboTests Change-Id: Ida6eb6182a8066ad1413b7f6142512345fd914d0
This commit is contained in:
83
res/xml/app_and_notification_new_advance_button.xml
Normal file
83
res/xml/app_and_notification_new_advance_button.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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>
|
128
res/xml/display_settings_new_advance_button.xml
Normal file
128
res/xml/display_settings_new_advance_button.xml
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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>
|
92
res/xml/language_and_input_new_advance_button.xml
Normal file
92
res/xml/language_and_input_new_advance_button.xml
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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: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: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>
|
||||
|
||||
<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>
|
195
res/xml/sound_settings_new_advance_button.xml
Normal file
195
res/xml/sound_settings_new_advance_button.xml
Normal file
@@ -0,0 +1,195 @@
|
||||
<?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.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.WorkOnlyCategory>
|
||||
</PreferenceScreen>
|
@@ -73,7 +73,8 @@ public class DisplaySettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.display_settings;
|
||||
return mProgressiveDisclosureMixin.isEnabled()
|
||||
? R.xml.display_settings : R.xml.display_settings_new_advance_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -60,7 +60,8 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.app_and_notification;
|
||||
return mProgressiveDisclosureMixin.isEnabled()
|
||||
? R.xml.app_and_notification : R.xml.app_and_notification_new_advance_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -24,6 +24,7 @@ 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;
|
||||
@@ -42,6 +43,8 @@ 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;
|
||||
@@ -102,12 +105,18 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
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.
|
||||
|
@@ -86,7 +86,8 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.language_and_input;
|
||||
return mProgressiveDisclosureMixin.isEnabled()
|
||||
? R.xml.language_and_input : R.xml.language_and_input_new_advance_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -109,7 +109,8 @@ public class SoundSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.sound_settings;
|
||||
return mProgressiveDisclosureMixin.isEnabled()
|
||||
? R.xml.sound_settings : R.xml.sound_settings_new_advance_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -2,8 +2,11 @@ package com.android.settings;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowPowerManagerWrapper;
|
||||
@@ -13,6 +16,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,9 +29,9 @@ public class DisplaySettingsTest {
|
||||
@Config(shadows = ShadowPowerManagerWrapper.class)
|
||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
// PowerManager wrapper = mock(PowerManager.class);
|
||||
// doReturn(wrapper).when(context).getSystemService(Context.POWER_SERVICE);
|
||||
final DisplaySettings fragment = new DisplaySettings();
|
||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
||||
mock(ProgressiveDisclosureMixin.class));
|
||||
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
fragment.getPreferenceScreenResId());
|
||||
final List<String> preferenceKeys = new ArrayList<>();
|
||||
|
@@ -19,6 +19,8 @@ package com.android.settings.applications;
|
||||
import android.content.Context;
|
||||
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
@@ -27,6 +29,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,7 +50,10 @@ public class AppAndNotificationDashboardFragmentTest {
|
||||
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(manager);
|
||||
final List<String> niks = AppAndNotificationDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
final int xmlId = (new AppAndNotificationDashboardFragment()).getPreferenceScreenResId();
|
||||
AppAndNotificationDashboardFragment fragment = new AppAndNotificationDashboardFragment();
|
||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
||||
mock(ProgressiveDisclosureMixin.class));
|
||||
final int xmlId = fragment.getPreferenceScreenResId();
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
|
||||
|
@@ -26,7 +26,9 @@ 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;
|
||||
@@ -39,6 +41,7 @@ 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;
|
||||
@@ -53,7 +56,8 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = {SettingsShadowSystemProperties.class})
|
||||
public class ProgressiveDisclosureTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
@@ -80,6 +84,25 @@ public class ProgressiveDisclosureTest {
|
||||
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);
|
||||
|
@@ -43,6 +43,7 @@ import android.view.textservice.TextServicesManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
@@ -59,6 +60,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -101,6 +103,9 @@ public class LanguageAndInputSettingsTest {
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -167,7 +172,10 @@ public class LanguageAndInputSettingsTest {
|
||||
.getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys);
|
||||
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
final int xmlId = (new LanguageAndInputSettings()).getPreferenceScreenResId();
|
||||
LanguageAndInputSettings settings = new LanguageAndInputSettings();
|
||||
ReflectionHelpers.setField(settings, "mProgressiveDisclosureMixin",
|
||||
mock(ProgressiveDisclosureMixin.class));
|
||||
final int xmlId = settings.getPreferenceScreenResId();
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
|
||||
@@ -178,6 +186,8 @@ public class LanguageAndInputSettingsTest {
|
||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
|
||||
ReflectionHelpers.setField(fragment, "mProgressiveDisclosureMixin",
|
||||
mock(ProgressiveDisclosureMixin.class));
|
||||
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
fragment.getPreferenceScreenResId());
|
||||
final List<String> preferenceKeys = new ArrayList<>();
|
||||
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.os.UserManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.ProgressiveDisclosureMixin;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
@@ -30,6 +31,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,7 +61,10 @@ public class SoundSettingsTest {
|
||||
|
||||
final List<String> niks = SoundSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
final int xmlId = (new SoundSettings()).getPreferenceScreenResId();
|
||||
SoundSettings settings = new SoundSettings();
|
||||
ReflectionHelpers.setField(settings, "mProgressiveDisclosureMixin",
|
||||
mock(ProgressiveDisclosureMixin.class));
|
||||
final int xmlId = settings.getPreferenceScreenResId();
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
R.xml.zen_mode_settings));
|
||||
|
Reference in New Issue
Block a user