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

3291 Commits

Author SHA1 Message Date
András Veres-Szentkirályi
df75853c64 replaced entrySet + getKey with keySet 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
3d327763b5 replaced for with for-each loop 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
e75dd7df39 replaced for with for-each loop 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
8627a3e702 replaced for with for-each loop 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
ac1e68af78 use built-in TextUtils.join instead of StringBuilder 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
572427cb57 use built-in TextUtils.join instead of StringBuilder 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
7ae3a15d7c converted for to for-each loop with short circuit evaluation 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
21fe3f6cd2 use built-in TextUtils.join instead of StringBuilder 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
1bc3271de3 replaced for with for-each loop and optimized List implementation 2014-02-15 23:59:23 +01:00
András Veres-Szentkirályi
1202f5109a removed unnecessary explicit cast 2014-02-15 23:59:22 +01:00
András Veres-Szentkirályi
e8d3553b2c replaced unnecessary explicit iterator use with for-each loop 2014-02-15 23:59:22 +01:00
András Veres-Szentkirályi
8ac942d828 replaced unnecessary explicit iterator use with for-each loop 2014-02-15 23:59:19 +01:00
András Veres-Szentkirályi
b942bf2889 typofix in comment (desti{o,}nation) 2014-02-15 23:58:31 +01:00
András Veres-Szentkirályi
309a4d6107 Use more efficient entrySet iterator instead of keySet + get()
The loop extracted keys from `folderMap` and then called
`folderMap.get(...)` for every key. If both the key and the value needs
to be iterated on, `Map.entrySet()` is a more efficient solution as it
doesn't require O(n) Map lookups.
2014-02-15 23:58:26 +01:00
András Veres-Szentkirályi
28398dbdad removed unnecessary unboxing followed by reboxing
Since id is a Long, Long.valueOf(long) unboxed the Long to a primitive
long, then reboxed it into a Long instance, which was again unboxed to
allow it to be set as an element of the array of longs. This commit
reduces the number of boxings from 3 to 1.
2014-02-15 21:33:08 +01:00
András Veres-Szentkirályi
0c7740ce86 removed unread field mAccount 2014-02-15 21:30:44 +01:00
cketti
53eac39a90 Extract code to scale the slider value for the message content font setting 2014-02-13 06:04:19 +01:00
cketti
90f63ba057 Remove old setting for message content font size
- export new setting
- add upgrade code to convert old setting to new format
2014-02-13 04:22:45 +01:00
cketti
3527930f89 Fix 'endless' loop in ImapFolderPusher
Under certain circumstances it's possible that the 'push state' isn't
updated to contain the most recent 'UIDNEXT' value. In that case
ImapFolderPusher.start() would execute the same code path through its
main loop over and over again, preventing the device from going to
sleep.
Rather than changing the code to update the 'push state' in the corner
case that triggers the behavior described above, this commit introduces
another mechanism to track the 'UIDNEXT' value. This should also catch
as of yet unknown cases where the 'push state' isn't properly updated.

At some point in the future I hope we get to a point where we only
persist the 'push state' when we manually stop/restart the service.
During normal operation there's no need to read from/write to storage
all the time.

