1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
Commit Graph

221 Commits

Author SHA1 Message Date
Joe Steele
5a46575dc2 Generally replace \n with \r\n when part of a message
This builds upon the efforts started 2 commits back where \r\n is used for
all message text and \n is only used when the text is inside an
EolConvertingEditText widget.
2013-10-11 11:39:46 -04:00
Joe Steele
114be7a15d More robust checking to prevent fatal IndexOutOfBoundsException
Even with the fix in the parent commit,  the X-K9mail-Identity header can
become invalid if, for example, a user creates a draft in K-9 Mail, then
edits the draft outside of K-9 Mail, then opens the draft again in K-9
Mail.

This commit assures that an invalid X-K9mail-Identity header will not
result in an IndexOutOfBoundsException.
2013-10-11 11:39:45 -04:00
Joe Steele
bfb0316583 Fix fatal IndexOutOfBoundsException
The problem:

Configure the account (just an example -- problems can occur in other
configurations as well):
Message Format: HTML
Reply quoting style: Prefix
Quote message when replying: yes
Reply after quoted text: yes

Reply to a message that has a large quantity (20+) of \r\n scattered in
the body of its HTML version (not an unusual scenario).

Add a reply.  Save the message as a draft.  Go back & open the draft
again.  A fatal IndexOutOfBoundsException occurs.

The cause:

When the draft was saved, the X-K9mail-Identity header was computed and
added to the message, then the text of the message was processed with
MimeUtility.fixDraftTextBody, replacing all occurrences of \r\n with \n in
the quoted message before being saved in LocalStore, thus invalidating the
X-K9mail-Identity header.

The fix:

Remove MimeUtility.fixDraftTextBody and implement
MessageCompose$EolConvertingEditText instead.  Any message text placed in
an EolConvertingEditText widget is assured to have \n line endings.  Any
message text extracted from an EolConvertingEditText widget is assured to
have \r\n line endings.  The X-K9mail-Identity header will always be
computed correctly.

Issues thought to be related:  4782, 5010, 5634, 5725

As noted in some of the referenced issues, errors didn't always result in
a fatal exception, but instead with mixed up text.

Ref:  commit f9a35aeaee
2013-10-11 11:39:15 -04:00
Joe Steele
005241d97b Issue 4594: draft not saved with shared info
When another app shared info with K-9 Mail, the draft was not
always being saved when the "Save as draft" menu option was selected.
2013-10-11 11:24:58 -04:00
Koji Arai
e4313067b6 Don't performSend() on onSave(). 2013-10-01 07:53:08 +09:00
Danny Baumann
890e0e22e3 Some assorted warning fixes. 2013-09-25 15:20:43 +02:00
cketti
2b7f5e7b70 Merge branch 'pick_attachment_fix'
Update LocalStore code to handle the newly introduced temporary files
for attachments

Conflicts:
	res/values/strings.xml
	src/com/fsck/k9/activity/MessageCompose.java
2013-09-25 05:22:00 +02:00
cketti
677d6c923d Don't stop the activity before attachments have been fetched
Display a progress dialog when the user tries to send the message or
save a draft and the attachments haven't been fetched completely.
2013-09-25 03:46:11 +02:00
cketti
62aa1b87d0 Fetch attachments while MessageCompose activity is running
Android allows other apps to access protected content of an app without requesting the
necessary permission when the app returns an Intent with FLAG_GRANT_READ_URI_PERMISSION.
This regularly happens as a result of ACTION_GET_CONTENT, i.e. what we use to pick content
to be attached to a message. Accessing that content only works while the receiving activity
is running. Afterwards accessing the content throws a SecurityException because of the
missing permission.
This commit changes K-9 Mail's behavior to copy the content to a temporary file in K-9's
cache directory while the activity is still running.

Fixes issue 4847, 5821

This also fixes bugs related to the fact that K-9 Mail didn't save a copy of attached content
in the message database.

Fixes issue 1187, 3330, 4930
2013-09-25 03:12:34 +02:00
Joe Steele
45e3d8459e Recursively convert attachments of type message/rfc822 to 7bit if necessary.
The preceding commit resulted in attachments of type message/rfc822 being
sent with 8bit encoding even when the SMTP server did not support
8BITMIME.  This commit assures that messages will be converted to 7bit
when necessary.

A new interface CompositeBody was created that extends Body, and classes
Message and Multipart were changed from implementing Body to
CompositeBody.  Additional classes BinaryTempFileMessageBody and
LocalAttachmentMessageBody were created (by extending BinaryTempFileBody
and LocalAttachmentBody, respectively), and they too implement
CompositeBody.

A CompositeBody is a Body containing a composite-type that can contain
subparts that may require recursive processing when converting from 8bit
to 7bit.  The Part to which a CompositeBody belongs is only permitted to
use 8bit or 7bit encoding for the CompositeBody.

