Merge "App Bubble control page should always be available, even if off globally" into qt-dev
am: f7f1dd37c2
Change-Id: I1cf0e56ea78e8792d0b7095789059bd7ebff9cf2
This commit is contained in:
@@ -64,7 +64,7 @@ public class AppBubbleNotificationSettings extends NotificationSettingsBase impl
|
||||
controllers.add(new BubblePreferenceController(context, fragment != null
|
||||
? fragment.getChildFragmentManager()
|
||||
: null,
|
||||
new NotificationBackend()));
|
||||
new NotificationBackend(), true /* isAppPage */));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -41,11 +41,13 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
static final int SYSTEM_WIDE_OFF = 0;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private boolean mIsAppPage;
|
||||
|
||||
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
|
||||
NotificationBackend backend) {
|
||||
NotificationBackend backend, boolean isAppPage) {
|
||||
super(context, backend);
|
||||
mFragmentManager = fragmentManager;
|
||||
mIsAppPage = isAppPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +60,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
if (!super.isAvailable()) {
|
||||
return false;
|
||||
}
|
||||
if (!isGloballyEnabled()) {
|
||||
if (!mIsAppPage && !isGloballyEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null) {
|
||||
|
@@ -115,7 +115,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
||||
mControllers.add(new DndPreferenceController(context, mBackend));
|
||||
mControllers.add(new NotificationsOffPreferenceController(context));
|
||||
mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
|
||||
mBackend));
|
||||
mBackend, false /* isAppPage */));
|
||||
return new ArrayList<>(mControllers);
|
||||
}
|
||||
}
|
||||
|
@@ -78,6 +78,7 @@ public class BubblePreferenceControllerTest {
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
private BubblePreferenceController mController;
|
||||
private BubblePreferenceController mAppPageController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -87,7 +88,10 @@ public class BubblePreferenceControllerTest {
|
||||
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
when(mFragmentManager.beginTransaction()).thenReturn(mock(FragmentTransaction.class));
|
||||
mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend));
|
||||
mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend,
|
||||
false /* isAppPage */));
|
||||
mAppPageController = spy(new BubblePreferenceController(mContext, mFragmentManager,
|
||||
mBackend, true /* isAppPage */));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,6 +154,16 @@ public class BubblePreferenceControllerTest {
|
||||
assertFalse(mController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_app_evenIfOffGlobally() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
mAppPageController.onResume(appRow, null, null, null);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
|
||||
|
||||
assertTrue(mAppPageController.isAvailable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_app() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
Reference in New Issue
Block a user