Search in sources :

Example 41 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DescriptionPreferenceControllerTest method testIsAvailable_notIfChannelGroupBlocked.

@Test
public void testIsAvailable_notIfChannelGroupBlocked() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    mController.onResume(appRow, null, group, null);
    assertFalse(mController.isAvailable());
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 42 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HeaderPreferenceControllerTest method testGetLabel.

@Test
public void testGetLabel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.label = "bananas";
    mController.onResume(appRow, null, null, null);
    assertEquals(appRow.label, mController.getLabel());
    NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
    mController.onResume(appRow, null, group, null);
    assertEquals(group.getName(), mController.getLabel());
    NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
    mController.onResume(appRow, channel, group, null);
    assertEquals(channel.getName(), mController.getLabel());
    NotificationChannel defaultChannel = new NotificationChannel(NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
    mController.onResume(appRow, defaultChannel, null, null);
    assertEquals(appRow.label, mController.getLabel());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 43 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ImportancePreferenceControllerTest method testIsAvailable_isGroupBlocked.

@Test
public void testIsAvailable_isGroupBlocked() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(true);
    mController.onResume(appRow, channel, group, null);
    assertFalse(mController.isAvailable());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 44 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationPreferenceControllerTest method isAvailable.

@Test
public void isAvailable() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    NotificationChannel channel = mock(NotificationChannel.class);
    when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
    NotificationChannelGroup group = mock(NotificationChannelGroup.class);
    when(group.isBlocked()).thenReturn(false);
    mController.onResume(appRow, channel, group, null);
    assertTrue(mController.isAvailable());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) Test(org.junit.Test)

Example 45 with NotificationChannelGroup

use of android.app.NotificationChannelGroup in project Signal-Android by signalapp.

the class NotificationChannels method isMessagesChannelGroupEnabled.

/**
 * Whether or not the notification category for messages is enabled. Note that even if it is,
 * a user could have blocked the specific channel, or notifications overall, and it'd still be
 * true. See {@link #isMessageChannelEnabled(Context)} and {@link #areNotificationsEnabled(Context)}.
 */
public static synchronized boolean isMessagesChannelGroupEnabled(@NonNull Context context) {
    if (Build.VERSION.SDK_INT < 28) {
        return true;
    }
    NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
    NotificationChannelGroup group = notificationManager.getNotificationChannelGroup(CATEGORY_MESSAGES);
    return group != null && !group.isBlocked();
}
Also used : NotificationChannelGroup(android.app.NotificationChannelGroup) NotificationManager(android.app.NotificationManager)

Aggregations

NotificationChannelGroup (android.app.NotificationChannelGroup)46 NotificationChannel (android.app.NotificationChannel)31 Test (org.junit.Test)20 TargetApi (android.annotation.TargetApi)8 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 FooterPreference (com.android.settingslib.widget.FooterPreference)6 NotificationManager (android.app.NotificationManager)5 Notification (android.app.Notification)4 AudioAttributes (android.media.AudioAttributes)4 ArrayList (java.util.ArrayList)4 Context (android.content.Context)2 Uri (android.net.Uri)2 RequiresApi (androidx.annotation.RequiresApi)2 Preference (androidx.preference.Preference)2 JSONObject (org.json.JSONObject)2 Application (android.app.Application)1