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 Log.w(TAG, "Missing package or uid or packageinfo or channel"); 46 finish(); 47 return; 48 } 49 50 for (NotificationPreferenceController controller : mControllers) { 51 controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable, 52 mConversationInfo, mSuspendedAppsAdmin); 53 controller.displayPreference(getPreferenceScreen()); 54 } 55 updatePreferenceStates(); 56 } 57 58 @Override onActivityResult(int requestCode, int resultCode, Intent data)59 public void onActivityResult(int requestCode, int resultCode, Intent data) { 60 for (NotificationPreferenceController controller : mControllers) { 61 if (controller instanceof PreferenceManager.OnActivityResultListener) { 62 ((PreferenceManager.OnActivityResultListener) controller) 63 .onActivityResult(requestCode, resultCode, data); 64 } 65 } 66 } 67 68 @Override getLogTag()69 protected String getLogTag() { 70 return TAG; 71 } 72 73 @Override getPreferenceScreenResId()74 protected int getPreferenceScreenResId() { 75 return R.xml.conversation_notification_settings; 76 } 77 78 @Override createPreferenceControllers(Context context)79 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 80 mControllers = new ArrayList<>(); 81 mControllers.add(new ConversationHeaderPreferenceController(context, this)); 82 mControllers.add(new ConversationPriorityPreferenceController( 83 context, mBackend, mDependentFieldListener)); 84 mControllers.add(new HighImportancePreferenceController( 85 context, mDependentFieldListener, mBackend)); 86 mControllers.add(new SoundPreferenceController(context, this, 87 mDependentFieldListener, mBackend)); 88 mControllers.add(new VibrationPreferenceController(context, mBackend)); 89 mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context), 90 mBackend)); 91 mControllers.add(new LightsPreferenceController(context, mBackend)); 92 mControllers.add(new BadgePreferenceController(context, mBackend)); 93 mControllers.add(new NotificationsOffPreferenceController(context)); 94 mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(), 95 mBackend, false /* isAppPage */, null /* dependentFieldListener */)); 96 mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend)); 97 mControllers.add(new BubbleCategoryPreferenceController(context)); 98 mControllers.add(new BubbleLinkPreferenceController(context)); 99 return new ArrayList<>(mControllers); 100 } 101 } 102