• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.core.PreferenceController;
25 import com.android.settings.core.lifecycle.Lifecycle;
26 import com.android.settings.dashboard.DashboardFragment;
27 import com.android.settings.gestures.SwipeToNotificationPreferenceController;
28 import com.android.settings.search.BaseSearchIndexProvider;
29 import com.android.settings.search.Indexable;
30 
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.List;
34 
35 public class ConfigureNotificationSettings extends DashboardFragment {
36     private static final String TAG = "ConfigNotiSettings";
37 
38     private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
39 
40     @Override
getMetricsCategory()41     public int getMetricsCategory() {
42         return MetricsEvent.CONFIGURE_NOTIFICATION;
43     }
44 
45     @Override
getLogTag()46     protected String getLogTag() {
47         return TAG;
48     }
49 
50     @Override
getPreferenceScreenResId()51     protected int getPreferenceScreenResId() {
52         return R.xml.configure_notification_settings;
53     }
54 
55     @Override
getPreferenceControllers(Context context)56     protected List<PreferenceController> getPreferenceControllers(Context context) {
57         return buildPreferenceControllers(context, getLifecycle());
58     }
59 
buildPreferenceControllers(Context context, Lifecycle lifecycle)60     private static List<PreferenceController> buildPreferenceControllers(Context context,
61             Lifecycle lifecycle) {
62         final List<PreferenceController> controllers = new ArrayList<>();
63         final BadgingNotificationPreferenceController badgeController =
64                 new BadgingNotificationPreferenceController(context);
65         final PulseNotificationPreferenceController pulseController =
66                 new PulseNotificationPreferenceController(context);
67         final LockScreenNotificationPreferenceController lockScreenNotificationController =
68                 new LockScreenNotificationPreferenceController(context,
69                         "lock_screen_notifications",
70                         "lock_screen_notifications_profile_header",
71                         "lock_screen_notifications_profile");
72         if (lifecycle != null) {
73             lifecycle.addObserver(pulseController);
74             lifecycle.addObserver(lockScreenNotificationController);
75         }
76         controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle,
77                 KEY_SWIPE_DOWN));
78         controllers.add(badgeController);
79         controllers.add(pulseController);
80         controllers.add(lockScreenNotificationController);
81         return controllers;
82     }
83 
84     /**
85      * For Search.
86      */
87     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
88             new BaseSearchIndexProvider() {
89                 @Override
90                 public List<SearchIndexableResource> getXmlResourcesToIndex(
91                         Context context, boolean enabled) {
92                     final SearchIndexableResource sir = new SearchIndexableResource(context);
93                     sir.xmlResId = R.xml.configure_notification_settings;
94                     return Arrays.asList(sir);
95                 }
96 
97                 @Override
98                 public List<PreferenceController> getPreferenceControllers(Context context) {
99                     return buildPreferenceControllers(context, null);
100                 }
101             };
102 }
103