From ddec88774a246f212e619041afe0c4ad607bc885 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 22 May 2019 10:01:35 -0700 Subject: [PATCH] Make sure the fragment manager is passed to BubblePreferenceController This wasn't being set always / at least for the app specific page. This CL ensures it is & makes it so that there is only 1 constructor. Fixes: 132864244 Test: make -j40 RunSettingsRoboTests ROBOTEST_FILTER=Bubble Change-Id: I9c422e75583b3091d1571cfb8cc43ec49b801599 --- .../notification/AppBubbleNotificationSettings.java | 5 ++++- .../notification/BubblePreferenceController.java | 9 +++------ .../notification/ChannelNotificationSettings.java | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java index f55c262e3e9..7214a88168f 100644 --- a/src/com/android/settings/notification/AppBubbleNotificationSettings.java +++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java @@ -61,7 +61,10 @@ public class AppBubbleNotificationSettings extends NotificationSettingsBase impl Context context, AppBubbleNotificationSettings fragment) { List controllers = new ArrayList<>(); controllers.add(new HeaderPreferenceController(context, fragment)); - controllers.add(new BubblePreferenceController(context, new NotificationBackend())); + controllers.add(new BubblePreferenceController(context, fragment != null + ? fragment.getChildFragmentManager() + : null, + new NotificationBackend())); return controllers; } diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java index 200c4b2dfec..6196549d124 100644 --- a/src/com/android/settings/notification/BubblePreferenceController.java +++ b/src/com/android/settings/notification/BubblePreferenceController.java @@ -18,6 +18,7 @@ package com.android.settings.notification; import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES; +import android.annotation.Nullable; import android.content.Context; import android.provider.Settings; @@ -41,11 +42,7 @@ public class BubblePreferenceController extends NotificationPreferenceController private FragmentManager mFragmentManager; - public BubblePreferenceController(Context context, NotificationBackend backend) { - super(context, backend); - } - - public BubblePreferenceController(Context context, FragmentManager fragmentManager, + public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager, NotificationBackend backend) { super(context, backend); mFragmentManager = fragmentManager; @@ -96,7 +93,7 @@ public class BubblePreferenceController extends NotificationPreferenceController mChannel.setAllowBubbles(value); saveChannel(); return true; - } else if (mAppRow != null) { + } else if (mAppRow != null && mFragmentManager != null) { RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference; // if the global setting is off, toggling app level permission requires extra // confirmation diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java index 9f9d438a90f..7f0f926bbae 100644 --- a/src/com/android/settings/notification/ChannelNotificationSettings.java +++ b/src/com/android/settings/notification/ChannelNotificationSettings.java @@ -114,7 +114,8 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { mControllers.add(new BadgePreferenceController(context, mBackend)); mControllers.add(new DndPreferenceController(context, mBackend)); mControllers.add(new NotificationsOffPreferenceController(context)); - mControllers.add(new BubblePreferenceController(context, mBackend)); + mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(), + mBackend)); return new ArrayList<>(mControllers); } }