2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.notification;
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.os.Bundle;
23 import android.preference.PreferenceManager;
24 import android.text.TextUtils;
25 import android.util.Log;
27 import androidx.preference.PreferenceScreen;
29 import com.android.internal.widget.LockPatternUtils;
30 import com.android.settings.R;
31 import com.android.settingslib.core.AbstractPreferenceController;
33 import java.util.ArrayList;
34 import java.util.List;
36 public class ChannelNotificationSettings extends NotificationSettingsBase {
37 private static final String TAG = "ChannelSettings";
40 public int getMetricsCategory() {
41 return SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION;
45 public void onCreate(Bundle savedInstanceState) {
46 super.onCreate(savedInstanceState);
47 final PreferenceScreen screen = getPreferenceScreen();
48 Bundle args = getArguments();
49 // If linking to this screen from an external app, expand settings
50 if (screen != null && args != null) {
51 if (!args.getBoolean(ARG_FROM_SETTINGS, false)) {
52 screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
58 public void onResume() {
60 if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
61 Log.w(TAG, "Missing package or uid or packageinfo or channel");
66 for (NotificationPreferenceController controller : mControllers) {
67 controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
68 controller.displayPreference(getPreferenceScreen());
70 updatePreferenceStates();
74 public void onActivityResult(int requestCode, int resultCode, Intent data) {
75 for (NotificationPreferenceController controller : mControllers) {
76 if (controller instanceof PreferenceManager.OnActivityResultListener) {
77 ((PreferenceManager.OnActivityResultListener) controller)
78 .onActivityResult(requestCode, resultCode, data);
84 protected String getLogTag() {
89 protected int getPreferenceScreenResId() {
90 return R.xml.channel_notification_settings;
94 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
95 mControllers = new ArrayList<>();
96 mControllers.add(new HeaderPreferenceController(context, this));
97 mControllers.add(new BlockPreferenceController(context, mImportanceListener, mBackend));
98 mControllers.add(new ImportancePreferenceController(
99 context, mImportanceListener, mBackend));
100 mControllers.add(new MinImportancePreferenceController(
101 context, mImportanceListener, mBackend));
102 mControllers.add(new HighImportancePreferenceController(
103 context, mImportanceListener, mBackend));
104 mControllers.add(new AllowSoundPreferenceController(
105 context, mImportanceListener, mBackend));
106 mControllers.add(new SoundPreferenceController(context, this,
107 mImportanceListener, mBackend));
108 mControllers.add(new VibrationPreferenceController(context, mBackend));
109 mControllers.add(new AppLinkPreferenceController(context));
110 mControllers.add(new DescriptionPreferenceController(context));
111 mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
113 mControllers.add(new LightsPreferenceController(context, mBackend));
114 mControllers.add(new BadgePreferenceController(context, mBackend));
115 mControllers.add(new DndPreferenceController(context, mBackend));
116 mControllers.add(new NotificationsOffPreferenceController(context));
117 mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
118 mBackend, false /* isAppPage */));
119 return new ArrayList<>(mControllers);