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

Commit cb4cd183 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Merged auto-config.

parent 2a2c0b00
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -39,6 +39,4 @@ public interface StoreConfig {
    int getDisplayCount();

    int getIdleRefreshMinutes();

    boolean shouldHideHostname();
}
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ dependencies {
    compile "com.squareup.okio:okio:${okioVersion}"
    compile 'commons-io:commons-io:2.4'
    compile "com.android.support:support-v4:${androidSupportLibraryVersion}"
    compile "com.android.support:design:${androidSupportLibraryVersion}"
    compile 'org.jsoup:jsoup:1.11.2'
    compile 'de.cketti.library.changelog:ckchangelog:1.2.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
+46 −45
Original line number Diff line number Diff line
@@ -27,22 +27,13 @@ import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.Transport;

import com.fsck.k9.activity.setup.AccountSetupCheckSettings;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig;
import com.fsck.k9.mailstore.StorageManager;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.view.ColorChip;
import com.larswerkman.colorpicker.ColorPicker;
import timber.log.Timber;

import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.NetworkType;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.Folder.FolderClass;
import com.fsck.k9.mail.TransportUris;
import com.fsck.k9.mail.filter.Base64;
@@ -52,10 +43,19 @@ import com.fsck.k9.mailstore.StorageManager.StorageProvider;
import com.fsck.k9.mailstore.LocalStore;
import com.fsck.k9.preferences.StorageEditor;
import com.fsck.k9.preferences.Storage;
import com.fsck.k9.provider.EmailProvider;
import com.fsck.k9.provider.EmailProvider.StatsColumns;
import com.fsck.k9.search.ConditionsTreeNode;
import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SqlQueryBuilder;
import com.fsck.k9.search.SearchSpecification.Attribute;
import com.fsck.k9.search.SearchSpecification.SearchCondition;
import com.fsck.k9.search.SearchSpecification.SearchField;
import com.fsck.k9.mail.ssl.LocalKeyStore;
import com.fsck.k9.view.ColorChip;
import com.larswerkman.colorpicker.ColorPicker;

import static com.fsck.k9.Preferences.getEnumStringPref;

/**
 * Account stores all of the settings for a single account defined by the user. It is able to save
@@ -425,7 +425,7 @@ public class Account implements BaseAccount, AccountConfig {
        latestOldMessageSeenTime = storage.getLong(accountUuid + ".latestOldMessageSeenTime", 0);
        notifyNewMail = storage.getBoolean(accountUuid + ".notifyNewMail", false);

        folderNotifyNewMailMode = Preferences.getEnumStringPref(storage, accountUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
        folderNotifyNewMailMode = getEnumStringPref(storage, accountUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
        notifySelfNewMail = storage.getBoolean(accountUuid + ".notifySelfNewMail", true);
        notifyContactsMailOnly = storage.getBoolean(accountUuid + ".notifyContactsMailOnly", false);
        notifySync = storage.getBoolean(accountUuid + ".notifyMailCheck", false);
@@ -436,7 +436,7 @@ public class Account implements BaseAccount, AccountConfig {
        trashFolderName = storage.getString(accountUuid + ".trashFolderName", "Trash");
        archiveFolderName = storage.getString(accountUuid + ".archiveFolderName", "Archive");
        spamFolderName = storage.getString(accountUuid + ".spamFolderName", "Spam");
        expungePolicy = Preferences.getEnumStringPref(storage, accountUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
        expungePolicy = getEnumStringPref(storage, accountUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
        syncRemoteDeletions = storage.getBoolean(accountUuid + ".syncRemoteDeletions", true);

        maxPushFolders = storage.getInt(accountUuid + ".maxPushFolders", 10);
@@ -450,7 +450,7 @@ public class Account implements BaseAccount, AccountConfig {
            messageFormat = MessageFormat.AUTO;
        }
        messageReadReceipt = storage.getBoolean(accountUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
        quoteStyle = Preferences.getEnumStringPref(storage, accountUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE);
        quoteStyle = getEnumStringPref(storage, accountUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE);
        quotePrefix = storage.getString(accountUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
        defaultQuotedTextShown = storage.getBoolean(accountUuid + ".defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN);
        replyAfterQuote = storage.getBoolean(accountUuid + ".replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE);
@@ -467,11 +467,11 @@ public class Account implements BaseAccount, AccountConfig {

        chipColor = storage.getInt(accountUuid + ".chipColor", ColorPicker.getRandomColor());

        sortType = Preferences.getEnumStringPref(storage, accountUuid + ".sortTypeEnum", SortType.SORT_DATE);
        sortType = getEnumStringPref(storage, accountUuid + ".sortTypeEnum", SortType.SORT_DATE);

        sortAscending.put(sortType, storage.getBoolean(accountUuid + ".sortAscending", false));

        showPictures = Preferences.getEnumStringPref(storage, accountUuid + ".showPicturesEnum", ShowPictures.NEVER);
        showPictures = getEnumStringPref(storage, accountUuid + ".showPicturesEnum", ShowPictures.NEVER);

        notificationSetting.setVibrate(storage.getBoolean(accountUuid + ".vibrate", false));
        notificationSetting.setVibratePattern(storage.getInt(accountUuid + ".vibratePattern", 0));
@@ -482,15 +482,15 @@ public class Account implements BaseAccount, AccountConfig {
        notificationSetting.setLed(storage.getBoolean(accountUuid + ".led", true));
        notificationSetting.setLedColor(storage.getInt(accountUuid + ".ledColor", chipColor));

        folderDisplayMode = Preferences.getEnumStringPref(storage, accountUuid + ".folderDisplayMode", FolderMode.NOT_SECOND_CLASS);
        folderDisplayMode = getEnumStringPref(storage, accountUuid + ".folderDisplayMode", FolderMode.NOT_SECOND_CLASS);

        folderSyncMode = Preferences.getEnumStringPref(storage, accountUuid + ".folderSyncMode", FolderMode.FIRST_CLASS);
        folderSyncMode = getEnumStringPref(storage, accountUuid + ".folderSyncMode", FolderMode.FIRST_CLASS);

        folderPushMode = Preferences.getEnumStringPref(storage, accountUuid + ".folderPushMode", FolderMode.FIRST_CLASS);
        folderPushMode = getEnumStringPref(storage, accountUuid + ".folderPushMode", FolderMode.FIRST_CLASS);

        folderTargetMode = Preferences.getEnumStringPref(storage, accountUuid + ".folderTargetMode", FolderMode.NOT_SECOND_CLASS);
        folderTargetMode = getEnumStringPref(storage, accountUuid + ".folderTargetMode", FolderMode.NOT_SECOND_CLASS);

        searchableFolders = Preferences.getEnumStringPref(storage, accountUuid + ".searchableFolders", Searchable.ALL);
        searchableFolders = getEnumStringPref(storage, accountUuid + ".searchableFolders", Searchable.ALL);

        isSignatureBeforeQuotedText = storage.getBoolean(accountUuid + ".signatureBeforeQuotedText", false);
        identities = loadIdentities(storage);
@@ -819,8 +819,8 @@ public class Account implements BaseAccount, AccountConfig {
                "account/" + getUuid() + "/stats");

        String[] projection = {
                EmailProvider.StatsColumns.UNREAD_COUNT,
                EmailProvider.StatsColumns.FLAGGED_COUNT
                StatsColumns.UNREAD_COUNT,
                StatsColumns.FLAGGED_COUNT
        };

        // Create LocalSearch instance to exclude special folders (Trash, Drafts, Spam, Outbox,
@@ -1017,7 +1017,7 @@ public class Account implements BaseAccount, AccountConfig {
        this.alwaysBcc = alwaysBcc;
    }

    /* Have we sent a new k9 notification on this account */
    /* Have we sent a new mail notification on this account */
    public boolean isRingNotified() {
        return ringNotified;
    }
@@ -1154,7 +1154,8 @@ public class Account implements BaseAccount, AccountConfig {
                folderName.equals(getArchiveFolderName()) ||
                folderName.equals(getSpamFolderName()) ||
                folderName.equals(getOutboxFolderName()) ||
                folderName.equals(getSentFolderName())));
                folderName.equals(getSentFolderName()) ||
                folderName.equals(getErrorFolderName())));
    }

    public synchronized String getDraftsFolderName() {
@@ -1177,6 +1178,10 @@ public class Account implements BaseAccount, AccountConfig {
        return sentFolderName;
    }

    public synchronized String getErrorFolderName() {
        return K9.ERROR_FOLDER_NAME;
    }

    public synchronized void setSentFolderName(String name) {
        sentFolderName = name;
    }
@@ -1557,11 +1562,6 @@ public class Account implements BaseAccount, AccountConfig {
        return idleRefreshMinutes;
    }

    @Override
    public boolean shouldHideHostname() {
        return K9.hideHostnameWhenConnecting();
    }

    public synchronized void setIdleRefreshMinutes(int idleRefreshMinutes) {
        this.idleRefreshMinutes = idleRefreshMinutes;
    }
@@ -1765,7 +1765,7 @@ public class Account implements BaseAccount, AccountConfig {
    }

    /**
     * @return <code>true</code> if our {@link StorageManager.StorageProvider} is ready. (e.g.
     * @return <code>true</code> if our {@link StorageProvider} is ready. (e.g.
     *         card inserted)
     */
    public boolean isAvailable(Context context) {
@@ -1824,18 +1824,18 @@ public class Account implements BaseAccount, AccountConfig {
        switch (displayMode) {
            case FIRST_CLASS: {
                // Count messages in the INBOX and non-special first class folders
                search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
                        SearchSpecification.Attribute.EQUALS);
                search.and(SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
                        Attribute.EQUALS);
                break;
            }
            case FIRST_AND_SECOND_CLASS: {
                // Count messages in the INBOX and non-special first and second class folders
                search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
                        SearchSpecification.Attribute.EQUALS);
                search.and(SearchField.DISPLAY_CLASS, FolderClass.FIRST_CLASS.name(),
                        Attribute.EQUALS);

                // TODO: Create a proper interface for creating arbitrary condition trees
                SearchSpecification.SearchCondition searchCondition = new SearchSpecification.SearchCondition(SearchSpecification.SearchField.DISPLAY_CLASS,
                        SearchSpecification.Attribute.EQUALS, FolderClass.SECOND_CLASS.name());
                SearchCondition searchCondition = new SearchCondition(SearchField.DISPLAY_CLASS,
                        Attribute.EQUALS, FolderClass.SECOND_CLASS.name());
                ConditionsTreeNode root = search.getConditions();
                if (root.mRight != null) {
                    root.mRight.or(searchCondition);
@@ -1846,8 +1846,8 @@ public class Account implements BaseAccount, AccountConfig {
            }
            case NOT_SECOND_CLASS: {
                // Count messages in the INBOX and non-special non-second-class folders
                search.and(SearchSpecification.SearchField.DISPLAY_CLASS, FolderClass.SECOND_CLASS.name(),
                        SearchSpecification.Attribute.NOT_EQUALS);
                search.and(SearchField.DISPLAY_CLASS, FolderClass.SECOND_CLASS.name(),
                        Attribute.NOT_EQUALS);
                break;
            }
            default:
@@ -1883,7 +1883,8 @@ public class Account implements BaseAccount, AccountConfig {
        excludeSpecialFolder(search, getSpamFolderName());
        excludeSpecialFolder(search, getOutboxFolderName());
        excludeSpecialFolder(search, getSentFolderName());
        search.or(new SearchSpecification.SearchCondition(SearchSpecification.SearchField.FOLDER, SearchSpecification.Attribute.EQUALS, getInboxFolderName()));
        excludeSpecialFolder(search, getErrorFolderName());
        search.or(new SearchCondition(SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName()));
    }

    /**
@@ -1907,21 +1908,21 @@ public class Account implements BaseAccount, AccountConfig {
        excludeSpecialFolder(search, getTrashFolderName());
        excludeSpecialFolder(search, getSpamFolderName());
        excludeSpecialFolder(search, getOutboxFolderName());
        search.or(new SearchSpecification.SearchCondition(SearchSpecification.SearchField.FOLDER, SearchSpecification.Attribute.EQUALS, getInboxFolderName()));
        search.or(new SearchCondition(SearchField.FOLDER, Attribute.EQUALS, getInboxFolderName()));
    }

    private void excludeSpecialFolder(LocalSearch search, String folderName) {
        if (folderName != null && !K9.FOLDER_NONE.equals(folderName)) {
            search.and(SearchSpecification.SearchField.FOLDER, folderName, SearchSpecification.Attribute.NOT_EQUALS);
            search.and(SearchField.FOLDER, folderName, Attribute.NOT_EQUALS);
        }
    }

    /**
     * Add a new certificate for the incoming or outgoing server to the local key store.
     */
    public void addCertificate(AccountSetupCheckSettings.CheckDirection direction, X509Certificate certificate) throws CertificateException {
    public void addCertificate(CheckDirection direction, X509Certificate certificate) throws CertificateException {
        Uri uri;
        if (direction == AccountSetupCheckSettings.CheckDirection.INCOMING) {
        if (direction == CheckDirection.INCOMING) {
            uri = Uri.parse(getStoreUri());
        } else {
            uri = Uri.parse(getTransportUri());
@@ -1938,7 +1939,7 @@ public class Account implements BaseAccount, AccountConfig {
    @Override
    public void deleteCertificate(String newHost, int newPort, CheckDirection direction) {
        Uri uri;
        if (direction == AccountSetupCheckSettings.CheckDirection.INCOMING) {
        if (direction == CheckDirection.INCOMING) {
            uri = Uri.parse(getStoreUri());
        } else {
            uri = Uri.parse(getTransportUri());
+10 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ package com.fsck.k9;

import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -153,6 +155,14 @@ public class K9 extends Application
     */
    public static boolean DEBUG_SENSITIVE = false;

    /**
     * Can create messages containing stack traces that can be forwarded
     * to the development team.
     *
     * Feature is enabled when DEBUG == true
     */
    public static final String ERROR_FOLDER_NAME = "K9mail-errors";

    /**
     * A reference to the {@link SharedPreferences} used for caching the last known database
     * version.
+2 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.fsck.k9.activity.misc.ExtendedAsyncTask;
import com.fsck.k9.activity.misc.NonConfigurationInstance;
import com.fsck.k9.activity.setup.AccountSettings;
import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.activity.setup.WelcomeMessage;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.mail.AuthType;
@@ -463,8 +464,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener
        else if (accounts.size() < 1)
        {
            // Don't show the welcome message, proceed to account setup instead
            // TODO Check if it's okay to disable this: WelcomeMessage.showWelcomeMessage(this);
            AccountSetupBasics.actionNewAccount(this);
            WelcomeMessage.showWelcomeMessage(this);
            finish();
            return;
        }
Loading