Previously, a Message was created so that it was 7bit clean by default
(even though that meant base64 encoding all attachments, including
messages).  Then, if the SMTP server supported 8BITMIME,
Message.setEncoding("8bit") was called so that bodies of type TextBody
would been transmitted using 8bit encoding rather than quoted-printable.

Now, messages are created with 8bit encoding by default.  Then, if the
SMTP server does not support 8BITMIME, Message.setUsing7bitTransport is
called to recursively convert the message and its subparts to 7bit.  The
method setUsing7bitTransport was added to the interfaces Part and
CompositeBody.

setEncoding no longer iterates over parts in Multipart.  That task belongs
to setUsing7bitTransport, which may in turn call setEncoding on the parts.

MimeUtility.getEncodingforType was created as a helper function for
choosing a default encoding that should be used for a given MIME type when
an attachment is added to a message (either while composing or when
retrieving from LocalStore).

setEncoding was implemented in MimeBodyPart to assure that the encoding
set in the Part's headers was the same as set for the Part's Body.  (The
method already existed in MimeMessage, which has similarities with
MimeBodyPart.)

MimeMessage.parse(InputStream in, boolean recurse) was implemented so that
the parser could be told to recursively process nested messages read from
the InputStream, thus giving access to all subparts at any level that may
need to be converted from 8bit to 7bit.
2013-09-03 19:53:13 -04:00
Joe Steele
77407eb5b7 Don't base64 encode attachments of type message/rfc822.
The problem:  Receive a message with an attachment of type message/rfc822
and forward it.  When the message is sent, K-9 Mail uses base64 encoding
for the attachment.  (Alternatively, you could compose a new message and
add such an attachment from a file using a filing-picking app, but that is
not 100% effective because the app may not choose the correct
message/rfc822 MIME type for the attachment.)

Such encoding is prohibited per RFC 2046 (5.2.1) and RFC 2045 (6.4).  Only
8bit or 7bit encoding is permitted for attachments of type message/rfc822.

Thunderbird refuses to decode such attachments.  All that is shown is the
base64 encoded body.

This commit implements LocalAttachmentBody.setEncoding.  If an attachment
to a newly composed message is itself a message, then setEncoding("8bit")
is called, otherwise setEncoding("base64")  is called for the attachment.
Similar behavior occurs when an attachment is retrieved from LocalStore.

The setEncoding method was added to the Body interface, since all
implementations of Body now declare the method.

The problem here differs from that in the preceding commit:  Here, the
encoding problem occurs on sending, not on receipt.  Here, the entire
message (headers and body) is base64 encoded, not just the body.  Here,
the headers correctly identify the encoding used;  it's just that the RFC
does not permit such encoding of attached messages.  The problem here
could in fact occur in combination with the preceding problem.
2013-09-03 19:52:11 -04:00
cketti
186f6d6ba2 Don't save signature to identity header if identity doesn't use a signature 2013-07-08 06:44:44 +02:00
cketti
bc665bffe1 Fix NPE introduced in 340d6e0522 2013-03-31 16:53:27 +02:00
cketti
340d6e0522 Use themed context when creating EmailAddressAdapter
Previously the activity theme was used to display the auto-complete
suggestions. This lead to unreadable text when the activity theme was
different from the "composer theme".
2013-03-28 19:36:41 +01:00
Joe Steele
548b8e07a6 Refactor code for MessageWebView.setText()
The MIME type for the supplied text was always text/html,
so there is no need to pass that as a parameter.
Furthermore, we are relying on it being text/html because
we are wrapping it with HTML code.

Likewise, change/simplify/rename AccessibleWebView.loadDataWithBaseURL().
2013-03-01 14:32:16 -05:00
Joe Steele
6a844a2553 Remove unused code in HtmlConverter.
HtmlConverter.getHtmlHeader() and getHtmlFooter() are
no longer used.  Remove them and other related code.
2013-03-01 14:30:42 -05:00
Joe Steele
e2c5229e85 Change when <html> tags are applied to messages.
Previously, <html>, <head>, & <body> tags were
attached to messages before they were stored locally.
But now that the <head> element also needs to include
a <meta> element (for proper MessageWebView display),
it seems unecesary to store all these tags with each
message.

Now the tags are no longer stored with the messages.  Instead,
MessageWebView applies the tags before displaying the message.

This also eliminates the need to upgrade an older
message database where all the old messages would have
otherwise needed to be wrapped with the new tags.
2013-03-01 12:59:59 -05:00
Jesse Vincent
c4b941b9b9 Switch our font sizes to have a "default", which is the size described in the XML.
Unify the text field size setting code. We should put it in a better place
2013-02-10 19:02:17 -05:00
m0viefreak
c59d70b8c6 Compose: Don't just theme the editboxes, but the whole content (but not the actionbar)
This way also the From: selection, To:, Cc, and Bcc: are themed correctly.
It looks more homogeneous and is consistent with the looks of the MessageView.
2013-02-08 15:24:04 +01:00
Danny Baumann
8f3e61feab Convert theme setting value to an enum. 2013-02-08 15:24:03 +01:00
Danny Baumann
bd154c4c0f Allow changing the message composer theme (background and text color). 2013-02-08 15:24:02 +01:00
cketti
b0b0ee6678 Add check to display database upgrade screen to more activities
Through shortcuts, widgets, etc. users can start the app using another
activity than Accounts. We still want to display the database upgrade
screen in such cases.
2013-01-14 09:32:58 +01:00
Danny Baumann
8cee3ee18d Add actions to notifications.
- If there's only a single message in the notification, add 'Reply' and
  'Read' (marks as read) buttons.
