• 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;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.provider.SearchIndexableResource;
22 
23 import com.android.settings.R;
24 import com.android.settings.search.BaseSearchIndexProvider;
25 import com.android.settings.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 
30 import java.util.ArrayList;
31 import java.util.List;
32 
33 @SearchIndexable
34 public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implements Indexable {
35 
36     @Override
createPreferenceControllers(Context context)37     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
38         return buildPreferenceControllers(context, getSettingsLifecycle());
39     }
40 
buildPreferenceControllers(Context context, Lifecycle lifecycle)41     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
42             Lifecycle lifecycle) {
43         List<AbstractPreferenceController> controllers = new ArrayList<>();
44         controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
45                 "zen_mode_calls_settings"));
46         controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
47                 "zen_mode_messages_settings"));
48         controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
49                 "zen_mode_alarms"));
50         controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
51         controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
52         controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
53         controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
54         controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
55                 R.string.zen_sound_footer));
56         controllers.add(new ZenModeBypassingAppsPreferenceController(context, lifecycle));
57         return controllers;
58     }
59 
60     @Override
getPreferenceScreenResId()61     protected int getPreferenceScreenResId() {
62         return R.xml.zen_mode_sound_vibration_settings;
63     }
64 
65     @Override
getMetricsCategory()66     public int getMetricsCategory() {
67         return SettingsEnums.NOTIFICATION_ZEN_MODE_PRIORITY;
68     }
69 
70     /**
71      * For Search.
72      */
73     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
74             new BaseSearchIndexProvider() {
75 
76                 @Override
77                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
78                         boolean enabled) {
79                     final ArrayList<SearchIndexableResource> result = new ArrayList<>();
80 
81                     final SearchIndexableResource sir = new SearchIndexableResource(context);
82                     sir.xmlResId = R.xml.zen_mode_sound_vibration_settings;
83                     result.add(sir);
84                     return result;
85                 }
86 
87                 @Override
88                 public List<String> getNonIndexableKeys(Context context) {
89                     final List<String> keys = super.getNonIndexableKeys(context);
90                     return keys;
91                 }
92 
93             @Override
94             public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
95                 return buildPreferenceControllers(context, null);
96             }
97         };
98 }
99