Files
packages_apps_Settings/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
Beverly bd775d9f62 ZenModeBackend gets newest notification policy
Previously, notification policy wouldn't be updated
so behavior zen mode settings pages wouldn't update
when an app changed the notification policy.  Now
notification policy will be updated on updateState of
each AbstractZenModePreferenceController.

Bug: 70662324
Test: make RunSettingsRoboTests -j40
Change-Id: Ibee20e4f27e0c833e05230ea8a3ea2cc75ae6bf0
2017-12-14 15:59:46 -05:00

45 lines
1.3 KiB
Java

package com.android.settings.notification;
import android.app.NotificationManager;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeMessagesPreferenceController extends AbstractZenModePreferenceController {
protected static final String KEY = "zen_mode_messages";
public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY, lifecycle);
}
@Override
public String getPreferenceKey() {
return KEY;
}
@Override
public boolean isAvailable() {
return true;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
switch (getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
preference.setSummary(mBackend.getContactsSummary(mBackend.SOURCE_NONE));
break;
default:
preference.setEnabled(true);
preference.setSummary(mBackend.getContactsSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
}
}
}