Fixes issue 4907
2014-02-11 20:17:47 +01:00
cketti
d419fab789 Add support for KitKat's Storage Access Framework
This allows users on KitKat to add multiple attachments at once.
2014-02-10 20:58:50 +01:00
cketti
aec1a38578 Build with SDK 19 2014-02-10 20:43:16 +01:00
Rene Treffer
32e1689255 Enable AOSP builds 2014-02-10 20:00:16 +01:00
Koji Arai
cbddf960b1 Should disable COMPOSE menu item
When message viewing and tap the next icon, menu icons (previous, next, delete and replys) disappears for an instant.
But a compose icon remains, then tap it accidentally.
2014-02-10 19:59:26 +01:00
cketti
cf228583bc Merge pull request #448
Change message body font size with slider
2014-02-01 00:52:32 +01:00
cketti
6e7fa0df03 Save/restore slider state 2014-02-01 00:49:39 +01:00
cketti
f224483df4 Fix display error in account settings
* correctly initialize summary of 'Server search limit'.
* don't persist value in shared preferences
2014-01-31 22:10:28 +01:00
Sergii Pylypenko
67abde055a Change message body font size with slider, using new setTextZoom() WebView API, from 40% to 250% 2014-01-31 23:09:25 +02:00
cketti
a62f7aaa29 Don't crash when startActivity() fails
Fixes issue 6201
2014-01-31 20:05:00 +01:00
Troy Rollo
abb3318846 Alternative fix for issue 5697 - ASUS display bug 2014-01-30 19:56:30 +01:00
cketti
b299713807 Support extras for ACTION_VIEW + mailto: URI
Support the extras documented for ACTION_SEND to be used with
ACTION_VIEW to support another app that doesn't care, namely Twitter.
2014-01-30 02:49:04 +01:00
cketti
1a16dbf295 Restore instance state in correct order
Fixes issue 5968
2014-01-23 01:35:21 +01:00
cketti
f24c298791 Disable pull-to-refresh when remote search is not allowed
Fixed issue 6151
2014-01-22 16:06:52 +01:00
Joe Steele
094156cc2a Fix issue 6064: Inline images don't display on KitKat
Eliminate the invocation of
WebSettings.setBlockNetworkImage(boolean flag),
thus maintaining the the default setting of "false".

On Android versions prior to KitKat, this setting has no
effect on inline image attachments loaded with content:
URIs.  Such images would load regardless.

With KitKat, this setting does have an effect -- a
setting of "true" will block image attachments loaded
with content: URIs.

By removing this call, K-9 Mail behaves the same on KitKat
as on earlier Android versions, and the behavior on earlier
versions is unchanged.
2014-01-19 01:31:55 +01:00
Joe Steele
e91e3f4e7d Eliminate needless use of reflection
The minSdkVersion was recently increased from 8 to 15.

WebSettings.setBlockNetworkLoads has been publicly available
since API level 8 (Froyo).

StrictMode has been publicly available since API level 9
(Gingerbread).
2014-01-10 18:27:55 -05:00
cketti
4955e34886 Merge pull request #437 from zjw/misc_clean_up 2014-01-05 04:30:28 +01:00
cketti
94296ec7df Revert "Add work-around for Asus Transformer WebView display bug"
This reverts commit 78428e287b.
2014-01-05 04:16:34 +01:00
cketti
06ec852090 Rename plurals to make Transifex happy 2014-01-04 01:44:31 +01:00
Joe Steele
03925fb409 Fix POP3 STLS command
The server response needed to be retrieved.

Thanks to Paul Durrant:
https://groups.google.com/d/msg/k-9-mail/0XHNNMR1TQ4/yExsr7nvJQwJ
2013-12-29 18:47:02 -05:00
Joe Steele
0de72c31b4 Use a locale-specific date in the header of a quoted message
Also, include the sent-date in the header when using
the "prefix" quote style.  "Be like mutt" (and gmail,
and thunderbird)

Also, the quoteOriginalHtmlMessage method was using the mSourceMessage
field in various places when it should be using its originalMessage
parameter.

Related issues:  2249, 3456
2013-12-29 18:46:51 -05:00
Joe Steele
88010be316 Account preferences clean-up
There were a number of preferences that were not being removed
from the preferences DB when an account was deleted, so they
would remain there forever.

There were a few attempts to remove preference keys from the DB where
the keys were obsolete and not in use for some time.

