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 static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES; 20 21 import android.content.Context; 22 import android.provider.SearchIndexableResource; 23 24 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 25 import com.android.settings.R; 26 import com.android.settings.search.BaseSearchIndexProvider; 27 import com.android.settings.search.Indexable; 28 import com.android.settingslib.core.AbstractPreferenceController; 29 import com.android.settingslib.core.lifecycle.Lifecycle; 30 31 import java.util.ArrayList; 32 import java.util.List; 33 34 public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable { 35 36 @Override createPreferenceControllers(Context context)37 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 38 return buildPreferenceControllers(context, getLifecycle()); 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 ZenModeEventsPreferenceController(context, lifecycle)); 45 controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle)); 46 controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle)); 47 controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle, 48 PRIORITY_CATEGORY_MESSAGES)); 49 controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle, 50 R.string.zen_msg_event_reminder_footer)); 51 return controllers; 52 } 53 54 @Override getPreferenceScreenResId()55 protected int getPreferenceScreenResId() { 56 return R.xml.zen_mode_msg_event_reminder_settings; 57 } 58 59 @Override getMetricsCategory()60 public int getMetricsCategory() { 61 return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY; 62 } 63 64 /** 65 * For Search. 66 */ 67 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 68 new BaseSearchIndexProvider() { 69 70 @Override 71 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 72 boolean enabled) { 73 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 74 75 final SearchIndexableResource sir = new SearchIndexableResource(context); 76 sir.xmlResId = R.xml.zen_mode_msg_event_reminder_settings; 77 result.add(sir); 78 return result; 79 } 80 81 @Override 82 public List<String> getNonIndexableKeys(Context context) { 83 final List<String> keys = super.getNonIndexableKeys(context); 84 return keys; 85 } 86 87 @Override 88 public List<AbstractPreferenceController> createPreferenceControllers(Context context) { 89 return buildPreferenceControllers(context, null); 90 } 91 }; 92 } 93