Link to dnd settings from notification settings
Test: make -j20 RunSettingsRoboTests Change-Id: Idf70155134b2e78bd410468497cabe8faf1557ce Fixes: 74319354
This commit is contained in:
@@ -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"
|
||||
|
@@ -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;
|
||||
@@ -117,6 +118,7 @@ public class ConfigureNotificationSettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
});
|
||||
controllers.add(new ZenModePreferenceController(context, lifecycle, KEY_ZEN_MODE));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
@@ -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
|
||||
|
||||
@@ -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 ===
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
@@ -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
|
||||
@@ -70,7 +71,7 @@ public class ZenModePreferenceController extends AdjustVolumeRestrictedPreferenc
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_ZEN_MODE;
|
||||
return mKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -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() {
|
||||
@@ -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);
|
||||
|
Reference in New Issue
Block a user