Commit Graph

67 Commits

Author SHA1 Message Date
Marc Blank 76f614720d Highlight utility for HTML and text
* Add utilities for adding highlighting markup to HTML and
  highlighting spans to plain text (for Webview and UI,
  respectively)
* Rename Snippet.java to TextUtilities.java and move to utility
  package

Change-Id: Ic443ab5ce9c0199fa82a68e1592bf259494cadd2
2011-03-31 13:49:52 -07:00
Todd Kennedy fe68c0e7c2 Use HostAuth to determine settings changes
There were two TODO's from a prior CL where deprecated HostAuth methods
were removed.

1. Do not use a generated URI to determine if account settings have changed.
   Instead, use the HostAuth structure for this purpose.
2. The account key in the HostAuth structure has been deprecated. Remove as
   much of it as possible (until the schema of the host auth database changes,
   we must still refer to it when adding rows).

In the process, HostAuth tests were broken out into a separate unit test
file.

Change-Id: I4075da09af168f734db7b20a9ef63d4178ac2064
2011-03-01 07:49:54 -08:00
Todd Kennedy 040ddf60cf Resolve build warnings; part 5
Remove dependence upon URIs for creating the host auth structure

Change-Id: I92dee36fa329a8976b76bbd4991ed3469c6475f2
2011-02-16 17:38:31 -08:00
Marc Blank 31d9acbf06 Email split, part huit: Refactor constants, clean emailcommon
* There are three pieces to this CL (sorry):
  1) Move and/or rename some constants into emailcommon
  2) Move Utility to emailcommon, moving the few UI
     related utilities back into Email (FolderProperties
     and UiUtilities)
  3) Remove all references to resources from emailcommon
* The three pieces relate in that, between them, they allow
  the emailcommon static library to compile cleanly

Bug: 3442973

Change-Id: Ic5e3abaa2a1b36999e0b6653c6c2134ea1bd544f
2011-02-14 12:18:10 -08:00
Marc Blank a7bc0319a7 Email split, part six: EmailContent
* Moved EmailContent to emailcommon

Change-Id: Ib3db1bfcfe74554c0e5afd3cfce6d72f26e9aeb9
2011-02-10 19:44:29 -08:00
Marc Blank 2193962ca2 Email split, part quatre: Move along, nothing to see here
* No code was harmed, er, changed in the making of this CL
* All that's happened is that code that is needed by both Email and
  Exchange have been moved into emailcommon
* This required import changes to many files, which explains the
  length of the CL

Change-Id: I4e12455ba057a4a8054fdbd0b578c73afa411c8a
2011-02-10 16:28:37 -08:00
Todd Kennedy b3740d227e Merge "Only show loaded messages in widget" into honeycomb 2011-01-25 10:06:51 -08:00
Todd Kennedy 543953ad87 Only show loaded messages in widget
The various selection strings were missing a test to only show messages that
have been loaded. This is only important for POP3 accounts.

bug 3377041

Change-Id: I3efe366d09dd547878dc0bf57dff58f76de5cca9
2011-01-25 09:42:04 -08:00
Andy Stadler 9128217da1 Merge forward small bug found in password storage
While fixing bug 2981433 in Gingerbread, I discovered one additional
place where passwords were being trimmed.  This brings the fix forward
into honeycomb, as well as a new unit test for the fix.

Bug: 2981433
Change-Id: I566f5c0c6693ca7c0069bca9e74f320fca48e600
2011-01-24 20:13:11 -08:00
Makoto Onuki d072f9905d Don't show trashed messages in Starred mailbox
Also show the *total* starred message count (excluding trashed starred)
in the mailbox list, not *per-account* starred count.

Bug 3346872
Bug 2149412

Change-Id: I2274f215f994b62280ac6138982b927cec22c677
2011-01-13 15:41:22 -08:00
Makoto Onuki 9c0da8b84f Don't show starred mailbox, if account has no starred
Bug 3334963

Change-Id: I751e56731b990a6e94b8547a577a84c1a848cbc7
2011-01-11 16:45:05 -08:00
Marc Blank d306ba3438 Handle query with an id of -1 more gracefully
* In query of an otherwise valid URI with -1 as an id, simply return
  an empty cursor
* Add unit test to verify proper handling of invalid uri's

Bug: 3183245
Bug: 3292080

