Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d6315b5 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Changed 'Mark Read' to 'Mark As Read' everywhere.

parent ad2797ff
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -2305,7 +2305,7 @@ public class MessagingController
    }

    /**
     * Processes a pending mark read or unread command.
     * Processes a pending mark as read or unread command.
     */
    void processPendingSetFlag(MessagingControllerCommands.PendingSetFlag command, Account account) throws MessagingException
    {
+4 −6
Original line number Diff line number Diff line
@@ -64,14 +64,12 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="account_clear_dlg_instructions_fmt">Local copies of messages in \"<xliff:g id="account">%s</xliff:g>\" will be removed. Account settings will be retained.</string>



    <!-- === App Store-specific strings ======================================================= -->

    <string name="import_dialog_error_message">Please install a file manager to continue with this import.</string>
    <string name="open_market">Open Play Store</string>



    <!-- === General strings ================================================================== -->

    <string name="app_authors_fmt">Authors: <xliff:g id="app_authors">%s</xliff:g></string>
@@ -216,8 +214,8 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="notification_additional_messages">+ <xliff:g id="additional_messages">%1$d</xliff:g> more on <xliff:g id="account">%2$s</xliff:g></string>

    <string name="notification_action_reply">Reply</string>
    <string name="notification_action_mark_as_read">Mark Read</string>
    <string name="notification_action_mark_all_as_read">Mark All Read</string>
    <string name="notification_action_mark_as_read">Mark As Read</string>
    <string name="notification_action_mark_all_as_read">Mark All As Read</string>
    <string name="notification_action_delete">Delete</string>
    <string name="notification_action_delete_all">Delete All</string>
    <string name="notification_action_archive">Archive</string>
+46 −24
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ import static org.mockito.Mockito.when;


@RunWith(K9RobolectricTestRunner.class)
public class DeviceNotificationsTest {
public class DeviceNotificationsTest
{
    private static final int UNREAD_MESSAGE_COUNT = 42;
    private static final int NEW_MESSAGE_COUNT = 2;
    private static final String ACCOUNT_NAME = "accountName";
@@ -61,7 +62,8 @@ public class DeviceNotificationsTest {


    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception
    {
        account = createFakeAccount();
        notificationData = createFakeNotificationData(account);

@@ -71,7 +73,8 @@ public class DeviceNotificationsTest {
    }

    @Test
    public void buildSummaryNotification_withPrivacyModeActive() throws Exception {
    public void buildSummaryNotification_withPrivacyModeActive() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.ALWAYS);

        Notification result = notifications.buildSummaryNotification(account, notificationData, false);
@@ -88,7 +91,8 @@ public class DeviceNotificationsTest {
    }

    @Test
    public void buildSummaryNotification_withSingleMessageNotification() throws Exception {
    public void buildSummaryNotification_withSingleMessageNotification() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.NEVER);
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.ALWAYS);
        when(notificationData.isSingleMessageNotification()).thenReturn(true);
@@ -104,14 +108,15 @@ public class DeviceNotificationsTest {
        verify(builder).setStyle(notifications.bigTextStyle);
        verify(notifications.bigTextStyle).bigText(PREVIEW);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_reply, "Reply", null);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_mark_as_read, "Mark Read", null);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_mark_as_read, "Mark As Read", null);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_delete, "Delete", null);
        verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData);
        assertEquals(FAKE_NOTIFICATION, result);
    }

    @Test
    public void buildSummaryNotification_withMultiMessageNotification() throws Exception {
    public void buildSummaryNotification_withMultiMessageNotification() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.NEVER);
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.ALWAYS);
        when(notificationData.isSingleMessageNotification()).thenReturn(false);
