use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class RecipientAdapter method bindView.
public void bindView(View view, Recipient recipient) {
RecipientTokenHolder holder = (RecipientTokenHolder) view.getTag();
holder.name.setText(highlightText(recipient.getDisplayNameOrUnknown(context)));
String address = recipient.address.getAddress();
holder.email.setText(highlightText(address));
setContactPhotoOrPlaceholder(context, holder.photo, recipient);
Integer cryptoStatusRes = null, cryptoStatusColor = null;
RecipientCryptoStatus cryptoStatus = recipient.getCryptoStatus();
switch(cryptoStatus) {
case AVAILABLE_TRUSTED:
{
cryptoStatusRes = R.drawable.status_lock_dots_3;
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_green);
break;
}
case AVAILABLE_UNTRUSTED:
{
cryptoStatusRes = R.drawable.status_lock_dots_2;
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_orange);
break;
}
case UNAVAILABLE:
{
cryptoStatusRes = R.drawable.status_lock_disabled_dots_1;
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_red);
break;
}
}
if (cryptoStatusRes != null) {
Drawable drawable = ContextCompat.getDrawable(context, cryptoStatusRes);
DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable.mutate(), cryptoStatusColor);
holder.cryptoStatusIcon.setImageDrawable(drawable);
holder.cryptoStatus.setVisibility(View.VISIBLE);
} else {
holder.cryptoStatus.setVisibility(View.GONE);
}
}
use of com.fsck.k9.mail.Address 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();
}
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class SmtpTransport method sendMessageTo.
private void sendMessageTo(List<String> addresses, Message message) throws MessagingException {
close();
open();
if (!m8bitEncodingAllowed) {
Log.d(LOG_TAG, "Server does not support 8bit transfer encoding");
}
// the size of messages, count the message's size before sending it
if (mLargestAcceptableMessage > 0 && message.hasAttachments()) {
if (message.calculateSize() > mLargestAcceptableMessage) {
throw new MessagingException("Message too large for server", true);
}
}
boolean entireMessageSent = false;
Address[] from = message.getFrom();
try {
String fromAddress = from[0].getAddress();
if (m8bitEncodingAllowed) {
executeCommand("MAIL FROM:<%s> BODY=8BITMIME", fromAddress);
} else {
executeCommand("MAIL FROM:<%s>", fromAddress);
}
for (String address : addresses) {
executeCommand("RCPT TO:<%s>", address);
}
executeCommand("DATA");
EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream(new LineWrapOutputStream(new SmtpDataStuffing(mOut), 1000));
message.writeTo(msgOut);
msgOut.endWithCrLfAndFlush();
// After the "\r\n." is attempted, we may have sent the message
entireMessageSent = true;
executeCommand(".");
} catch (NegativeSmtpReplyException e) {
throw e;
} catch (Exception e) {
MessagingException me = new MessagingException("Unable to send message", e);
me.setPermanentFailure(entireMessageSent);
throw me;
} finally {
close();
}
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageTest method sampleMessage.
private MimeMessage sampleMessage() throws MessagingException, IOException {
MimeMessage message = new MimeMessage();
message.setFrom(new Address("from@example.com"));
message.setRecipient(RecipientType.TO, new Address("to@example.com"));
message.setSubject("Test Message");
message.setHeader("Date", "Wed, 28 Aug 2013 08:51:09 -0400");
message.setEncoding(MimeUtil.ENC_7BIT);
MimeMultipart multipartBody = new MimeMultipart("multipart/mixed", generateBoundary());
multipartBody.addBodyPart(textBodyPart());
multipartBody.addBodyPart(binaryBodyPart());
MimeMessageHelper.setBody(message, multipartBody);
return message;
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageIdGeneratorTest method generateMessageId_withFromAndReplyToAddress.
@Test
public void generateMessageId_withFromAndReplyToAddress() throws Exception {
Message message = new MimeMessage();
message.setFrom(new Address("alice@example.org"));
message.setReplyTo(Address.parse("bob@example.com"));
String result = messageIdGenerator.generateMessageId(message);
assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result);
}
Aggregations