Change-Id: Ia0c35cbd0f5dd0dc4a8fc794226399644cf1fe13
2010-12-30 15:02:43 -08:00
Andy Stadler 6ebaa90847 Reduce/eliminate UI thread access in MailService
* Make most calls to AccountBackupRestore return immediately w/o DB access
* Move most workers in MailService into async runnables
* Remove account restore / null check from ACTION_SEND_PENDING_EMAIL
* Strengthened unit test on Mailbox.findMailboxOfType() because after
  removing the account check (above), sendPendingMessages depends on
  findMailboxOfType() returning -1 on a missing account.
* Clean up a bunch of warnings (no longer use deprecated Config.LOGD)

Bug: 3133763  (and probably others)
Change-Id: Id39707bca7a8ebf5000f84d542013411ff0f422e
2010-12-22 16:34:48 -08:00
Makoto Onuki aef9515ee7 Controller.Result callbacks should all have accountId
- Added accountId to loadAttachmentCallback/loadMessageForViewCallback

- Cleaned up LegacyListener/MessagingListener.
  Removed the constructors which take messageId and attachmentId, which
  are used to bridge loadAttachmentProgress, which the callsite doesn't know
  these IDs.  The inconsistency (only loadAttachmentProgress() uses the member
  messageId) doesn't look too good, so extracted this into a separate class,
  MessageRetrievalListenerBridge.

Change-Id: I46303e50df2b0e1fe8616e7c9cef632ac14f23aa
2010-12-10 18:11:44 -08:00
Makoto Onuki 9d5aaeacd6 Follow-up to Id18fb940. Tests, fix transaction.
Change-Id: If425db7d729e260102a9db82b98e14ff6f6be143
2010-12-03 10:55:27 -08:00
Marc Blank 349055aad4 Allow ProviderTests to work with ContentCache
Bug: 3204331
Change-Id: I5399345c2b759fb34d3dc7c694eb0eef8d7de493
2010-11-17 10:19:30 -08:00
Marc Blank fab77f147f EmailProvider content caching
* In this CL, we cache individual rows, based on the CONTENT_PROJECTION
  defined for the most common queries (Account, HostAuth, Mailbox, and
  Message)
* Queries on individual rows (most often Class.restoreClassById()) will
  look to the cache first, rather than querying the database
* Queries on smaller projections will build MatrixCursor's from cached
  data
* Write-through caching updates the cache with changed columns
* Experiments with live data indicate that > 95% of queries that are
  cacheable (single row, no selection) can be retrieved from the cache,
  thereby saving a great deal of disk access.
* Timing experiments show that cache hits are > 40x faster than cache
  misses
* Unit tests for the various classes exist, with more coming

TODO
----
* More unit tests

Change-Id: I386a948a2f4cc02b6548d07d9b2fefd1e018a262
2010-11-16 08:58:05 -08:00
Makoto Onuki 2ac1eaf8c3 Account selector rework.
- Show email address
- Show inbox unread message count

Initially I thought of using a join to get accounts with their unread
counts with one query, but there were enough subtle issues that I gave up
on the idea.

Instead it uses a MatrixCursor to build a completely new cursor,
based on a regular accounts cursor.

