• 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.content.Context;
20 import android.provider.SearchIndexableResource;
21 
22 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
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 
29 import java.util.ArrayList;
30 import java.util.List;
31 
32 public class ZenModeSoundVibrationSettings extends ZenModeSettingsBase implements Indexable {
33 
34     @Override
createPreferenceControllers(Context context)35     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
36         return buildPreferenceControllers(context, getLifecycle());
37     }
38 
buildPreferenceControllers(Context context, Lifecycle lifecycle)39     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
40             Lifecycle lifecycle) {
41         List<AbstractPreferenceController> controllers = new ArrayList<>();
42         controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
43         controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
44         controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
45         controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
46                 R.string.zen_sound_footer));
47         return controllers;
48     }
49 
50     @Override
getPreferenceScreenResId()51     protected int getPreferenceScreenResId() {
52         return R.xml.zen_mode_sound_vibration_settings;
53     }
54 
55     @Override
getMetricsCategory()56     public int getMetricsCategory() {
57         return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
58     }
59 
60     /**
61      * For Search.
62      */
63     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
64             new BaseSearchIndexProvider() {
65 
66                 @Override
67                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
68                         boolean enabled) {
69                     final ArrayList<SearchIndexableResource> result = new ArrayList<>();
70 
71                     final SearchIndexableResource sir = new SearchIndexableResource(context);
72                     sir.xmlResId = R.xml.zen_mode_sound_vibration_settings;
73                     result.add(sir);
74                     return result;
75                 }
76 
77                 @Override
78                 public List<String> getNonIndexableKeys(Context context) {
79                     final List<String> keys = super.getNonIndexableKeys(context);
80                     return keys;
81                 }
82 
83             @Override
84             public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
85                 return buildPreferenceControllers(context, null);
86             }
87         };
88 }
89