@@ -133,14 +138,15 @@ public class DeviceNotificationsTest {
        verify(notifications.inboxStyle).setSummaryText(ACCOUNT_NAME);
        verify(notifications.inboxStyle).addLine(SUMMARY);
        verify(notifications.inboxStyle).addLine(SUMMARY_2);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_mark_as_read, "Mark Read", null);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_mark_as_read, "Mark As Read", null);
        verify(builder).addAction(io.eelo.mail.R.drawable.notification_action_delete, "Delete", null);
        verify(lockScreenNotification).configureLockScreenNotification(builder, notificationData);
        assertEquals(FAKE_NOTIFICATION, result);
    }

    @Test
    public void buildSummaryNotification_withAdditionalMessages() throws Exception {
    public void buildSummaryNotification_withAdditionalMessages() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.NEVER);
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.ALWAYS);
        when(notificationData.isSingleMessageNotification()).thenReturn(false);
@@ -153,7 +159,8 @@ public class DeviceNotificationsTest {
    }

    @Test
    public void buildSummaryNotification_withoutDeleteAllAction() throws Exception {
    public void buildSummaryNotification_withoutDeleteAllAction() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.NEVER);
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.NEVER);
        when(notificationData.isSingleMessageNotification()).thenReturn(false);
@@ -164,7 +171,8 @@ public class DeviceNotificationsTest {
    }

    @Test
    public void buildSummaryNotification_withoutDeleteAction() throws Exception {
    public void buildSummaryNotification_withoutDeleteAction() throws Exception
    {
        K9.setNotificationHideSubject(K9.NotificationHideSubject.NEVER);
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.NEVER);
        when(notificationData.isSingleMessageNotification()).thenReturn(true);
@@ -174,13 +182,15 @@ public class DeviceNotificationsTest {
        verify(builder, never()).addAction(io.eelo.mail.R.drawable.notification_action_delete, "Delete", null);
    }

    private Builder createFakeNotificationBuilder() {
    private Builder createFakeNotificationBuilder()
    {
        Builder builder = MockHelper.mockBuilder(Builder.class);
        when(builder.build()).thenReturn(FAKE_NOTIFICATION);
        return builder;
    }

    private Account createFakeAccount() {
    private Account createFakeAccount()
    {
        Account account = mock(Account.class);

        when(account.getChipColor()).thenReturn(ACCOUNT_COLOR);
@@ -192,7 +202,8 @@ public class DeviceNotificationsTest {
        return account;
    }

    private NotificationData createFakeNotificationData(Account account) {
    private NotificationData createFakeNotificationData(Account account)
    {
        NotificationData notificationData = mock(NotificationData.class);
        when(notificationData.getUnreadMessageCount()).thenReturn(UNREAD_MESSAGE_COUNT);
        when(notificationData.getNewMessagesCount()).thenReturn(NEW_MESSAGE_COUNT);
@@ -210,7 +221,8 @@ public class DeviceNotificationsTest {
    }

    private TestDeviceNotifications createDeviceNotifications(Builder builder,
            LockScreenNotification lockScreenNotification) {
                                                              LockScreenNotification lockScreenNotification)
    {
        NotificationController controller = createFakeNotificationController(builder);
        NotificationActionCreator actionCreator = mock(NotificationActionCreator.class);
        WearNotifications wearNotifications = mock(WearNotifications.class);
@@ -218,23 +230,29 @@ public class DeviceNotificationsTest {
        return new TestDeviceNotifications(controller, actionCreator, lockScreenNotification, wearNotifications);
    }

    private NotificationController createFakeNotificationController(final Builder builder) {
    private NotificationController createFakeNotificationController(final Builder builder)
    {
        Application context = RuntimeEnvironment.application;

        NotificationController controller = mock(NotificationController.class);
        when(controller.getContext()).thenReturn(context);
        when(controller.getAccountName(any(Account.class))).thenReturn(ACCOUNT_NAME);
        when(controller.createNotificationBuilder()).thenAnswer(new Answer<Builder>() {
        when(controller.createNotificationBuilder()).thenAnswer(new Answer<Builder>()
        {
            private int invocationCount = 0;

            @Override
            public Builder answer(InvocationOnMock invocation) throws Throwable {
            public Builder answer(InvocationOnMock invocation) throws Throwable
            {
                invocationCount++;
                switch (invocationCount) {
                    case 1: {
                switch (invocationCount)
                {
                    case 1:
                    {
                        return builder;
                    }
                    case 2: {
                    case 2:
                    {
                        return builder2;
                    }
                }
@@ -247,23 +265,27 @@ public class DeviceNotificationsTest {
    }


    static class TestDeviceNotifications extends DeviceNotifications {
    static class TestDeviceNotifications extends DeviceNotifications
    {
        BigTextStyle bigTextStyle = MockHelper.mockBuilder(BigTextStyle.class);
        InboxStyle inboxStyle = MockHelper.mockBuilder(InboxStyle.class);


        TestDeviceNotifications(NotificationController controller, NotificationActionCreator actionCreator,
                LockScreenNotification lockScreenNotification, WearNotifications wearNotifications) {
                                LockScreenNotification lockScreenNotification, WearNotifications wearNotifications)
        {
            super(controller, actionCreator, lockScreenNotification, wearNotifications);
        }

        @Override
        protected BigTextStyle createBigTextStyle(Builder builder) {
        protected BigTextStyle createBigTextStyle(Builder builder)
        {
            return bigTextStyle;
        }

        @Override
        protected InboxStyle createInboxStyle(Builder builder) {
        protected InboxStyle createInboxStyle(Builder builder)
        {
            return inboxStyle;
        }
    }
+96 −48
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import io.eelo.mail.K9RobolectricTestRunner;
import io.eelo.mail.MockHelper;
import io.eelo.mail.activity.MessageReference;
import io.eelo.mail.controller.MessagingController;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +34,8 @@ import static org.mockito.Mockito.when;


@RunWith(K9RobolectricTestRunner.class)
public class WearNotificationsTest {
public class WearNotificationsTest
{
    private static final int ACCOUNT_NUMBER = 42;
    private static final String ACCOUNT_NAME = "accountName";

@@ -44,7 +46,8 @@ public class WearNotificationsTest {
    private Notification notification;

    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception
    {
        account = createAccount();
        notification = createNotification();
        builder = createNotificationBuilder(notification);
@@ -56,7 +59,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testBuildStackedNotification() throws Exception {
    public void testBuildStackedNotification() throws Exception
    {
        disableOptionalActions();
        int notificationIndex = 0;
        int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
@@ -74,12 +78,13 @@ public class WearNotificationsTest {
        assertEquals(notification, result);
        verifyExtendWasOnlyCalledOnce();
        verifyAddAction(io.eelo.mail.R.drawable.ic_action_single_message_options_dark, "Reply", replyPendingIntent);
        verifyAddAction(io.eelo.mail.R.drawable.ic_action_mark_as_read_dark, "Mark Read", markAsReadPendingIntent);
        verifyAddAction(io.eelo.mail.R.drawable.ic_action_mark_as_read_dark, "Mark As Read", markAsReadPendingIntent);
        verifyNumberOfActions(2);
    }

    @Test
    public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception {
    public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception
    {
        enableDeleteAction();
        int notificationIndex = 0;
        int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
@@ -98,7 +103,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception {
    public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception
    {
        enableArchiveAction();
        int notificationIndex = 0;
        int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
@@ -117,7 +123,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception {
    public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception
    {
        enableSpamAction();
        int notificationIndex = 0;
        int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
@@ -136,7 +143,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testAddSummaryActions() throws Exception {
    public void testAddSummaryActions() throws Exception
    {
        disableOptionalSummaryActions();
        int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
        ArrayList<MessageReference> messageReferences = createMessageReferenceList();
@@ -153,7 +161,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testAddSummaryActionsWithDeleteAllActionEnabled() throws Exception {
    public void testAddSummaryActionsWithDeleteAllActionEnabled() throws Exception
    {
        enableDeleteAction();
        int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
        ArrayList<MessageReference> messageReferences = createMessageReferenceList();
@@ -169,7 +178,8 @@ public class WearNotificationsTest {
    }

    @Test
    public void testAddSummaryActionsWithArchiveAllActionEnabled() throws Exception {
    public void testAddSummaryActionsWithArchiveAllActionEnabled() throws Exception
    {
        enableArchiveAction();
        int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
        ArrayList<MessageReference> messageReferences = createMessageReferenceList();
@@ -184,49 +194,59 @@ public class WearNotificationsTest {
        verifyAddAction(io.eelo.mail.R.drawable.ic_action_archive_dark, "Archive All", archivePendingIntent);
    }

    private void disableOptionalActions() {
    private void disableOptionalActions()
    {
        disableDeleteAction();
        disableArchiveAction();
        disableSpamAction();
    }

    private void disableDeleteAction() {
    private void disableDeleteAction()
    {
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.NEVER);
    }

    private void disableArchiveAction() {
    private void disableArchiveAction()
    {
        when(account.getArchiveFolderName()).thenReturn(K9.FOLDER_NONE);
    }

    private void disableSpamAction() {
    private void disableSpamAction()
    {
        when(account.getSpamFolderName()).thenReturn(K9.FOLDER_NONE);
    }

    private void enableDeleteAction() {
    private void enableDeleteAction()
    {
        K9.setNotificationQuickDeleteBehaviour(K9.NotificationQuickDelete.ALWAYS);
        K9.setConfirmDeleteFromNotification(false);
    }

    private void enableArchiveAction() {
    private void enableArchiveAction()
    {
        when(account.getArchiveFolderName()).thenReturn("Archive");
    }

    private void enableSpamAction() {
    private void enableSpamAction()
    {
        when(account.getSpamFolderName()).thenReturn("Spam");
    }

    private void disableOptionalSummaryActions() {
    private void disableOptionalSummaryActions()
    {
        disableDeleteAction();
        disableArchiveAction();
    }

    private Builder createNotificationBuilder(Notification notification) {
    private Builder createNotificationBuilder(Notification notification)
    {
        Builder builder = MockHelper.mockBuilder(Builder.class);
        when(builder.build()).thenReturn(notification);
        return builder;
    }

    private NotificationController createNotificationController(Context context, Builder builder) {
    private NotificationController createNotificationController(Context context, Builder builder)
    {
        NotificationController controller = mock(NotificationController.class);
        when(controller.createNotificationBuilder()).thenReturn(builder);
        when(controller.getAccountName(account)).thenReturn(ACCOUNT_NAME);
@@ -234,43 +254,52 @@ public class WearNotificationsTest {
        return controller;
    }

    private NotificationActionCreator createNotificationActionCreator() {
    private NotificationActionCreator createNotificationActionCreator()
    {
        return mock(NotificationActionCreator.class);
    }

    private Account createAccount() {
    private Account createAccount()
    {
        Account account = mock(Account.class);
        when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
        return account;
    }

    private MessagingController createMessagingController() {
    private MessagingController createMessagingController()
    {
        MessagingController messagingController = mock(MessagingController.class);
        when(messagingController.isMoveCapable(account)).thenReturn(true);
        return messagingController;
    }

    private NotificationContent createNotificationContent(MessageReference messageReference) {
    private NotificationContent createNotificationContent(MessageReference messageReference)
    {
        return new NotificationContent(messageReference, null, null, null, null, false);
    }

    private NotificationHolder createNotificationHolder(int notificationId, NotificationContent content) {
    private NotificationHolder createNotificationHolder(int notificationId, NotificationContent content)
    {
        return new NotificationHolder(notificationId, content);
    }

    private Notification createNotification() {
    private Notification createNotification()
    {
        return mock(Notification.class);
    }

    private MessageReference createMessageReference(int number) {
    private MessageReference createMessageReference(int number)
    {
        return new MessageReference("account", "folder", String.valueOf(number), null);
    }

    private PendingIntent createFakePendingIntent(int requestCode) {
    private PendingIntent createFakePendingIntent(int requestCode)
    {
        return PendingIntent.getActivity(RuntimeEnvironment.application, requestCode, null, 0);
    }

    private ArrayList<MessageReference> createMessageReferenceList() {
    private ArrayList<MessageReference> createMessageReferenceList()
    {
        ArrayList<MessageReference> messageReferences = new ArrayList<MessageReference>();
        messageReferences.add(createMessageReference(1));
        messageReferences.add(createMessageReference(2));
@@ -278,54 +307,66 @@ public class WearNotificationsTest {
        return messageReferences;
    }

    private NotificationData createNotificationData(ArrayList<MessageReference> messageReferences) {
    private NotificationData createNotificationData(ArrayList<MessageReference> messageReferences)
    {
        NotificationData notificationData = mock(NotificationData.class);
        when(notificationData.getAccount()).thenReturn(account);
        when(notificationData.getAllMessageReferences()).thenReturn(messageReferences);
        return notificationData;
    }

    private Builder verifyExtendWasOnlyCalledOnce() {
    private Builder verifyExtendWasOnlyCalledOnce()
    {
        return verify(builder, times(1)).extend(any(Extender.class));
    }

    private void verifyAddAction(int icon, String title, PendingIntent pendingIntent) {
    private void verifyAddAction(int icon, String title, PendingIntent pendingIntent)
    {
        verify(builder).extend(action(icon, title, pendingIntent));
    }

    private Builder verifyNumberOfActions(int expectedNumberOfActions) {
    private Builder verifyNumberOfActions(int expectedNumberOfActions)
    {
        return verify(builder).extend(numberOfActions(expectedNumberOfActions));
    }

    private WearableExtender action(int icon, String title, PendingIntent pendingIntent) {
    private WearableExtender action(int icon, String title, PendingIntent pendingIntent)
    {
        return argThat(new ActionMatcher(icon, title, pendingIntent));
    }

    private WearableExtender numberOfActions(int expectedNumberOfActions) {
    private WearableExtender numberOfActions(int expectedNumberOfActions)
    {
        return argThat(new NumberOfActionsMatcher(expectedNumberOfActions));
    }


    static class ActionMatcher extends ArgumentMatcher<WearableExtender> {
    static class ActionMatcher extends ArgumentMatcher<WearableExtender>
    {
        private int icon;
        private String title;
        private PendingIntent pendingIntent;

        public ActionMatcher(int icon, String title, PendingIntent pendingIntent) {
        public ActionMatcher(int icon, String title, PendingIntent pendingIntent)
        {
            this.icon = icon;
            this.title = title;
            this.pendingIntent = pendingIntent;
        }

        @Override
        public boolean matches(Object argument) {
            if (!(argument instanceof WearableExtender)) {
        public boolean matches(Object argument)
        {
            if (!(argument instanceof WearableExtender))
            {
                return false;
            }

            WearableExtender wearableExtender = (WearableExtender) argument;
            for (Action action : wearableExtender.getActions()) {
                if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
            for (Action action : wearableExtender.getActions())
            {
                if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent)
                {
                    return true;
                }
            }
@@ -334,16 +375,20 @@ public class WearNotificationsTest {
        }
    }

    static class NumberOfActionsMatcher extends ArgumentMatcher<WearableExtender> {
    static class NumberOfActionsMatcher extends ArgumentMatcher<WearableExtender>
    {
        private final int expectedNumberOfActions;

        public NumberOfActionsMatcher(int expectedNumberOfActions) {
        public NumberOfActionsMatcher(int expectedNumberOfActions)
        {
            this.expectedNumberOfActions = expectedNumberOfActions;
        }

        @Override
        public boolean matches(Object argument) {
            if (!(argument instanceof WearableExtender)) {
        public boolean matches(Object argument)
        {
            if (!(argument instanceof WearableExtender))
            {
                return false;
            }

@@ -352,17 +397,20 @@ public class WearNotificationsTest {
        }
    }

    static class TestWearNotifications extends WearNotifications {
    static class TestWearNotifications extends WearNotifications
    {
        private final MessagingController messagingController;

        public TestWearNotifications(NotificationController controller, NotificationActionCreator actionCreator,
                MessagingController messagingController) {
                                     MessagingController messagingController)
        {
            super(controller, actionCreator);
            this.messagingController = messagingController;
        }

        @Override
        MessagingController createMessagingController() {
        MessagingController createMessagingController()
        {
            return messagingController;
        }
    }