@Test public void buildSummaryNotification_withAdditionalMessages() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); when(notificationData.isSingleMessageNotification()).thenReturn(false); when(notificationData.hasSummaryOverflowMessages()).thenReturn(true); when(notificationData.getSummaryOverflowMessagesCount()).thenReturn(23); notifications.buildSummaryNotification(account, notificationData, false); verify(notifications.inboxStyle).setSummaryText("+ 23 more on " + ACCOUNT_NAME); }
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.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); }
DeviceNotifications extends BaseNotifications { 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.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } }
DeviceNotifications extends BaseNotifications { 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.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator,
            LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); }
DeviceNotifications extends BaseNotifications { 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.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator,
            LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData,
            boolean silent); }
DeviceNotifications extends BaseNotifications { 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.isRingEnabled()) ? notificationSetting.getRingtone() : null, (notificationSetting.isVibrateEnabled()) ? notificationSetting.getVibration() : null, (notificationSetting.isLedEnabled()) ? notificationSetting.getLedColor() : null, NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate); return builder.build(); } DeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator,
            LockScreenNotification lockScreenNotification, WearNotifications wearNotifications); static DeviceNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator, WearNotifications wearNotifications); Notification buildSummaryNotification(Account account, NotificationData notificationData,
            boolean silent);  }