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 22 import com.android.settings.R; 23 import com.android.settings.notification.NotificationBackend; 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 * Settings > Sound > Do Not Disturb > Conversations 34 */ 35 @SearchIndexable 36 public class ZenModeConversationsSettings extends ZenModeSettingsBase { 37 private final NotificationBackend mNotificationBackend = new NotificationBackend(); 38 39 @Override createPreferenceControllers(Context context)40 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 41 return buildPreferenceControllers(context, getSettingsLifecycle(), mNotificationBackend); 42 } 43 buildPreferenceControllers(Context context, Lifecycle lifecycle, NotificationBackend notificationBackend)44 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 45 Lifecycle lifecycle, NotificationBackend notificationBackend) { 46 List<AbstractPreferenceController> controllers = new ArrayList<>(); 47 controllers.add(new ZenModeConversationsImagePreferenceController(context, 48 "zen_mode_conversations_image", lifecycle, notificationBackend)); 49 controllers.add(new ZenModePriorityConversationsPreferenceController(context, 50 "zen_mode_conversations_radio_buttons", lifecycle, notificationBackend)); 51 return controllers; 52 } 53 54 @Override getPreferenceScreenResId()55 protected int getPreferenceScreenResId() { 56 return R.xml.zen_mode_conversations_settings; 57 } 58 59 @Override getMetricsCategory()60 public int getMetricsCategory() { 61 return SettingsEnums.DND_CONVERSATIONS; 62 } 63 64 /** 65 * For Search. 66 */ 67 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 68 new BaseSearchIndexProvider(R.xml.zen_mode_conversations_settings) { 69 70 @Override 71 public List<AbstractPreferenceController> createPreferenceControllers( 72 Context context) { 73 return buildPreferenceControllers(context, null, null); 74 } 75 }; 76 } 77