k-9/src/com/fsck/k9/activity/MessageView.java

2091 lines
71 KiB
Java
Raw Normal View History

package com.fsck.k9.activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.style.StyleSpan;
import android.util.Config;
import android.util.Log;
import android.util.TypedValue;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.*;
import com.fsck.k9.*;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
2010-07-27 08:10:09 -04:00
import com.fsck.k9.crypto.CryptoProvider;
import com.fsck.k9.crypto.PgpData;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.Message.RecipientType;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBodyPart;
import com.fsck.k9.mail.store.LocalStore.LocalMessage;
import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.view.AccessibleWebView;
import com.fsck.k9.view.AttachmentView;
import com.fsck.k9.view.MessageWebView;
import com.fsck.k9.view.ToggleScrollView;
import java.io.Serializable;
import java.util.*;
public class MessageView extends K9Activity implements OnClickListener
{
private static final String EXTRA_MESSAGE_REFERENCE = "com.fsck.k9.MessageView_messageReference";
private static final String EXTRA_MESSAGE_REFERENCES = "com.fsck.k9.MessageView_messageReferences";
private static final String EXTRA_NEXT = "com.fsck.k9.MessageView_next";
private static final String SHOW_PICTURES = "showPictures";
private static final String STATE_PGP_DATA = "pgpData";
private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1;
private static final int ACTIVITY_CHOOSE_FOLDER_COPY = 2;
private TextView mFromView;
private TextView mDateView;
private TextView mTimeView;
private TextView mToView;
private TextView mCcView;
private TextView mSubjectView;
public View chip;
2009-11-17 20:59:41 -05:00
private CheckBox mFlagged;
r62972@17h: jesse | 2009-05-07 10:49:32 -0400 First stab at a folderlist that doesn't know or care about messages r62973@17h: jesse | 2009-05-07 10:50:11 -0400 A very broken first stab at a message list that only knows about one folder. r62974@17h: jesse | 2009-05-07 10:50:44 -0400 When you go from an account list to an individual account, open a folderlist, not an fml r62975@17h: jesse | 2009-05-07 10:51:24 -0400 Update Welcome activity to open an ml instead of an fml r62976@17h: jesse | 2009-05-07 10:51:59 -0400 When setting up accounts is over, open an fl instead of an fml r62977@17h: jesse | 2009-05-07 10:52:51 -0400 Update MessageView to use folderinfoholders and messageinfoholders from the 'correct' classes. r62978@17h: jesse | 2009-05-07 10:59:07 -0400 MailService now notifies the fl instead of the fml. Not sure if it should also notify the ml. - will require testing r62979@17h: jesse | 2009-05-07 11:01:09 -0400 Switch MessagingController's notifications from notifying the FML to notifying an ML r62980@17h: jesse | 2009-05-07 11:25:22 -0400 Update AndroidManifest to know about the new world order r62981@17h: jesse | 2009-05-07 11:26:11 -0400 Try to follow the android sdk docs for intent creation r62982@17h: jesse | 2009-05-07 11:28:30 -0400 reset MessageList for another try at the conversion r62983@17h: jesse | 2009-05-07 11:47:33 -0400 This version doesn't crash and has a working 'folder' layer. now to clean up the message list layer r62984@17h: jesse | 2009-05-07 15:18:04 -0400 move step 1 r62985@17h: jesse | 2009-05-07 15:18:37 -0400 move step 1 r62986@17h: jesse | 2009-05-07 15:22:47 -0400 rename step 1 r62987@17h: jesse | 2009-05-07 17:38:02 -0400 checkpoint to move r62988@17h: jesse | 2009-05-07 17:40:01 -0400 checkpointing a state with a working folder list and a message list that doesn't explode r62989@17h: jesse | 2009-05-07 17:40:26 -0400 Remove debugging cruft from Welcome r62990@17h: jesse | 2009-05-07 22:00:12 -0400 Basic functionality works. r62991@17h: jesse | 2009-05-08 04:19:52 -0400 added a tool to build a K-9 "Beta" r62992@17h: jesse | 2009-05-08 04:20:03 -0400 remove a disused file r62993@17h: jesse | 2009-05-09 06:07:02 -0400 upgrading build infrastructure for the 1.5 sdk r62994@17h: jesse | 2009-05-09 06:22:02 -0400 further refine onOpenMessage, removing more folder assumptions r62995@17h: jesse | 2009-05-09 20:07:20 -0400 Make the Welcome activity open the autoexpandfolder rather than INBOX r62996@17h: jesse | 2009-05-09 20:14:10 -0400 MessageList now stores the Folder name it was working with across pause-reload r62997@17h: jesse | 2009-05-09 20:14:26 -0400 Removing dead code from FolderList r63060@17h: jesse | 2009-05-10 00:07:33 -0400 Replace the old message list refreshing code which cleared and rebuilt the list from scratch with code which updates or deletes existing messages. Add "go back to folder list" code r63061@17h: jesse | 2009-05-10 00:07:50 -0400 fix message list menus for new world order r63062@17h: jesse | 2009-05-10 00:08:11 -0400 Remove message list options from folder list menus r63063@17h: jesse | 2009-05-10 00:10:02 -0400 remove more message list options from the folder list r63064@17h: jesse | 2009-05-10 00:10:19 -0400 fix build.xml for the new android world order r63065@17h: jesse | 2009-05-10 00:39:23 -0400 reformatted in advance of bug tracing r63066@17h: jesse | 2009-05-10 05:53:28 -0400 fix our 'close' behavior to not leave extra activities around clean up more vestigal code r63067@17h: jesse | 2009-05-10 18:44:25 -0400 Improve "back button / accounts" workflow from FolderList -> AccountList r63068@17h: jesse | 2009-05-10 19:11:47 -0400 * Add required code for the 'k9beta' build r63069@17h: jesse | 2009-05-10 19:12:05 -0400 Make the folder list white backgrounded. r63070@17h: jesse | 2009-05-10 19:12:26 -0400 * Include our required libraries in build.xml r63071@17h: jesse | 2009-05-10 19:13:07 -0400 Added directories for our built code and our generated code r63072@17h: jesse | 2009-05-10 19:13:36 -0400 Added a "back" button image r63073@17h: jesse | 2009-05-10 20:13:50 -0400 Switch next/prev buttons to triangles for I18N and eventual "more easy-to-hit buttons" win r63074@17h: jesse | 2009-05-10 20:17:18 -0400 Tidy Accounts.java for some perf hacking. r63081@17h: jesse | 2009-05-10 22:13:33 -0400 First pass reformatting of the MessagingController r63082@17h: jesse | 2009-05-10 23:50:28 -0400 MessageList now correctly updates when a background sync happens r63083@17h: jesse | 2009-05-10 23:50:53 -0400 Tidying FolderList r63084@17h: jesse | 2009-05-10 23:51:09 -0400 tidy r63085@17h: jesse | 2009-05-10 23:51:27 -0400 tidy r63086@17h: jesse | 2009-05-11 00:17:06 -0400 Properly update unread counts in the FolderList after sync r63087@17h: jesse | 2009-05-11 01:38:14 -0400 Minor refactoring for readability. replace a boolean with a constant. r63090@17h: jesse | 2009-05-11 02:58:31 -0400 now that the foreground of message lists is light, we don't need the light messagebox r63091@17h: jesse | 2009-05-11 17:15:02 -0400 Added a string for "back to folder list" r63092@17h: jesse | 2009-05-11 17:15:24 -0400 Added a message list header with a back button r63093@17h: jesse | 2009-05-11 17:15:54 -0400 Remove the "folder list" button from the options menu. no sense duplicating it r63094@17h: jesse | 2009-05-11 17:17:06 -0400 Refactored views, adding our replacement scrollable header r63184@17h: jesse | 2009-05-12 07:07:15 -0400 fix weird bug where message lists could show a header element for a child r63185@17h: jesse | 2009-05-12 07:08:12 -0400 Add new-style headers to folder lists. reimplement "get folder by name" to not use a bloody for loop r63211@17h: jesse | 2009-05-12 18:37:48 -0400 Restore the former glory of the "load more messages" widget. it still needs an overhaul r63296@17h: jesse | 2009-05-12 23:23:21 -0400 Get the indeterminate progress bar to show up again when you click "get more messages" r63297@17h: jesse | 2009-05-13 02:40:39 -0400 Fixed off-by-one errors in click and keybindings for messagelist r63298@17h: jesse | 2009-05-13 06:04:01 -0400 Put the folder title in the name of the folderSettings popup r63299@17h: jesse | 2009-05-13 06:04:49 -0400 Reformatting. Removing debug logging r63300@17h: jesse | 2009-05-13 06:05:32 -0400 Fixing "wrong item selected" bugs in the FolderList r63328@17h: jesse | 2009-05-13 13:20:00 -0400 Update MessageView for 1.5 r63329@17h: jesse | 2009-05-13 13:50:29 -0400 A couple fixes to "picking the right item" Titles on the message context menu r63330@17h: jesse | 2009-05-13 13:58:37 -0400 Added an "open" context menu item to the folder list r63347@17h: jesse | 2009-05-13 18:00:02 -0400 Try to get folderlists to sort in a stable way, so they jump around less in the ui r63349@17h: jesse | 2009-05-13 20:37:19 -0400 Switch to using non-message-passing based notifications for redisplay of message lists, cut down redisplay frequency to not overload the display r63432@17h: jesse | 2009-05-16 13:38:49 -0400 Android 1.5 no longer gives us apache.commons.codec by default and apache.commons.logging by default. Import them so we have em. There's probably something smarter to do here. r63438@17h: jesse | 2009-05-16 14:12:06 -0400 removed dead code r63439@17h: jesse | 2009-05-16 14:30:57 -0400 Minor tidy r63440@17h: jesse | 2009-05-16 14:39:34 -0400 First pass implementation making MessageList streamy for faster startup r63441@17h: jesse | 2009-05-16 21:57:41 -0400 There's no reason for the FolderList to list local messages r63442@17h: jesse | 2009-05-16 21:58:57 -0400 Switch to actually refreshing the message list after each item is loaded r63450@17h: jesse | 2009-05-16 22:34:18 -0400 Default to pulling items out of the LocalStore by date, descending. (since that's the uneditable default ordering) This makes our messages come out of the store in the order the user should see them r63451@17h: jesse | 2009-05-16 22:34:44 -0400 Set some new defaults for the FolderList r63452@17h: jesse | 2009-05-16 22:35:43 -0400 set some new message list item defaults r63456@17h: jesse | 2009-05-17 12:56:10 -0400 It's not clear that Pop and WebDav actually set us an InternalDate. I'd rather use that so that spam doesn't topsort. But I also want this to _work_ r63457@17h: jesse | 2009-05-17 12:56:47 -0400 actually check to make sure we have a message to remove before removing it. r63458@17h: jesse | 2009-05-17 13:10:07 -0400 Flip "security type" to before the port number, since changing security type is the thing more users are likely to know/care about and resets port number r63469@17h: jesse | 2009-05-17 18:42:39 -0400 Provisional fix for "see the FoldeRList twice" bug r63471@17h: jesse | 2009-05-17 20:47:41 -0400 Remove title bar from the message view r63544@17h: jesse | 2009-05-20 23:53:38 -0400 folderlist tidying before i dig into the jumpy ordering bug r63545@17h: jesse | 2009-05-20 23:56:00 -0400 Killing dead variables r63546@17h: jesse | 2009-05-21 00:58:36 -0400 make the whole title section clicky r63556@17h: jesse | 2009-05-21 01:48:13 -0400 Fix where we go when someone deletes a message r63558@17h: jesse | 2009-05-21 22:44:46 -0400 Working toward switchable themes r63563@17h: jesse | 2009-05-21 23:53:09 -0400 Make the MessageList's colors actually just inherit from the theme, rather than hardcoding black r63567@17h: jesse | 2009-05-22 10:14:13 -0400 Kill a now-redundant comment r63571@17h: jesse | 2009-05-22 19:43:30 -0400 further theme-independence work r63572@17h: jesse | 2009-05-22 19:55:23 -0400 gete -> get (typo fix) r63573@17h: jesse | 2009-05-22 22:48:49 -0400 First cut of a global prefs system as well as a theme preference. not that it works yet r63577@17h: jesse | 2009-05-24 14:49:52 -0400 Once a user has actually put in valid user credentials, start syncing mail and folders in the background instantly. This gives us a much better "new startup" experience r63578@17h: jesse | 2009-05-24 14:55:00 -0400 MessageList doesn't need FolderUpdateWorker r63579@17h: jesse | 2009-05-24 17:57:15 -0400 Fix "get message by uid" Switch to showing messages 10 by 10, rather than 1 by 1 for huge loadtime performance improvements r63587@17h: jesse | 2009-05-24 19:19:56 -0400 Cut down LocalMessage creation to not generate a MessageId or date formatter. r63589@17h: jesse | 2009-05-24 22:22:32 -0400 Switch to null-escaping email address boundaries, rather than a VERY expensive URL-encoding r63590@17h: jesse | 2009-05-24 22:23:21 -0400 Clean up our "auto-refresh the list when adding messages after a sync" r63593@17h: jesse | 2009-05-24 22:53:45 -0400 replace isDateToday with a "rolling 18 hour window" variant that's more likely to give the user a useful answer and is 30x faster. r63595@17h: jesse | 2009-05-24 23:54:14 -0400 When instantiating messges from the LocalStore, there's no need to clear headers before setting them, nor is there a need to set a generated message id r63596@17h: jesse | 2009-05-24 23:54:39 -0400 make an overridable setGeneratedMessageId r63597@17h: jesse | 2009-05-24 23:54:55 -0400 Remove new lies from comments r63598@17h: jesse | 2009-05-24 23:55:35 -0400 Replace insanely expensive message header "name" part quoting with something consistent and cheap that does its work on the way INTO the database r63605@17h: jesse | 2009-05-25 17:28:24 -0400 bring back the 1.1 sdk build.xml r63606@17h: jesse | 2009-05-25 22:32:11 -0400 Actually enable switchable themese and compilation on 1.1 r63692@17h: jesse | 2009-05-29 23:55:17 -0400 Switch back to having titles for folder and message lists. Restore auto-open-folder functionality r63694@17h: jesse | 2009-05-30 18:50:39 -0400 Remove several off-by-one errors introduced by yesterday's return to android titlebars r63696@17h: jesse | 2009-05-30 23:45:03 -0400 use convertView properly for performance and memory imrpovement in FolderList and MessageList r63698@17h: jesse | 2009-05-31 19:42:59 -0400 Switch to using background shading to indicate "not yet fetched" r63701@17h: jesse | 2009-05-31 21:28:47 -0400 Remving code we don't actually need these bits of apache commons on 1.1
2009-05-31 21:35:05 -04:00
private int defaultSubjectColor;
2010-07-27 08:10:09 -04:00
private View mDecryptLayout;
private Button mDecryptButton;
private LinearLayout mCryptoSignatureLayout = null;
private ImageView mCryptoSignatureStatusImage = null;
private TextView mCryptoSignatureUserId = null;
private TextView mCryptoSignatureUserIdRest = null;
private MessageWebView mMessageContentView;
private boolean mScreenReaderEnabled;
private AccessibleWebView mAccessibleMessageContentView;
private LinearLayout mHeaderContainer;
private LinearLayout mAttachments;
private LinearLayout mToContainerView;
private LinearLayout mCcContainerView;
private TextView mAdditionalHeadersView;
private View mAttachmentIcon;
private View mShowPicturesSection;
private boolean mShowPictures;
private Button mDownloadRemainder;
2010-12-24 13:55:05 -05:00
private static Drawable answeredIcon;
View next;
View previous;
private View mDelete;
private View mArchive;
private View mMove;
private View mSpam;
private ToggleScrollView mToggleScrollView;
private Account mAccount;
private MessageReference mMessageReference;
private ArrayList<MessageReference> mMessageReferences;
private Message mMessage;
private PgpData mPgpData = null;
private static final int PREVIOUS = 1;
private static final int NEXT = 2;
private int mLastDirection = PREVIOUS;
private MessagingController mController = MessagingController.getInstance(getApplication());
private MessageReference mNextMessage = null;
private MessageReference mPreviousMessage = null;
private Menu optionsMenu = null;
private Listener mListener = new Listener();
private MessageViewHandler mHandler = new MessageViewHandler();
private FontSizes mFontSizes = K9.getFontSizes();
private Contacts mContacts;
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
private final class StorageListenerImplementation implements StorageManager.StorageListener
{
@Override
public void onUnmount(String providerId)
{
2011-01-06 11:55:34 -05:00
if (!providerId.equals(mAccount.getLocalStorageProviderId()))
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
{
2011-01-06 11:55:34 -05:00
return;
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
}
2011-01-06 11:55:34 -05:00
runOnUiThread(new Runnable()
{
@Override
public void run()
{
onAccountUnavailable();
}
});
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
}
@Override
2011-01-06 11:55:34 -05:00
public void onMount(String providerId) {} // no-op
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
}
/**
* Pair class is only available since API Level 5, so we need
* this helper class unfortunately
*/
private static class HeaderEntry
{
public String label;
public String value;
public HeaderEntry(String label, String value)
{
this.label = label;
this.value = value;
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev)
{
if (ev.getAction() == MotionEvent.ACTION_UP)
{
// Text selection is finished. Allow scrolling again.
mToggleScrollView.setScrolling(true);
}
else if (K9.zoomControlsEnabled())
{
// If we have system zoom controls enabled, disable scrolling so the screen isn't wiggling around while
// trying to zoom.
if (ev.getAction() == MotionEvent.ACTION_POINTER_2_DOWN)
{
mToggleScrollView.setScrolling(false);
}
else if (ev.getAction() == MotionEvent.ACTION_POINTER_2_UP)
{
mToggleScrollView.setScrolling(true);
}
}
return super.dispatchTouchEvent(ev);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
boolean ret = false;
if (KeyEvent.ACTION_DOWN == event.getAction())
{
ret = onKeyDown(event.getKeyCode(), event);
}
if (!ret)
{
ret = super.dispatchKeyEvent(event);
}
return ret;
}
@Override
2011-01-06 11:55:48 -05:00
public boolean onKeyDown(final int keyCode, final KeyEvent event)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_VOLUME_UP:
{
2010-08-30 23:58:33 -04:00
if (K9.useVolumeKeysForNavigationEnabled())
{
onNext();
return true;
}
}
case KeyEvent.KEYCODE_VOLUME_DOWN:
{
2010-08-30 23:58:33 -04:00
if (K9.useVolumeKeysForNavigationEnabled())
{
onPrevious();
return true;
}
}
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
{
/*
* Selecting text started via shift key. Disable scrolling as
* this causes problems when selecting text.
*/
mToggleScrollView.setScrolling(false);
break;
}
case KeyEvent.KEYCODE_DEL:
{
onDelete();
return true;
}
case KeyEvent.KEYCODE_D:
{
onDelete();
return true;
}
case KeyEvent.KEYCODE_F:
{
onForward();
return true;
}
case KeyEvent.KEYCODE_A:
{
onReplyAll();
return true;
}
case KeyEvent.KEYCODE_R:
{
onReply();
return true;
}
case KeyEvent.KEYCODE_G:
{
onFlag();
return true;
}
case KeyEvent.KEYCODE_M:
{
onMove();
return true;
}
case KeyEvent.KEYCODE_S:
{
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getSpamFolderName());
return true;
}
case KeyEvent.KEYCODE_V:
{
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getArchiveFolderName());
return true;
}
case KeyEvent.KEYCODE_Y:
{
onCopy();
return true;
}
case KeyEvent.KEYCODE_J:
case KeyEvent.KEYCODE_P:
{
onPrevious();
return true;
}
case KeyEvent.KEYCODE_N:
case KeyEvent.KEYCODE_K:
{
onNext();
return true;
}
case KeyEvent.KEYCODE_Z:
{
2011-01-06 11:55:48 -05:00
mHandler.post(new Runnable()
{
2011-01-06 11:55:48 -05:00
public void run()
{
2011-01-06 11:55:48 -05:00
if (mScreenReaderEnabled)
{
2011-01-06 11:55:48 -05:00
mAccessibleMessageContentView.zoomIn();
}
2011-01-06 11:55:48 -05:00
else
{
2011-01-06 11:55:48 -05:00
if (event.isShiftPressed())
{
2011-01-06 11:55:48 -05:00
mMessageContentView.zoomIn();
}
else
{
mMessageContentView.zoomOut();
}
}
2011-01-06 11:55:48 -05:00
}
});
return true;
}
case KeyEvent.KEYCODE_H:
{
Toast toast = Toast.makeText(this, R.string.message_help_key, Toast.LENGTH_LONG);
toast.show();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
// Swallow these events too to avoid the audible notification of a volume change
2010-08-30 23:58:33 -04:00
if (K9.useVolumeKeysForNavigationEnabled())
{
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
{
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "Swallowed key up.");
return true;
}
}
2010-12-25 22:49:23 -05:00
return super.onKeyUp(keyCode, event);
}
class MessageViewHandler extends Handler
{
public void progress(final boolean progress)
{
runOnUiThread(new Runnable()
{
public void run()
{
setProgressBarIndeterminateVisibility(progress);
}
});
}
public void addAttachment(final View attachmentView)
{
runOnUiThread(new Runnable()
{
public void run()
{
mAttachments.addView(attachmentView);
mAttachments.setVisibility(View.VISIBLE);
}
});
}
public void removeAllAttachments()
{
runOnUiThread(new Runnable()
{
2010-07-18 21:57:49 -04:00
public void run()
{
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++)
{
mAttachments.removeView(mAttachments.getChildAt(i));
}
2010-07-18 21:57:49 -04:00
}
});
}
public void setAttachmentsEnabled(final boolean enabled)
{
runOnUiThread(new Runnable()
{
public void run()
{
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++)
{
AttachmentView attachment = (AttachmentView) mAttachments.getChildAt(i);
attachment.viewButton.setEnabled(enabled);
attachment.downloadButton.setEnabled(enabled);
}
}
});
}
public void setHeaders(
2010-12-25 22:49:23 -05:00
final Message message) throws MessagingException
{
2010-12-25 17:30:31 -05:00
final Contacts contacts = K9.showContactName() ? mContacts : null;
final CharSequence from = Address.toFriendly(message.getFrom(), contacts);
final String date = getDateFormat().format(message.getSentDate());
final String time = getTimeFormat().format(message.getSentDate());
final CharSequence to = Address.toFriendly(message.getRecipients(RecipientType.TO), contacts);
final CharSequence cc = Address.toFriendly(message.getRecipients(RecipientType.CC), contacts);
runOnUiThread(new Runnable()
{
public void run()
{
2010-12-25 17:30:31 -05:00
String subject = message.getSubject();
setTitle(subject);
if (subject == null || subject.equals(""))
{
mSubjectView.setText(getText(R.string.general_no_subject));
}
else
{
mSubjectView.setText(subject);
}
mFromView.setText(from);
if (date != null)
{
mDateView.setText(date);
mDateView.setVisibility(View.VISIBLE);
}
else
{
mDateView.setVisibility(View.GONE);
}
mTimeView.setText(time);
2010-12-25 22:49:16 -05:00
mToContainerView.setVisibility((to != null && to.length() > 0) ? View.VISIBLE : View.GONE);
mToView.setText(to);
2010-12-25 22:49:16 -05:00
mCcContainerView.setVisibility((cc != null && cc.length() > 0) ? View.VISIBLE : View.GONE);
mCcView.setText(cc);
2010-12-25 17:30:31 -05:00
mAttachmentIcon.setVisibility(((LocalMessage) message).hasAttachments() ? View.VISIBLE : View.GONE);
mFlagged.setChecked(message.isSet(Flag.FLAGGED));
mSubjectView.setTextColor(0xff000000 | defaultSubjectColor);
chip.setBackgroundDrawable(mAccount.generateColorChip().drawable());
2010-12-25 17:30:31 -05:00
chip.getBackground().setAlpha(!message.isSet(Flag.SEEN) ? 255 : 127);
2010-12-25 22:49:16 -05:00
if (message.isSet(Flag.ANSWERED))
{
2010-12-25 17:30:31 -05:00
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(answeredIcon, null, null, null);
2010-12-25 22:49:16 -05:00
}
else
{
2010-12-25 17:30:31 -05:00
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
2010-07-18 21:57:49 -04:00
if (mMessage.isSet(Flag.X_DOWNLOADED_FULL))
{
mDownloadRemainder.setVisibility(View.GONE);
}
else
{
mDownloadRemainder.setEnabled(true);
mDownloadRemainder.setVisibility(View.VISIBLE);
}
2010-12-28 04:09:33 -05:00
mHeaderContainer.setVisibility(View.VISIBLE);
if (mAdditionalHeadersView.getVisibility() == View.VISIBLE)
{
showAdditionalHeaders();
}
}
});
}
public void networkError()
{
runOnUiThread(new Runnable()
{
public void run()
{
Toast.makeText(MessageView.this,
R.string.status_network_error, Toast.LENGTH_LONG).show();
}
});
}
public void invalidIdError()
{
runOnUiThread(new Runnable()
{
public void run()
{
Toast.makeText(MessageView.this,
R.string.status_invalid_id_error, Toast.LENGTH_LONG).show();
}
});
}
public void fetchingAttachment()
{
runOnUiThread(new Runnable()
{
public void run()
{
Toast.makeText(MessageView.this,
getString(R.string.message_view_fetching_attachment_toast),
Toast.LENGTH_SHORT).show();
}
});
}
public void showShowPictures(final boolean show)
{
runOnUiThread(new Runnable()
{
public void run()
{
mShowPicturesSection.setVisibility(show ? View.VISIBLE : View.GONE);
}
});
}
private void hideHeaderContainer()
{
{
runOnUiThread(new Runnable()
{
public void run()
{
mHeaderContainer.setVisibility(View.GONE);
}
});
}
}
/**
* Clear the text field for the additional headers display if they are
* not shown, to save UI resources.
*/
public void hideAdditionalHeaders()
{
runOnUiThread(new Runnable()
{
public void run()
{
mAdditionalHeadersView.setVisibility(View.GONE);
mAdditionalHeadersView.setText("");
mTopView.scrollTo(0, 0);
}
});
}
/**
* Set up and then show the additional headers view. Called by
* {@link #onShowAdditionalHeaders()}
* (when switching between messages).
*/
public void showAdditionalHeaders()
{
runOnUiThread(new Runnable()
{
public void run()
{
Integer messageToShow = null;
try
{
// Retrieve additional headers
boolean allHeadersDownloaded = mMessage.isSet(Flag.X_GOT_ALL_HEADERS);
List<HeaderEntry> additionalHeaders = getAdditionalHeaders(mMessage);
if (!additionalHeaders.isEmpty())
{
// Show the additional headers that we have got.
setupAdditionalHeadersView(additionalHeaders);
mAdditionalHeadersView.setVisibility(View.VISIBLE);
}
if (!allHeadersDownloaded)
{
/*
* Tell the user about the "save all headers" setting
*
* NOTE: This is only a temporary solution... in fact,
* the system should download headers on-demand when they
* have not been saved in their entirety initially.
*/
messageToShow = R.string.message_additional_headers_not_downloaded;
}
else if (additionalHeaders.isEmpty())
{
// All headers have been downloaded, but there are no additional headers.
messageToShow = R.string.message_no_additional_headers_available;
}
}
catch (MessagingException e)
{
messageToShow = R.string.message_additional_headers_retrieval_failed;
}
// Show a message to the user, if any
if (messageToShow != null)
{
Toast toast = Toast.makeText(MessageView.this, messageToShow, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
}
});
}
/**
* Set up the additional headers text view with the supplied header data.
*
* @param additionalHeaders
* List of header entries. Each entry consists of a header
* name and a header value. Header names may appear multiple
* times.
*
* This method is always called from within the UI thread by
* {@link #showAdditionalHeaders()}.
*/
private void setupAdditionalHeadersView(final List<HeaderEntry> additionalHeaders)
{
SpannableStringBuilder sb = new SpannableStringBuilder();
boolean first = true;
for (HeaderEntry additionalHeader : additionalHeaders)
{
if (!first)
{
sb.append("\n");
}
else
{
first = false;
}
StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
SpannableString label = new SpannableString(additionalHeader.label + ": ");
label.setSpan(boldSpan, 0, label.length(), 0);
sb.append(label);
sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value));
}
mAdditionalHeadersView.setText(sb);
}
}
public static void actionView(Context context, MessageReference messRef, List<MessageReference> messReferences)
{
actionView(context, messRef, messReferences, null);
}
public static void actionView(Context context, MessageReference messRef, List<MessageReference> messReferences, Bundle extras)
{
Intent i = new Intent(context, MessageView.class);
i.putExtra(EXTRA_MESSAGE_REFERENCE, messRef);
2010-12-25 22:49:16 -05:00
i.putExtra(EXTRA_MESSAGE_REFERENCES, (Serializable) messReferences);
if (extras != null)
{
i.putExtras(extras);
}
context.startActivity(i);
}
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle, false);
mContacts = Contacts.getInstance(this);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.message_view);
mMessageContentView = (MessageWebView) findViewById(R.id.message_content);
mAccessibleMessageContentView = (AccessibleWebView) findViewById(R.id.accessible_message_content);
mScreenReaderEnabled = isScreenReaderActive();
2010-12-12 20:56:57 -05:00
answeredIcon = getResources().getDrawable(R.drawable.ic_mms_answered_small);
if (mScreenReaderEnabled)
{
mAccessibleMessageContentView.setVisibility(View.VISIBLE);
mMessageContentView.setVisibility(View.GONE);
}
else
{
mAccessibleMessageContentView.setVisibility(View.GONE);
mMessageContentView.setVisibility(View.VISIBLE);
}
2009-11-19 01:03:59 -05:00
2010-12-28 04:11:35 -05:00
setupDecryptLayout();
setTitle("");
Intent intent = getIntent();
Uri uri = intent.getData();
if (icicle != null)
2010-07-27 08:10:09 -04:00
{
mMessageReference = (MessageReference) icicle.getSerializable(EXTRA_MESSAGE_REFERENCE);
mMessageReferences = (ArrayList<MessageReference>) icicle.getSerializable(EXTRA_MESSAGE_REFERENCES);
mPgpData = (PgpData) icicle.getSerializable(STATE_PGP_DATA);
updateDecryptLayout();
}
else
{
if (uri == null)
2010-07-27 08:10:09 -04:00
{
mMessageReference = (MessageReference) intent.getSerializableExtra(EXTRA_MESSAGE_REFERENCE);
mMessageReferences = (ArrayList<MessageReference>) intent.getSerializableExtra(EXTRA_MESSAGE_REFERENCES);
}
else
{
List<String> segmentList = uri.getPathSegments();
if (segmentList.size() != 3)
2010-07-27 08:10:09 -04:00
{
//TODO: Use ressource to externalize message
Toast.makeText(this, "Invalid intent uri: " + uri.toString(), Toast.LENGTH_LONG).show();
return;
}
String accountId = segmentList.get(0);
Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts();
boolean found = false;
for (Account account : accounts)
{
if (String.valueOf(account.getAccountNumber()).equals(accountId))
2010-07-27 08:10:09 -04:00
{
mAccount = account;
found = true;
break;
2010-07-27 08:10:09 -04:00
}
}
if (!found)
2010-07-27 08:10:09 -04:00
{
//TODO: Use ressource to externalize message
Toast.makeText(this, "Invalid account id: " + accountId, Toast.LENGTH_LONG).show();
return;
2010-07-27 08:10:09 -04:00
}
mMessageReference = new MessageReference();
mMessageReference.accountUuid = mAccount.getUuid();
mMessageReference.folderName = segmentList.get(1);
mMessageReference.uid = segmentList.get(2);
mMessageReferences = new ArrayList<MessageReference>();
2010-07-27 08:10:09 -04:00
}
}
2010-07-27 08:10:09 -04:00
mAccount = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
r62972@17h: jesse | 2009-05-07 10:49:32 -0400 First stab at a folderlist that doesn't know or care about messages r62973@17h: jesse | 2009-05-07 10:50:11 -0400 A very broken first stab at a message list that only knows about one folder. r62974@17h: jesse | 2009-05-07 10:50:44 -0400 When you go from an account list to an individual account, open a folderlist, not an fml r62975@17h: jesse | 2009-05-07 10:51:24 -0400 Update Welcome activity to open an ml instead of an fml r62976@17h: jesse | 2009-05-07 10:51:59 -0400 When setting up accounts is over, open an fl instead of an fml r62977@17h: jesse | 2009-05-07 10:52:51 -0400 Update MessageView to use folderinfoholders and messageinfoholders from the 'correct' classes. r62978@17h: jesse | 2009-05-07 10:59:07 -0400 MailService now notifies the fl instead of the fml. Not sure if it should also notify the ml. - will require testing r62979@17h: jesse | 2009-05-07 11:01:09 -0400 Switch MessagingController's notifications from notifying the FML to notifying an ML r62980@17h: jesse | 2009-05-07 11:25:22 -0400 Update AndroidManifest to know about the new world order r62981@17h: jesse | 2009-05-07 11:26:11 -0400 Try to follow the android sdk docs for intent creation r62982@17h: jesse | 2009-05-07 11:28:30 -0400 reset MessageList for another try at the conversion r62983@17h: jesse | 2009-05-07 11:47:33 -0400 This version doesn't crash and has a working 'folder' layer. now to clean up the message list layer r62984@17h: jesse | 2009-05-07 15:18:04 -0400 move step 1 r62985@17h: jesse | 2009-05-07 15:18:37 -0400 move step 1 r62986@17h: jesse | 2009-05-07 15:22:47 -0400 rename step 1 r62987@17h: jesse | 2009-05-07 17:38:02 -0400 checkpoint to move r62988@17h: jesse | 2009-05-07 17:40:01 -0400 checkpointing a state with a working folder list and a message list that doesn't explode r62989@17h: jesse | 2009-05-07 17:40:26 -0400 Remove debugging cruft from Welcome r62990@17h: jesse | 2009-05-07 22:00:12 -0400 Basic functionality works. r62991@17h: jesse | 2009-05-08 04:19:52 -0400 added a tool to build a K-9 "Beta" r62992@17h: jesse | 2009-05-08 04:20:03 -0400 remove a disused file r62993@17h: jesse | 2009-05-09 06:07:02 -0400 upgrading build infrastructure for the 1.5 sdk r62994@17h: jesse | 2009-05-09 06:22:02 -0400 further refine onOpenMessage, removing more folder assumptions r62995@17h: jesse | 2009-05-09 20:07:20 -0400 Make the Welcome activity open the autoexpandfolder rather than INBOX r62996@17h: jesse | 2009-05-09 20:14:10 -0400 MessageList now stores the Folder name it was working with across pause-reload r62997@17h: jesse | 2009-05-09 20:14:26 -0400 Removing dead code from FolderList r63060@17h: jesse | 2009-05-10 00:07:33 -0400 Replace the old message list refreshing code which cleared and rebuilt the list from scratch with code which updates or deletes existing messages. Add "go back to folder list" code r63061@17h: jesse | 2009-05-10 00:07:50 -0400 fix message list menus for new world order r63062@17h: jesse | 2009-05-10 00:08:11 -0400 Remove message list options from folder list menus r63063@17h: jesse | 2009-05-10 00:10:02 -0400 remove more message list options from the folder list r63064@17h: jesse | 2009-05-10 00:10:19 -0400 fix build.xml for the new android world order r63065@17h: jesse | 2009-05-10 00:39:23 -0400 reformatted in advance of bug tracing r63066@17h: jesse | 2009-05-10 05:53:28 -0400 fix our 'close' behavior to not leave extra activities around clean up more vestigal code r63067@17h: jesse | 2009-05-10 18:44:25 -0400 Improve "back button / accounts" workflow from FolderList -> AccountList r63068@17h: jesse | 2009-05-10 19:11:47 -0400 * Add required code for the 'k9beta' build r63069@17h: jesse | 2009-05-10 19:12:05 -0400 Make the folder list white backgrounded. r63070@17h: jesse | 2009-05-10 19:12:26 -0400 * Include our required libraries in build.xml r63071@17h: jesse | 2009-05-10 19:13:07 -0400 Added directories for our built code and our generated code r63072@17h: jesse | 2009-05-10 19:13:36 -0400 Added a "back" button image r63073@17h: jesse | 2009-05-10 20:13:50 -0400 Switch next/prev buttons to triangles for I18N and eventual "more easy-to-hit buttons" win r63074@17h: jesse | 2009-05-10 20:17:18 -0400 Tidy Accounts.java for some perf hacking. r63081@17h: jesse | 2009-05-10 22:13:33 -0400 First pass reformatting of the MessagingController r63082@17h: jesse | 2009-05-10 23:50:28 -0400 MessageList now correctly updates when a background sync happens r63083@17h: jesse | 2009-05-10 23:50:53 -0400 Tidying FolderList r63084@17h: jesse | 2009-05-10 23:51:09 -0400 tidy r63085@17h: jesse | 2009-05-10 23:51:27 -0400 tidy r63086@17h: jesse | 2009-05-11 00:17:06 -0400 Properly update unread counts in the FolderList after sync r63087@17h: jesse | 2009-05-11 01:38:14 -0400 Minor refactoring for readability. replace a boolean with a constant. r63090@17h: jesse | 2009-05-11 02:58:31 -0400 now that the foreground of message lists is light, we don't need the light messagebox r63091@17h: jesse | 2009-05-11 17:15:02 -0400 Added a string for "back to folder list" r63092@17h: jesse | 2009-05-11 17:15:24 -0400 Added a message list header with a back button r63093@17h: jesse | 2009-05-11 17:15:54 -0400 Remove the "folder list" button from the options menu. no sense duplicating it r63094@17h: jesse | 2009-05-11 17:17:06 -0400 Refactored views, adding our replacement scrollable header r63184@17h: jesse | 2009-05-12 07:07:15 -0400 fix weird bug where message lists could show a header element for a child r63185@17h: jesse | 2009-05-12 07:08:12 -0400 Add new-style headers to folder lists. reimplement "get folder by name" to not use a bloody for loop r63211@17h: jesse | 2009-05-12 18:37:48 -0400 Restore the former glory of the "load more messages" widget. it still needs an overhaul r63296@17h: jesse | 2009-05-12 23:23:21 -0400 Get the indeterminate progress bar to show up again when you click "get more messages" r63297@17h: jesse | 2009-05-13 02:40:39 -0400 Fixed off-by-one errors in click and keybindings for messagelist r63298@17h: jesse | 2009-05-13 06:04:01 -0400 Put the folder title in the name of the folderSettings popup r63299@17h: jesse | 2009-05-13 06:04:49 -0400 Reformatting. Removing debug logging r63300@17h: jesse | 2009-05-13 06:05:32 -0400 Fixing "wrong item selected" bugs in the FolderList r63328@17h: jesse | 2009-05-13 13:20:00 -0400 Update MessageView for 1.5 r63329@17h: jesse | 2009-05-13 13:50:29 -0400 A couple fixes to "picking the right item" Titles on the message context menu r63330@17h: jesse | 2009-05-13 13:58:37 -0400 Added an "open" context menu item to the folder list r63347@17h: jesse | 2009-05-13 18:00:02 -0400 Try to get folderlists to sort in a stable way, so they jump around less in the ui r63349@17h: jesse | 2009-05-13 20:37:19 -0400 Switch to using non-message-passing based notifications for redisplay of message lists, cut down redisplay frequency to not overload the display r63432@17h: jesse | 2009-05-16 13:38:49 -0400 Android 1.5 no longer gives us apache.commons.codec by default and apache.commons.logging by default. Import them so we have em. There's probably something smarter to do here. r63438@17h: jesse | 2009-05-16 14:12:06 -0400 removed dead code r63439@17h: jesse | 2009-05-16 14:30:57 -0400 Minor tidy r63440@17h: jesse | 2009-05-16 14:39:34 -0400 First pass implementation making MessageList streamy for faster startup r63441@17h: jesse | 2009-05-16 21:57:41 -0400 There's no reason for the FolderList to list local messages r63442@17h: jesse | 2009-05-16 21:58:57 -0400 Switch to actually refreshing the message list after each item is loaded r63450@17h: jesse | 2009-05-16 22:34:18 -0400 Default to pulling items out of the LocalStore by date, descending. (since that's the uneditable default ordering) This makes our messages come out of the store in the order the user should see them r63451@17h: jesse | 2009-05-16 22:34:44 -0400 Set some new defaults for the FolderList r63452@17h: jesse | 2009-05-16 22:35:43 -0400 set some new message list item defaults r63456@17h: jesse | 2009-05-17 12:56:10 -0400 It's not clear that Pop and WebDav actually set us an InternalDate. I'd rather use that so that spam doesn't topsort. But I also want this to _work_ r63457@17h: jesse | 2009-05-17 12:56:47 -0400 actually check to make sure we have a message to remove before removing it. r63458@17h: jesse | 2009-05-17 13:10:07 -0400 Flip "security type" to before the port number, since changing security type is the thing more users are likely to know/care about and resets port number r63469@17h: jesse | 2009-05-17 18:42:39 -0400 Provisional fix for "see the FoldeRList twice" bug r63471@17h: jesse | 2009-05-17 20:47:41 -0400 Remove title bar from the message view r63544@17h: jesse | 2009-05-20 23:53:38 -0400 folderlist tidying before i dig into the jumpy ordering bug r63545@17h: jesse | 2009-05-20 23:56:00 -0400 Killing dead variables r63546@17h: jesse | 2009-05-21 00:58:36 -0400 make the whole title section clicky r63556@17h: jesse | 2009-05-21 01:48:13 -0400 Fix where we go when someone deletes a message r63558@17h: jesse | 2009-05-21 22:44:46 -0400 Working toward switchable themes r63563@17h: jesse | 2009-05-21 23:53:09 -0400 Make the MessageList's colors actually just inherit from the theme, rather than hardcoding black r63567@17h: jesse | 2009-05-22 10:14:13 -0400 Kill a now-redundant comment r63571@17h: jesse | 2009-05-22 19:43:30 -0400 further theme-independence work r63572@17h: jesse | 2009-05-22 19:55:23 -0400 gete -> get (typo fix) r63573@17h: jesse | 2009-05-22 22:48:49 -0400 First cut of a global prefs system as well as a theme preference. not that it works yet r63577@17h: jesse | 2009-05-24 14:49:52 -0400 Once a user has actually put in valid user credentials, start syncing mail and folders in the background instantly. This gives us a much better "new startup" experience r63578@17h: jesse | 2009-05-24 14:55:00 -0400 MessageList doesn't need FolderUpdateWorker r63579@17h: jesse | 2009-05-24 17:57:15 -0400 Fix "get message by uid" Switch to showing messages 10 by 10, rather than 1 by 1 for huge loadtime performance improvements r63587@17h: jesse | 2009-05-24 19:19:56 -0400 Cut down LocalMessage creation to not generate a MessageId or date formatter. r63589@17h: jesse | 2009-05-24 22:22:32 -0400 Switch to null-escaping email address boundaries, rather than a VERY expensive URL-encoding r63590@17h: jesse | 2009-05-24 22:23:21 -0400 Clean up our "auto-refresh the list when adding messages after a sync" r63593@17h: jesse | 2009-05-24 22:53:45 -0400 replace isDateToday with a "rolling 18 hour window" variant that's more likely to give the user a useful answer and is 30x faster. r63595@17h: jesse | 2009-05-24 23:54:14 -0400 When instantiating messges from the LocalStore, there's no need to clear headers before setting them, nor is there a need to set a generated message id r63596@17h: jesse | 2009-05-24 23:54:39 -0400 make an overridable setGeneratedMessageId r63597@17h: jesse | 2009-05-24 23:54:55 -0400 Remove new lies from comments r63598@17h: jesse | 2009-05-24 23:55:35 -0400 Replace insanely expensive message header "name" part quoting with something consistent and cheap that does its work on the way INTO the database r63605@17h: jesse | 2009-05-25 17:28:24 -0400 bring back the 1.1 sdk build.xml r63606@17h: jesse | 2009-05-25 22:32:11 -0400 Actually enable switchable themese and compilation on 1.1 r63692@17h: jesse | 2009-05-29 23:55:17 -0400 Switch back to having titles for folder and message lists. Restore auto-open-folder functionality r63694@17h: jesse | 2009-05-30 18:50:39 -0400 Remove several off-by-one errors introduced by yesterday's return to android titlebars r63696@17h: jesse | 2009-05-30 23:45:03 -0400 use convertView properly for performance and memory imrpovement in FolderList and MessageList r63698@17h: jesse | 2009-05-31 19:42:59 -0400 Switch to using background shading to indicate "not yet fetched" r63701@17h: jesse | 2009-05-31 21:28:47 -0400 Remving code we don't actually need these bits of apache commons on 1.1
2009-05-31 21:35:05 -04:00
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "MessageView got message " + mMessageReference);
if (intent.getBooleanExtra(EXTRA_NEXT, false))
{
next.requestFocus();
}
2009-11-17 20:59:41 -05:00
setupHeaderLayout();
setupButtonViews();
displayMessage(mMessageReference);
}
private void setupButtonViews()
{
setOnClickListener(R.id.from);
Complete merge of DAmail functionality into K9mail. Following features are added to K9mail: 1) Show unread message count on each folder 2) Sum unread count of all shown folders in an account to the account display 3) Periodically check selected folders for new mail, not just Inbox 4) Don't refresh folder when opened (unless folder is empty) 5) Show date and time of last sync for each folder 6) Fix timer for automatic periodic sync (use wakelock to assure completion) 7) Optimize local folder queries (speeds up account and folder lists) 8) Show Loading... message in status bar indicating which folder is being synced 9) Eliminate redundant sync of new messages (performance enhancement) 10) Improve notification text for multiple accounts 11) Do not automatically sync folders more often than the account-specific period 12) Use user-configured date and time formats 13) Select which folders are shown, using configurable Classes 14) Select which folders are synced, using configurable Classes 15) Added context (long press) menu to folders, to provide for Refresh and Folder Settings 16) Status light flashes purple when there are unread messages 17) Folder list more quickly eliminates display of deleted and out-of-Class folders. 18) Delete works 19) Mark all messages as read (in the folder context menu) 20) Notifications only for new unread messages 21) One minute synchronization frequency 22) Deleting an unread message decrements unread counter 23) Notifications work for POP3 accounts 24) Message deletes work for POP3 accounts 25) Explicit errors show in folder list 26) Stack traces saved to folder K9mail-errors 27) Clear pending actions (danger, for emergencies only!) 28) Delete policy in Account settings 29) DNS cache in InetAddress disabled 30) Trapped some crash-causing error conditions 31) Eliminate duplicate copies to Sent folder 32) Prevent crashes due to message listener concurrency 33) Empty Trash 34) Nuclear "Mark all messages as read" (marks all messages as read in server-side folder, irrespective of which messages have been downloaded) 35) Forward (alternate) to allow forwarding email through other programs 36) Accept text/plain Intents to allow other programs to send email through K9mail 37) Displays Outbox sending status 38) Manual retry of outbox sending when "Refresh"ing Outbox 39) Folder error status is persisted 40) Ability to log to arbitrary file Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104, 107, 120, 148, 154
2008-12-30 22:49:09 -05:00
setOnClickListener(R.id.reply);
setOnClickListener(R.id.reply_all);
Complete merge of DAmail functionality into K9mail. Following features are added to K9mail: 1) Show unread message count on each folder 2) Sum unread count of all shown folders in an account to the account display 3) Periodically check selected folders for new mail, not just Inbox 4) Don't refresh folder when opened (unless folder is empty) 5) Show date and time of last sync for each folder 6) Fix timer for automatic periodic sync (use wakelock to assure completion) 7) Optimize local folder queries (speeds up account and folder lists) 8) Show Loading... message in status bar indicating which folder is being synced 9) Eliminate redundant sync of new messages (performance enhancement) 10) Improve notification text for multiple accounts 11) Do not automatically sync folders more often than the account-specific period 12) Use user-configured date and time formats 13) Select which folders are shown, using configurable Classes 14) Select which folders are synced, using configurable Classes 15) Added context (long press) menu to folders, to provide for Refresh and Folder Settings 16) Status light flashes purple when there are unread messages 17) Folder list more quickly eliminates display of deleted and out-of-Class folders. 18) Delete works 19) Mark all messages as read (in the folder context menu) 20) Notifications only for new unread messages 21) One minute synchronization frequency 22) Deleting an unread message decrements unread counter 23) Notifications work for POP3 accounts 24) Message deletes work for POP3 accounts 25) Explicit errors show in folder list 26) Stack traces saved to folder K9mail-errors 27) Clear pending actions (danger, for emergencies only!) 28) Delete policy in Account settings 29) DNS cache in InetAddress disabled 30) Trapped some crash-causing error conditions 31) Eliminate duplicate copies to Sent folder 32) Prevent crashes due to message listener concurrency 33) Empty Trash 34) Nuclear "Mark all messages as read" (marks all messages as read in server-side folder, irrespective of which messages have been downloaded) 35) Forward (alternate) to allow forwarding email through other programs 36) Accept text/plain Intents to allow other programs to send email through K9mail 37) Displays Outbox sending status 38) Manual retry of outbox sending when "Refresh"ing Outbox 39) Folder error status is persisted 40) Ability to log to arbitrary file Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104, 107, 120, 148, 154
2008-12-30 22:49:09 -05:00
setOnClickListener(R.id.delete);
setOnClickListener(R.id.forward);
setOnClickListener(R.id.next);
setOnClickListener(R.id.previous);
setOnClickListener(R.id.archive);
setOnClickListener(R.id.move);
setOnClickListener(R.id.spam);
// To show full header
setOnClickListener(R.id.header_container);
setOnClickListener(R.id.reply_scrolling);
// setOnClickListener(R.id.reply_all_scrolling);
setOnClickListener(R.id.delete_scrolling);
setOnClickListener(R.id.forward_scrolling);
setOnClickListener(R.id.next_scrolling);
setOnClickListener(R.id.previous_scrolling);
setOnClickListener(R.id.archive_scrolling);
setOnClickListener(R.id.move_scrolling);
setOnClickListener(R.id.spam_scrolling);
Complete merge of DAmail functionality into K9mail. Following features are added to K9mail: 1) Show unread message count on each folder 2) Sum unread count of all shown folders in an account to the account display 3) Periodically check selected folders for new mail, not just Inbox 4) Don't refresh folder when opened (unless folder is empty) 5) Show date and time of last sync for each folder 6) Fix timer for automatic periodic sync (use wakelock to assure completion) 7) Optimize local folder queries (speeds up account and folder lists) 8) Show Loading... message in status bar indicating which folder is being synced 9) Eliminate redundant sync of new messages (performance enhancement) 10) Improve notification text for multiple accounts 11) Do not automatically sync folders more often than the account-specific period 12) Use user-configured date and time formats 13) Select which folders are shown, using configurable Classes 14) Select which folders are synced, using configurable Classes 15) Added context (long press) menu to folders, to provide for Refresh and Folder Settings 16) Status light flashes purple when there are unread messages 17) Folder list more quickly eliminates display of deleted and out-of-Class folders. 18) Delete works 19) Mark all messages as read (in the folder context menu) 20) Notifications only for new unread messages 21) One minute synchronization frequency 22) Deleting an unread message decrements unread counter 23) Notifications work for POP3 accounts 24) Message deletes work for POP3 accounts 25) Explicit errors show in folder list 26) Stack traces saved to folder K9mail-errors 27) Clear pending actions (danger, for emergencies only!) 28) Delete policy in Account settings 29) DNS cache in InetAddress disabled 30) Trapped some crash-causing error conditions 31) Eliminate duplicate copies to Sent folder 32) Prevent crashes due to message listener concurrency 33) Empty Trash 34) Nuclear "Mark all messages as read" (marks all messages as read in server-side folder, irrespective of which messages have been downloaded) 35) Forward (alternate) to allow forwarding email through other programs 36) Accept text/plain Intents to allow other programs to send email through K9mail 37) Displays Outbox sending status 38) Manual retry of outbox sending when "Refresh"ing Outbox 39) Folder error status is persisted 40) Ability to log to arbitrary file Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104, 107, 120, 148, 154
2008-12-30 22:49:09 -05:00
setOnClickListener(R.id.show_pictures);
setOnClickListener(R.id.download_remainder);
// Perhaps the ScrollButtons should be global, instead of account-specific
Account.ScrollButtons scrollButtons = mAccount.getScrollMessageViewButtons();
if
((Account.ScrollButtons.ALWAYS == scrollButtons)
||
(Account.ScrollButtons.KEYBOARD_AVAILABLE == scrollButtons &&
(this.getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)))
{
scrollButtons();
}
else // never or the keyboard is open
{
staticButtons();
}
Account.ScrollButtons scrollMoveButtons = mAccount.getScrollMessageViewMoveButtons();
if ((Account.ScrollButtons.ALWAYS == scrollMoveButtons)
|| (Account.ScrollButtons.KEYBOARD_AVAILABLE == scrollMoveButtons &&
(this.getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)))
{
scrollMoveButtons();
}
else
{
staticMoveButtons();
}
if (!mAccount.getEnableMoveButtons())
{
View buttons = findViewById(R.id.move_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
buttons = findViewById(R.id.scrolling_move_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
}
}
private void setupHeaderLayout()
{
mAttachments = (LinearLayout) findViewById(R.id.attachments);
mAttachmentIcon = findViewById(R.id.attachment);
mShowPicturesSection = findViewById(R.id.show_pictures_section);
mShowPictures = false;
mDownloadRemainder = (Button) findViewById(R.id.download_remainder);
mMessageContentView.configure();
mHeaderContainer = (LinearLayout) findViewById(R.id.header_container);
mFromView = (TextView) findViewById(R.id.from);
mToView = (TextView) findViewById(R.id.to);
mCcView = (TextView) findViewById(R.id.cc);
mToContainerView = (LinearLayout) findViewById(R.id.to_container);
mCcContainerView = (LinearLayout) findViewById(R.id.cc_container);
mSubjectView = (TextView) findViewById(R.id.subject);
defaultSubjectColor = mSubjectView.getCurrentTextColor();
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
chip = findViewById(R.id.chip);
mDateView = (TextView) findViewById(R.id.date);
mTimeView = (TextView) findViewById(R.id.time);
mTopView = mToggleScrollView = (ToggleScrollView) findViewById(R.id.top_view);
mFlagged = (CheckBox) findViewById(R.id.flagged);
mFlagged.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
onFlag();
}
});
mFromView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewSender());
mToView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewTo());
((TextView) findViewById(R.id.to_label)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewTo());
mCcView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewCC());
((TextView) findViewById(R.id.cc_label)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewCC());
mSubjectView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewSubject());
mTimeView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewTime());
mDateView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewDate());
mAdditionalHeadersView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getMessageViewAdditionalHeaders());
mAdditionalHeadersView.setVisibility(View.GONE);
mAttachments.setVisibility(View.GONE);
mAttachmentIcon.setVisibility(View.GONE);
}
2010-12-28 04:11:35 -05:00
private void setupDecryptLayout()
{
mDecryptLayout = (View) findViewById(R.id.layout_decrypt);
mDecryptButton = (Button) findViewById(R.id.btn_decrypt);
mDecryptButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
try
{
String data = null;
Part part = MimeUtility.findFirstPartByMimeType(mMessage, "text/plain");
if (part == null)
{
part = MimeUtility.findFirstPartByMimeType(mMessage, "text/html");
}
if (part != null)
{
data = MimeUtility.getTextFromPart(part);
}
mAccount.getCryptoProvider().decrypt(MessageView.this, data, mPgpData);
}
catch (MessagingException me)
{
Log.e(K9.LOG_TAG, "Unable to decrypt email.", me);
}
}
});
mCryptoSignatureLayout = (LinearLayout) findViewById(R.id.crypto_signature);
mCryptoSignatureStatusImage = (ImageView) findViewById(R.id.ic_crypto_signature_status);
mCryptoSignatureUserId = (TextView) findViewById(R.id.userId);
mCryptoSignatureUserIdRest = (TextView) findViewById(R.id.userIdRest);
mCryptoSignatureLayout.setVisibility(View.INVISIBLE);
}
private boolean isScreenReaderActive()
{
final String SCREENREADER_INTENT_ACTION = "android.accessibilityservice.AccessibilityService";
final String SCREENREADER_INTENT_CATEGORY = "android.accessibilityservice.category.FEEDBACK_SPOKEN";
// Restrict the set of intents to only accessibility services that have
// the category FEEDBACK_SPOKEN (aka, screen readers).
Intent screenReaderIntent = new Intent(SCREENREADER_INTENT_ACTION);
screenReaderIntent.addCategory(SCREENREADER_INTENT_CATEGORY);
List<ResolveInfo> screenReaders = getPackageManager().queryIntentServices(
screenReaderIntent, 0);
ContentResolver cr = getContentResolver();
Cursor cursor = null;
int status = 0;
for (ResolveInfo screenReader : screenReaders)
{
// All screen readers are expected to implement a content provider
// that responds to
// content://<nameofpackage>.providers.StatusProvider
cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName
+ ".providers.StatusProvider"), null, null, null, null);
if (cursor != null)
{
cursor.moveToFirst();
// These content providers use a special cursor that only has
// one element,
// an integer that is 1 if the screen reader is running.
status = cursor.getInt(0);
cursor.close();
if (status == 1)
{
return true;
}
}
}
return false;
}
2009-10-22 11:54:49 -04:00
@Override
protected void onSaveInstanceState(Bundle outState)
{
outState.putSerializable(EXTRA_MESSAGE_REFERENCE, mMessageReference);
outState.putSerializable(EXTRA_MESSAGE_REFERENCES, mMessageReferences);
outState.putSerializable(STATE_PGP_DATA, mPgpData);
outState.putBoolean(SHOW_PICTURES, mShowPictures);
2010-07-27 08:10:09 -04:00
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
setLoadPictures(savedInstanceState.getBoolean(SHOW_PICTURES));
2010-12-28 04:11:35 -05:00
initializeCrypto((PgpData) savedInstanceState.getSerializable(STATE_PGP_DATA));
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
2009-10-22 11:54:49 -04:00
}
private void displayMessage(MessageReference ref)
{
mMessageReference = ref;
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "MessageView displaying message " + mMessageReference);
mAccount = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
mTopView.setVisibility(View.GONE);
mTopView.scrollTo(0, 0);
mMessageContentView.scrollTo(0, 0);
mHandler.hideHeaderContainer();
mMessageContentView.clearView();
setLoadPictures(false);
mAttachments.removeAllViews();
findSurroundingMessagesUid();
// start with fresh, empty PGP data
initializeCrypto(null);
mTopView.setVisibility(View.VISIBLE);
mController.loadMessageForView(
mAccount,
mMessageReference.folderName,
mMessageReference.uid,
mListener);
setupDisplayMessageButtons();
}
private void setupDisplayMessageButtons()
{
mDelete.setEnabled(true);
2010-12-25 22:49:09 -05:00
next.setEnabled(mNextMessage != null);
previous.setEnabled(mPreviousMessage != null);
// If moving isn't support at all, then all of them must be disabled anyway.
if (mController.isMoveCapable(mAccount))
{
// Only enable the button if the Archive folder is not the current folder and not NONE.
2010-12-25 22:49:09 -05:00
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
2010-12-25 22:49:23 -05:00
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName()));
// Only enable the button if the Spam folder is not the current folder and not NONE.
2010-12-25 22:49:09 -05:00
mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) &&
2010-12-25 22:49:23 -05:00
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()));
mMove.setEnabled(true);
}
2010-07-26 21:28:03 -04:00
else
2010-08-01 21:27:40 -04:00
{
2010-07-26 21:28:03 -04:00
disableMoveButtons();
}
}
private void staticButtons()
{
View buttons = findViewById(R.id.scrolling_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
next = findViewById(R.id.next);
previous = findViewById(R.id.previous);
mDelete = findViewById(R.id.delete);
}
private void scrollButtons()
{
View buttons = findViewById(R.id.bottom_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
next = findViewById(R.id.next_scrolling);
previous = findViewById(R.id.previous_scrolling);
mDelete = findViewById(R.id.delete_scrolling);
}
private void staticMoveButtons()
{
View buttons = findViewById(R.id.scrolling_move_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
mArchive = findViewById(R.id.archive);
mMove = findViewById(R.id.move);
mSpam = findViewById(R.id.spam);
}
private void scrollMoveButtons()
{
View buttons = findViewById(R.id.move_buttons);
if (buttons != null)
{
buttons.setVisibility(View.GONE);
}
mArchive = findViewById(R.id.archive_scrolling);
mMove = findViewById(R.id.move_scrolling);
mSpam = findViewById(R.id.spam_scrolling);
}
private void disableButtons()
{
setLoadPictures(false);
disableMoveButtons();
next.setEnabled(false);
previous.setEnabled(false);
mDelete.setEnabled(false);
}
private void disableMoveButtons()
{
2010-07-11 11:39:26 -04:00
mArchive.setEnabled(false);
mMove.setEnabled(false);
mSpam.setEnabled(false);
}
private void setOnClickListener(int viewCode)
{
View thisView = findViewById(viewCode);
if (thisView != null)
{
thisView.setOnClickListener(this);
}
Complete merge of DAmail functionality into K9mail. Following features are added to K9mail: 1) Show unread message count on each folder 2) Sum unread count of all shown folders in an account to the account display 3) Periodically check selected folders for new mail, not just Inbox 4) Don't refresh folder when opened (unless folder is empty) 5) Show date and time of last sync for each folder 6) Fix timer for automatic periodic sync (use wakelock to assure completion) 7) Optimize local folder queries (speeds up account and folder lists) 8) Show Loading... message in status bar indicating which folder is being synced 9) Eliminate redundant sync of new messages (performance enhancement) 10) Improve notification text for multiple accounts 11) Do not automatically sync folders more often than the account-specific period 12) Use user-configured date and time formats 13) Select which folders are shown, using configurable Classes 14) Select which folders are synced, using configurable Classes 15) Added context (long press) menu to folders, to provide for Refresh and Folder Settings 16) Status light flashes purple when there are unread messages 17) Folder list more quickly eliminates display of deleted and out-of-Class folders. 18) Delete works 19) Mark all messages as read (in the folder context menu) 20) Notifications only for new unread messages 21) One minute synchronization frequency 22) Deleting an unread message decrements unread counter 23) Notifications work for POP3 accounts 24) Message deletes work for POP3 accounts 25) Explicit errors show in folder list 26) Stack traces saved to folder K9mail-errors 27) Clear pending actions (danger, for emergencies only!) 28) Delete policy in Account settings 29) DNS cache in InetAddress disabled 30) Trapped some crash-causing error conditions 31) Eliminate duplicate copies to Sent folder 32) Prevent crashes due to message listener concurrency 33) Empty Trash 34) Nuclear "Mark all messages as read" (marks all messages as read in server-side folder, irrespective of which messages have been downloaded) 35) Forward (alternate) to allow forwarding email through other programs 36) Accept text/plain Intents to allow other programs to send email through K9mail 37) Displays Outbox sending status 38) Manual retry of outbox sending when "Refresh"ing Outbox 39) Folder error status is persisted 40) Ability to log to arbitrary file Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104, 107, 120, 148, 154
2008-12-30 22:49:09 -05:00
}
private void findSurroundingMessagesUid()
{
mNextMessage = mPreviousMessage = null;
int i = mMessageReferences.indexOf(mMessageReference);
if (i < 0)
return;
if (i != 0)
mNextMessage = mMessageReferences.get(i - 1);
if (i != (mMessageReferences.size() - 1))
mPreviousMessage = mMessageReferences.get(i + 1);
}
@Override
public void onResume()
{
super.onResume();
Merge branch 'mail-on-sd' * mail-on-sd: (40 commits) Added more comments to explain how the locking mecanism works for LocalStore Fixed wrong method being called during experimental provider initialization (since provider isn't enabled, that didn't harm) Add more comments about how the various StorageProviders work and how they're enabled find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs French localization for storage related settings Remove unused SD card strings (replaced with storage indirection) Merge mail-on-sd branch from trunk Reset mail service on storage mount (even if no account uses the storage, to be improved) find src/com/fsck/ -name \*.java|xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs Migraion -> Migration move the Storage location preference into preferences rather than the wizard. Made LocalStore log less verbose Added @Override compile checks Added ACTION_SHUTDOWN broadcast receiver to properly initiate shutdown sequence (not yet implemented) and cancel any scheduled Intent Be more consistent about which SQLiteDatabase variable is used (from instance variable to argument variable) to make code more refactoring-friendly (class is already big, code extraction should be easier if not referencing the instance variable). Added transaction timing logging Factorised storage lock/transaction handling code for regular operations. Use DB transactions to batch modifications (makes code more robust / could improve performances) Merge mail-on-sd branch from trunk Update issue 888 Added DB close on unmount / DB open on mount Update issue 888 Back to account list when underlying storage not available/unmounting in MessageView / MessageList ...
2010-11-13 16:40:56 -05:00
if (!mAccount.isAvailable(this))
{
onAccountUnavailable();
return;
}
StorageManager.getInstance(getApplication()).addListener(mStorageListener);
}
@Override
protected void onPause()
{
StorageManager.getInstance(getApplication()).removeListener(mStorageListener);
super.onPause();
}
protected void onAccountUnavailable()
{
finish();
// TODO inform user about account unavailability using Toast
Accounts.listAccounts(this);
}
2009-10-22 11:54:49 -04:00
/**
* Called from UI thread when user select Delete
*/
private void onDelete()
{
if (K9.confirmDelete())
{
showDialog(R.id.dialog_confirm_delete);
}
else
{
delete();
}
}
/**
* @param id
* @return Never <code>null</code>
*/
protected Dialog createConfirmDeleteDialog(final int id)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.dialog_confirm_delete_title);
builder.setMessage(R.string.dialog_confirm_delete_message);
builder.setPositiveButton(R.string.dialog_confirm_delete_confirm_button,
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dismissDialog(id);
delete();
}
});
builder.setNegativeButton(R.string.dialog_confirm_delete_cancel_button,
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dismissDialog(id);
}
});
2010-12-25 22:49:23 -05:00
return builder.create();
}
private void delete()
{
if (mMessage != null)
{
// Disable the delete button after it's tapped (to try to prevent
// accidental clicks)
disableButtons();
Message messageToDelete = mMessage;
showNextMessageOrReturn();
mController.deleteMessages(
2010-12-25 22:49:23 -05:00
new Message[] {messageToDelete},
null);
}
}
2010-12-25 22:49:20 -05:00
private void onRefile(String dstFolder)
{
if (!mController.isMoveCapable(mAccount))
{
return;
}
if (!mController.isMoveCapable(mMessage))
{
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
toast.show();
return;
}
String srcFolder = mMessageReference.folderName;
Message messageToMove = mMessage;
2010-07-05 14:06:30 -04:00
if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder))
{
return;
}
showNextMessageOrReturn();
mController
2010-12-25 22:49:23 -05:00
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
}
private void showNextMessageOrReturn()
{
if (K9.messageViewReturnToList())
{
finish();
}
else
{
showNextMessage();
}
}
private void showNextMessage()
{
findSurroundingMessagesUid();
mMessageReferences.remove(mMessageReference);
if (mLastDirection == NEXT && mNextMessage != null)
{
onNext();
}
else if (mLastDirection == PREVIOUS && mPreviousMessage != null)
{
onPrevious();
}
else if (mNextMessage != null)
{
onNext();
}
else if (mPreviousMessage != null)
{
onPrevious();
}
else
{
finish();
}
}
private void onClickSender()
{
if (mMessage != null)
{
try
{
final Address senderEmail = mMessage.getFrom()[0];
mContacts.createContact(this, senderEmail);
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Couldn't create contact", e);
}
}
}
private void onReply()
{
if (mMessage != null)
{
MessageCompose.actionReply(this, mAccount, mMessage, false, mPgpData.getDecryptedData());
finish();
}
}
private void onReplyAll()
{
if (mMessage != null)
{
MessageCompose.actionReply(this, mAccount, mMessage, true, mPgpData.getDecryptedData());
finish();
}
}
private void onForward()
{
if (mMessage != null)
{
MessageCompose.actionForward(this, mAccount, mMessage, mPgpData.getDecryptedData());
finish();
}
}
private void onFlag()
{
if (mMessage != null)
{
mController.setFlag(mAccount,
mMessage.getFolder().getName(), new String[] {mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
try
{
mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
mHandler.setHeaders( mMessage);
prepareMenuItems();
}
catch (MessagingException me)
{
Log.e(K9.LOG_TAG, "Could not set flag on local message", me);
}
}
}
private void onMove()
{
if ((!mController.isMoveCapable(mAccount))
|| (mMessage == null))
{
return;
}
if (!mController.isMoveCapable(mMessage))
{
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
toast.show();
return;
}
2010-12-25 22:49:13 -05:00
startRefileActivity(ACTIVITY_CHOOSE_FOLDER_MOVE);
}
private void onCopy()
{
if ((!mController.isCopyCapable(mAccount))
2011-01-06 11:55:08 -05:00
|| (mMessage == null))
{
return;
}
if (!mController.isCopyCapable(mMessage))
{
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
toast.show();
return;
}
2010-12-25 22:49:13 -05:00
startRefileActivity(ACTIVITY_CHOOSE_FOLDER_COPY);
}
private void startRefileActivity(int activity)
{
Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mMessageReference.folderName);
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, mAccount.getLastSelectedFolderName());
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, mMessageReference);
2010-12-25 22:49:13 -05:00
startActivityForResult(intent, activity);
}
private void onShowAdditionalHeaders()
{
int currentVisibility = mAdditionalHeadersView.getVisibility();
if (currentVisibility == View.VISIBLE)
{
mHandler.hideAdditionalHeaders();
}
else
{
mHandler.showAdditionalHeaders();
}
}
private List<HeaderEntry> getAdditionalHeaders(final Message message)
throws MessagingException
{
List<HeaderEntry> additionalHeaders = new LinkedList<HeaderEntry>();
/*
* Remove "Subject" header as it is already shown in the standard
* message view header. But do show "From", "To", and "Cc" again.
* This time including the email addresses. See issue 1805.
*/
Set<String> headerNames = new HashSet<String>(message.getHeaderNames());
headerNames.remove("Subject");
for (String headerName : headerNames)
{
String[] headerValues = message.getHeader(headerName);
for (String headerValue : headerValues)
{
additionalHeaders.add(new HeaderEntry(headerName, headerValue));
}
}
return additionalHeaders;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (mAccount.getCryptoProvider().onActivityResult(this, requestCode, resultCode, data, mPgpData))
2010-07-27 08:10:09 -04:00
{
return;
}
if (resultCode != RESULT_OK)
return;
switch (requestCode)
{
case ACTIVITY_CHOOSE_FOLDER_MOVE:
case ACTIVITY_CHOOSE_FOLDER_COPY:
if (data == null)
return;
String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
String srcFolderName = data.getStringExtra(ChooseFolder.EXTRA_CUR_FOLDER);
2010-12-25 22:49:16 -05:00
MessageReference ref = (MessageReference) data.getSerializableExtra(ChooseFolder.EXTRA_MESSAGE);
if (mMessageReference.equals(ref))
{
mAccount.setLastSelectedFolderName(destFolderName);
switch (requestCode)
{
case ACTIVITY_CHOOSE_FOLDER_MOVE:
Message messageToMove = mMessage;
showNextMessageOrReturn();
mController.moveMessage(mAccount,
srcFolderName, messageToMove, destFolderName, null);
break;
case ACTIVITY_CHOOSE_FOLDER_COPY:
mController.copyMessage(mAccount,
srcFolderName, mMessage, destFolderName, null);
break;
}
}
2010-07-27 08:10:09 -04:00
break;
}
}
private void onSendAlternate()
{
if (mMessage != null)
{
mController.sendAlternate(this, mAccount, mMessage);
}
}
@Override
protected void onNext()
{
if (mNextMessage == null)
{
Toast.makeText(this, getString(R.string.end_of_folder), Toast.LENGTH_SHORT).show();
return;
}
mLastDirection = NEXT;
disableButtons();
if (K9.showAnimations())
{
mTopView.startAnimation(outToLeftAnimation());
}
displayMessage(mNextMessage);
next.requestFocus();
}
@Override
protected void onPrevious()
{
if (mPreviousMessage == null)
{
Toast.makeText(this, getString(R.string.end_of_folder), Toast.LENGTH_SHORT).show();
return;
}
mLastDirection = PREVIOUS;
disableButtons();
if (K9.showAnimations())
{
mTopView.startAnimation(inFromRightAnimation());
}
displayMessage(mPreviousMessage);
previous.requestFocus();
}
private void onMarkAsUnread()
{
if (mMessage != null)
{
mController.setFlag(
mAccount,
mMessageReference.folderName,
new String[] { mMessage.getUid() },
Flag.SEEN,
false);
try
{
mMessage.setFlag(Flag.SEEN, false);
mHandler.setHeaders(mMessage);
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Unable to unset SEEN flag on message", e);
}
}
}
private void onDownloadRemainder()
2010-07-18 21:57:49 -04:00
{
if (mMessage.isSet(Flag.X_DOWNLOADED_FULL))
{
2010-07-18 21:57:49 -04:00
return;
}
mDownloadRemainder.setEnabled(false);
mController.loadMessageForViewRemote(
mAccount,
mMessageReference.folderName,
mMessageReference.uid,
mListener);
2010-07-18 21:57:49 -04:00
}
private void onShowPictures()
{
// TODO: Download attachments that are used as inline image
setLoadPictures(true);
}
/**
* Enable/disable image loading of the WebView. But always hide the
* "Show pictures" button!
*
* @param enable true, if (network) images should be loaded.
* false, otherwise.
*/
private void setLoadPictures(boolean enable)
{
mMessageContentView.blockNetworkData(!enable);
mShowPictures = enable;
mHandler.showShowPictures(false);
}
public void onClick(View view)
{
switch (view.getId())
{
case R.id.from:
onClickSender();
break;
case R.id.reply:
case R.id.reply_scrolling:
onReply();
break;
case R.id.reply_all:
onReplyAll();
break;
case R.id.delete:
case R.id.delete_scrolling:
onDelete();
break;
case R.id.forward:
case R.id.forward_scrolling:
onForward();
break;
case R.id.archive:
case R.id.archive_scrolling:
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getArchiveFolderName());
break;
case R.id.spam:
case R.id.spam_scrolling:
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getSpamFolderName());
break;
case R.id.move:
case R.id.move_scrolling:
onMove();
break;
case R.id.next:
case R.id.next_scrolling:
onNext();
break;
case R.id.previous:
case R.id.previous_scrolling:
onPrevious();
break;
case R.id.download:
((AttachmentView)view).saveFile();
break;
case R.id.show_pictures:
onShowPictures();
break;
case R.id.header_container:
onShowAdditionalHeaders();
break;
case R.id.download_remainder:
onDownloadRemainder();
break;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.delete:
onDelete();
break;
case R.id.reply:
onReply();
break;
case R.id.reply_all:
onReplyAll();
break;
case R.id.forward:
onForward();
break;
case R.id.send_alternate:
onSendAlternate();
break;
case R.id.mark_as_unread:
onMarkAsUnread();
break;
case R.id.flag:
onFlag();
break;
case R.id.archive:
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getArchiveFolderName());
break;
case R.id.spam:
2010-12-25 22:49:20 -05:00
onRefile(mAccount.getSpamFolderName());
break;
case R.id.move:
onMove();
break;
case R.id.copy:
onCopy();
break;
case R.id.show_full_header:
onShowAdditionalHeaders();
break;
case R.id.select_text:
mToggleScrollView.setScrolling(false);
mMessageContentView.emulateShiftHeld();
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
2009-11-16 14:27:57 -05:00
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.message_view_option, menu);
optionsMenu = menu;
prepareMenuItems();
if (!mController.isCopyCapable(mAccount))
{
menu.findItem(R.id.copy).setVisible(false);
}
if (!mController.isMoveCapable(mAccount))
{
menu.findItem(R.id.move).setVisible(false);
menu.findItem(R.id.archive).setVisible(false);
menu.findItem(R.id.spam).setVisible(false);
}
if (K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName()))
{
menu.findItem(R.id.archive).setVisible(false);
}
if (K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()))
{
menu.findItem(R.id.spam).setVisible(false);
}
return true;
}
2009-11-16 14:27:57 -05:00
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
prepareMenuItems();
2009-11-16 14:27:57 -05:00
return super.onPrepareOptionsMenu(menu);
}
2010-12-24 19:27:09 -05:00
// TODO: when switching to API version 8, override onCreateDialog(int, Bundle)
2010-12-25 22:49:23 -05:00
/**
2010-12-25 22:49:23 -05:00
* @param id The id of the dialog.
* @return The dialog. If you return null, the dialog will not be created.
2010-12-24 19:27:09 -05:00
* @see android.app.Activity#onCreateDialog(int)
*/
@Override
protected Dialog onCreateDialog(final int id)
{
switch (id)
{
case R.id.dialog_confirm_delete:
{
2010-11-30 22:00:36 -05:00
return createConfirmDeleteDialog(id);
}
}
return super.onCreateDialog(id);
}
private void prepareMenuItems()
{
Menu menu = optionsMenu;
if (menu != null)
{
MenuItem flagItem = menu.findItem(R.id.flag);
if (flagItem != null && mMessage != null)
{
flagItem.setTitle((mMessage.isSet(Flag.FLAGGED) ? R.string.unflag_action : R.string.flag_action));
}
MenuItem additionalHeadersItem = menu.findItem(R.id.show_full_header);
if (additionalHeadersItem != null)
{
additionalHeadersItem.setTitle((mAdditionalHeadersView.getVisibility() == View.VISIBLE) ?
R.string.hide_full_header_action : R.string.show_full_header_action);
}
}
}
private void renderAttachments(Part part, int depth) throws MessagingException
{
if (part.getBody() instanceof Multipart)
{
Multipart mp = (Multipart) part.getBody();
for (int i = 0; i < mp.getCount(); i++)
{
renderAttachments(mp.getBodyPart(i), depth + 1);
}
}
else if (part instanceof LocalAttachmentBodyPart)
{
String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition());
// Inline parts with a content-id are almost certainly components of an HTML message
// not attachments. Don't show attachment download buttons for them.
if (contentDisposition != null &&
MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)")
&& part.getHeader("Content-ID") != null)
{
return;
}
renderPartAsAttachment(part);
}
}
private void renderPartAsAttachment(Part part) throws MessagingException
{
LayoutInflater inflater = getLayoutInflater();
AttachmentView view = (AttachmentView)inflater.inflate(R.layout.message_view_attachment, null);
if (view.populateFromPart(part, mMessage, mAccount, mController, mListener))
{
mHandler.addAttachment((View)view);
}
return;
}
class Listener extends MessagingListener
{
@Override
public void loadMessageForViewHeadersAvailable(Account account, String folder, String uid,
final Message message)
{
if (!mMessageReference.uid.equals(uid) || !mMessageReference.folderName.equals(folder)
|| !mMessageReference.accountUuid.equals(account.getUuid()))
{
return;
}
MessageView.this.mMessage = message;
if (!message.isSet(Flag.X_DOWNLOADED_FULL)
&& !message.isSet(Flag.X_DOWNLOADED_PARTIAL))
{
mHandler.post(new Runnable()
{
public void run()
{
mMessageContentView.loadUrl("file:///android_asset/downloading.html");
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
}
});
}
try
{
mHandler.setHeaders(message);
}
catch (MessagingException me)
{
Log.e(K9.LOG_TAG, "loadMessageForViewHeadersAvailable", me);
}
}
@Override
public void loadMessageForViewBodyAvailable(Account account, String folder, String uid,
Message message)
{
if (!mMessageReference.uid.equals(uid) || !mMessageReference.folderName.equals(folder)
2011-01-06 11:55:08 -05:00
|| !mMessageReference.accountUuid.equals(account.getUuid()))
{
return;
}
try
{
2010-12-25 22:49:23 -05:00
if (MessageView.this.mMessage != null
2011-01-06 11:55:08 -05:00
&& MessageView.this.mMessage.isSet(Flag.X_DOWNLOADED_PARTIAL)
&& message.isSet(Flag.X_DOWNLOADED_FULL))
{
mHandler.setHeaders(message);
}
MessageView.this.mMessage = message;
mHandler.removeAllAttachments();
String text, type;
if (mPgpData.getDecryptedData() != null)
2010-07-27 08:10:09 -04:00
{
text = mPgpData.getDecryptedData();
2010-07-27 08:10:09 -04:00
type = "text/plain";
}
else
{
// getTextForDisplay() always returns HTML-ified content.
text = ((LocalMessage)mMessage).getTextForDisplay();
type = "text/html";
}
if (text != null)
{
final String emailText = text;
final String contentType = type;
mHandler.post(new Runnable()
{
public void run()
{
mTopView.scrollTo(0, 0);
if (mScreenReaderEnabled)
{
mAccessibleMessageContentView.loadDataWithBaseURL("http://",
emailText, contentType, "utf-8", null);
}
else
{
mMessageContentView.loadDataWithBaseURL("http://", emailText,
contentType, "utf-8", null);
mMessageContentView.scrollTo(0, 0);
}
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
}
});
// If the message contains external pictures and the "Show pictures"
// button wasn't already pressed, see if the user's preferences has us
// showing them anyway.
if (Utility.hasExternalImages(text) && !mShowPictures)
{
if ((account.getShowPictures() == Account.ShowPictures.ALWAYS) ||
((account.getShowPictures() == Account.ShowPictures.ONLY_FROM_CONTACTS) &&
2010-08-17 22:48:55 -04:00
mContacts.isInContacts(message.getFrom()[0].getAddress())))
{
onShowPictures();
}
else
{
mHandler.showShowPictures(true);
}
}
}
else
{
mHandler.post(new Runnable()
{
public void run()
{
mMessageContentView.loadUrl("file:///android_asset/empty.html");
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
}
});
}
renderAttachments(mMessage, 0);
}
catch (Exception e)
{
if (Config.LOGV)
{
Log.v(K9.LOG_TAG, "loadMessageForViewBodyAvailable", e);
}
}
}//loadMessageForViewBodyAvailable
@Override
public void loadMessageForViewFailed(Account account, String folder, String uid,
final Throwable t)
{
if (!mMessageReference.uid.equals(uid) || !mMessageReference.folderName.equals(folder)
|| !mMessageReference.accountUuid.equals(account.getUuid()))
{
return;
}
mHandler.post(new Runnable()
{
public void run()
{
setProgressBarIndeterminateVisibility(false);
if (t instanceof IllegalArgumentException)
{
mHandler.invalidIdError();
}
else
{
mHandler.networkError();
}
2010-07-10 12:41:48 -04:00
if ((MessageView.this.mMessage == null) ||
!MessageView.this.mMessage.isSet(Flag.X_DOWNLOADED_PARTIAL))
{
mMessageContentView.loadUrl("file:///android_asset/empty.html");
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
}
}
});
}
@Override
public void loadMessageForViewFinished(Account account, String folder, String uid,
Message message)
{
if (!mMessageReference.uid.equals(uid) || !mMessageReference.folderName.equals(folder)
|| !mMessageReference.accountUuid.equals(account.getUuid()))
{
return;
}
mHandler.post(new Runnable()
{
public void run()
{
setProgressBarIndeterminateVisibility(false);
}
});
}
@Override
public void loadMessageForViewStarted(Account account, String folder, String uid)
{
if (!mMessageReference.uid.equals(uid) || !mMessageReference.folderName.equals(folder)
|| !mMessageReference.accountUuid.equals(account.getUuid()))
{
return;
}
mHandler.post(new Runnable()
{
public void run()
{
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
setProgressBarIndeterminateVisibility(true);
}
});
}
@Override
public void loadAttachmentStarted(Account account, Message message,
Part part, Object tag, boolean requiresDownload)
{
2010-12-25 22:49:23 -05:00
if (mMessage != message)
{
return;
}
mHandler.setAttachmentsEnabled(false);
mHandler.progress(true);
if (requiresDownload)
{
mHandler.fetchingAttachment();
}
}
@Override
public void loadAttachmentFinished(Account account, Message message,
Part part, Object tag)
{
2010-12-25 22:49:23 -05:00
if (mMessage != message)
{
return;
}
mHandler.setAttachmentsEnabled(true);
mHandler.progress(false);
Object[] params = (Object[]) tag;
boolean download = (Boolean) params[0];
AttachmentView attachment = (AttachmentView) params[1];
if (download)
{
attachment.writeFile();
}
else
{
attachment.showFile();
}
}
@Override
public void loadAttachmentFailed(Account account, Message message, Part part,
Object tag, String reason)
{
2010-12-25 22:49:23 -05:00
if (mMessage != message)
{
return;
}
mHandler.setAttachmentsEnabled(true);
mHandler.progress(false);
mHandler.networkError();
}
}
private void initializeCrypto(PgpData data)
2010-07-27 08:10:09 -04:00
{
if (data == null)
2010-07-27 08:10:09 -04:00
{
if (mAccount == null)
{
mAccount = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
}
mPgpData = new PgpData();
2010-07-27 08:10:09 -04:00
}
else
2010-07-27 08:10:09 -04:00
{
mPgpData = data;
2010-07-27 08:10:09 -04:00
}
}
/**
2010-07-27 08:10:09 -04:00
* Fill the decrypt layout with signature data, if known, make controls visible, if
* they should be visible.
*/
public void updateDecryptLayout()
{
if (mPgpData.getSignatureKeyId() != 0)
2010-07-27 08:10:09 -04:00
{
mCryptoSignatureUserIdRest.setText(
getString(R.string.key_id, Long.toHexString(mPgpData.getSignatureKeyId() & 0xffffffffL)));
String userId = mPgpData.getSignatureUserId();
2010-07-27 08:10:09 -04:00
if (userId == null)
{
userId = getString(R.string.unknown_crypto_signature_user_id);
}
String chunks[] = userId.split(" <", 2);
String name = chunks[0];
if (chunks.length > 1)
{
mCryptoSignatureUserIdRest.setText("<" + chunks[1]);
}
mCryptoSignatureUserId.setText(name);
if (mPgpData.getSignatureSuccess())
2010-07-27 08:10:09 -04:00
{
mCryptoSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
}
else if (mPgpData.getSignatureUnknown())
2010-07-27 08:10:09 -04:00
{
mCryptoSignatureStatusImage.setImageResource(R.drawable.overlay_error);
}
else
{
mCryptoSignatureStatusImage.setImageResource(R.drawable.overlay_error);
}
mCryptoSignatureLayout.setVisibility(View.VISIBLE);
mDecryptLayout.setVisibility(View.VISIBLE);
2010-08-17 22:48:55 -04:00
}
else
{
mCryptoSignatureLayout.setVisibility(View.INVISIBLE);
2010-07-27 08:10:09 -04:00
}
if (false || ((mMessage == null) && (mPgpData.getDecryptedData() == null)))
2010-07-27 08:10:09 -04:00
{
mDecryptLayout.setVisibility(View.GONE);
return;
}
if (mPgpData.getDecryptedData() != null)
2010-07-27 08:10:09 -04:00
{
if (mPgpData.getSignatureKeyId() == 0)
2010-07-27 08:10:09 -04:00
{
mDecryptLayout.setVisibility(View.GONE);
}
else
{
// no need to show this after decryption/verification
mDecryptButton.setVisibility(View.GONE);
}
return;
}
mDecryptButton.setVisibility(View.VISIBLE);
CryptoProvider crypto = mAccount.getCryptoProvider();
if (crypto.isEncrypted(mMessage))
2010-07-27 08:10:09 -04:00
{
mDecryptButton.setText(R.string.btn_decrypt);
mDecryptLayout.setVisibility(View.VISIBLE);
}
else if (crypto.isSigned(mMessage))
2010-07-27 08:10:09 -04:00
{
mDecryptButton.setText(R.string.btn_verify);
mDecryptLayout.setVisibility(View.VISIBLE);
}
else
{
mDecryptLayout.setVisibility(View.GONE);
try
{
// check for PGP/MIME encryption
Part pgp = MimeUtility.findFirstPartByMimeType(mMessage, "application/pgp-encrypted");
if (pgp != null)
{
Toast.makeText(this, R.string.pgp_mime_unsupported, Toast.LENGTH_LONG).show();
}
}
catch (MessagingException e)
{
// nothing to do...
}
}
}
public void onDecryptDone()
{
// TODO: this might not be enough if the orientation was changed while in APG,
// sometimes shows the original encrypted content
mMessageContentView.loadDataWithBaseURL("email://", mPgpData.getDecryptedData(), "text/plain", "utf-8", null);
2010-07-27 08:10:09 -04:00
updateDecryptLayout();
}
}