• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.zen;
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 
31 import com.android.settings.R;
32 import com.android.settings.search.BaseSearchIndexProvider;
33 import com.android.settingslib.core.AbstractPreferenceController;
34 import com.android.settingslib.core.lifecycle.Lifecycle;
35 import com.android.settingslib.search.Indexable;
36 import com.android.settingslib.search.SearchIndexable;
37 
38 import java.util.ArrayList;
39 import java.util.List;
40 
41 @SearchIndexable
42 public class ZenModeBlockedEffectsSettings extends ZenModeSettingsBase implements Indexable {
43 
44     @Override
onCreate(Bundle icicle)45     public void onCreate(Bundle icicle) {
46         super.onCreate(icicle);
47     }
48 
49     @Override
createPreferenceControllers(Context context)50     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
51         return buildPreferenceControllers(context, getSettingsLifecycle());
52     }
53 
buildPreferenceControllers(Context context, Lifecycle lifecycle)54     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
55             Lifecycle lifecycle) {
56         List<AbstractPreferenceController> controllers = new ArrayList<>();
57         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
58                 "zen_effect_intent", SUPPRESSED_EFFECT_FULL_SCREEN_INTENT,
59                 SettingsEnums.ACTION_ZEN_BLOCK_FULL_SCREEN_INTENTS, null));
60         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
61                 "zen_effect_light", SUPPRESSED_EFFECT_LIGHTS,
62                 SettingsEnums.ACTION_ZEN_BLOCK_LIGHT, null));
63         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
64                 "zen_effect_peek", SUPPRESSED_EFFECT_PEEK,
65                 SettingsEnums.ACTION_ZEN_BLOCK_PEEK, null));
66         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
67                 "zen_effect_status", SUPPRESSED_EFFECT_STATUS_BAR,
68                 SettingsEnums.ACTION_ZEN_BLOCK_STATUS,
69                 new int[] {SUPPRESSED_EFFECT_NOTIFICATION_LIST}));
70         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
71                 "zen_effect_badge", SUPPRESSED_EFFECT_BADGE,
72                 SettingsEnums.ACTION_ZEN_BLOCK_BADGE, null));
73         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
74                 "zen_effect_ambient", SUPPRESSED_EFFECT_AMBIENT,
75                 SettingsEnums.ACTION_ZEN_BLOCK_AMBIENT, null));
76         controllers.add(new ZenModeVisEffectPreferenceController(context, lifecycle,
77                 "zen_effect_list", SUPPRESSED_EFFECT_NOTIFICATION_LIST,
78                 SettingsEnums.ACTION_ZEN_BLOCK_NOTIFICATION_LIST, null));
79         return controllers;
80     }
81 
82     @Override
getPreferenceScreenResId()83     protected int getPreferenceScreenResId() {
84         return R.xml.zen_mode_block_settings;
85     }
86 
87     @Override
getMetricsCategory()88     public int getMetricsCategory() {
89         return SettingsEnums.ZEN_WHAT_TO_BLOCK;
90     }
91 
92     /**
93      * For Search.
94      */
95     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
96             new BaseSearchIndexProvider(R.xml.zen_mode_block_settings) {
97 
98             @Override
99             public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
100                 return buildPreferenceControllers(context, null);
101             }
102         };
103 }
104