Merge "Updates main page for Do Not Disturb" into rvc-dev am: 4d4c55ad72

Change-Id: I40f114a95b899c28f41ca1f899f0760297eb7953
This commit is contained in:
TreeHugger Robot
2020-03-23 14:21:30 +00:00
committed by Automerger Merge Worker
10 changed files with 511 additions and 207 deletions

View File

@@ -39,7 +39,6 @@
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="center"
android:paddingTop="@dimen/zen_mode_button_padding_vertical"
android:text="@string/zen_mode_button_turn_on"/>
<Button
@@ -51,7 +50,6 @@
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="center"
android:paddingTop="@dimen/zen_mode_button_padding_vertical"
android:text="@string/zen_mode_button_turn_off" />
</LinearLayout>

View File

@@ -7757,13 +7757,13 @@
<!-- Setting summary for controlling how caption text display in real time [CHAR LIMIT=NONE]-->
<string name="live_caption_summary">Automatically caption media</string>
<!-- Sound: Summary for the Do not Disturb option when there is no automatic rules turned on. [CHAR LIMIT=NONE]-->
<string name="zen_mode_settings_summary_off">Never</string>
<!-- Sound: Summary for the Do not Disturb option when there are no automatic rules enabled. [CHAR LIMIT=NONE]-->
<string name="zen_mode_settings_summary_off">None</string>
<!-- Sound: Summary for the Do not Disturb option when at least one automatic rules turned on. [CHAR LIMIT=NONE]-->
<!-- Sound: Summary for the Do not Disturb option when at least one automatic rule is enabled. [CHAR LIMIT=NONE]-->
<plurals name="zen_mode_settings_summary_on">
<item quantity="one">1 enabled</item>
<item quantity="other"><xliff:g id="on_count" example="10">%d</xliff:g> enabled</item>
<item quantity="one">1 schedule set</item>
<item quantity="other"><xliff:g id="on_count" example="10">%d</xliff:g> schedules set</item>
</plurals>
<!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=50]-->
@@ -7778,26 +7778,8 @@
<!-- Do not disturb: Title for the Do not Disturb dialog to turn on Do not disturb. [CHAR LIMIT=50]-->
<string name="zen_mode_settings_turn_on_dialog_title">Turn on Do Not Disturb</string>
<!-- Do not disturb: Title for the page describing what can bypass DND. [CHAR LIMIT=30] -->
<string name="zen_mode_behavior_settings_title">Exceptions</string>
<!-- Do not disturb: Title for the dnd duration setting (user can specify how long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=30] -->
<string name="zen_mode_duration_settings_title">Default duration</string>
<!-- Do not disturb: Instructions indicating what types of sounds can bypass DND. [CHAR LIMIT=52] -->
<string name="zen_mode_behavior_allow_title">Allow sounds and vibrations from</string>
<!-- Do not disturb: Subtitle for DND behavior indicating no sound will get past DND. [CHAR LIMIT=30] -->
<string name="zen_mode_behavior_no_sound">No sound</string>
<!-- Do not disturb: Subtitle for DND behavior indicating no sound will get past DND. [CHAR LIMIT=40] -->
<string name="zen_mode_behavior_total_silence">Total Silence</string>
<!-- Do not disturb: Used before specifying which sounds can bypass DND (ie: No sound except alarms and reminders). [CHAR LIMIT=40] -->
<string name="zen_mode_behavior_no_sound_except">No sound except <xliff:g id="categories" example="alarms, media and system feedback">%1$s</xliff:g></string>
<!-- Do not disturb: Specifies alarms and media can bypass DND. [CHAR LIMIT=100] -->
<string name="zen_mode_behavior_alarms_only">No sound except alarms and media</string>
<string name="zen_mode_behavior_alarms_only">Alarms and media sounds can interrupt</string>
<!-- Do not disturb: Title for the zen mode automation option in Settings. [CHAR LIMIT=40] -->
<string name="zen_mode_automation_settings_title">Schedules</string>
@@ -7832,15 +7814,6 @@
<!-- Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
<string name="zen_mode_use_automatic_rule">Use schedule</string>
<!-- Do not disturb: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
<string name="zen_mode_option_important_interruptions">Priority only</string>
<!-- Do not disturb: Zen mode option: Alarms only [CHAR LIMIT=60] -->
<string name="zen_mode_option_alarms">Alarms only</string>
<!-- Do not disturb: Zen mode option: No interruptions [CHAR LIMIT=60] -->
<string name="zen_mode_option_no_interruptions">Total silence</string>
<!-- Do not disturb: Zen mode combined summary + condition line [CHAR LIMIT=60] -->
<string name="zen_mode_summary_combination"><xliff:g id="mode" example="Priority only">%1$s</xliff:g>: <xliff:g id="exit condition" example="Until you turn this off">%2$s</xliff:g></string>
@@ -7853,8 +7826,8 @@
<!-- Do not disturb: zen settings screens category title [CHAR LIMIT=100] -->
<string name="zen_mode_settings_category">Allow interruptions that make sound</string>
<!-- Do not disturb: restrict notifications title [CHAR LIMIT=80] -->
<string name="zen_mode_restrict_notifications_title">Restrict notifications</string>
<!-- Do not disturb: restrict notifications settings title [CHAR LIMIT=80] -->
<string name="zen_mode_restrict_notifications_title">Display options for hidden notifications</string>
<!-- Do not disturb: Mute notifications option [CHAR LIMIT=60] -->
<string name="zen_mode_restrict_notifications_mute">No sound from notifications</string>
<!-- Do not disturb:Mute notifications summary [CHAR LIMIT=NONE] -->
@@ -7993,7 +7966,7 @@
</plurals>
<!-- Do not disturb settings, main screen, category header [CHAR LIMIT=120]-->
<string name="zen_category_behavior">Exceptions when Do Not Disturb is on</string>
<string name="zen_category_behavior">What can interrupt Do Not Disturb</string>
<!-- Do not disturb settings, main screen, field, dnd breakthrough [CHAR LIMIT=100]-->
<string name="zen_category_people">People</string>
<!-- Do not disturb settings, main screen, field, dnd breakthrough [CHAR LIMIT=100]-->
@@ -8002,23 +7975,12 @@
<string name="zen_category_exceptions">Alarms &amp; other interruptions</string>
<!-- Do not disturb settings, main screen, field, schedules [CHAR LIMIT=100]-->
<string name="zen_category_schedule">Schedules</string>
<!-- Do not disturb settings, main screen, field, dnd visuals [CHAR LIMIT=100]-->
<string name="zen_category_visuals">Silenced notifications</string>
<!-- Do not disturb settings, main screen, field, duration setting where user can specify how
long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=100] -->
<string name="zen_category_duration">Set duration for Quick Settings</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 custom settings dialog title [CHAR LIMIT=40]-->
<string name="zen_custom_settings_dialog_title">Custom settings</string>
@@ -8923,19 +8885,15 @@
<!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
<string name="zen_mode_calls">Allow calls</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Allow calls toggle title -->
<string name="zen_mode_calls_title">Calls</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Calls screen footer -->
<string name="zen_mode_calls_footer">To be sure allowed calls make sound, check whether your device is set to ring, vibrate, or silent.</string>
<!-- [CHAR LIMIT=NONE] Zen mode custom rule settings: Calls screen footer -->
<string name="zen_mode_custom_calls_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Starred contacts preference title -->
<string name="zen_mode_starred_contacts_title">Starred contacts</string>
<!-- Zen mode settings: Starred contacts summary [CHAR LIMIT=NONE] -->
<plurals name="zen_mode_starred_contacts_summary_additional_contacts">
<item quantity="one">1 other</item>
@@ -8949,128 +8907,119 @@
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Allow messages</string>
<!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
<string name="zen_mode_messages_footer">To be sure allowed messages make sound, check whether your device is set to ring, vibrate, or silent.</string>
<!-- [CHAR LIMIT=NONE] Zen mode custom rule settings: Messages screen footer -->
<string name="zen_mode_custom_messages_footer">For \u2018<xliff:g id="schedule_name" example="Schedule 1">%1$s</xliff:g>\u2019 incoming messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Allow messages to bypass DND title -->
<string name="zen_mode_messages_title">SMS, MMS, and messaging apps</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
<string name="zen_mode_from_anyone">From anyone</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From contacts only -->
<string name="zen_mode_from_contacts">From contacts only</string>
<!-- [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 and/or messages from none-->
<string name="zen_mode_from_none">None</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Calls option value: No calls allowed -->
<string name="zen_mode_from_none_calls">Don\u2019t allow any calls</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option value: No messages allowed -->
<string name="zen_mode_from_none_messages">Don\u2019t allow any messages</string>
<!-- [CHAR LIMIT=80] Zen mode settings: Allow alarms option -->
<string name="zen_mode_alarms">Alarms</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Allow alarms summary -->
<string name="zen_mode_alarms_summary">From timers, alarms, security systems, and other apps</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option (ie: sound from alarm clock) -->
<string name="zen_mode_alarms_list">alarms</string>
<!-- [CHAR LIMIT=80] Zen mode settings: Allow media (sound from video) to bypass dnd -->
<string name="zen_mode_media">Media sounds</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Allow media (sound from video) to bypass dnd summary-->
<string name="zen_mode_media_summary">From videos, games, and other media</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
<string name="zen_mode_media_list">media</string>
<!-- [CHAR LIMIT=80] Zen mode settings: allow touch sounds to bypass DND -->
<string name="zen_mode_system">Touch sounds</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: allow touch sounds to bypass DND summary -->
<string name="zen_mode_system_summary">From your keyboard and other buttons</string>
<!-- [CHAR LIMIT=50] Zen mode settings: System sounds (ie: touch sounds) -->
<string name="zen_mode_system_list">touch sounds</string>
<!-- [CHAR LIMIT=80] Zen mode settings: Allow reminder notifications/sounds to bypass DND -->
<string name="zen_mode_reminders">Reminders</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Allow reminder notifications/sounds to bypass DND summary -->
<string name="zen_mode_reminders_summary">From tasks and reminders</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders (ie: calendar reminders are allowed to bypass dnd) -->
<string name="zen_mode_reminders_list">reminders</string>
<!-- [CHAR LIMIT=80] Zen mode settings: Allow event notifications/sounds to bypass DND -->
<string name="zen_mode_events">Events</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Allow event notifications/sounds to bypass DND summary -->
<string name="zen_mode_events_summary">From upcoming calendar events</string>
<!-- [CHAR LIMIT=100] Zen mode settings: Allow apps to bypass DND -->
<string name="zen_mode_bypassing_apps">Allow apps to override</string>
<!-- [CHAR LIMIT=100] Zen mode settings: Allow apps to bypass DND title-->
<string name="zen_mode_bypassing_apps_title">App exceptions</string>
<!-- [CHAR LIMIT=120] Zen mode settings: No apps are bypassing DND -->
<string name="zen_mode_bypassing_apps_subtext_none">No apps can override Do Not Disturb</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Allow apps to bypass DND -->
<plurals name="zen_mode_bypassing_apps_subtext">
<item quantity="zero">No apps can override Do Not Disturb</item>
<item quantity="one">Notifications from 1 app can override Do Not Disturb</item>
<item quantity="other">Notifications from <xliff:g id="number" example="2">%1$d</xliff:g> apps can override Do Not Disturb</item>
</plurals>
<!-- [CHAR LIMIT=50] Zen mode settings: Events (ie: calendar events) -->
<string name="zen_mode_events_list">events</string>
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
<string name="zen_mode_all_callers">anyone</string>
<!-- [CHAR LIMIT=100] Zen mode settings: Allow apps to bypass DND -->
<string name="zen_mode_bypassing_apps">Allow apps to override</string>
<!-- [CHAR LIMIT=120] Zen mode settings: No apps are bypassing DND -->
<string name="zen_mode_bypassing_apps_subtext_none">No apps can interrupt</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Allow apps to bypass DND -->
<plurals name="zen_mode_bypassing_apps_subtext">
<item quantity="one"><xliff:g id="app_name" example="Nest">%s</xliff:g> can interrupt</item>
<item quantity="other"><xliff:g id="app_names" example="Nest and Google Play Store">%s</xliff:g> can interrupt</item>
</plurals>
<!-- [CHAR LIMIT=30] Zen mode settings: List item in a summary indicating additional apps are
allowed to bypass Do Not Disturb. For example, "Nest, Messages, and 2 more can interrupt". -->
<string name="zen_mode_apps_bypassing_list_count"><xliff:g id="number" example="2">%d</xliff:g> more</string>
<!-- [CHAR LIMIT=100] Zen mode settings: Allow apps to bypass DND title-->
<string name="zen_mode_bypassing_apps_title">App exceptions</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
<string name="zen_mode_contacts_callers">contacts</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Summary for sound interruption settings -->
<plurals name="zen_mode_other_sounds_summary">
<item quantity="one"><xliff:g id="sound_category">%s</xliff:g> can interrupt</item>
<item quantity="other"><xliff:g id="sound_categories" example="Alarms, media sounds, and 2 more">%s</xliff:g> can interrupt</item>
</plurals>
<!-- [CHAR LIMIT=120] Zen mode settings: No other sounds are allowed to bypass DND -->
<string name="zen_mode_other_sounds_none">Nothing can interrupt</string>
<!-- [CHAR LIMIT=30] Zen mode settings: List item in a summary indicating additional sounds
are allowed to bypass Do Not Disturb. For example, "Alarms, media sounds, and 2 more can
interrupt". -->
<string name="zen_mode_other_sounds_list_count"><xliff:g id="number" example="2">%d</xliff:g> more</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
<string name="zen_mode_starred_callers">starred contacts</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Summary for people category -->
<string name="zen_mode_people_none">No one can interrupt</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Summary for people category -->
<string name="zen_mode_people_some">Some people can interrupt</string>
<!-- [CHAR LIMIT=120] Zen mode settings: Summary for people category -->
<string name="zen_mode_people_all">All people can interrupt</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: Repeat callers (ie: repeat callers are allowed to bypass dnd) -->
<string name="zen_mode_repeat_callers_list">repeat callers</string>
<!-- [CHAR LIMIT=70] Zen mode settings: Allow repeat callers toggle title -->
<string name="zen_mode_repeat_callers_title">Allow repeat callers</string>
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
<string name="zen_mode_all_callers">anyone</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary -->
<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 (ie: repeat callers are allowed to bypass dnd) -->
<string name="zen_mode_repeat_callers_list">repeat callers</string>
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
<string name="zen_mode_calls_summary_one">Allow from <xliff:g id="caller type" example="contacts">%1$s</xliff:g></string>
<!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
<string name="zen_mode_calls_summary_two">Allow 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>
@@ -9079,43 +9028,33 @@
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
<string name="zen_mode_when">Automatically turn on</string>
<!-- [CHAR LIMIT=20] Zen mode settings: When option value: Never -->
<string name="zen_mode_when_never">Never</string>
<!-- [CHAR LIMIT=20] Zen mode settings: When option value: Every night -->
<string name="zen_mode_when_every_night">Every night</string>
<!-- [CHAR LIMIT=20] Zen mode settings: When option value: Weeknights -->
<string name="zen_mode_when_weeknights">Weeknights</string>
<!-- [CHAR LIMIT=20] Zen mode settings: Start time option -->
<string name="zen_mode_start_time">Start time</string>
<!-- [CHAR LIMIT=20] Zen mode settings: End time option -->
<string name="zen_mode_end_time">End time</string>
<!-- [CHAR LIMIT=60] Zen mode settings: End time option: Summary text value format when end time = next day -->
<string name="zen_mode_end_time_next_day_summary_format"><xliff:g id="formatted_time" example="7:00 AM">%s</xliff:g> next day</string>
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only forever. -->
<string name="zen_mode_summary_alarms_only_indefinite">Change to alarms only indefinitely</string>
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only for < 60 minutes. -->
<plurals name="zen_mode_summary_alarms_only_by_minute">
<item quantity="one">Change to alarms only for one minute until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
<item quantity="other">Change to alarms only for <xliff:g id="duration" example="2">%1$d</xliff:g> minutes (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item>
</plurals>
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only for N hours. -->
<plurals name="zen_mode_summary_alarms_only_by_hour">
<item quantity="one">Change to alarms only for one hour until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
<item quantity="other">Change to alarms only for <xliff:g id="duration" example="2">%1$d</xliff:g> hours until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g></item>
</plurals>
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: switch to alarms only until a specific time. -->
<string name="zen_mode_summary_alarms_only_by_time">Change to alarms only until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g></string>
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: Turn on all notifications. -->
<string name="zen_mode_summary_always">Change to always interrupt</string>

View File

@@ -26,7 +26,6 @@
android:title="@string/zen_mode_settings_title"
android:selectable="false"
android:layout="@layout/zen_mode_settings_button"
settings:allowDividerAbove="true"
settings:allowDividerBelow="true"
settings:keywords="@string/keywords_zen_mode_settings"/>
@@ -55,26 +54,26 @@
<!-- Automatic rules -->
<Preference
android:key="zen_mode_automation_settings"
android:title="@string/zen_mode_automation_settings_title"
android:title="@string/zen_category_schedule"
settings:allowDividerAbove="true"
settings:allowDividerBelow="true"
android:fragment="com.android.settings.notification.zen.ZenModeAutomationSettings"/>
<PreferenceCategory
android:key="zen_mode_settings_advanced"
settings:initialExpandedChildrenCount="1">
settings:initialExpandedChildrenCount="0">
<!-- DND duration settings -->
<com.android.settings.notification.zen.ZenDurationDialogPreference
android:key="zen_mode_duration_settings"
android:title="@string/zen_category_duration"
android:widgetLayout="@null"/>
<!-- 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.zen.ZenModeRestrictNotificationsSettings" />
<!-- DND duration settings -->
<com.android.settings.notification.zen.ZenDurationDialogPreference
android:key="zen_mode_duration_settings"
android:title="@string/zen_mode_duration_settings_title"
android:widgetLayout="@null"/>
</PreferenceCategory>
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->

View File

@@ -1,19 +1,53 @@
package com.android.settings.notification.zen;
import android.app.Application;
import android.app.NotificationChannel;
import android.content.Context;
import android.os.UserHandle;
import android.icu.text.ListFormatter;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.core.text.BidiFormatter;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeBypassingAppsPreferenceController extends AbstractZenModePreferenceController {
import java.util.ArrayList;
import java.util.List;
/**
* Controls the summary for preference found at:
* Settings > Sound > Do Not Disturb > Apps
*/
public class ZenModeBypassingAppsPreferenceController extends AbstractZenModePreferenceController
implements PreferenceControllerMixin {
protected static final String KEY = "zen_mode_behavior_apps";
@VisibleForTesting protected Preference mPreference;
private ApplicationsState.Session mAppSession;
private NotificationBackend mNotificationBackend = new NotificationBackend();
public ZenModeBypassingAppsPreferenceController(Context context, Lifecycle lifecycle) {
private String mSummary;
public ZenModeBypassingAppsPreferenceController(Context context, Application app,
Fragment host, Lifecycle lifecycle) {
this(context, app == null ? null : ApplicationsState.getInstance(app), host, lifecycle);
}
private ZenModeBypassingAppsPreferenceController(Context context, ApplicationsState appState,
Fragment host, Lifecycle lifecycle) {
super(context, KEY, lifecycle);
if (appState != null && host != null) {
mAppSession = appState.newSession(mAppSessionCallbacks, host.getLifecycle());
}
}
@Override
@@ -22,13 +56,125 @@ public class ZenModeBypassingAppsPreferenceController extends AbstractZenModePre
}
@Override
public String getSummary() {
final int channelsBypassing =
mNotificationBackend.getNumAppsBypassingDnd(UserHandle.getCallingUserId());
if (channelsBypassing == 0) {
return mContext.getResources().getString(R.string.zen_mode_bypassing_apps_subtext_none);
}
return mContext.getResources().getQuantityString(R.plurals.zen_mode_bypassing_apps_subtext,
channelsBypassing, channelsBypassing);
public String getPreferenceKey() {
return KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
mPreference = screen.findPreference(KEY);
updateAppsBypassingDndSummaryText();
super.displayPreference(screen);
}
@Override
public String getSummary() {
return mSummary;
}
private void updateAppsBypassingDndSummaryText() {
if (mAppSession == null) {
return;
}
ApplicationsState.AppFilter filter = ApplicationsState.FILTER_ALL_ENABLED;
List<ApplicationsState.AppEntry> apps = mAppSession.rebuild(filter,
ApplicationsState.ALPHA_COMPARATOR);
updateAppsBypassingDndSummaryText(apps);
}
@VisibleForTesting
void updateAppsBypassingDndSummaryText(List<ApplicationsState.AppEntry> apps) {
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
// users cannot change their DND settings when an app puts the device total
// silence or alarms only (both deprecated) modes
mPreference.setEnabled(false);
mSummary = mContext.getResources().getString(
R.string.zen_mode_bypassing_apps_subtext_none);
return;
default:
mPreference.setEnabled(true);
}
if (apps == null) {
return;
}
List<String> appsBypassingDnd = new ArrayList<>();
for (ApplicationsState.AppEntry entry : apps) {
String pkg = entry.info.packageName;
for (NotificationChannel channel : mNotificationBackend
.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
if (!TextUtils.isEmpty(channel.getConversationId())) {
// conversation channels that bypass dnd will be shown on the People page
continue;
}
appsBypassingDnd.add(BidiFormatter.getInstance().unicodeWrap(entry.label));
continue;
}
}
if (appsBypassingDnd.size() == 0) {
mSummary = mContext.getResources().getString(
R.string.zen_mode_bypassing_apps_subtext_none);
refreshSummary(mPreference);
return;
}
List<String> displayAppsBypassing = new ArrayList<>();
if (appsBypassingDnd.size() <= 2) {
displayAppsBypassing = appsBypassingDnd;
} else {
displayAppsBypassing.add(appsBypassingDnd.get(0));
displayAppsBypassing.add(appsBypassingDnd.get(1));
displayAppsBypassing.add(mContext.getResources().getString(
R.string.zen_mode_apps_bypassing_list_count,
appsBypassingDnd.size() - 2));
}
mSummary = mContext.getResources().getQuantityString(
R.plurals.zen_mode_bypassing_apps_subtext,
appsBypassingDnd.size(),
ListFormatter.getInstance().format(displayAppsBypassing));
refreshSummary(mPreference);
}
private final ApplicationsState.Callbacks mAppSessionCallbacks =
new ApplicationsState.Callbacks() {
@Override
public void onRunningStateChanged(boolean running) {
updateAppsBypassingDndSummaryText();
}
@Override
public void onPackageListChanged() {
updateAppsBypassingDndSummaryText();
}
@Override
public void onRebuildComplete(ArrayList<ApplicationsState.AppEntry> apps) {
updateAppsBypassingDndSummaryText(apps);
}
@Override
public void onPackageIconChanged() { }
@Override
public void onPackageSizeChanged(String packageName) {
updateAppsBypassingDndSummaryText();
}
@Override
public void onAllSizesComputed() { }
@Override
public void onLauncherInfoChanged() { }
@Override
public void onLoadEntriesCompleted() {
updateAppsBypassingDndSummaryText();
}
};
}

View File

@@ -16,25 +16,33 @@
package com.android.settings.notification.zen;
import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
import android.app.NotificationManager;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
/**
* Controls the summary for preference found at:
* Settings > Sound > Do Not Disturb > People
*/
public class ZenModePeoplePreferenceController extends
AbstractZenModePreferenceController implements PreferenceControllerMixin {
private final String KEY;
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
public ZenModePeoplePreferenceController(Context context, Lifecycle lifecycle, String key) {
super(context, key, lifecycle);
KEY = key;
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
}
@Override
@@ -60,8 +68,28 @@ public class ZenModePeoplePreferenceController extends
break;
default:
preference.setEnabled(true);
// TODO: How do all of the people options roll up into the summary?
//preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
preference.setSummary(getPeopleSummary());
}
}
private String getPeopleSummary() {
final int callersAllowed = mBackend.getPriorityCallSenders();
final int messagesAllowed = mBackend.getPriorityMessageSenders();
final int conversationsAllowed = mBackend.getPriorityConversationSenders();
final boolean areRepeatCallersAllowed =
mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_REPEAT_CALLERS);
if (callersAllowed == PRIORITY_SENDERS_ANY
&& messagesAllowed == PRIORITY_SENDERS_ANY
&& conversationsAllowed == CONVERSATION_SENDERS_ANYONE) {
return mContext.getResources().getString(R.string.zen_mode_people_all);
} else if (callersAllowed == ZenModeBackend.SOURCE_NONE
&& messagesAllowed == ZenModeBackend.SOURCE_NONE
&& conversationsAllowed == CONVERSATION_SENDERS_NONE
&& !areRepeatCallersAllowed) {
return mContext.getResources().getString(R.string.zen_mode_people_none);
} else {
return mContext.getResources().getString(R.string.zen_mode_people_some);
}
}
}

