Merge "DO NOT MERGE DND settings redesign" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e9211d58d2
@@ -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 android.support.v7.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,13 +16,12 @@
|
||||
|
||||
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;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -30,14 +29,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 +50,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 android.support.v7.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 android.support.v7.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,91 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.
|
||||
@@ -29,7 +29,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Indexable {
|
||||
public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
@@ -39,23 +39,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
|
||||
@@ -75,7 +69,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;
|
||||
@@ -25,7 +34,6 @@ import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
@@ -39,17 +47,12 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
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
|
||||
@@ -75,7 +78,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));
|
||||
@@ -95,19 +100,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);
|
||||
@@ -193,22 +242,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(
|
||||
@@ -217,13 +263,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(
|
||||
@@ -240,10 +293,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,88 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
@@ -75,10 +75,12 @@ import com.android.settings.nfc.PaymentSettings;
|
||||
import com.android.settings.notification.ConfigureNotificationSettings;
|
||||
import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.notification.ZenModeAutomationSettings;
|
||||
import com.android.settings.notification.ZenModeBehaviorSettings;
|
||||
import com.android.settings.notification.ZenModeCallsSettings;
|
||||
import com.android.settings.notification.ZenModeMsgEventReminderSettings;
|
||||
import com.android.settings.notification.ZenModeBlockedEffectsSettings;
|
||||
import com.android.settings.notification.ZenModeRestrictNotificationsSettings;
|
||||
import com.android.settings.notification.ZenModeSettings;
|
||||
import com.android.settings.notification.ZenModeSoundVibrationSettings;
|
||||
import com.android.settings.print.PrintSettingsFragment;
|
||||
import com.android.settings.security.EncryptionAndCredential;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
@@ -178,7 +180,9 @@ public class SearchIndexableResourcesImpl implements SearchIndexableResources {
|
||||
addIndex(LockscreenDashboardFragment.class);
|
||||
addIndex(UsbDetailsFragment.class);
|
||||
addIndex(WifiDisplaySettings.class);
|
||||
addIndex(ZenModeBehaviorSettings.class);
|
||||
addIndex(ZenModeMsgEventReminderSettings.class);
|
||||
addIndex(ZenModeCallsSettings.class);
|
||||
addIndex(ZenModeSoundVibrationSettings.class);
|
||||
addIndex(ZenModeBlockedEffectsSettings.class);
|
||||
addIndex(ZenModeAutomationSettings.class);
|
||||
addIndex(ZenModeRestrictNotificationsSettings.class);
|
||||
|
Reference in New Issue
Block a user