Search in sources :

Example 1 with NotificationSetting

use of com.fsck.k9.NotificationSetting in project k-9 by k9mail.

the class DeviceNotifications method buildSummaryNotification.

public Notification buildSummaryNotification(Account account, NotificationData notificationData, boolean silent) {
    int unreadMessageCount = notificationData.getUnreadMessageCount();
    NotificationCompat.Builder builder;
    if (isPrivacyModeActive() || !platformSupportsExtendedNotifications()) {
        builder = createSimpleSummaryNotification(account, unreadMessageCount);
    } else if (notificationData.isSingleMessageNotification()) {
        NotificationHolder holder = notificationData.getHolderForLatestNotification();
        builder = createBigTextStyleSummaryNotification(account, holder);
    } else {
        builder = createInboxStyleSummaryNotification(account, notificationData, unreadMessageCount);
    }
    if (notificationData.containsStarredMessages()) {
        builder.setPriority(NotificationCompat.PRIORITY_HIGH);
    }
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent(account, notificationId);
    builder.setDeleteIntent(deletePendingIntent);
    lockScreenNotification.configureLockScreenNotification(builder, notificationData);
    boolean ringAndVibrate = false;
    if (!silent && !account.isRingNotified()) {
        account.setRingNotified(true);
        ringAndVibrate = true;
    }
    NotificationSetting notificationSetting = account.getNotificationSetting();
    controller.configureNotification(builder, (notificationSetting.shouldRing()) ? notificationSetting.getRingtone() : null, (notificationSetting.shouldVibrate()) ? notificationSetting.getVibration() : null, (notificationSetting.isLed()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate);
    return builder.build();
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) NotificationSetting(com.fsck.k9.NotificationSetting) PendingIntent(android.app.PendingIntent)

Example 2 with NotificationSetting

use of com.fsck.k9.NotificationSetting in project k-9 by k9mail.

the class DeviceNotificationsTest method createFakeAccount.

private Account createFakeAccount() {
    Account account = mock(Account.class);
    when(account.getChipColor()).thenReturn(ACCOUNT_COLOR);
    when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
    NotificationSetting notificationSetting = mock(NotificationSetting.class);
    when(account.getNotificationSetting()).thenReturn(notificationSetting);
    return account;
}
Also used : Account(com.fsck.k9.Account) NotificationSetting(com.fsck.k9.NotificationSetting)

Aggregations

NotificationSetting (com.fsck.k9.NotificationSetting)2 PendingIntent (android.app.PendingIntent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 Builder (android.support.v4.app.NotificationCompat.Builder)1 Account (com.fsck.k9.Account)1