View File

@@ -25,15 +25,19 @@ 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.Activity;
import android.app.Application;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
import android.app.NotificationManager.Policy;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.icu.text.ListFormatter;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
@@ -67,7 +71,9 @@ public class ZenModeSettings extends ZenModeSettingsBase {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPreferenceControllers(context, getSettingsLifecycle(), getFragmentManager());
final Activity activity = getActivity();
return buildPreferenceControllers(context, getSettingsLifecycle(), getFragmentManager(),
activity != null ? activity.getApplication() : null, this);
}
@Override
@@ -76,15 +82,19 @@ public class ZenModeSettings extends ZenModeSettingsBase {
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle, FragmentManager fragmentManager) {
Lifecycle lifecycle, FragmentManager fragmentManager, Application app,
Fragment fragment) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new ZenModeButtonPreferenceController(context, lifecycle, fragmentManager));
controllers.add(new ZenModePeoplePreferenceController(context, lifecycle,
"zen_mode_behavior_people"));
controllers.add(new ZenModeBypassingAppsPreferenceController(context, lifecycle));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
controllers.add(new ZenModeBypassingAppsPreferenceController(context, app,
fragment, lifecycle));
controllers.add(new ZenModeSoundVibrationPreferenceController(context, lifecycle,
"zen_sound_vibration_settings"));
controllers.add(new ZenModeAutomationPreferenceController(context));
controllers.add(new ZenModeButtonPreferenceController(context, lifecycle, fragmentManager));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeSettingsFooterPreferenceController(context, lifecycle,
fragmentManager));
return controllers;
@@ -110,29 +120,34 @@ public class ZenModeSettings extends ZenModeSettingsBase {
PRIORITY_CATEGORY_REPEAT_CALLERS,
};
String getSoundSettingSummary(Policy policy) {
List<String> enabledCategories = getEnabledCategories(policy,
String getOtherSoundCategoriesSummary(Policy policy) {
List<String> enabledCategories = getEnabledCategories(
policy,
category -> PRIORITY_CATEGORY_ALARMS == category
|| PRIORITY_CATEGORY_MEDIA == category
|| PRIORITY_CATEGORY_SYSTEM == category, false);
|| PRIORITY_CATEGORY_SYSTEM == category
|| PRIORITY_CATEGORY_REMINDERS == category
|| PRIORITY_CATEGORY_EVENTS == category,
true);
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));
} else if (numCategories == 2) {
return mContext.getString(R.string.zen_sound_two_allowed,
enabledCategories.get(0),
enabledCategories.get(1));
} else if (numCategories == 3) {
return mContext.getString(R.string.zen_sound_three_allowed,
enabledCategories.get(0),
enabledCategories.get(1),
enabledCategories.get(2));
} else {
return mContext.getString(R.string.zen_sound_none_muted);
return mContext.getResources().getString(R.string.zen_mode_other_sounds_none);
}
List<String> displayCategories = new ArrayList<>();
if (numCategories <= 2) {
displayCategories = enabledCategories;
} else {
displayCategories.add(enabledCategories.get(0));
displayCategories.add(enabledCategories.get(1));
displayCategories.add(mContext.getString(R.string.zen_mode_other_sounds_list_count,
numCategories - 2));
}
return mContext.getResources().getQuantityString(
R.plurals.zen_mode_other_sounds_summary,
numCategories /* quantity */,
ListFormatter.getInstance().format(displayCategories));
}
String getCallsSettingSummary(Policy policy) {
@@ -322,7 +337,8 @@ public class ZenModeSettings extends ZenModeSettingsBase {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(Context
context) {
return buildPreferenceControllers(context, null, null);
return buildPreferenceControllers(context, null, null,
null, null);
}
};
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2020 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.zen;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
/**
* Controls the summary for preference found at:
* Settings > Sound > Do Not Disturb > Alarms & other interruptions
*/
public class ZenModeSoundVibrationPreferenceController extends
AbstractZenModePreferenceController implements PreferenceControllerMixin {
private final String mKey;
private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
public ZenModeSoundVibrationPreferenceController(Context context, Lifecycle lifecycle,
String key) {
super(context, key, lifecycle);
mKey = key;
mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
}
@Override
public String getPreferenceKey() {
return mKey;
}
@Override
public boolean isAvailable() {
return true;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
preference.setEnabled(false);
preference.setSummary(mContext.getString(R.string.zen_mode_other_sounds_none));
break;
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
preference.setSummary(mContext.getString(R.string.zen_mode_behavior_alarms_only));
break;
default:
preference.setEnabled(true);
preference.setSummary(mSummaryBuilder.getOtherSoundCategoriesSummary(getPolicy()));
}
}
}

