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

Commit 658884a1 authored by cketti's avatar cketti
Browse files

Remove folder notification class

parent 8e85321e
Loading
Loading
Loading
Loading
+2 −27
Original line number Diff line number Diff line
@@ -32,38 +32,13 @@ class K9NotificationStrategy(
            return false
        }

        val folder = message.folder
        if (folder != null) {
            when (folder.databaseId) {
                account.inboxFolderId -> {
                    // Don't skip notifications if the Inbox folder is also configured as another special folder
                }
                account.trashFolderId -> {
                    Timber.v("No notification: Message is in Trash folder")
                    return false
                }
                account.draftsFolderId -> {
                    Timber.v("No notification: Message is in Drafts folder")
                    return false
                }
                account.spamFolderId -> {
                    Timber.v("No notification: Message is in Spam folder")
                    return false
                }
                account.sentFolderId -> {
                    Timber.v("No notification: Message is in Sent folder")
                    return false
                }
            }
        }

        if (isModeMismatch(account.folderDisplayMode, localFolder.displayClass)) {
            Timber.v("No notification: Message is in folder not being displayed")
            return false
        }

        if (isModeMismatch(account.folderNotifyNewMailMode, localFolder.notifyClass)) {
            Timber.v("No notification: Notifications are disabled for this folder class")
        if (!localFolder.isNotificationsEnabled) {
            Timber.v("No notification: Notifications are not enabled for this folder")
            return false
        }

+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ class FolderSettingsProvider(val preferences: Preferences, val account: Account)
            visibleLimit = account.displayCount,
            displayClass = storage.getString("$prefix.displayMode", null).toFolderClass(FolderClass.NO_CLASS),
            syncClass = storage.getString("$prefix.syncMode", null).toFolderClass(FolderClass.INHERITED),
            notifyClass = storage.getString("$prefix.notifyMode", null).toFolderClass(FolderClass.INHERITED),
            isNotificationsEnabled = storage.getBoolean("$prefix.notificationsEnabled", false),
            pushClass = storage.getString("$prefix.pushMode", null).toFolderClass(FolderClass.SECOND_CLASS),
            inTopGroup = storage.getBoolean("$prefix.inTopGroup", false),
            integrate = storage.getBoolean("$prefix.integrate", false),
@@ -31,7 +31,7 @@ class FolderSettingsProvider(val preferences: Preferences, val account: Account)

        editor.remove("$prefix.displayMode")
        editor.remove("$prefix.syncMode")
        editor.remove("$prefix.notifyMode")
        editor.remove("$prefix.notificationsEnabled")
        editor.remove("$prefix.pushMode")
        editor.remove("$prefix.inTopGroup")
        editor.remove("$prefix.integrate")
+4 −10
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class LocalFolder {
    private FolderClass displayClass = FolderClass.NO_CLASS;
    private FolderClass syncClass = FolderClass.INHERITED;
    private FolderClass pushClass = FolderClass.SECOND_CLASS;
    private FolderClass notifyClass = FolderClass.INHERITED;
    private boolean notificationsEnabled = false;

    private boolean isInTopGroup = false;
    private boolean isIntegrate = false;
@@ -177,8 +177,7 @@ public class LocalFolder {
        String noClass = FolderClass.NO_CLASS.toString();
        String displayClass = cursor.getString(LocalStore.FOLDER_DISPLAY_CLASS_INDEX);
        this.displayClass = FolderClass.valueOf((displayClass == null) ? noClass : displayClass);
        String notifyClass = cursor.getString(LocalStore.FOLDER_NOTIFY_CLASS_INDEX);
        this.notifyClass = FolderClass.valueOf((notifyClass == null) ? noClass : notifyClass);
        this.notificationsEnabled = cursor.getInt(LocalStore.FOLDER_NOTIFICATIONS_ENABLED_INDEX) == 1;
        String pushClass = cursor.getString(LocalStore.FOLDER_PUSH_CLASS_INDEX);
        this.pushClass = FolderClass.valueOf((pushClass == null) ? noClass : pushClass);
        String syncClass = cursor.getString(LocalStore.FOLDER_SYNC_CLASS_INDEX);
@@ -308,10 +307,6 @@ public class LocalFolder {
        return (FolderClass.INHERITED == syncClass) ? getDisplayClass() : syncClass;
    }

    public FolderClass getNotifyClass() {
        return (FolderClass.INHERITED == notifyClass) ? getPushClass() : notifyClass;
    }

    public FolderClass getPushClass() {
        return (FolderClass.INHERITED == pushClass) ? getSyncClass() : pushClass;
    }
@@ -331,9 +326,8 @@ public class LocalFolder {
        updateFolderColumn("push_class", this.pushClass.name());
    }

    public void setNotifyClass(FolderClass notifyClass) throws MessagingException {
        this.notifyClass = notifyClass;
        updateFolderColumn("notify_class", this.notifyClass.name());
    public boolean isNotificationsEnabled() {
        return notificationsEnabled;
    }

    public boolean isIntegrate() {
+2 −2
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public class LocalStore {

    static final String GET_FOLDER_COLS =
        "folders.id, name, visible_limit, last_updated, status, " +
        "integrate, top_group, poll_class, push_class, display_class, notify_class, more_messages, server_id, " +
        "integrate, top_group, poll_class, push_class, display_class, notifications_enabled, more_messages, server_id, " +
        "local_only, type";

    static final int FOLDER_ID_INDEX = 0;
@@ -125,7 +125,7 @@ public class LocalStore {
    static final int FOLDER_SYNC_CLASS_INDEX = 7;
    static final int FOLDER_PUSH_CLASS_INDEX = 8;
    static final int FOLDER_DISPLAY_CLASS_INDEX = 9;
    static final int FOLDER_NOTIFY_CLASS_INDEX = 10;
    static final int FOLDER_NOTIFICATIONS_ENABLED_INDEX = 10;
    static final int MORE_MESSAGES_INDEX = 11;
    static final int FOLDER_SERVER_ID_INDEX = 12;
    static final int LOCAL_ONLY_INDEX = 13;
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class SpecialFolderUpdater(
            folderRepository.setDisplayClass(account, newInboxId, FolderClass.FIRST_CLASS)
            folderRepository.setSyncClass(account, newInboxId, FolderClass.FIRST_CLASS)
            folderRepository.setPushClass(account, newInboxId, FolderClass.FIRST_CLASS)
            folderRepository.setNotificationClass(account, newInboxId, FolderClass.FIRST_CLASS)
            folderRepository.setNotificationsEnabled(account, newInboxId, true)
        }
    }

Loading