1 /* 2 * Copyright (C) 2020 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.app; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.preference.PreferenceManager; 23 import android.text.TextUtils; 24 import android.util.Log; 25 26 import com.android.internal.widget.LockPatternUtils; 27 import com.android.settings.R; 28 import com.android.settingslib.core.AbstractPreferenceController; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 33 public class ConversationNotificationSettings extends NotificationSettings { 34 private static final String TAG = "ConvoSettings"; 35 36 @Override getMetricsCategory()37 public int getMetricsCategory() { 38 return SettingsEnums.NOTIFICATION_CONVERSATION_SETTINGS; 39 } 40 41 @Override onResume()42 public void onResume() { 43 super.onResume(); 44 if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null 45 || mConversationInfo == null) { 46 Log.w(TAG, "Missing package or uid or packageinfo or channel"); 47 finish(); 48 return; 49 } 50 getActivity().setTitle(mConversationInfo.getLabel()); 51 52 for (NotificationPreferenceController controller : mControllers) { 53 controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable, 54 mConversationInfo, mSuspendedAppsAdmin, mPreferenceFilter); 55 controller.displayPreference(getPreferenceScreen()); 56 } 57 updatePreferenceStates(); 58 animatePanel(); 59 } 60 61 @Override onActivityResult(int requestCode, int resultCode, Intent data)62 public void onActivityResult(int requestCode, int resultCode, Intent data) { 63 for (NotificationPreferenceController controller : mControllers) { 64 if (controller instanceof PreferenceManager.OnActivityResultListener) { 65 ((PreferenceManager.OnActivityResultListener) controller) 66 .onActivityResult(requestCode, resultCode, data); 67 } 68 } 69 } 70 71 @Override getLogTag()72 protected String getLogTag() { 73 return TAG; 74 } 75 76 @Override getPreferenceScreenResId()77 protected int getPreferenceScreenResId() { 78 return R.xml.conversation_notification_settings; 79 } 80 81 @Override createPreferenceControllers(Context context)82 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 83 mControllers = new ArrayList<>(); 84 mControllers.add(new ConversationHeaderPreferenceController(context, this)); 85 mControllers.add(new ConversationPriorityPreferenceController( 86 context, mBackend, mDependentFieldListener)); 87 mControllers.add(new HighImportancePreferenceController( 88 context, mDependentFieldListener, mBackend)); 89 mControllers.add(new SoundPreferenceController(context, this, 90 mDependentFieldListener, mBackend)); 91 mControllers.add(new VibrationPreferenceController(context, mBackend)); 92 mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context), 93 mBackend)); 94 mControllers.add(new LightsPreferenceController(context, mBackend)); 95 mControllers.add(new BadgePreferenceController(context, mBackend)); 96 mControllers.add(new NotificationsOffPreferenceController(context)); 97 mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(), 98 mBackend, false /* isAppPage */, null /* dependentFieldListener */)); 99 mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend)); 100 mControllers.add(new BubbleCategoryPreferenceController(context)); 101 mControllers.add(new BubbleLinkPreferenceController(context)); 102 return new ArrayList<>(mControllers); 103 } 104 } 105