ConfigureNotificationSettings.java revision 33b0d91d74bb29cbfd49e3f4c3ebd9d99001bfa9
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 17package com.android.settings.notification; 18 19import android.content.Context; 20import android.os.Bundle; 21 22import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 23import com.android.settings.R; 24import com.android.settings.core.PreferenceController; 25import com.android.settings.dashboard.DashboardFragment; 26import com.android.settings.gestures.SwipeToNotificationPreferenceController; 27import com.android.settings.overlay.FeatureFactory; 28 29import java.util.ArrayList; 30import java.util.List; 31 32public class ConfigureNotificationSettings extends DashboardFragment { 33 private static final String TAG = "ConfigNotiSettings"; 34 35 private LockScreenNotificationPreferenceController mLockScreenNotificationController; 36 37 @Override 38 public int getMetricsCategory() { 39 return MetricsEvent.CONFIGURE_NOTIFICATION; 40 } 41 42 @Override 43 protected String getCategoryKey() { 44 return ""; 45 } 46 47 @Override 48 protected String getLogTag() { 49 return TAG; 50 } 51 52 @Override 53 protected int getPreferenceScreenResId() { 54 return R.xml.configure_notification_settings; 55 } 56 57 @Override 58 protected List<PreferenceController> getPreferenceControllers(Context context) { 59 final List<PreferenceController> controllers = new ArrayList<>(); 60 final PulseNotificationPreferenceController pulseController = 61 new PulseNotificationPreferenceController(context); 62 mLockScreenNotificationController = new LockScreenNotificationPreferenceController(context); 63 getLifecycle().addObserver(pulseController); 64 getLifecycle().addObserver(mLockScreenNotificationController); 65 controllers.add(new SwipeToNotificationPreferenceController(context, getLifecycle())); 66 controllers.add(pulseController); 67 controllers.add(mLockScreenNotificationController); 68 return controllers; 69 } 70 71 @Override 72 public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { 73 super.onCreatePreferences(savedInstanceState, rootKey); 74 final Context context = getContext(); 75 if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context).isEnabled()) { 76 final String prefKey = getPreferenceController( 77 SwipeToNotificationPreferenceController.class) 78 .getPreferenceKey(); 79 removePreference(prefKey); 80 } 81 } 82} 83