• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 import androidx.fragment.app.FragmentManager;
26 
27 import com.android.settings.R;
28 import com.android.settings.notification.NotificationBackend;
29 import com.android.settingslib.core.AbstractPreferenceController;
30 import com.android.settingslib.core.lifecycle.Lifecycle;
31 import com.android.settingslib.search.Indexable;
32 
33 import java.util.ArrayList;
34 import java.util.List;
35 
36 public class ZenModePeopleSettings extends ZenModeSettingsBase implements Indexable {
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(
48                 context, getSettingsLifecycle(), app, this, getFragmentManager(),
49                 new NotificationBackend());
50     }
51 
buildPreferenceControllers(Context context, Lifecycle lifecycle, Application app, Fragment host, FragmentManager fragmentManager, NotificationBackend notificationBackend)52     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
53             Lifecycle lifecycle, Application app, Fragment host, FragmentManager fragmentManager,
54             NotificationBackend notificationBackend) {
55         List<AbstractPreferenceController> controllers = new ArrayList<>();
56         controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
57                 "zen_mode_people_calls"));
58         controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
59                 "zen_mode_people_messages"));
60         controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
61                 R.string.zen_mode_people_footer));
62         return controllers;
63     }
64 
65     @Override
getPreferenceScreenResId()66     protected int getPreferenceScreenResId() {
67         return R.xml.zen_mode_people_settings;
68     }
69 
70     @Override
getMetricsCategory()71     public int getMetricsCategory() {
72         return SettingsEnums.DND_PEOPLE;
73     }
74 }
75