1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.notification; 18 19 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; 20 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE; 21 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; 22 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; 23 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; 24 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; 25 import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR; 26 27 import android.app.settings.SettingsEnums; 28 import android.content.Context; 29 import android.os.Bundle; 30 import android.provider.SearchIndexableResource; 31 32 import com.android.settings.R; 33 import com.android.settings.search.BaseSearchIndexProvider; 34 import com.android.settings.search.Indexable; 35 import com.android.settingslib.core.AbstractPreferenceController; 36 import com.android.settingslib.core.lifecycle.Lifecycle; 37 import com.android.settingslib.search.SearchIndexable; 38 39 import java.util.ArrayList; 40 import java.util.List; 41 42 @SearchIndexable 43 public class ZenModeBlockedEffectsSettings extends ZenModeSettingsBase implements Indexable { 44 45 @Override onCreate(Bundle icicle)46 public void onCreate(Bundle icicle) { 47 super.onCreate(icicle); 48 mFooterPreferenceMixin.createFooterPreference().setTitle( 49 R.string.zen_mode_blocked_effects_footer); 50 } 51 52 @Override createPreferenceControllers(Context context)53 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 54 return buildPreferenceControllers(context, getSettingsLifecycle()); 55 } 56 buildPreferenceControllers(Context context, Lifecycle lifecycle)57 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 58 Lifecycle lifecycle) { 59 List<AbstractPreferenceController> controllers = new ArrayList<>(); 60 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 61 "zen_effect_intent", SUPPRESSED_EFFECT_FULL_SCREEN_INTENT, 62 SettingsEnums.ACTION_ZEN_BLOCK_FULL_SCREEN_INTENTS, null)); 63 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 64 "zen_effect_light", SUPPRESSED_EFFECT_LIGHTS, 65 SettingsEnums.ACTION_ZEN_BLOCK_LIGHT, null)); 66 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 67 "zen_effect_peek", SUPPRESSED_EFFECT_PEEK, 68 SettingsEnums.ACTION_ZEN_BLOCK_PEEK, null)); 69 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 70 "zen_effect_status", SUPPRESSED_EFFECT_STATUS_BAR, 71 SettingsEnums.ACTION_ZEN_BLOCK_STATUS, 72 new int[] {SUPPRESSED_EFFECT_NOTIFICATION_LIST})); 73 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 74 "zen_effect_badge", SUPPRESSED_EFFECT_BADGE, 75 SettingsEnums.ACTION_ZEN_BLOCK_BADGE, null)); 76 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 77 "zen_effect_ambient", SUPPRESSED_EFFECT_AMBIENT, 78 SettingsEnums.ACTION_ZEN_BLOCK_AMBIENT, null)); 79 controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle, 80 "zen_effect_list", SUPPRESSED_EFFECT_NOTIFICATION_LIST, 81 SettingsEnums.ACTION_ZEN_BLOCK_NOTIFICATION_LIST, null)); 82 return controllers; 83 } 84 85 @Override getPreferenceScreenResId()86 protected int getPreferenceScreenResId() { 87 return R.xml.zen_mode_block_settings; 88 } 89 90 @Override getMetricsCategory()91 public int getMetricsCategory() { 92 return SettingsEnums.ZEN_WHAT_TO_BLOCK; 93 } 94 95 /** 96 * For Search. 97 */ 98 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 99 new BaseSearchIndexProvider() { 100 @Override 101 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 102 boolean enabled) { 103 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 104 105 final SearchIndexableResource sir = new SearchIndexableResource(context); 106 sir.xmlResId = R.xml.zen_mode_block_settings; 107 result.add(sir); 108 return result; 109 } 110 111 @Override 112 public List<AbstractPreferenceController> createPreferenceControllers(Context context) { 113 return buildPreferenceControllers(context, null); 114 } 115 }; 116 } 117