DND settings redesign
Test: robotests Change-Id: I7b980218feea28e945994c8b7f8a934df6bc11f9 Bug: 78447976
This commit is contained in:
@@ -727,6 +727,10 @@
|
||||
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
@@ -752,23 +756,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$ZenModeBehaviorSettingsActivity"
|
||||
android:label="@string/zen_mode_behavior_settings_title"
|
||||
android:icon="@drawable/ic_settings_notifications"
|
||||
android:exported="true"
|
||||
android:taskAffinity="com.android.settings"
|
||||
android:parentActivityName="Settings">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.notification.ZenModeBehaviorSettings" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$ZenModeAutomationSettingsActivity"
|
||||
android:label="@string/zen_mode_automation_settings_title"
|
||||
|
@@ -7225,24 +7225,23 @@
|
||||
<!-- Do not disturb: Subtitle for the Visual signals option to toggle on/off visual signals/alerts when the screen is on/when screen is off. [CHAR LIMIT=30] -->
|
||||
<string name="zen_mode_visual_signals_settings_subtitle">Allow visual signals</string>
|
||||
|
||||
<!-- Do not disturb: restrict notifications title [CHAR LIMIT=60] -->
|
||||
<string name="zen_mode_restrict_notifications_screen_title">Restrict notifications</string>
|
||||
<!-- Do not disturb: zen settings screens category title [CHAR LIMIT=100] -->
|
||||
<string name="zen_mode_settings_category">When Do Not Disturb is turned on</string>
|
||||
|
||||
<!-- Do not disturb: restrict notifications title [CHAR LIMIT=60] -->
|
||||
<string name="zen_mode_restrict_notifications_title">Notifications</string>
|
||||
<!-- Do not disturb: restrict notifications category title [CHAR LIMIT=100] -->
|
||||
<string name="zen_mode_restrict_notifications_category">When Do Not Disturb is turned on</string>
|
||||
<!-- Do not disturb: Mute notifications option [CHAR LIMIT=60] -->
|
||||
<string name="zen_mode_restrict_notifications_mute">Mute notifications</string>
|
||||
<string name="zen_mode_restrict_notifications_mute">Show notifications silently</string>
|
||||
<!-- Do not disturb:Mute notifications summary [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_restrict_notifications_mute_summary">Show notifications but mute sounds & vibrations</string>
|
||||
<string name="zen_mode_restrict_notifications_mute_summary">Notifications will be muted</string>
|
||||
<!-- Do not disturb:Mute notifications footer [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_restrict_notifications_mute_footer">When new notifications arrive your phone won\u2019t make a sound or vibration</string>
|
||||
<string name="zen_mode_restrict_notifications_mute_footer">When notifications arrive, your phone won\u2019t make a sound or vibrate.</string>
|
||||
<!-- Do not disturb: Hide notifications option [CHAR LIMIT=60] -->
|
||||
<string name="zen_mode_restrict_notifications_hide">Hide & mute notifications</string>
|
||||
<string name="zen_mode_restrict_notifications_hide">Hide notifications</string>
|
||||
<!-- Do not disturb: Hide notifications summary [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_restrict_notifications_hide_summary">Notifications will not appear at all</string>
|
||||
<string name="zen_mode_restrict_notifications_hide_summary">You won\u2019t see new or existing notifications</string>
|
||||
<!-- Do not disturb: Hide notifications footer [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_restrict_notifications_hide_footer">You won\u2019t see new or existing notifications when Do Not Disturb is on. However, notifications needed for basic phone activity and status will still appear.</string>
|
||||
<string name="zen_mode_restrict_notifications_hide_footer">Your phone won\u2019t show new or existing notifications, and won\u2019t make a sound or vibrate. Notifications won\u2019t appear when you swipe down from the top of your screen.\n\nKeep in mind, critical notifications for phone activity and status will still appear.</string>
|
||||
<!-- Do not disturb: Custom settings option [CHAR LIMIT=60] -->
|
||||
<string name="zen_mode_restrict_notifications_custom">Custom</string>
|
||||
<!-- Do not disturb: restrict notifications page, menu option [CHAR LIMIT=60] -->
|
||||
@@ -7362,6 +7361,35 @@
|
||||
<item quantity="other"><xliff:g id="on_count" example="3">%d</xliff:g> rules can turn on automatically</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
|
||||
<string name="zen_category_behavior">Behavior</string>
|
||||
<!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
|
||||
<string name="zen_category_exceptions">Exceptions</string>
|
||||
<!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
|
||||
<string name="zen_category_schedule">Schedule</string>
|
||||
|
||||
<!-- Do not disturb settings, sound and vibrations title [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_title">Sound & vibration</string>
|
||||
<!-- Do not disturb settings, sound and vibrations screen footer [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_sound_footer">When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above.</string>
|
||||
<!-- Do not disturb settings, sound and vibrations screen category [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_category_title">Mute all except</string>
|
||||
<!-- Do not disturb settings, sound and vibrations summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_all_muted">Muted</string>
|
||||
<!-- Do not disturb settings, sound and vibrations summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_none_muted">Not muted</string>
|
||||
<!-- Do not disturb settings, sound and vibrations summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_one_allowed">Muted, but allow <xliff:g id="sound_type" example="alarms">%1$s</xliff:g></string>
|
||||
<!-- Do not disturb settings, sound and vibrations summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_two_allowed">Muted, but allow <xliff:g id="sound_type" example="alarms">%1$s</xliff:g> and <xliff:g id="sound_type" example="media">%2$s</xliff:g></string>
|
||||
<!-- Do not disturb settings, sound and vibrations summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_sound_three_allowed">Muted, but allow <xliff:g id="sound_type" example="alarms">%1$s</xliff:g>, <xliff:g id="sound_type" example="alarms">%2$s</xliff:g>, and <xliff:g id="sound_type" example="media">%3$s</xliff:g></string>
|
||||
|
||||
<!-- Do not disturb settings, messages, events and reminders title [CHAR LIMIT=100]-->
|
||||
<string name="zen_msg_event_reminder_title">Messages, events & reminders</string>
|
||||
<!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_msg_event_reminder_footer">When Do Not Disturb is on, messages, reminders, and events will muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
|
||||
<!-- Do not disturb onboarding dialog, accept new settings [CHAR LIMIT=30]-->
|
||||
<string name="zen_onboarding_ok">Update</string>
|
||||
<!-- Do not disturb onboarding dialog, do not accept new settings [CHAR LIMIT=30]-->
|
||||
@@ -7893,14 +7921,17 @@
|
||||
<!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
|
||||
<string name="zen_mode_calls">Calls</string>
|
||||
|
||||
<!-- [CHAR LIMIT=20] Zen mode settings: Calls screen footer -->
|
||||
<string name="zen_mode_calls_footer">When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
|
||||
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
|
||||
<string name="zen_mode_messages">Messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
|
||||
<string name="zen_mode_all_messages">All messages</string>
|
||||
<string name="zen_mode_all_messages">Messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Selected messages summary -->
|
||||
<string name="zen_mode_selected_messages">Selected messages</string>
|
||||
<string name="zen_mode_selected_messages">Some messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
|
||||
<string name="zen_mode_from_anyone">From anyone</string>
|
||||
@@ -7911,6 +7942,15 @@
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From starred contacts only -->
|
||||
<string name="zen_mode_from_starred">From starred contacts only</string>
|
||||
|
||||
<!-- Do not disturb settings, calls summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_calls_summary_starred_repeat">From starred contacts and repeat callers</string>
|
||||
|
||||
<!-- Do not disturb settings, calls summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_calls_summary_contacts_repeat">From contacts and repeat callers</string>
|
||||
|
||||
<!-- Do not disturb settings, calls summary [CHAR LIMIT=100]-->
|
||||
<string name="zen_calls_summary_repeat_only">From repeat callers only</string>
|
||||
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: None -->
|
||||
<string name="zen_mode_from_none">None</string>
|
||||
|
||||
@@ -7930,14 +7970,23 @@
|
||||
<string name="zen_mode_events">Events</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
|
||||
<string name="zen_mode_all_callers">All callers</string>
|
||||
<string name="zen_mode_all_callers">anyone</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
|
||||
<string name="zen_mode_selected_callers">Selected callers</string>
|
||||
<string name="zen_mode_contacts_callers">contacts</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
|
||||
<string name="zen_mode_starred_callers">starred contacts</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
|
||||
<string name="zen_mode_repeat_callers">Repeat callers</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
||||
<string name="zen_mode_calls_summary_one">From <xliff:g id="caller type" example="contacts">%1$s</xliff:g> only</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
|
||||
<string name="zen_mode_calls_summary_two">From <xliff:g id="caller type" example="starred contacts">%1$s</xliff:g> and <xliff:g id="callert tpye" example="repeat callers">%2$s</xliff:g></string>
|
||||
|
||||
<!-- [CHAR LIMIT=200] Zen mode settings: Repeat callers option summary -->
|
||||
<string name="zen_mode_repeat_callers_summary">If the same person calls a second time within a <xliff:g id="minutes">%d</xliff:g> minute period</string>
|
||||
|
||||
|
@@ -1,70 +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-auto"
|
||||
android:key="zen_mode_behavior_settings_page"
|
||||
android:title="@string/zen_mode_behavior_settings_title" >
|
||||
|
||||
<!-- Alarms -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_alarms"
|
||||
android:title="@string/zen_mode_alarms"/>
|
||||
|
||||
<!-- Media -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_media"
|
||||
android:title="@string/zen_mode_media"/>
|
||||
|
||||
<!-- System -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_system"
|
||||
android:title="@string/zen_mode_system"/>
|
||||
|
||||
<!-- Reminders -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_reminders"
|
||||
android:title="@string/zen_mode_reminders"/>
|
||||
|
||||
<!-- Events -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_events"
|
||||
android:title="@string/zen_mode_events"/>
|
||||
|
||||
<!-- Messages -->
|
||||
<ListPreference
|
||||
android:key="zen_mode_messages"
|
||||
android:title="@string/zen_mode_messages"
|
||||
android:entries="@array/zen_mode_contacts_entries"
|
||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||
|
||||
<!-- Calls -->
|
||||
<ListPreference
|
||||
android:key="zen_mode_calls"
|
||||
android:title="@string/zen_mode_calls"
|
||||
android:entries="@array/zen_mode_contacts_entries"
|
||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||
|
||||
<!-- Repeat callers -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_repeat_callers"
|
||||
android:title="@string/zen_mode_repeat_callers" />
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference />
|
||||
|
||||
</PreferenceScreen>
|
43
res/xml/zen_mode_calls_settings.xml
Normal file
43
res/xml/zen_mode_calls_settings.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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"
|
||||
android:key="zen_mode_calls_settings_page"
|
||||
android:title="@string/zen_mode_calls" >
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/zen_mode_settings_category"
|
||||
android:key="zen_mode_settings_category_calls">
|
||||
<!-- Calls -->
|
||||
<ListPreference
|
||||
android:key="zen_mode_calls"
|
||||
android:title="@string/zen_mode_calls"
|
||||
android:entries="@array/zen_mode_contacts_entries"
|
||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||
|
||||
<!-- TODO: setting that links to contacts or placeholder for external app -->
|
||||
|
||||
<!-- Repeat callers -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_repeat_callers"
|
||||
android:title="@string/zen_mode_repeat_callers" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference/>
|
||||
|
||||
</PreferenceScreen>
|
46
res/xml/zen_mode_msg_event_reminder_settings.xml
Normal file
46
res/xml/zen_mode_msg_event_reminder_settings.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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"
|
||||
android:key="zen_mode_msg_event_reminder_settings_page"
|
||||
android:title="@string/zen_msg_event_reminder_title" >
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/zen_mode_settings_category"
|
||||
android:key="zen_mode_settings_category_msg_event_reminder">
|
||||
<!-- Messages -->
|
||||
<ListPreference
|
||||
android:key="zen_mode_messages"
|
||||
android:title="@string/zen_mode_messages"
|
||||
android:entries="@array/zen_mode_contacts_entries"
|
||||
android:entryValues="@array/zen_mode_contacts_values"/>
|
||||
|
||||
<!-- Reminders -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_reminders"
|
||||
android:title="@string/zen_mode_reminders"/>
|
||||
|
||||
<!-- Events -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_events"
|
||||
android:title="@string/zen_mode_events"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference />
|
||||
|
||||
</PreferenceScreen>
|
@@ -18,11 +18,11 @@
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="zen_mode_restrict_settings_page"
|
||||
android:title="@string/zen_mode_restrict_notifications_screen_title">
|
||||
android:title="@string/zen_mode_restrict_notifications_title">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="restrict_category"
|
||||
android:title="@string/zen_mode_restrict_notifications_category">
|
||||
android:title="@string/zen_mode_settings_category">
|
||||
<com.android.settings.notification.ZenCustomRadioButtonPreference
|
||||
android:key="zen_mute_notifications"
|
||||
android:title="@string/zen_mode_restrict_notifications_mute"
|
||||
|
@@ -22,39 +22,50 @@
|
||||
android:title="@string/zen_mode_settings_title"
|
||||
settings:keywords="@string/keywords_zen_mode_settings">
|
||||
|
||||
<!-- sound vibration -->
|
||||
<com.android.settings.widget.DisabledCheckBoxPreference
|
||||
android:key="zen_effect_sound"
|
||||
android:title="@string/zen_mode_block_effect_sound"
|
||||
android:enabled="false"/>
|
||||
|
||||
<!-- What to block (effects) -->
|
||||
<Preference
|
||||
android:key="zen_mode_block_effects_settings"
|
||||
android:title="@string/zen_mode_restrict_notifications_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings" />
|
||||
|
||||
<!-- Behavior settings (exceptions) -->
|
||||
<Preference
|
||||
android:key="zen_mode_behavior_settings"
|
||||
android:title="@string/zen_mode_behavior_settings_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeBehaviorSettings" />
|
||||
|
||||
<!-- DND duration settings -->
|
||||
<Preference
|
||||
android:key="zen_mode_duration_settings"
|
||||
android:title="@string/zen_mode_duration_settings_title" />
|
||||
|
||||
<!-- Automatic rules -->
|
||||
<Preference
|
||||
android:key="zen_mode_automation_settings"
|
||||
android:title="@string/zen_mode_automation_settings_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
|
||||
|
||||
<!-- placeholder -->
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="5" />
|
||||
android:key="zen_mode_settings_category_behavior"
|
||||
android:title="@string/zen_category_behavior">
|
||||
<!-- sound vibration -->
|
||||
<Preference
|
||||
android:key="zen_sound_vibration_settings"
|
||||
android:title="@string/zen_sound_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeSoundVibrationSettings"/>
|
||||
|
||||
<!-- What to block (effects) -->
|
||||
<Preference
|
||||
android:key="zen_mode_block_effects_settings"
|
||||
android:title="@string/zen_mode_restrict_notifications_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="zen_mode_settings_category_exceptions"
|
||||
android:title="@string/zen_category_exceptions">
|
||||
<Preference
|
||||
android:key="zen_mode_calls_settings"
|
||||
android:title="@string/zen_mode_calls"
|
||||
android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
|
||||
<Preference
|
||||
android:key="zen_mode_msg_event_reminder_settings"
|
||||
android:title="@string/zen_msg_event_reminder_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeMsgEventReminderSettings" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="zen_mode_settings_category_schedule"
|
||||
android:title="@string/zen_category_schedule">
|
||||
<!-- DND duration settings -->
|
||||
<Preference
|
||||
android:key="zen_mode_duration_settings"
|
||||
android:title="@string/zen_mode_duration_settings_title" />
|
||||
|
||||
<!-- Automatic rules -->
|
||||
<Preference
|
||||
android:key="zen_mode_automation_settings"
|
||||
android:title="@string/zen_mode_automation_settings_title"
|
||||
android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Turn on DND button -->
|
||||
<!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
|
||||
|
44
res/xml/zen_mode_sound_vibration_settings.xml
Normal file
44
res/xml/zen_mode_sound_vibration_settings.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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"
|
||||
android:key="zen_mode_sound_vibration_settings_page"
|
||||
android:title="@string/zen_sound_title" >
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/zen_mode_settings_category"
|
||||
android:key="zen_mode_settings_category_sound_vibration">
|
||||
<!-- Alarms -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_alarms"
|
||||
android:title="@string/zen_mode_alarms"/>
|
||||
|
||||
<!-- Media -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_media"
|
||||
android:title="@string/zen_mode_media"/>
|
||||
|
||||
<!-- System -->
|
||||
<SwitchPreference
|
||||
android:key="zen_mode_system"
|
||||
android:title="@string/zen_mode_system"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference/>
|
||||
|
||||
</PreferenceScreen>
|
@@ -106,9 +106,10 @@ import com.android.settings.notification.NotificationStation;
|
||||
import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.notification.ZenAccessSettings;
|
||||
import com.android.settings.notification.ZenModeAutomationSettings;
|
||||
import com.android.settings.notification.ZenModeBehaviorSettings;
|
||||
import com.android.settings.notification.ZenModeMsgEventReminderSettings;
|
||||
import com.android.settings.notification.ZenModeBlockedEffectsSettings;
|
||||
import com.android.settings.notification.ZenModeEventRuleSettings;
|
||||
import com.android.settings.notification.ZenModeRestrictNotificationsSettings;
|
||||
import com.android.settings.notification.ZenModeScheduleRuleSettings;
|
||||
import com.android.settings.notification.ZenModeSettings;
|
||||
import com.android.settings.password.ChooseLockPassword;
|
||||
@@ -220,7 +221,6 @@ public class SettingsGateway {
|
||||
ApnSettings.class.getName(),
|
||||
ApnEditor.class.getName(),
|
||||
WifiCallingSettings.class.getName(),
|
||||
ZenModeBehaviorSettings.class.getName(),
|
||||
ZenModeScheduleRuleSettings.class.getName(),
|
||||
ZenModeEventRuleSettings.class.getName(),
|
||||
ZenModeBlockedEffectsSettings.class.getName(),
|
||||
|
@@ -22,13 +22,13 @@ import androidx.preference.Preference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class ZenModeBehaviorPreferenceController extends
|
||||
public class ZenModeBehaviorCallsPreferenceController extends
|
||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||
|
||||
protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_behavior_settings";
|
||||
protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_calls_settings";
|
||||
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
|
||||
|
||||
public ZenModeBehaviorPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
public ZenModeBehaviorCallsPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
|
||||
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
|
||||
}
|
||||
@@ -47,7 +47,6 @@ public class ZenModeBehaviorPreferenceController extends
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
preference.setSummary(mSummaryBuilder.getBehaviorSettingSummary(getPolicy(),
|
||||
getZenMode()));
|
||||
preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
|
||||
}
|
||||
}
|
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
@@ -30,14 +30,17 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
public class ZenModeBehaviorFooterPreferenceController extends AbstractZenModePreferenceController {
|
||||
|
||||
protected static final String KEY = "footer_preference";
|
||||
private final int mTitleRes;
|
||||
|
||||
public ZenModeBehaviorFooterPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
public ZenModeBehaviorFooterPreferenceController(Context context, Lifecycle lifecycle,
|
||||
int titleRes) {
|
||||
super(context, KEY, lifecycle);
|
||||
mTitleRes = titleRes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return isDeprecatedZenMode(getZenMode());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,45 +51,45 @@ public class ZenModeBehaviorFooterPreferenceController extends AbstractZenModePr
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
boolean isAvailable = isAvailable();
|
||||
preference.setVisible(isAvailable);
|
||||
if (isAvailable) {
|
||||
preference.setTitle(getFooterText());
|
||||
}
|
||||
|
||||
preference.setTitle(getFooterText());
|
||||
}
|
||||
|
||||
protected String getFooterText() {
|
||||
ZenModeConfig config = getZenModeConfig();
|
||||
if (isDeprecatedZenMode(getZenMode())) {
|
||||
ZenModeConfig config = getZenModeConfig();
|
||||
|
||||
// DND turned on by manual rule with deprecated zen mode
|
||||
if (config.manualRule != null &&
|
||||
isDeprecatedZenMode(config.manualRule.zenMode)) {
|
||||
final Uri id = config.manualRule.conditionId;
|
||||
if (config.manualRule.enabler != null) {
|
||||
// app triggered manual rule
|
||||
String appOwner = mZenModeConfigWrapper.getOwnerCaption(config.manualRule.enabler);
|
||||
if (!appOwner.isEmpty()) {
|
||||
return mContext.getString(R.string.zen_mode_app_set_behavior, appOwner);
|
||||
}
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_qs_set_behavior);
|
||||
}
|
||||
}
|
||||
|
||||
// DND turned on by an automatic rule with deprecated zen mode
|
||||
for (ZenModeConfig.ZenRule automaticRule : config.automaticRules.values()) {
|
||||
if (automaticRule.isAutomaticActive() && isDeprecatedZenMode(automaticRule.zenMode)) {
|
||||
ComponentName component = automaticRule.component;
|
||||
if (component != null) {
|
||||
return mContext.getString(R.string.zen_mode_app_set_behavior,
|
||||
component.getPackageName());
|
||||
// DND turned on by manual rule with deprecated zen mode
|
||||
if (config.manualRule != null &&
|
||||
isDeprecatedZenMode(config.manualRule.zenMode)) {
|
||||
final Uri id = config.manualRule.conditionId;
|
||||
if (config.manualRule.enabler != null) {
|
||||
// app triggered manual rule
|
||||
String appOwner = mZenModeConfigWrapper.getOwnerCaption(
|
||||
config.manualRule.enabler);
|
||||
if (!appOwner.isEmpty()) {
|
||||
return mContext.getString(R.string.zen_mode_app_set_behavior, appOwner);
|
||||
}
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_qs_set_behavior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mContext.getString(R.string.zen_mode_unknown_app_set_behavior);
|
||||
// DND turned on by an automatic rule with deprecated zen mode
|
||||
for (ZenModeConfig.ZenRule automaticRule : config.automaticRules.values()) {
|
||||
if (automaticRule.isAutomaticActive() && isDeprecatedZenMode(
|
||||
automaticRule.zenMode)) {
|
||||
ComponentName component = automaticRule.component;
|
||||
if (component != null) {
|
||||
return mContext.getString(R.string.zen_mode_app_set_behavior,
|
||||
component.getPackageName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mContext.getString(R.string.zen_mode_unknown_app_set_behavior);
|
||||
} else {
|
||||
return mContext.getString(mTitleRes);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDeprecatedZenMode(int zenMode) {
|
||||
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class ZenModeBehaviorMsgEventReminderPreferenceController extends
|
||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||
|
||||
protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_msg_event_reminder_settings";
|
||||
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
|
||||
|
||||
public ZenModeBehaviorMsgEventReminderPreferenceController(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
|
||||
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_BEHAVIOR_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
preference.setSummary(mSummaryBuilder.getMsgEventReminderSettingSummary(getPolicy()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class ZenModeBehaviorSoundPreferenceController extends
|
||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||
|
||||
protected static final String KEY_BEHAVIOR_SETTINGS = "zen_sound_vibration_settings";
|
||||
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
|
||||
|
||||
public ZenModeBehaviorSoundPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
|
||||
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_BEHAVIOR_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
preference.setSummary(mSummaryBuilder.getSoundSettingSummary(getPolicy()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class ZenModeCallsSettings extends ZenModeSettingsBase implements Indexable {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
|
||||
// TODO: is a controller needed for a pref that just launches an external activity?
|
||||
// or can the contacts app insert this setting themselves?
|
||||
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
|
||||
context.getResources().getInteger(com.android.internal.R.integer
|
||||
.config_zen_repeat_callers_threshold)));
|
||||
controllers.add(new ZenModeBehaviorFooterPreferenceController(
|
||||
context, lifecycle, R.string.zen_mode_calls_footer));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.zen_mode_calls_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.zen_mode_calls_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, null);
|
||||
}
|
||||
};
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* Copyright (C) 2018 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.
|
||||
@@ -31,7 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Indexable {
|
||||
public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
@@ -41,23 +41,17 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
|
||||
context.getResources().getInteger(com.android.internal.R.integer
|
||||
.config_zen_repeat_callers_threshold)));
|
||||
controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
|
||||
R.string.zen_msg_event_reminder_footer));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.zen_mode_behavior_settings;
|
||||
return R.xml.zen_mode_msg_event_reminder_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +71,7 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.zen_mode_behavior_settings;
|
||||
sir.xmlResId = R.xml.zen_mode_msg_event_reminder_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
@@ -16,6 +16,15 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
|
||||
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM;
|
||||
|
||||
import android.app.AutomaticZenRule;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.NotificationManager;
|
||||
@@ -42,19 +51,13 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@SearchIndexable
|
||||
public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
private static final String KEY_SOUND = "zen_effect_sound";
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
CheckBoxPreference soundPreference =
|
||||
(CheckBoxPreference) getPreferenceScreen().findPreference(KEY_SOUND);
|
||||
if (soundPreference != null) {
|
||||
soundPreference.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +83,9 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle, FragmentManager fragmentManager) {
|
||||
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new ZenModeBehaviorPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBehaviorMsgEventReminderPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBehaviorSoundPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBehaviorCallsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle,
|
||||
fragmentManager));
|
||||
@@ -100,19 +105,63 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
|
||||
// these should match NotificationManager.Policy#ALL_PRIORITY_CATEGORIES
|
||||
private static final int[] ALL_PRIORITY_CATEGORIES = {
|
||||
Policy.PRIORITY_CATEGORY_ALARMS,
|
||||
Policy.PRIORITY_CATEGORY_MEDIA,
|
||||
Policy.PRIORITY_CATEGORY_SYSTEM,
|
||||
Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
Policy.PRIORITY_CATEGORY_EVENTS,
|
||||
Policy.PRIORITY_CATEGORY_MESSAGES,
|
||||
Policy.PRIORITY_CATEGORY_CALLS,
|
||||
Policy.PRIORITY_CATEGORY_REPEAT_CALLERS,
|
||||
PRIORITY_CATEGORY_ALARMS,
|
||||
PRIORITY_CATEGORY_MEDIA,
|
||||
PRIORITY_CATEGORY_SYSTEM,
|
||||
PRIORITY_CATEGORY_MESSAGES,
|
||||
PRIORITY_CATEGORY_EVENTS,
|
||||
PRIORITY_CATEGORY_REMINDERS,
|
||||
PRIORITY_CATEGORY_CALLS,
|
||||
PRIORITY_CATEGORY_REPEAT_CALLERS,
|
||||
};
|
||||
|
||||
String getBehaviorSettingSummary(Policy policy, int zenMode) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy);
|
||||
String getSoundSettingSummary(Policy policy) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_ALARMS == category
|
||||
|| PRIORITY_CATEGORY_MEDIA == category
|
||||
|| PRIORITY_CATEGORY_SYSTEM == category);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_sound_all_muted);
|
||||
} else if (numCategories == 1) {
|
||||
return mContext.getString(R.string.zen_sound_one_allowed,
|
||||
enabledCategories.get(0).toLowerCase());
|
||||
} else if (numCategories == 2) {
|
||||
return mContext.getString(R.string.zen_sound_two_allowed,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase());
|
||||
} else if (numCategories == 3) {
|
||||
return mContext.getString(R.string.zen_sound_three_allowed,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase(),
|
||||
enabledCategories.get(2).toLowerCase());
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_sound_none_muted);
|
||||
}
|
||||
}
|
||||
|
||||
String getCallsSettingSummary(Policy policy) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_CALLS == category
|
||||
|| PRIORITY_CATEGORY_REPEAT_CALLERS == category);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
} else if (numCategories == 1) {
|
||||
return mContext.getString(R.string.zen_mode_calls_summary_one,
|
||||
enabledCategories.get(0).toLowerCase());
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_calls_summary_two,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
String getMsgEventReminderSettingSummary(Policy policy) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_EVENTS == category
|
||||
|| PRIORITY_CATEGORY_REMINDERS == category
|
||||
|| PRIORITY_CATEGORY_MESSAGES == category);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
@@ -201,22 +250,19 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
return count;
|
||||
}
|
||||
|
||||
private List<String> getEnabledCategories(Policy policy) {
|
||||
private List<String> getEnabledCategories(Policy policy,
|
||||
Predicate<Integer> filteredCategories) {
|
||||
List<String> enabledCategories = new ArrayList<>();
|
||||
for (int category : ALL_PRIORITY_CATEGORIES) {
|
||||
if (isCategoryEnabled(policy, category)) {
|
||||
if (category == Policy.PRIORITY_CATEGORY_ALARMS) {
|
||||
if (filteredCategories.test(category) && isCategoryEnabled(policy, category)) {
|
||||
if (category == PRIORITY_CATEGORY_ALARMS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_MEDIA) {
|
||||
} else if (category == PRIORITY_CATEGORY_MEDIA) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_media));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_SYSTEM) {
|
||||
} else if (category == PRIORITY_CATEGORY_SYSTEM) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_system));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_events));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
@@ -225,13 +271,20 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_selected_messages));
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_events));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
|
||||
if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_all_callers));
|
||||
} else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_contacts_callers));
|
||||
} else {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_selected_callers));
|
||||
R.string.zen_mode_starred_callers));
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
|
||||
if (!enabledCategories.contains(mContext.getString(
|
||||
@@ -248,10 +301,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
private boolean isCategoryEnabled(Policy policy, int categoryType) {
|
||||
return (policy.priorityCategories & categoryType) != 0;
|
||||
}
|
||||
|
||||
private boolean isEffectSuppressed(Policy policy, int effect) {
|
||||
return (policy.suppressedVisualEffects & effect) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implements Indexable {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
|
||||
controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
|
||||
R.string.zen_sound_footer));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.zen_mode_sound_vibration_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.zen_mode_sound_vibration_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, null);
|
||||
}
|
||||
};
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public final class ZenModeBehaviorCallsPreferenceControllerTest {
|
||||
|
||||
private ZenModeBehaviorCallsPreferenceController mController;
|
||||
@Mock
|
||||
private NotificationManager mNotificationManager;
|
||||
@Mock
|
||||
private NotificationManager.Policy mPolicy;
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ZenModeBackend mBackend;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowApplication = ShadowApplication.getInstance();
|
||||
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
|
||||
|
||||
mController = new ZenModeBehaviorCallsPreferenceController(
|
||||
mContext, mock(Lifecycle.class));
|
||||
ReflectionHelpers.setField(mController, "mBackend", mBackend);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasSummary() {
|
||||
Preference pref = mock(Preference.class);
|
||||
mController.updateState(pref);
|
||||
verify(pref).setSummary(any());
|
||||
}
|
||||
}
|
@@ -41,6 +41,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.notification.AbstractZenModePreferenceController.ZenModeConfigWrapper;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -77,6 +78,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mContentResolver;
|
||||
private int mTitleResId = R.string.zen_sound_title;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -88,8 +90,8 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
|
||||
mContentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
when(mNotificationManager.getZenModeConfig()).thenReturn(mZenModeConfig);
|
||||
|
||||
mController =
|
||||
new ZenModeBehaviorFooterPreferenceController(mContext, mock(Lifecycle.class));
|
||||
mController = new ZenModeBehaviorFooterPreferenceController(
|
||||
mContext, mock(Lifecycle.class), mTitleResId);
|
||||
ReflectionHelpers.setField(mController, "mZenModeConfigWrapper", mConfigWrapper);
|
||||
|
||||
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
|
||||
@@ -112,13 +114,13 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
|
||||
@Test
|
||||
public void priorityOnly_footerIsAvailable() {
|
||||
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zenModeOff_footerIsNotAvailable() {
|
||||
public void zenModeOff_footerIsAvailable() {
|
||||
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_OFF);
|
||||
assertFalse(mController.isAvailable());
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +128,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
|
||||
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_OFF);
|
||||
mController.updateState(mockPref);
|
||||
|
||||
verify(mockPref, never()).setTitle(any(String.class));
|
||||
verify(mockPref).setTitle(mContext.getString(mTitleResId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +136,7 @@ public class ZenModeBehaviorFooterPreferenceControllerTest {
|
||||
Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
mController.updateState(mockPref);
|
||||
|
||||
verify(mockPref, never()).setTitle(any(String.class));
|
||||
verify(mockPref).setTitle(mContext.getString(mTitleResId));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public final class ZenModeBehaviorMsgEventReminderPreferenceControllerTest {
|
||||
|
||||
private ZenModeBehaviorMsgEventReminderPreferenceController mController;
|
||||
@Mock
|
||||
private NotificationManager mNotificationManager;
|
||||
@Mock
|
||||
private NotificationManager.Policy mPolicy;
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ZenModeBackend mBackend;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowApplication = ShadowApplication.getInstance();
|
||||
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
|
||||
|
||||
mController = new ZenModeBehaviorMsgEventReminderPreferenceController(
|
||||
mContext, mock(Lifecycle.class));
|
||||
ReflectionHelpers.setField(mController, "mBackend", mBackend);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasSummary() {
|
||||
Preference pref = mock(Preference.class);
|
||||
mController.updateState(pref);
|
||||
verify(pref).setSummary(any());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.notification;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public final class ZenModeBehaviorSoundPreferenceControllerTest {
|
||||
|
||||
private ZenModeBehaviorSoundPreferenceController mController;
|
||||
@Mock
|
||||
private NotificationManager mNotificationManager;
|
||||
@Mock
|
||||
private NotificationManager.Policy mPolicy;
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ZenModeBackend mBackend;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowApplication = ShadowApplication.getInstance();
|
||||
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
|
||||
|
||||
mController = new ZenModeBehaviorSoundPreferenceController(
|
||||
mContext, mock(Lifecycle.class));
|
||||
ReflectionHelpers.setField(mController, "mBackend", mBackend);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
assertTrue(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasSummary() {
|
||||
Preference pref = mock(Preference.class);
|
||||
mController.updateState(pref);
|
||||
verify(pref).setSummary(any());
|
||||
}
|
||||
}
|
@@ -20,9 +20,9 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -46,54 +46,140 @@ public class ZenModeSettingsTest {
|
||||
mBuilder = new ZenModeSettings.SummaryBuilder(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBehaviorSettingSummary_noSoundsCanBypass() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
|
||||
final String result = mBuilder.getBehaviorSettingSummary(policy,
|
||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
|
||||
String totalSilence = mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
assertEquals(totalSilence, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBehaviorSettingSummary_alarmsAndMedia() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
|
||||
| NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA,
|
||||
0, 0);
|
||||
final String result = mBuilder.getBehaviorSettingSummary(policy,
|
||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
|
||||
String alarmsAndMedia = mContext.getString(R.string.join_two_items,
|
||||
mContext.getString(R.string.zen_mode_alarms),
|
||||
mContext.getString(R.string.zen_mode_media).toLowerCase());
|
||||
assertEquals(alarmsAndMedia, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_none() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0, 0);
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_muted),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_some() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
|
||||
Policy policy = new Policy(0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_custom),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_all() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
0, 0, 0, 511);
|
||||
Policy policy = new Policy(0, 0, 0, 511);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_hidden),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_none() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("None");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_single() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_EVENTS, 0 , 0 , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Events");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgs() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
|
||||
Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
|
||||
|
||||
policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
|
||||
Policy.PRIORITY_SENDERS_STARRED , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_msgs() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0, 0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Messages");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgsAndOther() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Some messages and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgsAndAllOthers() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_EVENTS
|
||||
| Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Some messages, events, and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_noMsgsAndOther() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_EVENTS | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0,0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Events and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_none() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("None");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_contacts() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
|
||||
Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts only");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_repeatCallers() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers only");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_starredRepeatCallers() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | Policy.PRIORITY_CATEGORY_CALLS,
|
||||
Policy.PRIORITY_SENDERS_STARRED, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy))
|
||||
.isEqualTo("From starred contacts and repeat callers");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOff() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOn() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_SYSTEM
|
||||
| Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy))
|
||||
.isEqualTo("Muted, but allow alarms, media, and touch sounds");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOffButOne() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted, but allow media");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOffButTwo() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_SYSTEM
|
||||
| Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy))
|
||||
.isEqualTo("Muted, but allow media and touch sounds");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchProvider_shouldIndexDefaultXml() {
|
||||
final List<SearchIndexableResource> sir = ZenModeSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
|
Reference in New Issue
Block a user