@Test public void buildSummaryNotification_withMultiMessageNotification() throws Exception { QMail.setNotificationHideSubject(NotificationHideSubject.NEVER); QMail.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.ALWAYS); when(notificationData.isSingleMessageNotification()).thenReturn(false); when(notificationData.containsStarredMessages()).thenReturn(true); Notification result = notifications.buildSummaryNotification(account, notificationData, false); verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail); verify(builder).setColor(ACCOUNT_COLOR); verify(builder).setAutoCancel(true); verify(builder).setTicker(SUMMARY); verify(builder).setContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(builder).setSubText(ACCOUNT_NAME); verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER); verify(builder).setGroupSummary(true); verify(builder).setPriority(NotificationCompat.PRIORITY_HIGH); verify(builder).setStyle(notifications.inboxStyle); verify(notifications.inboxStyle).setBigContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(notifications.inboxStyle).setSummaryText(ACCOUNT_NAME); verify(notifications.inboxStyle).addLine(SUMMARY); verify(notifications.inboxStyle).addLine(SUMMARY_2); verify(builder).addAction(R.drawable.notification_action_mark_as_read, "Mark Read", null); verify(builder).addAction(R.drawable.notification_action_delete, "Delete", null); verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData); assertEquals(FAKE_NOTIFICATION, result); }
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);  }