Rename some variables/methods for better readability
This commit is contained in:
parent
ae092e1c6e
commit
75cdb7b498
9 changed files with 99 additions and 98 deletions
|
@ -60,7 +60,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
}
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent deletePendingIntent = actionCreator.createDismissAllMessagesPendingIntent(
|
||||
account, notificationId);
|
||||
builder.setDeleteIntent(deletePendingIntent);
|
||||
|
@ -91,7 +91,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
String unreadMessageCountText = context.getString(R.string.notification_new_one_account_fmt,
|
||||
unreadMessageCount, accountName);
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent contentIntent = actionCreator.createViewFolderListPendingIntent(account, notificationId);
|
||||
|
||||
return createAndInitializeNotificationBuilder(account)
|
||||
|
@ -105,7 +105,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
private NotificationCompat.Builder createBigTextStyleSummaryNotification(Account account,
|
||||
NotificationHolder holder) {
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
Builder builder = createBigTextStyleNotification(account, holder, notificationId)
|
||||
.setGroupSummary(true);
|
||||
|
||||
|
@ -154,7 +154,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
|
||||
wearNotifications.addSummaryActions(builder, notificationData);
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
PendingIntent contentIntent = actionCreator.createViewMessagesPendingIntent(
|
||||
account, messageReferences, notificationId);
|
||||
|
@ -180,7 +180,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
|
||||
Account account = notificationData.getAccount();
|
||||
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent markAllAsReadPendingIntent =
|
||||
actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId);
|
||||
|
||||
|
@ -196,7 +196,7 @@ class DeviceNotifications extends BaseNotifications {
|
|||
String title = context.getString(R.string.notification_action_delete);
|
||||
|
||||
Account account = notificationData.getAccount();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class NewMailNotifications {
|
|||
cancelNotification(notificationId);
|
||||
}
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
cancelNotification(notificationId);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class NewMailNotifications {
|
|||
|
||||
private void createSummaryNotification(Account account, NotificationData notificationData, boolean silent) {
|
||||
Notification notification = deviceNotifications.buildSummaryNotification(account, notificationData, silent);
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
|
||||
getNotificationManager().notify(notificationId, notification);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import com.fsck.k9.activity.MessageReference;
|
|||
class NotificationData {
|
||||
// Note: As of Jellybean, phone notifications show a maximum of 5 lines, while tablet notifications show 7 lines.
|
||||
static final int MAX_NUMBER_OF_MESSAGES_FOR_SUMMARY_NOTIFICATION = 5;
|
||||
// Note: This class assumes MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS >= MAX_NUMBER_OF_MESSAGES_FOR_SUMMARY_NOTIFICATION
|
||||
static final int MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS = 8;
|
||||
// Note: This class assumes MAX_NUMBER_OF_STACKED_NOTIFICATIONS >= MAX_NUMBER_OF_MESSAGES_FOR_SUMMARY_NOTIFICATION
|
||||
static final int MAX_NUMBER_OF_STACKED_NOTIFICATIONS = 8;
|
||||
|
||||
|
||||
private final Account account;
|
||||
|
@ -58,7 +58,7 @@ class NotificationData {
|
|||
}
|
||||
|
||||
private boolean isMaxNumberOfActiveNotificationsReached() {
|
||||
return activeNotifications.size() == MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS;
|
||||
return activeNotifications.size() == MAX_NUMBER_OF_STACKED_NOTIFICATIONS;
|
||||
}
|
||||
|
||||
private void addToAdditionalNotifications(NotificationHolder notificationHolder) {
|
||||
|
@ -66,8 +66,8 @@ class NotificationData {
|
|||
}
|
||||
|
||||
private int getNewNotificationId() {
|
||||
for (int i = 1; i <= MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS; i++) {
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, i);
|
||||
for (int i = 1; i <= MAX_NUMBER_OF_STACKED_NOTIFICATIONS; i++) {
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, i);
|
||||
if (!isNotificationInUse(notificationId)) {
|
||||
markNotificationIdAsInUse(notificationId);
|
||||
return notificationId;
|
||||
|
|
|
@ -10,24 +10,25 @@ class NotificationIds {
|
|||
private static final int OFFSET_CERTIFICATE_ERROR_OUTGOING = 2;
|
||||
private static final int OFFSET_FETCHING_MAIL = 3;
|
||||
private static final int OFFSET_NEW_MAIL_SUMMARY = 4;
|
||||
|
||||
private static final int OFFSET_NEW_MAIL_STACKED = 5;
|
||||
|
||||
private static final int NUMBER_OF_DEVICE_NOTIFICATIONS = OFFSET_NEW_MAIL_STACKED;
|
||||
|
||||
private static final int NUMBER_OF_DEVICE_NOTIFICATIONS = 5;
|
||||
private static final int NUMBER_OF_STACKED_NOTIFICATIONS = NotificationData.MAX_NUMBER_OF_STACKED_NOTIFICATIONS;
|
||||
private static final int NUMBER_OF_NOTIFICATIONS_PER_ACCOUNT = NUMBER_OF_DEVICE_NOTIFICATIONS +
|
||||
NotificationData.MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS;
|
||||
NUMBER_OF_STACKED_NOTIFICATIONS;
|
||||
|
||||
|
||||
public static int getNewMailNotificationId(Account account) {
|
||||
public static int getNewMailSummaryNotificationId(Account account) {
|
||||
return getBaseNotificationId(account) + OFFSET_NEW_MAIL_SUMMARY;
|
||||
}
|
||||
|
||||
public static int getNewMailNotificationId(Account account, int offset) {
|
||||
if (offset < 1 || offset > NotificationData.MAX_NUMBER_OF_ACTIVE_NOTIFICATIONS) {
|
||||
throw new IllegalArgumentException("Invalid value for offset: " + offset);
|
||||
public static int getNewMailStackedNotificationId(Account account, int index) {
|
||||
if (index < 1 || index > NUMBER_OF_STACKED_NOTIFICATIONS) {
|
||||
throw new IndexOutOfBoundsException("Invalid value: " + index);
|
||||
}
|
||||
|
||||
return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + offset - 1;
|
||||
return getBaseNotificationId(account) + OFFSET_NEW_MAIL_STACKED + index - 1;
|
||||
}
|
||||
|
||||
public static int getFetchingMailNotificationId(Account account) {
|
||||
|
|
|
@ -60,7 +60,7 @@ class WearNotifications extends BaseNotifications {
|
|||
|
||||
Account account = notificationData.getAccount();
|
||||
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent action = actionCreator.createMarkAllAsReadPendingIntent(
|
||||
account, messageReferences, notificationId);
|
||||
|
||||
|
@ -74,7 +74,7 @@ class WearNotifications extends BaseNotifications {
|
|||
|
||||
Account account = notificationData.getAccount();
|
||||
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
|
||||
|
||||
NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
|
||||
|
@ -87,7 +87,7 @@ class WearNotifications extends BaseNotifications {
|
|||
|
||||
Account account = notificationData.getAccount();
|
||||
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
PendingIntent action = actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId);
|
||||
|
||||
NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
|
||||
|
|
|
@ -55,10 +55,10 @@ public class NewMailNotificationsTest {
|
|||
|
||||
@Test
|
||||
public void testAddNewMailNotification() throws Exception {
|
||||
int notificationOffset = 1;
|
||||
int notificationIndex = 1;
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
Notification wearNotification = createNotification();
|
||||
|
@ -68,18 +68,18 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.addNewMailNotification(account, message, 42);
|
||||
|
||||
int wearNotificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).notify(wearNotificationId, wearNotification);
|
||||
verify(notificationManager).notify(summaryNotificationId, summaryNotification);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewMailNotificationWithCancelingExistingNotification() throws Exception {
|
||||
int notificationOffset = 1;
|
||||
int notificationIndex = 1;
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.replaceNotification(holder));
|
||||
Notification wearNotification = createNotification();
|
||||
|
@ -89,8 +89,8 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.addNewMailNotification(account, message, 42);
|
||||
|
||||
int wearNotificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).notify(wearNotificationId, wearNotification);
|
||||
verify(notificationManager).cancel(wearNotificationId);
|
||||
verify(notificationManager).notify(summaryNotificationId, summaryNotification);
|
||||
|
@ -99,10 +99,10 @@ public class NewMailNotificationsTest {
|
|||
@Test
|
||||
public void testAddNewMailNotificationWithPrivacyModeEnabled() throws Exception {
|
||||
enablePrivacyMode();
|
||||
int notificationOffset = 1;
|
||||
int notificationIndex = 1;
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
Notification wearNotification = createNotification();
|
||||
|
@ -110,22 +110,22 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.addNewMailNotification(account, message, 42);
|
||||
|
||||
int wearNotificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager, never()).notify(eq(wearNotificationId), any(Notification.class));
|
||||
verify(notificationManager).notify(summaryNotificationId, wearNotification);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewMailNotificationTwice() throws Exception {
|
||||
int notificationOffsetOne = 1;
|
||||
int notificationOffsetTwo = 2;
|
||||
int notificationIndexOne = 1;
|
||||
int notificationIndexTwo = 2;
|
||||
LocalMessage messageOne = createLocalMessage();
|
||||
LocalMessage messageTwo = createLocalMessage();
|
||||
NotificationContent contentOne = createNotificationContent();
|
||||
NotificationContent contentTwo = createNotificationContent();
|
||||
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationOffsetOne);
|
||||
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationOffsetTwo);
|
||||
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndexOne);
|
||||
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndexTwo);
|
||||
addToNotificationContentCreator(messageOne, contentOne);
|
||||
addToNotificationContentCreator(messageTwo, contentTwo);
|
||||
whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne));
|
||||
|
@ -140,9 +140,9 @@ public class NewMailNotificationsTest {
|
|||
newMailNotifications.addNewMailNotification(account, messageOne, 42);
|
||||
newMailNotifications.addNewMailNotification(account, messageTwo, 42);
|
||||
|
||||
int wearNotificationIdOne = NotificationIds.getNewMailNotificationId(account, notificationOffsetOne);
|
||||
int wearNotificationIdTwo = NotificationIds.getNewMailNotificationId(account, notificationOffsetTwo);
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int wearNotificationIdOne = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexOne);
|
||||
int wearNotificationIdTwo = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexTwo);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).notify(wearNotificationIdOne, wearNotificationOne);
|
||||
verify(notificationManager).notify(wearNotificationIdTwo, wearNotificationTwo);
|
||||
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
|
||||
|
@ -161,10 +161,10 @@ public class NewMailNotificationsTest {
|
|||
public void testRemoveNewMailNotificationWithUnknownMessageReference() throws Exception {
|
||||
enablePrivacyMode();
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
int notificationOffset = 1;
|
||||
int notificationIndex = 1;
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
Notification summaryNotification = createNotification();
|
||||
|
@ -181,11 +181,11 @@ public class NewMailNotificationsTest {
|
|||
public void testRemoveNewMailNotification() throws Exception {
|
||||
enablePrivacyMode();
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
Notification summaryNotification = createNotification();
|
||||
|
@ -195,7 +195,7 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.removeNewMailNotification(account, messageReference);
|
||||
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).cancel(notificationId);
|
||||
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
|
||||
}
|
||||
|
@ -203,11 +203,11 @@ public class NewMailNotificationsTest {
|
|||
@Test
|
||||
public void testRemoveNewMailNotificationClearingAllNotifications() throws Exception {
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
Notification summaryNotification = createNotification();
|
||||
|
@ -219,7 +219,7 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.removeNewMailNotification(account, messageReference);
|
||||
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).cancel(notificationId);
|
||||
verify(notificationManager).cancel(summaryNotificationId);
|
||||
}
|
||||
|
@ -227,13 +227,13 @@ public class NewMailNotificationsTest {
|
|||
@Test
|
||||
public void testRemoveNewMailNotificationWithCreateNotification() throws Exception {
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent contentOne = createNotificationContent();
|
||||
NotificationContent contentTwo = createNotificationContent();
|
||||
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationOffset);
|
||||
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationOffset);
|
||||
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndex);
|
||||
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndex);
|
||||
addToNotificationContentCreator(message, contentOne);
|
||||
whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne));
|
||||
Notification summaryNotification = createNotification();
|
||||
|
@ -247,7 +247,7 @@ public class NewMailNotificationsTest {
|
|||
|
||||
newMailNotifications.removeNewMailNotification(account, messageReference);
|
||||
|
||||
int summaryNotificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
verify(notificationManager).cancel(notificationId);
|
||||
verify(notificationManager).notify(notificationId, wearNotificationTwo);
|
||||
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
|
||||
|
@ -262,11 +262,11 @@ public class NewMailNotificationsTest {
|
|||
|
||||
@Test
|
||||
public void testClearNewMailNotifications() throws Exception {
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
LocalMessage message = createLocalMessage();
|
||||
NotificationContent content = createNotificationContent();
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationOffset);
|
||||
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
|
||||
addToNotificationContentCreator(message, content);
|
||||
setActiveNotificationIds(notificationId);
|
||||
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
|
||||
|
@ -275,7 +275,7 @@ public class NewMailNotificationsTest {
|
|||
newMailNotifications.clearNewMailNotifications(account);
|
||||
|
||||
verify(notificationManager).cancel(notificationId);
|
||||
verify(notificationManager).cancel(NotificationIds.getNewMailNotificationId(account));
|
||||
verify(notificationManager).cancel(NotificationIds.getNewMailSummaryNotificationId(account));
|
||||
}
|
||||
|
||||
private Account createAccount() {
|
||||
|
@ -292,8 +292,8 @@ public class NewMailNotificationsTest {
|
|||
return new NotificationContent(null, null, null, null, null, false);
|
||||
}
|
||||
|
||||
private NotificationHolder createNotificationHolder(NotificationContent content, int offset) {
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, offset);
|
||||
private NotificationHolder createNotificationHolder(NotificationContent content, int index) {
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, index);
|
||||
return new NotificationHolder(notificationId, content);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class NotificationDataTest {
|
|||
assertFalse(result.shouldCancelNotification());
|
||||
NotificationHolder holder = result.getNotificationHolder();
|
||||
assertNotNull(holder);
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 1), holder.notificationId);
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 1), holder.notificationId);
|
||||
assertEquals(content, holder.content);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class NotificationDataTest {
|
|||
AddNotificationResult result = notificationData.addNotificationContent(createNotificationContent("9"));
|
||||
|
||||
assertTrue(result.shouldCancelNotification());
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 1), result.getNotificationId());
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 1), result.getNotificationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,7 +76,7 @@ public class NotificationDataTest {
|
|||
RemoveNotificationResult result = notificationData.removeNotificationForMessage(content.messageReference);
|
||||
|
||||
assertFalse(result.isUnknownNotification());
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 1), result.getNotificationId());
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 1), result.getNotificationId());
|
||||
assertFalse(result.shouldCreateNotification());
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ public class NotificationDataTest {
|
|||
notificationData.removeNotificationForMessage(latestContent.messageReference);
|
||||
|
||||
assertFalse(result.isUnknownNotification());
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 2), result.getNotificationId());
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 2), result.getNotificationId());
|
||||
assertTrue(result.shouldCreateNotification());
|
||||
NotificationHolder holder = result.getNotificationHolder();
|
||||
assertNotNull(holder);
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 2), holder.notificationId);
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 2), holder.notificationId);
|
||||
assertEquals(content, holder.content);
|
||||
}
|
||||
|
||||
|
@ -214,8 +214,8 @@ public class NotificationDataTest {
|
|||
int[] notificationIds = notificationData.getActiveNotificationIds();
|
||||
|
||||
assertEquals(2, notificationIds.length);
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 2), notificationIds[0]);
|
||||
assertEquals(NotificationIds.getNewMailNotificationId(account, 1), notificationIds[1]);
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 2), notificationIds[0]);
|
||||
assertEquals(NotificationIds.getNewMailStackedNotificationId(account, 1), notificationIds[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,53 +18,53 @@ public class NotificationIdsTest {
|
|||
private static final boolean OUTGOING = false;
|
||||
|
||||
@Test
|
||||
public void getNewMailNotificationId_withDefaultAccount() throws Exception {
|
||||
public void getNewMailSummaryNotificationId_withDefaultAccount() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(0);
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
|
||||
assertEquals(4, notificationId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNewMailNotificationId_withDefaultAccountAndOffset() throws Exception {
|
||||
public void getNewMailStackedNotificationId_withDefaultAccount() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(0);
|
||||
int notificationOffset = 1;
|
||||
int notificationIndex = 1;
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
|
||||
assertEquals(5, notificationId);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getNewMailNotificationId_withTooLowOffset() throws Exception {
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void getNewMailStackedNotificationId_withTooLowIndex() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(0);
|
||||
|
||||
NotificationIds.getNewMailNotificationId(account, 0);
|
||||
NotificationIds.getNewMailStackedNotificationId(account, 0);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getNewMailNotificationId_withTooLargeOffset() throws Exception {
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void getNewMailStackedNotificationId_withTooLargeIndex() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(0);
|
||||
|
||||
NotificationIds.getNewMailNotificationId(account, 9);
|
||||
NotificationIds.getNewMailStackedNotificationId(account, 9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNewMailNotificationId_withSecondAccount() throws Exception {
|
||||
public void getNewMailSummaryNotificationId_withSecondAccount() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(1);
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
|
||||
assertEquals(17, notificationId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNewMailNotificationId_withSecondAccountAndOffset() throws Exception {
|
||||
public void getNewMailStackedNotificationId_withSecondAccount() throws Exception {
|
||||
Account account = createMockAccountWithAccountNumber(1);
|
||||
int notificationOffset = 8;
|
||||
int notificationIndex = 8;
|
||||
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
|
||||
assertEquals(25, notificationId);
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testBuildStackedNotification() throws Exception {
|
||||
disableOptionalActions();
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
NotificationContent content = createNotificationContent(messageReference);
|
||||
NotificationHolder holder = createNotificationHolder(notificationId, content);
|
||||
|
@ -85,8 +85,8 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception {
|
||||
enableDeleteAction();
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
NotificationContent content = createNotificationContent(messageReference);
|
||||
NotificationHolder holder = createNotificationHolder(notificationId, content);
|
||||
|
@ -104,8 +104,8 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception {
|
||||
enableArchiveAction();
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
NotificationContent content = createNotificationContent(messageReference);
|
||||
NotificationHolder holder = createNotificationHolder(notificationId, content);
|
||||
|
@ -123,8 +123,8 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception {
|
||||
enableSpamAction();
|
||||
int notificationOffset = 1;
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account, notificationOffset);
|
||||
int notificationIndex = 1;
|
||||
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
|
||||
MessageReference messageReference = createMessageReference(1);
|
||||
NotificationContent content = createNotificationContent(messageReference);
|
||||
NotificationHolder holder = createNotificationHolder(notificationId, content);
|
||||
|
@ -142,7 +142,7 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testAddSummaryActions() throws Exception {
|
||||
disableOptionalSummaryActions();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
|
||||
NotificationData notificationData = createNotificationData(messageReferences);
|
||||
PendingIntent markAllAsReadPendingIntent = createFakePendingIntent(1);
|
||||
|
@ -159,7 +159,7 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testAddSummaryActionsWithDeleteAllActionEnabled() throws Exception {
|
||||
enableDeleteAction();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
|
||||
NotificationData notificationData = createNotificationData(messageReferences);
|
||||
PendingIntent deletePendingIntent = createFakePendingIntent(1);
|
||||
|
@ -175,7 +175,7 @@ public class WearNotificationsTest {
|
|||
@Test
|
||||
public void testAddSummaryActionsWithArchiveAllActionEnabled() throws Exception {
|
||||
enableArchiveAction();
|
||||
int notificationId = NotificationIds.getNewMailNotificationId(account);
|
||||
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
|
||||
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
|
||||
NotificationData notificationData = createNotificationData(messageReferences);
|
||||
PendingIntent archivePendingIntent = createFakePendingIntent(1);
|
||||
|
|
Loading…
Reference in a new issue