Certain obsolete preferences were not modified:
mUuid + ".name"
mUuid + ".email"
mUuid + ".signature"
mUuid + ".signatureUse"
These were in use before implementing multiple identities, and are still used
as a fallback for old accounts without multiple identities configured.
2013-12-29 18:45:19 -05:00
cketti
aaa1bdd115 Fix ClassCastException 2013-12-18 00:21:18 +01:00
cketti
79a5bc9c7e Revert "Make IMAP autoconfig recognize "Draft" as drafts folder"
This reverts commit 453f10128c.
See https://github.com/k9mail/k-9/pull/429
2013-12-17 18:45:57 +01:00
erlendorf
453f10128c Make IMAP autoconfig recognize "Draft" as drafts folder
Yahoo names it "Draft" instead of the more common "Drafts".
2013-12-16 17:14:56 +01:00
Jasper Klein
78428e287b Add work-around for Asus Transformer WebView display bug 2013-12-16 17:11:28 +01:00
cketti
c1a77181bc Ignore all errors in initialization of TrustedSocketFactory
On Android 2.2 getEnabledProtocols() throws an
ArrayIndexOutOfBoundsException
2013-12-12 16:48:30 +01:00
cketti
43bf41332d Return proper error message when certificate couldn't be verified against global key store 2013-12-06 06:53:57 +01:00
cketti
9b807c325d Add support for bitcoin URIs 2013-12-05 04:28:28 +01:00
Joe Steele
dab8d3807f Change LocalKeyStore error reporting
The error reporting assures an exception is thrown if
setKeyStoreFile(null) is called without a prior call to
setKeyStoreLocation(String directory).

Also, fix TrustManagerFactoryTest indentation.
2013-12-04 12:10:12 -05:00
cketti
3fd7470d68 Change the way we harden SSL/TLS sockets
Blacklist a couple of weak ciphers, bring known ones in a defined order and sort unknown
ciphers at the end. Also re-enable SSLv3 because it's still used a lot.
2013-12-04 04:50:41 +01:00
Joe Steele
cedcd7e47c Eliminate the need to pass a context to LocalKeyStore.getInstance
Instead, have K9.onCreate initialize the location of the key
store file (similar to what is done with
BinaryTempFileBody.setTempDirectory).

Also, LocalKeyStore.getInstance has been changed so that it
no longer needs to be synchronized.
2013-12-03 19:24:37 -05:00
Joe Steele
9333f4f7f4 Don't delete certs. on account creation, & assure that only one instance of LocalKeyStore is created. 2013-12-03 19:21:57 -05:00
cketti
765b390eb5 Remove LocalKeyStore's dependency on K9.app 2013-12-03 13:28:48 +01:00
cketti
2a9ac867b9 Remove LocalKeyStore's dependency on Account to reduce coupling 2013-12-03 12:56:31 +01:00
Joe Steele
0f39a9d5ba "upgrade" the LocalKeyStore
Implement an "upgrade" capability for the key store file,
and then use it to delete the old file.

The existing certs in the old file are not a security
risk, but they are now useless because the format of
their aliases was changed in commit a4440b4.  They now are
just taking up storage space and memory.

Users will need to re-accept *ALL* certificates that they had
previously accepted and are still using.  (Actually, this requirement
was effective with commit 4b57d79a.  Before that, certificates whose
Subject matched did not require re-accepting.)
2013-12-02 14:49:53 -05:00
Joe Steele
8eef43c282 Implement pruning of old certificates from LocalKeyStore
Certificates are deleted whenever server settings are changed
or an account is deleted.
2013-12-02 14:49:47 -05:00
Joe Steele
40404c3700 Move some classes out of com.fsck.k9.mail.store
The classes are just as much related to com.fsck.k9.mail.transport
as com.fsck.k9.mail.store, so having them in
com.fsck.k9.mail.store doesn't seem appropriate.

Move LocalKeyStore to com.fsck.k9.security

Move TrustManagerFactory and TrustedSocketFactory to com.fsck.k9.net.ssl
2013-12-02 14:07:57 -05:00
Joe Steele
76605f7d86 Extract code into new LocalKeyStore class
Also, implement the ability to configure an alternate key store
file location. This permits the running of unit tests without
clobbering the live key store file.

Also, add a test to confirm that the key store file is being written
out and reread correctly.
2013-12-02 14:04:40 -05:00
cketti
4b57d79acf Only check against the certificate stored for a server, not all of them 2013-11-29 14:06:02 +01:00
cketti
c5c195d243 Add unit tests for TrustManagerFactory 2013-11-29 10:49:52 +01:00
cketti
48d11fd386 Properly save and restore instance state in AccountSetupBasics 2013-11-29 05:33:48 +01:00
Joe Steele
a4440b4042 Fix inadequate certificate validation
Proper host name validation was not being performed for certificates
kept in the local keystore.  If an attacker could convince a user to
accept and store an attacker's certificate, then that certificate
could be used for MITM attacks, giving the attacker access to all
connections to all servers in all accounts in K-9.

