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

Unverified Commit bb87dcc9 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #3706 from k9mail/remove_FOLDER_NONE

Use null instead of special folder value "-NONE-"
parents fe8d01dc fa1d6aab
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -306,11 +306,11 @@ public class Account implements BaseAccount, StoreConfig {
        isEnabled = true;
        markMessageAsReadOnView = true;
        alwaysShowCcBcc = false;
        archiveFolder = K9.FOLDER_NONE;
        draftsFolder = K9.FOLDER_NONE;
        sentFolder = K9.FOLDER_NONE;
        spamFolder = K9.FOLDER_NONE;
        trashFolder = K9.FOLDER_NONE;
        archiveFolder = null;
        draftsFolder = null;
        sentFolder = null;
        spamFolder = null;
        trashFolder = null;

        searchableFolders = Searchable.ALL;

@@ -366,11 +366,11 @@ public class Account implements BaseAccount, StoreConfig {
        notifySync = storage.getBoolean(accountUuid + ".notifyMailCheck", false);
        deletePolicy =  DeletePolicy.fromInt(storage.getInt(accountUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
        inboxFolder = storage.getString(accountUuid + ".inboxFolderName", INBOX);
        draftsFolder = storage.getString(accountUuid + ".draftsFolderName", K9.FOLDER_NONE);
        sentFolder = storage.getString(accountUuid + ".sentFolderName", K9.FOLDER_NONE);
        trashFolder = storage.getString(accountUuid + ".trashFolderName", K9.FOLDER_NONE);
        archiveFolder = storage.getString(accountUuid + ".archiveFolderName", K9.FOLDER_NONE);
        spamFolder = storage.getString(accountUuid + ".spamFolderName", K9.FOLDER_NONE);
        draftsFolder = storage.getString(accountUuid + ".draftsFolderName", null);
        sentFolder = storage.getString(accountUuid + ".sentFolderName", null);
        trashFolder = storage.getString(accountUuid + ".trashFolderName", null);
        archiveFolder = storage.getString(accountUuid + ".archiveFolderName", null);
        spamFolder = storage.getString(accountUuid + ".spamFolderName", null);
        expungePolicy = getEnumStringPref(storage, accountUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
        syncRemoteDeletions = storage.getBoolean(accountUuid + ".syncRemoteDeletions", true);

@@ -946,7 +946,7 @@ public class Account implements BaseAccount, StoreConfig {
     * @return true if account has a drafts folder set.
     */
    public synchronized boolean hasDraftsFolder() {
        return !K9.FOLDER_NONE.equals(draftsFolder);
        return draftsFolder != null;
    }

    public synchronized String getSentFolder() {
@@ -962,7 +962,7 @@ public class Account implements BaseAccount, StoreConfig {
     * @return true if account has a sent folder set.
     */
    public synchronized boolean hasSentFolder() {
        return !K9.FOLDER_NONE.equals(sentFolder);
        return sentFolder != null;
    }


@@ -979,7 +979,7 @@ public class Account implements BaseAccount, StoreConfig {
     * @return true if account has a trash folder set.
     */
    public synchronized boolean hasTrashFolder() {
        return !K9.FOLDER_NONE.equals(trashFolder);
        return trashFolder != null;
    }

    public synchronized String getArchiveFolder() {
@@ -995,7 +995,7 @@ public class Account implements BaseAccount, StoreConfig {
     * @return true if account has an archive folder set.
     */
    public synchronized boolean hasArchiveFolder() {
        return !K9.FOLDER_NONE.equals(archiveFolder);
        return archiveFolder != null;
    }

    public synchronized String getSpamFolder() {
@@ -1011,7 +1011,7 @@ public class Account implements BaseAccount, StoreConfig {
     * @return true if account has a spam folder set.
     */
    public synchronized boolean hasSpamFolder() {
        return !K9.FOLDER_NONE.equals(spamFolder);
        return spamFolder != null;
    }

    public String getOutboxFolder() {
@@ -1723,7 +1723,7 @@ public class Account implements BaseAccount, StoreConfig {
    }

    private void excludeSpecialFolder(LocalSearch search, String folderServerId) {
        if (folderServerId != null && !K9.FOLDER_NONE.equals(folderServerId)) {
        if (folderServerId != null) {
            search.and(SearchField.FOLDER, folderServerId, Attribute.NOT_EQUALS);
        }
    }
+0 −5
Original line number Diff line number Diff line
@@ -203,11 +203,6 @@ public class K9 {
     */
    private static boolean databasesUpToDate = false;

    /**
     * For use when displaying that no folder is selected
     */
    public static final String FOLDER_NONE = "-NONE-";

    public static final String LOCAL_UID_PREFIX = "K9LOCAL:";

    public static final String REMOTE_UID_PREFIX = "K9REMOTE:";
+9 −4
Original line number Diff line number Diff line
@@ -1713,6 +1713,11 @@ public class MessagingController {

    private void moveMessageToDraftsFolder(Account account, Folder localFolder, LocalStore localStore, Message message)
            throws MessagingException {
        if (!account.hasDraftsFolder()) {
            Timber.d("Can't move message to Drafts folder. No Drafts folder configured.");
            return;
        }

        LocalFolder draftsFolder = localStore.getFolder(account.getDraftsFolder());
        localFolder.moveMessages(Collections.singletonList(message), draftsFolder);
    }
@@ -2723,10 +2728,10 @@ public class MessagingController {
        if (folder != null) {
            String folderServerId = folder.getServerId();
            if (!account.getInboxFolder().equals(folderServerId) &&
                    (account.getTrashFolder().equals(folderServerId)
                            || account.getDraftsFolder().equals(folderServerId)
                            || account.getSpamFolder().equals(folderServerId)
                            || account.getSentFolder().equals(folderServerId))) {
                    (folderServerId.equals(account.getTrashFolder())
                            || folderServerId.equals(account.getDraftsFolder())
                            || folderServerId.equals(account.getSpamFolder())
                            || folderServerId.equals(account.getSentFolder()))) {
                return false;
            }
        }
+3 −5
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public class NotificationActionService extends CoreService {
        }

        String spamFolderName = account.getSpamFolder();
        if (spamFolderName != null && !K9.confirmSpam() && isMovePossible(controller, account, spamFolderName)) {
        if (!K9.confirmSpam() && isMovePossible(controller, account, spamFolderName)) {
            String sourceFolderName = messageReference.getFolderServerId();
            controller.moveMessage(account, sourceFolderName, messageReference, spamFolderName);
        }
@@ -233,10 +233,8 @@ public class NotificationActionService extends CoreService {
        }
    }

    private boolean isMovePossible(MessagingController controller, Account account,
            String destinationFolderName) {
        boolean isSpecialFolderConfigured = !K9.FOLDER_NONE.equals(destinationFolderName);

    private boolean isMovePossible(MessagingController controller, Account account, String destinationFolderName) {
        boolean isSpecialFolderConfigured = destinationFolderName != null;
        return isSpecialFolderConfigured && controller.isMoveCapable(account);
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -231,17 +231,15 @@ class WearNotifications extends BaseNotifications {
    }

    private boolean isArchiveActionAvailableForWear(Account account) {
        String archiveFolderName = account.getArchiveFolder();
        return archiveFolderName != null && isMovePossible(account, archiveFolderName);
        return isMovePossible(account, account.getArchiveFolder());
    }

    private boolean isSpamActionAvailableForWear(Account account) {
        String spamFolderName = account.getSpamFolder();
        return spamFolderName != null && !K9.confirmSpam() && isMovePossible(account, spamFolderName);
        return !K9.confirmSpam() && isMovePossible(account, account.getSpamFolder());
    }

    private boolean isMovePossible(Account account, String destinationFolderName) {
        if (K9.FOLDER_NONE.equals(destinationFolderName)) {
        if (destinationFolderName == null) {
            return false;
        }

Loading