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 android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.os.Bundle;
22 
23 import com.android.settings.R;
24 import com.android.settings.search.BaseSearchIndexProvider;
25 import com.android.settingslib.search.Indexable;
26 import com.android.settingslib.core.AbstractPreferenceController;
27 import com.android.settingslib.core.lifecycle.Lifecycle;
28 import com.android.settingslib.search.SearchIndexable;
29 import com.android.settingslib.widget.FooterPreference;
30 
31 import java.util.ArrayList;
32 import java.util.List;
33 
34 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
35 public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase implements Indexable {
36 
37     @Override
onCreate(Bundle icicle)38     public void onCreate(Bundle icicle) {
39         super.onCreate(icicle);
40     }
41 
42     @Override
createPreferenceControllers(Context context)43     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
44         return buildPreferenceControllers(context, getSettingsLifecycle());
45     }
46 
47     @Override
getHelpResource()48     public int getHelpResource() {
49         return R.string.help_uri_interruptions;
50     }
51 
buildPreferenceControllers(Context context, Lifecycle lifecycle)52     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
53             Lifecycle lifecycle) {
54         List<AbstractPreferenceController> controllers = new ArrayList<>();
55         controllers.add(new ZenModeVisEffectsNonePreferenceController(
56                 context, lifecycle, "zen_mute_notifications"));
57         controllers.add(new ZenModeVisEffectsAllPreferenceController(
58                 context, lifecycle, "zen_hide_notifications"));
59         controllers.add(new ZenModeVisEffectsCustomPreferenceController(
60                 context, lifecycle, "zen_custom"));
61         controllers.add(new ZenFooterPreferenceController(context, lifecycle,
62                 FooterPreference.KEY_FOOTER));
63         return controllers;
64     }
65 
66     @Override
getPreferenceScreenResId()67     protected int getPreferenceScreenResId() {
68         return R.xml.zen_mode_restrict_notifications_settings;
69     }
70 
71     @Override
getMetricsCategory()72     public int getMetricsCategory() {
73         return SettingsEnums.SETTINGS_ZEN_NOTIFICATIONS;
74     }
75 
76     /**
77      * For Search.
78      */
79     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
80             new BaseSearchIndexProvider(R.xml.zen_mode_restrict_notifications_settings) {
81 
82             @Override
83             public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
84                 return buildPreferenceControllers(context, null);
85             }
86         };
87 }
88