• 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 android.app.Activity;
20 import android.app.Application;
21 import android.app.settings.SettingsEnums;
22 import android.content.Context;
23 
24 import androidx.fragment.app.Fragment;
25 
26 import com.android.settings.R;
27 import com.android.settings.notification.NotificationBackend;
28 import com.android.settingslib.core.AbstractPreferenceController;
29 import com.android.settingslib.search.Indexable;
30 
31 import java.util.ArrayList;
32 import java.util.List;
33 
34 public class ZenModeBypassingAppsSettings extends ZenModeSettingsBase implements
35         Indexable {
36     private final String TAG = "ZenBypassingApps";
37 
38     @Override
createPreferenceControllers(Context context)39     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
40         final Activity activity = getActivity();
41         final Application app;
42         if (activity != null) {
43             app = activity.getApplication();
44         } else {
45             app = null;
46         }
47         return buildPreferenceControllers(context, app, this, new NotificationBackend());
48     }
49 
buildPreferenceControllers(Context context, Application app, Fragment host, NotificationBackend notificationBackend)50     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
51             Application app, Fragment host, NotificationBackend notificationBackend) {
52         final List<AbstractPreferenceController> controllers = new ArrayList<>();
53         controllers.add(new ZenModeAllBypassingAppsPreferenceController(context, app, host,
54                 notificationBackend));
55         controllers.add(new ZenModeAddBypassingAppsPreferenceController(context, app, host,
56                 notificationBackend));
57         return controllers;
58     }
59 
60     @Override
getPreferenceScreenResId()61     protected int getPreferenceScreenResId() {
62         return R.xml.zen_mode_bypassing_apps;
63     }
64 
65     @Override
getLogTag()66     protected String getLogTag() {
67         return TAG;
68     }
69 
70     @Override
getMetricsCategory()71     public int getMetricsCategory() {
72         return SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APPS;
73     }
74 }
75