Search in sources :

Example 56 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class MessageList method useSplitView.

private boolean useSplitView() {
    SplitViewMode splitViewMode = K9.getSplitViewMode();
    int orientation = getResources().getConfiguration().orientation;
    return (splitViewMode == SplitViewMode.ALWAYS || (splitViewMode == SplitViewMode.WHEN_IN_LANDSCAPE && orientation == Configuration.ORIENTATION_LANDSCAPE));
}
Also used : SplitViewMode(com.fsck.k9.K9.SplitViewMode) SuppressLint(android.annotation.SuppressLint)

Example 57 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class Account method loadAccount.

/**
     * Load stored settings for this account.
     */
private synchronized void loadAccount(Preferences preferences) {
    Storage storage = preferences.getStorage();
    mStoreUri = Base64.decode(storage.getString(mUuid + ".storeUri", null));
    mLocalStorageProviderId = storage.getString(mUuid + ".localStorageProvider", StorageManager.getInstance(K9.app).getDefaultProviderId());
    mTransportUri = Base64.decode(storage.getString(mUuid + ".transportUri", null));
    mDescription = storage.getString(mUuid + ".description", null);
    mAlwaysBcc = storage.getString(mUuid + ".alwaysBcc", mAlwaysBcc);
    mAutomaticCheckIntervalMinutes = storage.getInt(mUuid + ".automaticCheckIntervalMinutes", -1);
    mIdleRefreshMinutes = storage.getInt(mUuid + ".idleRefreshMinutes", 24);
    mPushPollOnConnect = storage.getBoolean(mUuid + ".pushPollOnConnect", true);
    mDisplayCount = storage.getInt(mUuid + ".displayCount", K9.DEFAULT_VISIBLE_LIMIT);
    if (mDisplayCount < 0) {
        mDisplayCount = K9.DEFAULT_VISIBLE_LIMIT;
    }
    mLatestOldMessageSeenTime = storage.getLong(mUuid + ".latestOldMessageSeenTime", 0);
    mNotifyNewMail = storage.getBoolean(mUuid + ".notifyNewMail", false);
    mFolderNotifyNewMailMode = getEnumStringPref(storage, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
    mNotifySelfNewMail = storage.getBoolean(mUuid + ".notifySelfNewMail", true);
    mNotifyContactsMailOnly = storage.getBoolean(mUuid + ".notifyContactsMailOnly", false);
    mNotifySync = storage.getBoolean(mUuid + ".notifyMailCheck", false);
    mDeletePolicy = DeletePolicy.fromInt(storage.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
    mInboxFolderName = storage.getString(mUuid + ".inboxFolderName", INBOX);
    mDraftsFolderName = storage.getString(mUuid + ".draftsFolderName", "Drafts");
    mSentFolderName = storage.getString(mUuid + ".sentFolderName", "Sent");
    mTrashFolderName = storage.getString(mUuid + ".trashFolderName", "Trash");
    mArchiveFolderName = storage.getString(mUuid + ".archiveFolderName", "Archive");
    mSpamFolderName = storage.getString(mUuid + ".spamFolderName", "Spam");
    mExpungePolicy = getEnumStringPref(storage, mUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
    mSyncRemoteDeletions = storage.getBoolean(mUuid + ".syncRemoteDeletions", true);
    mMaxPushFolders = storage.getInt(mUuid + ".maxPushFolders", 10);
    goToUnreadMessageSearch = storage.getBoolean(mUuid + ".goToUnreadMessageSearch", false);
    subscribedFoldersOnly = storage.getBoolean(mUuid + ".subscribedFoldersOnly", false);
    maximumPolledMessageAge = storage.getInt(mUuid + ".maximumPolledMessageAge", -1);
    maximumAutoDownloadMessageSize = storage.getInt(mUuid + ".maximumAutoDownloadMessageSize", 32768);
    mMessageFormat = getEnumStringPref(storage, mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT);
    mMessageFormatAuto = storage.getBoolean(mUuid + ".messageFormatAuto", DEFAULT_MESSAGE_FORMAT_AUTO);
    if (mMessageFormatAuto && mMessageFormat == MessageFormat.TEXT) {
        mMessageFormat = MessageFormat.AUTO;
    }
    mMessageReadReceipt = storage.getBoolean(mUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
    mQuoteStyle = getEnumStringPref(storage, mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE);
    mQuotePrefix = storage.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
    mDefaultQuotedTextShown = storage.getBoolean(mUuid + ".defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN);
    mReplyAfterQuote = storage.getBoolean(mUuid + ".replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE);
    mStripSignature = storage.getBoolean(mUuid + ".stripSignature", DEFAULT_STRIP_SIGNATURE);
    for (NetworkType type : NetworkType.values()) {
        Boolean useCompression = storage.getBoolean(mUuid + ".useCompression." + type, true);
        compressionMap.put(type, useCompression);
    }
    mAutoExpandFolderName = storage.getString(mUuid + ".autoExpandFolderName", INBOX);
    mAccountNumber = storage.getInt(mUuid + ".accountNumber", 0);
    mChipColor = storage.getInt(mUuid + ".chipColor", ColorPicker.getRandomColor());
    mSortType = getEnumStringPref(storage, mUuid + ".sortTypeEnum", SortType.SORT_DATE);
    mSortAscending.put(mSortType, storage.getBoolean(mUuid + ".sortAscending", false));
    mShowPictures = getEnumStringPref(storage, mUuid + ".showPicturesEnum", ShowPictures.NEVER);
    mNotificationSetting.setVibrate(storage.getBoolean(mUuid + ".vibrate", false));
    mNotificationSetting.setVibratePattern(storage.getInt(mUuid + ".vibratePattern", 0));
    mNotificationSetting.setVibrateTimes(storage.getInt(mUuid + ".vibrateTimes", 5));
    mNotificationSetting.setRing(storage.getBoolean(mUuid + ".ring", true));
    mNotificationSetting.setRingtone(storage.getString(mUuid + ".ringtone", "content://settings/system/notification_sound"));
    mNotificationSetting.setLed(storage.getBoolean(mUuid + ".led", true));
    mNotificationSetting.setLedColor(storage.getInt(mUuid + ".ledColor", mChipColor));
    mFolderDisplayMode = getEnumStringPref(storage, mUuid + ".folderDisplayMode", FolderMode.NOT_SECOND_CLASS);
    mFolderSyncMode = getEnumStringPref(storage, mUuid + ".folderSyncMode", FolderMode.FIRST_CLASS);
    mFolderPushMode = getEnumStringPref(storage, mUuid + ".folderPushMode", FolderMode.FIRST_CLASS);
    mFolderTargetMode = getEnumStringPref(storage, mUuid + ".folderTargetMode", FolderMode.NOT_SECOND_CLASS);
    searchableFolders = getEnumStringPref(storage, mUuid + ".searchableFolders", Searchable.ALL);
    mIsSignatureBeforeQuotedText = storage.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
    identities = loadIdentities(storage);
    mCryptoKey = storage.getLong(mUuid + ".cryptoKey", NO_OPENPGP_KEY);
    mAllowRemoteSearch = storage.getBoolean(mUuid + ".allowRemoteSearch", false);
    mRemoteSearchFullText = storage.getBoolean(mUuid + ".remoteSearchFullText", false);
    mRemoteSearchNumResults = storage.getInt(mUuid + ".remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS);
    mEnabled = storage.getBoolean(mUuid + ".enabled", true);
    mMarkMessageAsReadOnView = storage.getBoolean(mUuid + ".markMessageAsReadOnView", true);
    mAlwaysShowCcBcc = storage.getBoolean(mUuid + ".alwaysShowCcBcc", false);
    cacheChips();
    // Use email address as account description if necessary
    if (mDescription == null) {
        mDescription = getEmail();
    }
}
Also used : Storage(com.fsck.k9.preferences.Storage) NetworkType(com.fsck.k9.mail.NetworkType)

Example 58 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class AccountList method populateListView.

/**
     * Create a new {@link AccountsAdapter} instance and assign it to the {@link ListView}.
     *
     * @param realAccounts
     *         An array of accounts to display.
     */
public void populateListView(List<Account> realAccounts) {
    List<BaseAccount> accounts = new ArrayList<BaseAccount>();
    if (displaySpecialAccounts() && !K9.isHideSpecialAccounts()) {
        BaseAccount unifiedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
        BaseAccount allMessagesAccount = SearchAccount.createAllMessagesAccount(this);
        accounts.add(unifiedInboxAccount);
        accounts.add(allMessagesAccount);
    }
    accounts.addAll(realAccounts);
    AccountsAdapter adapter = new AccountsAdapter(accounts);
    ListView listView = getListView();
    listView.setAdapter(adapter);
    listView.invalidate();
}
Also used : ListView(android.widget.ListView) BaseAccount(com.fsck.k9.BaseAccount) ArrayList(java.util.ArrayList)

Example 59 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class Accounts method refresh.

private void refresh() {
    accounts.clear();
    accounts.addAll(Preferences.getPreferences(this).getAccounts());
    // see if we should show the welcome message
    //        if (accounts.length < 1) {
    //            WelcomeMessage.showWelcomeMessage(this);
    //            finish();
    //        }
    List<BaseAccount> newAccounts;
    if (!K9.isHideSpecialAccounts() && accounts.size() > 0) {
        if (mUnifiedInboxAccount == null || mAllMessagesAccount == null) {
            createSpecialAccounts();
        }
        newAccounts = new ArrayList<BaseAccount>(accounts.size() + SPECIAL_ACCOUNTS_COUNT);
        newAccounts.add(mUnifiedInboxAccount);
        newAccounts.add(mAllMessagesAccount);
    } else {
        newAccounts = new ArrayList<BaseAccount>(accounts.size());
    }
    newAccounts.addAll(accounts);
    mAdapter = new AccountsAdapter(newAccounts);
    getListView().setAdapter(mAdapter);
    if (!newAccounts.isEmpty()) {
        mHandler.progress(Window.PROGRESS_START);
    }
    pendingWork.clear();
    mHandler.refreshTitle();
    MessagingController controller = MessagingController.getInstance(getApplication());
    for (BaseAccount account : newAccounts) {
        pendingWork.put(account, "true");
        if (account instanceof Account) {
            Account realAccount = (Account) account;
            controller.getAccountStats(this, realAccount, mListener);
        } else if (K9.countSearchMessages() && account instanceof SearchAccount) {
            final SearchAccount searchAccount = (SearchAccount) account;
            controller.getSearchAccountStats(searchAccount, mListener);
        }
    }
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) BaseAccount(com.fsck.k9.BaseAccount) BaseAccount(com.fsck.k9.BaseAccount) MessagingController(com.fsck.k9.controller.MessagingController) SearchAccount(com.fsck.k9.search.SearchAccount)

Example 60 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class Accounts method onOpenAccount.

/**
     * Show that account's inbox or folder-list
     * or return false if the account is not available.
     * @param account the account to open ({@link SearchAccount} or {@link Account})
     * @return false if unsuccessful
     */
private boolean onOpenAccount(BaseAccount account) {
    if (account instanceof SearchAccount) {
        SearchAccount searchAccount = (SearchAccount) account;
        MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false, false);
    } else {
        Account realAccount = (Account) account;
        if (!realAccount.isEnabled()) {
            onActivateAccount(realAccount);
            return false;
        } else if (!realAccount.isAvailable(this)) {
            String toastText = getString(R.string.account_unavailable, account.getDescription());
            Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT);
            toast.show();
            Timber.i("refusing to open account that is not available");
            return false;
        }
        if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
            FolderList.actionHandleAccount(this, realAccount);
        } else {
            LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderName());
            search.addAllowedFolder(realAccount.getAutoExpandFolderName());
            search.addAccountUuid(realAccount.getUuid());
            MessageList.actionDisplaySearch(this, search, false, true);
        }
    }
    return true;
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) BaseAccount(com.fsck.k9.BaseAccount) Toast(android.widget.Toast) LocalSearch(com.fsck.k9.search.LocalSearch) SearchAccount(com.fsck.k9.search.SearchAccount)

Aggregations

Account (com.fsck.k9.Account)20 MessagingException (com.fsck.k9.mail.MessagingException)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)10 LocalStore (com.fsck.k9.mailstore.LocalStore)10 Message (com.fsck.k9.mail.Message)9 Store (com.fsck.k9.mail.Store)9 LocalFolder (com.fsck.k9.mailstore.LocalFolder)9 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)9 Intent (android.content.Intent)8 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)8 LocalMessage (com.fsck.k9.mailstore.LocalMessage)8 SuppressLint (android.annotation.SuppressLint)7 BaseAccount (com.fsck.k9.BaseAccount)7 Preferences (com.fsck.k9.Preferences)7 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)7 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)7 Folder (com.fsck.k9.mail.Folder)7 SearchAccount (com.fsck.k9.search.SearchAccount)7