This commit changes how the certificates are stored.  Previously, an
entire certificate chain was stored for a server (and any of those
certificates in the chain were available for validating signatures on
certificates received when connecting).  Now just the single
certificate for the server is stored.

This commit changes how locally stored certificates are retrieved.
They can only be retrieved using the host:port that the user
configured for the server.

This also fixes issue 1326.  Users can now use different certificates
for different servers on the same host (listening to different ports).

The above changes mean that users might have to re-accept certificates
that they had previously accepted and are still using (but only if the
certificate's Subject doesn't match the host that they are connecting
to).

This commit modifies AccountSetupBasics so that it now calls
AccountSetupCheckSettings twice -- once for checking the incoming
settings and once for the outgoing settings.  Otherwise, an exception
could occur while checking incoming settings, the user could say
continue (or the user could accept a certificate key), and the
outgoing settings would not be checked.  This also helps with
determining if a certificate exception was for the incoming or
outgoing server, which is needed if the user decides to add the
certificate to the keystore.
2013-11-23 13:26:57 -05:00
Danny Baumann
b500047e42 Fix contact picture color generation.
Make sure to return different colors for senders with different name,
but the same mail address (e.g. mails sent by certain issue tracking
systems).
2013-11-11 13:31:58 +01:00
brian m. carlson
1bfb78ee51 Use TrustedSocketFactory for STARTTLS.
The TrustedSocketFactory, which provides goodies like better cipher suites and
TLSv1.2, was only being used for tunnelled connections.  Use it for STARTTLS
connections as well.
2013-11-10 00:27:01 +00:00
Jesse Vincent
d4246a0976 With the new webview scrollview combo we've got loadinoverviewmode seems to behave better. 2013-11-07 10:39:37 -08:00
cketti
b398c4d7f4 Fix file selection for import
Using FLAG_ACTIVITY_NO_HISTORY will cause the file selection
to fail when KitKat's "Open from" activity opens a third-party activity.
2013-11-07 07:33:33 +01:00
Jesse Vincent
e20e513039 Sadly, KitKat's file manager fails to recognize our mimetype and won't let users import settings 2013-11-05 20:19:27 -05:00
Joe Steele
1cbdd390f3 Use non-deprecated constants 2013-11-05 16:26:29 -05:00
Joe Steele
5311a2ef01 NonLockingScrollview fixes.
Implement methods missing in API 7

Fix coordinate reference frame mismatch.  Touch events are
relative to the view display, whereas view children are relative
to the view.
2013-11-05 16:26:28 -05:00
Joe Steele
fa962e7bd7 Move AOSP files.
Patch RigidWebView for K9.
MessageWebView would need to extend RigidWebView.
2013-11-05 16:26:27 -05:00
Joe Steele
97d571cb43 Import RigidWebView from AOSP Email client.
Also import prerequisite classes.

As contained in current master:
b3c37a31cc
2013-11-05 16:26:26 -05:00
Joe Steele
7b0082026c Revert auto-scroll changes that are no longer needed.
Revert "Only Jelly Bean seems to have the auto-scroll issue"

This reverts commit a3802a7a8e.

Revert "Hack around WebView's initial auto-scrolling past the message header"

This reverts commit 8dcc769c50.

Conflicts:

	src/com/fsck/k9/view/MessageWebView.java
2013-11-05 16:26:25 -05:00
Joe Steele
94a4585317 Switch to using NonLockingScrollView
This implements the AOSP Email solution for incorporating
a Webview inside a ScrollView, while still being able to
scroll diagonally.

