Loading res/xml/configure_notification_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,13 @@ android:title="@string/fingerprint_swipe_for_notifications_title" android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" /> <com.android.settingslib.RestrictedPreference android:key="zen_mode_notifications" android:title="@string/zen_mode_settings_title" settings:useAdminDisabledSummary="true" android:fragment="com.android.settings.notification.ZenModeSettings" settings:allowDividerAbove="false" /> <!-- Empty category to draw divider --> <PreferenceCategory android:key="all_notifications_divider" Loading src/com/android/settings/notification/ConfigureNotificationSettings.java +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications"; private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone"; private static final String KEY_ZEN_MODE = "zen_mode_notifications"; private RingtonePreference mRequestPreference; private static final int REQUEST_CODE = 200; Loading Loading @@ -117,6 +118,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { } }); controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE)); return controllers; } Loading Loading @@ -177,6 +179,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { keys.add(KEY_LOCKSCREEN); keys.add(KEY_LOCKSCREEN_WORK_PROFILE); keys.add(KEY_LOCKSCREEN_WORK_PROFILE_HEADER); keys.add(KEY_ZEN_MODE); return keys; } }; Loading src/com/android/settings/notification/SoundSettings.java +4 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class SoundSettings extends DashboardFragment { private static final String SELECTED_PREFERENCE_KEY = "selected_preference"; private static final int REQUEST_CODE = 200; private static final String KEY_ZEN_MODE = "zen_mode"; private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds Loading Loading @@ -180,7 +181,7 @@ public class SoundSettings extends DashboardFragment { SoundSettings fragment, VolumeSeekBarPreference.Callback callback, Lifecycle lifecycle) { final List<AbstractPreferenceController> controllers = new ArrayList<>(); controllers.add(new ZenModePreferenceController(context, lifecycle)); controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE)); controllers.add(new VibrateWhenRingPreferenceController(context)); // === Volumes === Loading Loading @@ -265,7 +266,8 @@ public class SoundSettings extends DashboardFragment { public List<String> getNonIndexableKeys(Context context) { List<String> keys = super.getNonIndexableKeys(context); // Duplicate results keys.add((new ZenModePreferenceController(context, null)).getPreferenceKey()); keys.add((new ZenModePreferenceController(context, null, KEY_ZEN_MODE)) .getPreferenceKey()); return keys; } }; Loading src/com/android/settings/notification/ZenModePreferenceController.java +5 −4 Original line number Diff line number Diff line Loading @@ -35,23 +35,24 @@ import com.android.settingslib.core.lifecycle.events.OnResume; public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenceController implements LifecycleObserver, OnResume, OnPause { private static final String KEY_ZEN_MODE = "zen_mode"; private final String mKey; private SettingObserver mSettingObserver; private ZenModeSettings.SummaryBuilder mSummaryBuilder; public ZenModePreferenceController(Context context, Lifecycle lifecycle) { public ZenModePreferenceController(Context context, Lifecycle lifecycle, String key) { super(context); mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context); if (lifecycle != null) { lifecycle.addObserver(this); } mKey = key; } @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mSettingObserver = new SettingObserver(screen.findPreference(KEY_ZEN_MODE)); mSettingObserver = new SettingObserver(screen.findPreference(mKey)); } @Override Loading @@ -70,7 +71,7 @@ public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenc @Override public String getPreferenceKey() { return KEY_ZEN_MODE; return mKey; } @Override Loading tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class ZenModePreferenceControllerTest { private Context mContext; private ZenModePreferenceController mController; private ZenModeSettings.SummaryBuilder mSummaryBuilder; private static final String KEY_ZEN_MODE = "zen_mode"; @Before public void setUp() { Loading @@ -60,7 +61,7 @@ public class ZenModePreferenceControllerTest { ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager); mContext = shadowApplication.getApplicationContext(); mController = new ZenModePreferenceController(mContext, null); mController = new ZenModePreferenceController(mContext, null, KEY_ZEN_MODE); when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy); mSummaryBuilder = spy(new ZenModeSettings.SummaryBuilder(mContext)); ReflectionHelpers.setField(mController, "mSummaryBuilder", mSummaryBuilder); Loading Loading
res/xml/configure_notification_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,13 @@ android:title="@string/fingerprint_swipe_for_notifications_title" android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" /> <com.android.settingslib.RestrictedPreference android:key="zen_mode_notifications" android:title="@string/zen_mode_settings_title" settings:useAdminDisabledSummary="true" android:fragment="com.android.settings.notification.ZenModeSettings" settings:allowDividerAbove="false" /> <!-- Empty category to draw divider --> <PreferenceCategory android:key="all_notifications_divider" Loading
src/com/android/settings/notification/ConfigureNotificationSettings.java +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications"; private static final String KEY_NOTI_DEFAULT_RINGTONE = "notification_default_ringtone"; private static final String KEY_ZEN_MODE = "zen_mode_notifications"; private RingtonePreference mRequestPreference; private static final int REQUEST_CODE = 200; Loading Loading @@ -117,6 +118,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { } }); controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE)); return controllers; } Loading Loading @@ -177,6 +179,7 @@ public class ConfigureNotificationSettings extends DashboardFragment { keys.add(KEY_LOCKSCREEN); keys.add(KEY_LOCKSCREEN_WORK_PROFILE); keys.add(KEY_LOCKSCREEN_WORK_PROFILE_HEADER); keys.add(KEY_ZEN_MODE); return keys; } }; Loading
src/com/android/settings/notification/SoundSettings.java +4 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class SoundSettings extends DashboardFragment { private static final String SELECTED_PREFERENCE_KEY = "selected_preference"; private static final int REQUEST_CODE = 200; private static final String KEY_ZEN_MODE = "zen_mode"; private static final int SAMPLE_CUTOFF = 2000; // manually cap sample playback at 2 seconds Loading Loading @@ -180,7 +181,7 @@ public class SoundSettings extends DashboardFragment { SoundSettings fragment, VolumeSeekBarPreference.Callback callback, Lifecycle lifecycle) { final List<AbstractPreferenceController> controllers = new ArrayList<>(); controllers.add(new ZenModePreferenceController(context, lifecycle)); controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE)); controllers.add(new VibrateWhenRingPreferenceController(context)); // === Volumes === Loading Loading @@ -265,7 +266,8 @@ public class SoundSettings extends DashboardFragment { public List<String> getNonIndexableKeys(Context context) { List<String> keys = super.getNonIndexableKeys(context); // Duplicate results keys.add((new ZenModePreferenceController(context, null)).getPreferenceKey()); keys.add((new ZenModePreferenceController(context, null, KEY_ZEN_MODE)) .getPreferenceKey()); return keys; } }; Loading
src/com/android/settings/notification/ZenModePreferenceController.java +5 −4 Original line number Diff line number Diff line Loading @@ -35,23 +35,24 @@ import com.android.settingslib.core.lifecycle.events.OnResume; public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenceController implements LifecycleObserver, OnResume, OnPause { private static final String KEY_ZEN_MODE = "zen_mode"; private final String mKey; private SettingObserver mSettingObserver; private ZenModeSettings.SummaryBuilder mSummaryBuilder; public ZenModePreferenceController(Context context, Lifecycle lifecycle) { public ZenModePreferenceController(Context context, Lifecycle lifecycle, String key) { super(context); mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context); if (lifecycle != null) { lifecycle.addObserver(this); } mKey = key; } @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mSettingObserver = new SettingObserver(screen.findPreference(KEY_ZEN_MODE)); mSettingObserver = new SettingObserver(screen.findPreference(mKey)); } @Override Loading @@ -70,7 +71,7 @@ public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenc @Override public String getPreferenceKey() { return KEY_ZEN_MODE; return mKey; } @Override Loading
tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public class ZenModePreferenceControllerTest { private Context mContext; private ZenModePreferenceController mController; private ZenModeSettings.SummaryBuilder mSummaryBuilder; private static final String KEY_ZEN_MODE = "zen_mode"; @Before public void setUp() { Loading @@ -60,7 +61,7 @@ public class ZenModePreferenceControllerTest { ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager); mContext = shadowApplication.getApplicationContext(); mController = new ZenModePreferenceController(mContext, null); mController = new ZenModePreferenceController(mContext, null, KEY_ZEN_MODE); when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy); mSummaryBuilder = spy(new ZenModeSettings.SummaryBuilder(mContext)); ReflectionHelpers.setField(mController, "mSummaryBuilder", mSummaryBuilder); Loading