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.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.settingslib.core.AbstractPreferenceController; 26 import com.android.settingslib.core.lifecycle.Lifecycle; 27 import com.android.settingslib.search.SearchIndexable; 28 29 import java.util.ArrayList; 30 import java.util.List; 31 32 /** 33 * DND Calls Settings page to determine which priority senders can bypass DND. 34 */ 35 @SearchIndexable 36 public class ZenModeCallsSettings extends ZenModeSettingsBase { 37 38 @Override createPreferenceControllers(Context context)39 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 40 return buildPreferenceControllers(context, getSettingsLifecycle()); 41 } 42 buildPreferenceControllers(Context context, Lifecycle lifecycle)43 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 44 Lifecycle lifecycle) { 45 List<AbstractPreferenceController> controllers = new ArrayList<>(); 46 controllers.add(new ZenModePrioritySendersPreferenceController(context, 47 "zen_mode_settings_category_calls", lifecycle, false)); 48 controllers.add(new ZenModeSendersImagePreferenceController(context, 49 "zen_mode_calls_image", lifecycle, false)); 50 controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle, 51 context.getResources().getInteger(com.android.internal.R.integer 52 .config_zen_repeat_callers_threshold))); 53 controllers.add(new ZenModeBehaviorFooterPreferenceController( 54 context, lifecycle, R.string.zen_mode_calls_footer)); 55 return controllers; 56 } 57 58 @Override getPreferenceScreenResId()59 protected int getPreferenceScreenResId() { 60 return R.xml.zen_mode_calls_settings; 61 } 62 63 @Override getMetricsCategory()64 public int getMetricsCategory() { 65 return SettingsEnums.DND_CALLS; 66 } 67 68 /** 69 * For Search. 70 */ 71 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 72 new BaseSearchIndexProvider() { 73 @Override 74 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 75 boolean enabled) { 76 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 77 78 final SearchIndexableResource sir = new SearchIndexableResource(context); 79 sir.xmlResId = R.xml.zen_mode_calls_settings; 80 result.add(sir); 81 return result; 82 } 83 84 @Override 85 public List<AbstractPreferenceController> createPreferenceControllers( 86 Context context) { 87 return buildPreferenceControllers(context, null); 88 } 89 }; 90 } 91