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.os.Bundle; 22 import android.provider.SearchIndexableResource; 23 24 import com.android.settings.R; 25 import com.android.settings.search.BaseSearchIndexProvider; 26 import com.android.settings.search.Indexable; 27 import com.android.settingslib.core.AbstractPreferenceController; 28 import com.android.settingslib.core.lifecycle.Lifecycle; 29 import com.android.settingslib.search.SearchIndexable; 30 import com.android.settingslib.widget.FooterPreference; 31 32 import java.util.ArrayList; 33 import java.util.List; 34 35 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) 36 public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase implements Indexable { 37 38 @Override onCreate(Bundle icicle)39 public void onCreate(Bundle icicle) { 40 super.onCreate(icicle); 41 } 42 43 @Override createPreferenceControllers(Context context)44 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 45 return buildPreferenceControllers(context, getSettingsLifecycle()); 46 } 47 48 @Override getHelpResource()49 public int getHelpResource() { 50 return R.string.help_uri_interruptions; 51 } 52 buildPreferenceControllers(Context context, Lifecycle lifecycle)53 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 54 Lifecycle lifecycle) { 55 List<AbstractPreferenceController> controllers = new ArrayList<>(); 56 controllers.add(new ZenModeVisEffectsNonePreferenceController( 57 context, lifecycle, "zen_mute_notifications")); 58 controllers.add(new ZenModeVisEffectsAllPreferenceController( 59 context, lifecycle, "zen_hide_notifications")); 60 controllers.add(new ZenModeVisEffectsCustomPreferenceController( 61 context, lifecycle, "zen_custom")); 62 controllers.add(new ZenFooterPreferenceController(context, lifecycle, 63 FooterPreference.KEY_FOOTER)); 64 return controllers; 65 } 66 67 @Override getPreferenceScreenResId()68 protected int getPreferenceScreenResId() { 69 return R.xml.zen_mode_restrict_notifications_settings; 70 } 71 72 @Override getMetricsCategory()73 public int getMetricsCategory() { 74 return SettingsEnums.SETTINGS_ZEN_NOTIFICATIONS; 75 } 76 77 /** 78 * For Search. 79 */ 80 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 81 new BaseSearchIndexProvider() { 82 @Override 83 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 84 boolean enabled) { 85 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 86 87 final SearchIndexableResource sir = new SearchIndexableResource(context); 88 sir.xmlResId = R.xml.zen_mode_restrict_notifications_settings; 89 result.add(sir); 90 return result; 91 } 92 93 @Override 94 public List<AbstractPreferenceController> createPreferenceControllers(Context context) { 95 return buildPreferenceControllers(context, null); 96 } 97 }; 98 } 99