This replaces the functionality of TitleBarWebView (which
is now removed).
2013-11-05 16:26:23 -05:00
Joe Steele
f4de21187d Import NonLockingScrollView from AOSP Email client.
As contained in current AOSP master:
b3c37a31cc
2013-11-05 16:24:48 -05:00
cketti
a036e4d2f9 Merge branch 'tls-hardening' 2013-10-29 04:40:06 +01:00
cketti
a97705ffa9 Refactor TrustedSocketFactory 2013-10-29 04:37:52 +01:00
cketti
8f45d76b5c Extract WebDavSocketFactory 2013-10-29 03:42:37 +01:00
András Veres-Szentkirályi
105d3b3c4e filter TLS protocol versions by support as well 2013-10-20 10:42:39 +02:00
András Veres-Szentkirályi
77d43fb7bd extracted method filterBySupport 2013-10-20 10:30:33 +02:00
András Veres-Szentkirályi
dbc47c7297 filter enabled cipher suites by availability 2013-10-20 10:22:53 +02:00
András Veres-Szentkirályi
d84ce6ddb9 Hardened TLS cipher suites and versions
As Georg Lukas wrote in his blog post about how Android handles TLS
handshake (http://op-co.de/blog/posts/android_ssl_downgrade/), an
explicit order of cipher suites and TLS versions must be supplied to
avoid having the weak (presumably broken) RC4 cipher at the top of the
preference list.

This commit adds the list included in the blog post to every TLS socket
creation, including IMAP, POP3 and SMTP, see Wireshark screenshots done
during testing at http://vsza.hu/k9mail-tls-hardening/
2013-10-15 10:16:42 +02:00
Joe Steele
0323af09e5 Don't add blank lines to composed messages if there is no quoted text 2013-10-11 11:39:50 -04:00
Joe Steele
ef01cabccc Remove \n from R.string.message_compose_reply_header_fmt
This string resource is used in two places -- both with and without the
linefeed at the end.  Instead of having a linefeed in the string and
having the code remove it if not needed, the linefeed is now omitted from
the string and the code adds it if needed.

Also, the line ending is changed from \n to \r\n.

Also, the string in the DE and FR locales had linefeeds at the start that
were removed so they match all the other locales.

(The string in the zh-rTW locale was left alone, since it had no
linefeeds.  It looks like that file has numerous instances where \n was
replaced with actual newlines, which is probably not correct.)
2013-10-11 11:39:48 -04:00
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
Joe Steele
33678ea022 Eliminate unnecessary override in LocalAttachmentBody.
The overriding code is the same as the overridden code.
2013-10-11 11:24:56 -04:00
Joe Steele
313a5bff9c Contact picture fix.
Clear out old/unrelated (previously bound) contactBadge info in
MessageListAdapter.bindView that could otherwise be displayed
when tapping on a contactBadge with no counterpartyAddress (may
require scrolling the message list up and down first before the
bug becomes evident).
2013-10-11 11:24:53 -04:00
Joe Steele
1afff1e38f Delete related files when deleting a database.
The journal file was not being deleted when an account was deleted.
Over time, one can end up with a collection of dead journal files.
2013-10-11 11:24:51 -04:00
cketti
1aca9eb22c ContactPictureLoader code cleanup 2013-10-03 21:21:54 +02:00
cketti
bea6ba6881 Fix JavaDoc to match the changes in ContactPictureLoader 2013-10-01 01:53:21 +02:00
Koji Arai
e4313067b6 Don't performSend() on onSave(). 2013-10-01 07:53:08 +09:00
Danny Baumann
8777441d92 Use address object as contact picture instead of email address only.
Fixes assignment problems for emails sent by some issue tracking
systems, which send out mails with a fixed mail address on behalf of
different people.
2013-09-27 08:53:14 +02:00
Danny Baumann
890e0e22e3 Some assorted warning fixes. 2013-09-25 15:20:43 +02:00
Danny Baumann
d6d22a82bc Fix build with latest SDK tools. 2013-09-25 14:54:27 +02:00
Danny Baumann
aa798fad85 Fix caching of fallback contact icons.
The cache key must be consistent with how calcUnknownContactLetter()
works, otherwise one gets the same fallback icon for different senders.
2013-09-25 14:52:59 +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
Koji Arai
0be299fbd0 Avoid StringIndexOutOfBoundsException when the header is broken like "=?us-ascii?q?abc?= =?" 2013-09-20 13:15:57 +09:00