View File

@@ -21,14 +21,17 @@ import android.content.Context;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
/**
* Settings > Sound > Do Not Disturb > Alarms & Other Interruptions
*/
@SearchIndexable
public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implements Indexable {
@@ -40,10 +43,6 @@ public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implement
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
"zen_mode_calls_settings"));
controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
"zen_mode_messages_settings"));
controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
"zen_mode_alarms"));
controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
@@ -52,7 +51,6 @@ public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implement
controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
R.string.zen_sound_footer));
controllers.add(new ZenModeBypassingAppsPreferenceController(context, lifecycle));
return controllers;
}

View File

@@ -18,16 +18,23 @@ package com.android.settings.notification.zen;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.app.NotificationChannel;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ParceledListSlice;
import android.provider.Settings;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
import com.android.settings.notification.zen.ZenModeBypassingAppsPreferenceController;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,6 +44,9 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class ZenModeBypassingAppsPreferenceControllerTest {
@@ -45,30 +55,156 @@ public class ZenModeBypassingAppsPreferenceControllerTest {
private Context mContext;
@Mock
private NotificationBackend mBackend;
private int mPreviousZenSetting;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new ZenModeBypassingAppsPreferenceController(mContext, mock(Lifecycle.class));
mController = new ZenModeBypassingAppsPreferenceController(
mContext, null, mock(Fragment.class), mock(Lifecycle.class));
mController.mPreference = new Preference(mContext);
mPreviousZenSetting =
Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_OFF);
ReflectionHelpers.setField(mController, "mNotificationBackend", mBackend);
}
@After
public void tearDown() {
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
mPreviousZenSetting);
}
@Test
public void testIsAvailable() {
when(mBackend.getNumAppsBypassingDnd(anyInt())).thenReturn(5);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void testNotAvailable() {
when(mBackend.getNumAppsBypassingDnd(anyInt())).thenReturn(0);
assertThat(mController.isAvailable()).isFalse();
public void testUpdateBypassingApps() {
// GIVEN DND is off
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_OFF);
// mock app list
ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
entry.info = new ApplicationInfo();
entry.info.packageName = "test";
entry.label = "test";
entry.info.uid = 0;
List<ApplicationsState.AppEntry> appEntries = new ArrayList<>();
appEntries.add(entry);
List<NotificationChannel> channelsBypassing = new ArrayList<>();
channelsBypassing.add(mock(NotificationChannel.class));
when(mBackend.getNotificationChannelsBypassingDnd(entry.info.packageName,
entry.info.uid)).thenReturn(new ParceledListSlice<>(channelsBypassing));
// WHEN a single app is passed to the controller
mController.updateAppsBypassingDndSummaryText(appEntries);
// THEN the preference is enabled and the summary contains the app name from the list
assertThat(mController.mPreference.isEnabled()).isTrue();
assertThat(mController.getSummary().contains(entry.label)).isTrue();
}
@Test
public void testHasSummary() {
assertThat(mController.getSummary()).isNotNull();
public void testUpdateBypassingApps_multipleApps() {
// GIVEN DND is off
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_OFF);
// mock app list
ApplicationsState.AppEntry entry1 = mock(ApplicationsState.AppEntry.class);
entry1.info = new ApplicationInfo();
entry1.info.packageName = "test1";
entry1.label = "test1";
entry1.info.uid = 1;
ApplicationsState.AppEntry entry2 = mock(ApplicationsState.AppEntry.class);
entry2.info = new ApplicationInfo();
entry2.info.packageName = "test2";
entry2.label = "test2";
entry2.info.uid = 2;
List<ApplicationsState.AppEntry> appEntries = new ArrayList<>();
appEntries.add(entry1);
appEntries.add(entry2);
List<NotificationChannel> channelsBypassing = new ArrayList<>();
channelsBypassing.add(mock(NotificationChannel.class));
when(mBackend.getNotificationChannelsBypassingDnd(entry1.info.packageName,
entry1.info.uid)).thenReturn(new ParceledListSlice<>(channelsBypassing));
when(mBackend.getNotificationChannelsBypassingDnd(entry2.info.packageName,
entry2.info.uid)).thenReturn(new ParceledListSlice<>(channelsBypassing));
// WHEN a list of apps is passed to the controller
mController.updateAppsBypassingDndSummaryText(appEntries);
// THEN the preference is enabled and the summary contains the app names from the list
assertThat(mController.mPreference.isEnabled()).isTrue();
assertThat(mController.getSummary().contains(entry1.label)).isTrue();
assertThat(mController.getSummary().contains(entry2.label)).isTrue();
}
@Test
public void testUpdateAppsBypassingDnd_nullAppsList() {
// GIVEN DND is off
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_OFF);
// WHEN the list of apps is null
mController.updateAppsBypassingDndSummaryText(null);
// THEN the preference is enabled and summary is unchanged (in this case, null)
assertThat(mController.mPreference.isEnabled()).isTrue();
assertThat(mController.getSummary()).isNull();
}
@Test
public void testUpdateAppsBypassingDnd_emptyAppsList() {
// GIVEN the DND is off
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_OFF);
// WHEN the list of apps is an empty list
mController.updateAppsBypassingDndSummaryText(new ArrayList<>());
// THEN the preference is enabled and summary is updated
assertThat(mController.mPreference.isEnabled()).isTrue();
assertThat(mController.getSummary().contains("No apps")).isTrue();
}
@Test
public void testUpdateAppsBypassingDnd_alarmsOnly() {
// GIVEN alarms only DND mode
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ZEN_MODE,
Settings.Global.ZEN_MODE_ALARMS);
// mock app entries
ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
entry.info = new ApplicationInfo();
entry.info.packageName = "test";
entry.label = "test";
entry.info.uid = 0;
List<ApplicationsState.AppEntry> appEntries = new ArrayList<>();
appEntries.add(entry);
List<NotificationChannel> channelsBypassing = new ArrayList<>();
channelsBypassing.add(mock(NotificationChannel.class));
when(mBackend.getNotificationChannelsBypassingDnd(entry.info.packageName,
entry.info.uid)).thenReturn(new ParceledListSlice<>(channelsBypassing));
// WHEN we update apps bypassing dnd summary text
mController.updateAppsBypassingDndSummaryText(appEntries);
// THEN the preference is disabled and the summary says no apps can bypass
assertThat(mController.mPreference.isEnabled()).isFalse();
assertThat(mController.getSummary().contains("No apps")).isTrue();
}
}

View File

@@ -97,34 +97,6 @@ public class ZenModeSettingsTest {
.isEqualTo("Allow 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