Change-Id: I09e8762f131cc2bd3637e1a3d302088a3b5b2479
2010-11-10 17:41:29 -08:00
Makoto Onuki 6f3d167cfa Don't show non-incoming message in notification.
Filter out non-incoming messages using a subquery.
(because the message table doen't have the mailbox type.)

I was initially thinking of adding a new content URL for
the message table joined with the mailbox table, but it turned out
to be a bit of pain, so ended up using a subquery.
(one of the problems was that both tables had the "_id" field.)

Bug 3177220

Change-Id: I276efb70db1589835f3ddb8c7da4773e72d8691b
2010-11-10 10:22:41 -08:00
Makoto Onuki ee7205d100 Put the dest mailbox name in the "message moved" toast
Also removed obsolete todo

Bug 3075984

Change-Id: I10ce9df29c4913c328d2a962151d4a9f2e6e1408
2010-10-14 15:14:46 -07:00
Makoto Onuki 899c5b8661 Switch to tablet style notification
- Now we show separate notification for each account
- New notification has sender photo, sender name, and subject
  of the latest email
- Added the NotificationController class, which is intended to manage
  all notifications besides "new message" eventually.

The framework doesn't seem to be 100% ready, and it's not clear how to
add the 3rd line in the expanded notification at this point.  Need to
revisit it later to verify UI details.

Change-Id: I40193ee372cb6b2b7245c1588890f238b2469699
2010-09-29 18:35:17 -07:00
Marc Blank 0efe738e05 Add Uri for Message queries that include a LIMIT
* Use a query parameter (e.g. ?limit=2); LIMIT works with any
  query

Change-Id: Idd106ab4b61aec237ac9676a201e797c4f65f15b
2010-09-28 10:58:36 -07:00
Makoto Onuki d25d87c7ba Fix NPE with use of getFirstRowXxx
Make sure not to cast null into a primitive type.
(i.e. If null isn't expected as a return value, make sure to set a non-null
default value.)

Bug 3032143

Change-Id: I9a344d765c75a66f529ad8d99b00b2b919139f9c
2010-09-24 16:59:51 -07:00
Makoto Onuki 261d6c3f0c Notify only account cursors when resetting new msg count
- Resetting the new message count is now correctly done on a BG thread.
- Added special content provider URI to reset the count.
  (/resetNewMessageCount)
- This URI only supports update, which will notify only account
  cursors.
- Fixed a problem that an insert with MAILBOX_ID/MESSAGE_ID/ACCOUNT_ID
  triggers two notifications.

- This CL changes how we use notification URIs, but unfortunately
  no tests for this part.  It turned out MockContentResolver doesn't
  support the notification mechanism, which made it very hard
  to write tests.

Bug 2911646

Change-Id: I35b30a7e6bf2d57510486c7ed19b9f263d8c9b58
2010-09-15 10:53:17 -07:00
Makoto Onuki 5b0c2c7f34 Fix tests broken by I2bf5de4e (Clean-ups for EmailProvider)
My previous CL broke some tests.
- make sure to set 0 to unreadCount when adding a new row
- when updating messageCount in the tests, directly manipulate
  the DB.  (the provider no longer allows this)

Change-Id: Ib569349707007badf4f23600fbca37110c78fa6d
2010-09-10 14:37:01 -07:00
Marc Blank e7b9e4ab94 Add snippets to messages
* Add 'snippet' column in Message table and handle upgrades to the
  new schema
* Generate a snippet from either HTML or plain-text message body,
  removing tags, extraneous whitespace, and other superfluous text
  along the way.  Store the snippet in the Message table
* Clean up MessagesAdapter to use the pre-existing list projection
  and constants
* Write unit tests for snippet creation
* The UI in this CL is always single-line, ellipsized

TODO: Handle two-line subject if portrait and XL

Change-Id: I84a2cbe10957975942edad6eb1255a726924a78a
2010-09-03 23:23:19 -07:00
Makoto Onuki 767f9fe2eb Implement batch move.
* UI is still temporary
* In this version, we check if the selected messages can be moved *after*
  you click "Move", rather than disabling the button beforehand.

Change-Id: Ief2864d2a513001847844963b2b0cb6b714e8667
2010-09-03 15:39:04 -07:00
Makoto Onuki a25aa613f7 Open MessageComponse when draft in All Starred is selected
Also removed a silly unnecessary code in Mailbox.isRefreshable.

Bug 2968445

Change-Id: I75187e5abf1c3e67c8b9ead38c7f749fc8b6cfb0
2010-09-01 18:27:12 -07:00
Makoto Onuki e357f58791 Fully implement "refresh" action bar button
* Now it'll refresh mailbox list (left pane) as well.
(With the minimal interval of 30 seconds)

* Always refresh inbox.
(also with the minimal interval of 10 seconds)

* Also make sure the "auto-refresh" won't refresh
non-refreshable mailboxes. (drafts, etc)

Bug 2929889
Bug 2930018

Change-Id: I09452d40aad6008a721cfbc3f491617224d7048f
2010-08-31 16:49:12 -07:00
Makoto Onuki 25144e2b79 Fix testAccountIsEasAccount
Bug 2953763

Change-Id: Iad1bf94e676c1fb41335e8bd7f3297af0033b0f5
2010-08-26 15:08:57 -07:00
Makoto Onuki 5247ab8cae Make isEasAccount always work.
isEasAccount now uses getProtocol(), so it works even if the hostauth
hasn't been restored yet.

Bug 2929896

Change-Id: Iee902c18ef59680d8a7d4622230489ec7946f38c
2010-08-24 14:27:10 -07:00
Marc Blank bca4e6e70b Add utilities to retrieve Mailbox and Account from a message id
Change-Id: Ice727f82b5c284617b831f19e2667078cd3da5dc
2010-08-24 09:24:21 -07:00
Makoto Onuki 6d8bfa67c4 Make AccountBackupRestore/"delete account" robust.
Fix for crashes caused by an incomplete account
which typically a crashed unit test leaves behind.

- "Delete account" now works for incomplete accounts
- AccountBackupRestore won't crash.

Change-Id: Ie235aa15cf9b970fd184c60f14406aa7353c6f00
2010-08-10 13:49:56 -07:00
Makoto Onuki 833fe73b99 Aadd special boxes to mailbox list.
Change-Id: I36616f53555346ca7fbb6f3426a0c3196d7bacbc
2010-08-03 17:06:04 -07:00
Makoto Onuki 574854b528 Add the messageCount column to the mailbox table.
- Use trrigers to keep them up-to-date.
- Batch-update them upon upgrade.

- Motivation:
  On the mailbox list, we show the number of messages in trash/drafts.
  We currently do this with count(*) on the fly, which is okay
  because MailboxList is really shown right now.
  However, on the 2 pane, it's always shown and constantly refreshed,
  so the use of count(*) can be a huge penalty.

  It also make the code significantly simpler.

Change-Id: I26efa238d5183df43420a65925876248ef6c6cb6
2010-07-30 17:37:28 -07:00
Makoto Onuki bcf32320e2 Move isSecurityHold/clearAccountHoldFlags to Account
- Added unit tests
- I see the "open a cursor, move to the first row, read a column" pattern over
  and over.  Added a utility method for this.  (Let's try not to bloat the
  binary by copying code around!)
- Added helper classes for database related tests
- Removed code dup

Change-Id: I380959215cc1661b252158f0f6e35369b499cdf8
2010-07-28 11:12:38 -07:00
Marc Blank 8d8f86e899 Cleanup and speed up isMessagingController
* Use the new Account.getProtocol() method to determine whether an
  Account "isMessagingController" (i.e. uses the legacy controller)
* Cache the result of this test, so that it's only done once per
  Account
* Add unit test

Change-Id: I6a0ec789a84bdf30b55156e6337a627fb4e81a08
2010-06-28 10:21:45 -07:00
Makoto Onuki c133e6f185 Fix for Account.isValidId() crash when getting -1.
Bug 2493026
2010-03-05 15:06:12 -08:00
Makoto Onuki 652be6fb3d MessageList: Go to Welcome if account not found.
If the account specified with an Intent doesn't exist, show the Welcome
activity instead, which will navigate the user to the appropriate activity.
(e.g. account list if there're more than one account)

Bug 2479609
2010-03-03 17:07:29 -08:00
Makoto Onuki e37881aac5 Store UUID instead of _id in desktop shortcuts.
- Because AccountBackupRestore won't preserve _id.
- Now MessageList accepts both Donut(1.6)-style URIs and Eclair(2.0-2.1)-style
  URIs.

Bug 2479609
2010-03-03 15:41:10 -08:00
Mihai Preda 1575e7860d MessageCompose: fix delete quoted on reply/forward for EAS.
Also fix display of quoted html text for a draft (Exchange 2007).

Bug 2363249
Bug 2444496
2010-02-17 15:28:25 +01:00
Marc Blank 694257cb7e Handle calendar sync state changes by observing Calendars; cleanup
* Use a content observer to detect changes in Calendars; we use this to
  determine whether or not sync has been turned off.  If sync is turned
  off, all events will be deleted, so we need to reset the sync key
* Make sure that all code working on Contacts also now works on Calendar
  (push, etc.)
* Remove some old crufty logging and out-of-date comments
* Addresses 2433061

Bug: 2433061
Change-Id: I6299168903fcce9bf820b72b5f6bb157d9169653
2010-02-13 12:58:56 -08:00
Marc Blank 0e1595c177 Handle unexpected deletion of EmailProvider database
* Addresses #2226426
* If the user deletes Email data, or if data corruption causes
  EmailProvider.db to be deleted, we will be in an inconsistent
  state with any existing Exchange accounts, since the AccountManager
  will still know about them, contacts (and eventually calendar) items will
  continue to exist, etc.
* Run an integrity check when the provider is created, deleting any
  orphaned EmailProvider.db or EmailProviderBody.db
* Catch SQLiteException's in the Provider and do an integrity check
  if any is caught

Change-Id: I47d523b90a6b8f71ba8e13fba4b04846b3da1b1d
2009-12-07 21:12:57 -08:00
Marc Blank ef83299b99 Clear out orphaned messages in updates/deletes tables
Case #1:
* Fixes #2184702
* Messages can be in the base Messages table, but also in
  Message_Deletes and Message_Updates; the latter two were not
  being purged of deleted messages.
* This CL deletes from all three tables when a Mailbox is deleted
* Also run a check for orphaned deletes/updates when the email
  provider's db is first opened
* Unit test updated to check for proper deletion
* Unit test for the provider check for orphans

Case #2:
* Fixes #2184708
* Messages in Outbox/Drafts can get modified or deleted, but the
  rows added to the updates/delete tables never get removed because
  the boxes don't sync
* Added code to SyncManager.ping (which gets notifications of these
  changes) to delete these rows

Change-Id: Ib53e441136b0da1e88bc220150d631999058a8f0
2009-10-15 10:58:00 -07:00
Andrew Stadler e4a7cc440f Re-enable modernized version of "optional" SSL/TLS
* Add "Accept all certificates" modes to incoming/outgoing secure choices
* Change URI scheme slightly to make "trust" a flag, not part of the
    protocol.
* Change Stores to know about new URI scheme
* Slightly rework Transport API to make "trust" an independent flag
* Adapt HostAuth to handle new Uri scheme
* Remove the old ambiguous "optional" code, which was allowing
    some unsigned certificates, but was *also* allowing TLS to
    optionally start (though not SSL, despite the UI strings.)
* Add a few unit tests to EmailContent
* Add logging and a bunch of comments to TrustManagerFactory, and a bit
    of simple cleanup to make it more readable.
* Add missing conversion of SSLException->CertificateValidationException
    in TLS so we get the correct certificate errors from TLS too.
* Re-enable TLS for mac.com accounts (which had a certificate problem)

Fixes bug http://b/2119755, http://b/1374780, and probably a raft of
earlier and/or external bugs about certificate problems.

Change-Id: Iaf99a8da3eaadaa4cdeec224737838b5d6813e55
2009-09-29 15:28:43 -07:00
Andrew Stadler c41c47fa07 Enable message upload
* Create logic to detect upsyncable messages in Sent
* Note:  Drafts is now local only for IMAP - no sync, either way
* Rewrite MessageController.processPendingAppend for Provider world
* Write provider message -> legacy message converter
* Fixed bug in IMAP APPEND (it was not picking the right UID for the
    uploaded message.)
* Better handling of server internaldate
* Add constants for new X-Android-Body-Quoted-Part header
* Add EmailContent routines to get each of the 5 parts of the body
* Remove "Load more" from unsynced message lists
* Add toString to MimeHeader for debug support

Bug # 2097471

TODO (next CL): Upload attachments records too

Change-Id: I209182f5adc6b6696919f559e3cbbdd58b3eed3a
2009-09-25 14:54:32 -07:00
Marc Blank 5fc57eccef Fix reply/forward for both SMTP and EAS; fixes #2138725
* Add new introText column in the Body database
* Reply/Forward put the appropriate String into this new column
* Rfc822Output uses this when required when streaming the message

Change-Id: I34602fdb3f91692c46fc8bc31ba0e6f680d445a0
2009-09-23 07:31:01 -07:00
Andrew Stadler 0d00889f83 Cleanup Provider Message in preparation for upload
* Remove mServerIntId and its special logic
* Add mServerTimeStamp
* Add column dynamically so we don't lose accounts

Bug # 2097471
2009-09-22 18:31:10 -07:00
Andrew Stadler da8836a76c Give warnings if dupe account created:
* Check for existing accounts with matching servername + username
* Show a dialog and block account creation
* Triggers in three cases:
  * After input of an auto-setup account (e.g. Gmail or AOL)
  * After input of manual setup (incoming) parameters
  * After changing incoming parameters of *any* existing account
* Made some notes in EmailContent regarding fields in HostAuth that we
    are not actually using.
* Added HostAuth unit tests

Primarily fixes bug # 1964449
Bonus fix for bug # 1594408

Change-Id: I49310faf6654280582e0ab3d3e40f2701bfcd21d
2009-09-15 16:33:44 -07:00
Andrew Stadler 6c21942ec4 Implement move-to-trash for IMAP and POP3.
* Define new message-loaded state "FLAG_LOADED_DELETED" (used only for
   POP3, which needs to write sentinel messages that are not displayed.)
* Also renamed the other flags to make the naming more consistent.
* Tweak MessageList query generation to inhibit display of deleted
    message sentinels, and MessagingController won't try to resync them.
* Clean up implementation of Controller.deleteMessage()
* Add support for move to trash to MessagingController.  This operates
    in three primary modes:
  * POP3 local delete (no server-side interaction)
  * POP3 server delete
  * IMAP server delete (and copy to IMAP trash mailbox)
* Add missing implementation in provider to delete all of the attachments
    for a given message
* Fix progress reporting in activities (the test for error vs. progress
    was inverted, which caused progress indicators to keep spinning
    after errors.)
* Fix broken account settings UI (POP3 delete policy was not persisting)

Addresses bug 2097409

TODO delete from trash / empty trash

Change-Id: I00188e6dc2093823106e009f35b68c760227c9e6
2009-09-10 12:44:05 -07:00