OSDN Git Service

[automerger skipped] Merge "Do not allow draw on top for App notification settings...
[android-x86/packages-apps-Settings.git] / src / com / android / settings / notification / ChannelNotificationSettings.java
1 /*
2  * Copyright (C) 2016 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.content.Intent;
22 import android.os.Bundle;
23 import android.preference.PreferenceManager;
24 import android.text.TextUtils;
25 import android.util.Log;
26
27 import androidx.preference.PreferenceScreen;
28
29 import com.android.internal.widget.LockPatternUtils;
30 import com.android.settings.R;
31 import com.android.settingslib.core.AbstractPreferenceController;
32
33 import java.util.ArrayList;
34 import java.util.List;
35
36 public class ChannelNotificationSettings extends NotificationSettingsBase {
37     private static final String TAG = "ChannelSettings";
38
39     @Override
40     public int getMetricsCategory() {
41         return SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION;
42     }
43
44     @Override
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);
53             }
54         }
55     }
56
57     @Override
58     public void onResume() {
59         super.onResume();
60         if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
61             Log.w(TAG, "Missing package or uid or packageinfo or channel");
62             finish();
63             return;
64         }
65
66         for (NotificationPreferenceController controller : mControllers) {
67             controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
68             controller.displayPreference(getPreferenceScreen());
69         }
70         updatePreferenceStates();
71     }
72
73     @Override
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);
79             }
80         }
81     }
82
83     @Override
84     protected String getLogTag() {
85         return TAG;
86     }
87
88     @Override
89     protected int getPreferenceScreenResId() {
90         return  R.xml.channel_notification_settings;
91     }
92
93     @Override
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),
112                 mBackend));
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);
120     }
121 }