- If there's more than one message pending, add only 'Read'.
2013-01-02 14:17:20 +01:00
Andrew Chen
c63a756500 No functional changes; whitespace only. 2012-12-21 15:36:54 -08:00
Andrew Chen
c6beeacb7d Outlook 2013 uses a new color for the quote divider. Updating to match The New Hotness™. 2012-12-21 15:31:13 -08:00
cketti
349b1e997e Use type of compose action as action bar title
I.e. one of "Compose", "Reply", "Reply all", "Forward"
2012-11-21 01:42:19 +01:00
cketti
bb01102403 Use Uri.getQueryParameterNames() workaround on pre-API 11 devices 2012-11-16 18:28:40 +01:00
András Veres-Szentkirályi
a86354be7d Treat mailto-URI parameters case-insensitive
RFC 6068 defines these parameters case-insensitive, yet we only
supported lower-case values because the method Uri.getQueryParameters()
treats parameter names case-sensitive.
This patch introduces a wrapper class that implements case-insensitive
parameter name matching.

Note: commit message edited by cketti
2012-11-13 13:33:22 +01:00
Koji Arai
c0cb734288 Should change Bcc address when Identity changed. 2012-11-05 00:02:57 +09:00
cketti
93b13362b4 Converted message list to a fragment 2012-10-06 03:41:32 +02:00
cketti
d5b9aec39f Display a dark-themed "Send as" dialog when using the dark theme on HC+ 2012-09-16 03:24:40 +02:00
cketti
163557ae8a Use ContextThemeWrapper for "Send as" dialog
The old code changed the theme of the activity by wrongly using
ContextWrapper + setTheme().
2012-09-16 03:16:29 +02:00
cketti
1155324df0 Retain visibility state of "Add Cc/Bcc" menu item on orientation change 2012-09-14 04:26:57 +02:00
cketti
ba0c530c7b Avoid NullPointerException
Fixes issue 4557
2012-09-14 04:09:18 +02:00
cketti
8018be3e16 Some code cleanup 2012-09-14 04:08:17 +02:00
Sander Bogaert
24d5d3208a Use SupportProgressBar methods. 2012-09-09 13:13:44 -07:00
Sander Bogaert
13dc96eca9 Have the cc/bbc and attachment action on top with nice icons. 2012-09-09 13:13:43 -07:00
Sander Bogaert
4293914855 Initial actionbar integration. On top of every activity, no real integration yet. 2012-09-08 21:14:55 -07:00
Andrew Chen
2b0b929aa2 Add references and in-reply-to for forwarded messages. 2012-09-07 11:03:46 -07:00
Bernhard Redl
56105bcfe3 + add support for $Forwarded IMAP flag 2012-08-29 02:26:38 +02:00
cketti
d9f1690741 Added option to always show the CC/BCC text input fields 2012-08-10 03:38:10 +02:00
cketti
1ff3b6b88f Disable the 'Add Cc/Bcc' menu option when both fields are visible 2012-08-10 02:31:55 +02:00
András Veres-Szentkirályi
7ae7fc9d9d removed unread private field mFontSizes 2012-07-06 14:03:48 +02:00
cketti
e88633cf78 Put the logic that decides which message format to use in one place
This change is in preparation for the future rich text editing
functionality.
2012-05-30 15:20:51 +02:00
cketti
71b3b2916e Extracted methods for easier reading 2012-05-30 15:20:51 +02:00
cketti
01c8e84396 Introduced enum for the MessageCompose actions (compose, reply, ...) 2012-05-30 15:20:51 +02:00
cketti
dc476eb3e8 Support ACTION_SEND extras when handling ACTION_SENDTO
Too many applications get this wrong and rely on the undocumented
behavior of the AOSP Email app and Gmail.

See https://code.google.com/p/android/issues/detail?id=30190
2012-05-06 17:47:59 +02:00
Andrew Chen
32ae7bad9c Migrate to Account.has(Special)Folder() methods. 2012-04-17 08:23:22 -07:00
cketti
ff4d6a66c8 Fixed bug introduced with 6f525f0e31
Intent extra was renamed but the code in MessageCompose still used the
(hardcoded) old name.
2012-04-11 04:47:10 +02:00
cketti
52b5c567ef Don't use EmailAddressAdapter as singleton 2012-04-11 03:26:45 +02:00