From 203dcfe2c3d63f0e6ff79c2c5566115c2571a35c Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Sat, 4 Oct 2014 11:45:45 +0100 Subject: [PATCH] use interfaces, not implementions --- src/com/fsck/k9/Account.java | 2 +- src/com/fsck/k9/K9.java | 3 +- .../AccessibleEmailContentActivity.java | 6 +- src/com/fsck/k9/activity/Accounts.java | 8 +- src/com/fsck/k9/activity/FolderList.java | 6 +- .../fsck/k9/activity/FolderListFilter.java | 8 +- src/com/fsck/k9/activity/MessageCompose.java | 10 +- .../NotificationDeleteConfirmation.java | 8 +- .../k9/controller/MessagingController.java | 36 +++---- .../fsck/k9/fragment/MessageListFragment.java | 4 +- src/com/fsck/k9/helper/Contacts.java | 3 +- src/com/fsck/k9/helper/Utility.java | 22 +++++ src/com/fsck/k9/mail/Address.java | 2 +- src/com/fsck/k9/mail/Multipart.java | 2 +- src/com/fsck/k9/mail/Store.java | 8 +- src/com/fsck/k9/mail/internet/MimeHeader.java | 6 +- src/com/fsck/k9/mail/store/ImapStore.java | 20 ++-- src/com/fsck/k9/mail/store/Pop3Store.java | 16 ++-- src/com/fsck/k9/mail/store/WebDavStore.java | 94 +++++++++---------- .../fsck/k9/mail/store/imap/ImapUtility.java | 4 +- .../fsck/k9/mail/store/local/LocalFolder.java | 2 +- .../k9/mail/store/local/LocalMessage.java | 3 +- .../fsck/k9/mail/store/local/LocalStore.java | 10 +- .../fsck/k9/mail/transport/SmtpTransport.java | 22 ++--- src/com/fsck/k9/preferences/Editor.java | 5 +- src/com/fsck/k9/preferences/Storage.java | 24 +++-- .../fsck/k9/search/ConditionsTreeNode.java | 2 +- src/com/fsck/k9/search/LocalSearch.java | 2 +- .../k9/service/NotificationActionService.java | 20 ++-- src/com/fsck/k9/service/PollService.java | 3 +- .../fsck/k9/view/NonLockingScrollView.java | 5 +- 31 files changed, 205 insertions(+), 161 deletions(-) diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index 323d53762..faf9d1e7c 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -181,7 +181,7 @@ public class Account implements BaseAccount { private boolean mPushPollOnConnect; private boolean mNotifySync; private SortType mSortType; - private HashMap mSortAscending = new HashMap(); + private Map mSortAscending = new HashMap(); private ShowPictures mShowPictures; private boolean mIsSignatureBeforeQuotedText; private String mExpungePolicy = EXPUNGE_IMMEDIATELY; diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index 9eead455a..6b5d83d56 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -5,6 +5,7 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.SynchronousQueue; @@ -263,7 +264,7 @@ public class K9 extends Application { private static boolean mHideTimeZone = false; private static SortType mSortType; - private static HashMap mSortAscending = new HashMap(); + private static Map mSortAscending = new HashMap(); private static boolean sUseBackgroundAsUnreadIndicator = true; private static boolean sThreadedViewEnabled = true; diff --git a/src/com/fsck/k9/activity/AccessibleEmailContentActivity.java b/src/com/fsck/k9/activity/AccessibleEmailContentActivity.java index 4b62641e4..b81c0cb09 100644 --- a/src/com/fsck/k9/activity/AccessibleEmailContentActivity.java +++ b/src/com/fsck/k9/activity/AccessibleEmailContentActivity.java @@ -17,6 +17,8 @@ package com.fsck.k9.activity; import java.util.ArrayList; +import java.util.List; + import android.app.ListActivity; import android.os.Bundle; import android.text.Html; @@ -40,7 +42,7 @@ public class AccessibleEmailContentActivity extends ListActivity { Spanned parsedHtml = Html.fromHtml(htmlSource, null, null); String[] rawListItems = parsedHtml.toString().split("\n"); - ArrayList cleanedList = new ArrayList(); + List cleanedList = new ArrayList(); for (String rawListItem : rawListItems) { if (rawListItem.trim().length() > 0) { addToCleanedList(cleanedList, rawListItem); @@ -53,7 +55,7 @@ public class AccessibleEmailContentActivity extends ListActivity { setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, listItems)); } - private void addToCleanedList(ArrayList cleanedList, String line) { + private void addToCleanedList(List cleanedList, String line) { if (line.length() < 80) { cleanedList.add(line); } else { diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 76cfe3abb..0b9a76f06 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import android.app.ActionBar; import android.app.Activity; @@ -75,6 +76,7 @@ import com.fsck.k9.activity.setup.Prefs; import com.fsck.k9.activity.setup.WelcomeMessage; import com.fsck.k9.controller.MessagingController; import com.fsck.k9.helper.SizeFormatter; +import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.ServerSettings; import com.fsck.k9.mail.Store; @@ -120,9 +122,9 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { private static final int DIALOG_RECREATE_ACCOUNT = 3; private static final int DIALOG_NO_FILE_MANAGER = 4; - private ConcurrentHashMap accountStats = new ConcurrentHashMap(); + private ConcurrentMap accountStats = new ConcurrentHashMap(); - private ConcurrentHashMap pendingWork = new ConcurrentHashMap(); + private ConcurrentMap pendingWork = new ConcurrentHashMap(); private BaseAccount mSelectedContextAccount; private int mUnreadMessageCount = 0; @@ -495,7 +497,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { outState.putString(SELECTED_CONTEXT_ACCOUNT, mSelectedContextAccount.getUuid()); } outState.putSerializable(STATE_UNREAD_COUNT, mUnreadMessageCount); - outState.putSerializable(ACCOUNT_STATS, accountStats); + outState.putSerializable(ACCOUNT_STATS, Utility.toSerializableConcurrentMap(accountStats)); } private StorageManager.StorageListener storageListener = new StorageManager.StorageListener() { diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index bd5be538b..217658b33 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -660,7 +660,7 @@ public class FolderList extends K9ListActivity { } class FolderListAdapter extends BaseAdapter implements Filterable { - private ArrayList mFolders = new ArrayList(); + private List mFolders = new ArrayList(); private List mFilteredFolders = Collections.unmodifiableList(mFolders); private Filter mFilter = new FolderListFilter(); @@ -1176,7 +1176,7 @@ public class FolderList extends K9ListActivity { Locale locale = Locale.getDefault(); if ((searchTerm == null) || (searchTerm.length() == 0)) { - ArrayList list = new ArrayList(mFolders); + List list = new ArrayList(mFolders); results.values = list; results.count = list.size(); } else { @@ -1184,7 +1184,7 @@ public class FolderList extends K9ListActivity { final String[] words = searchTermString.split(" "); final int wordCount = words.length; - final ArrayList newValues = new ArrayList(); + final List newValues = new ArrayList(); for (final FolderInfoHolder value : mFolders) { if (value.displayName == null) { diff --git a/src/com/fsck/k9/activity/FolderListFilter.java b/src/com/fsck/k9/activity/FolderListFilter.java index 30a012600..ec01589c3 100644 --- a/src/com/fsck/k9/activity/FolderListFilter.java +++ b/src/com/fsck/k9/activity/FolderListFilter.java @@ -29,7 +29,7 @@ public class FolderListFilter extends Filter { /** * All folders. */ - private ArrayList mOriginalValues = null; + private List mOriginalValues = null; /** * Create a filter for a list of folders. @@ -62,7 +62,7 @@ public class FolderListFilter extends Filter { Locale locale = Locale.getDefault(); if ((searchTerm == null) || (searchTerm.length() == 0)) { - ArrayList list = new ArrayList(mOriginalValues); + List list = new ArrayList(mOriginalValues); results.values = list; results.count = list.size(); } else { @@ -70,9 +70,9 @@ public class FolderListFilter extends Filter { final String[] words = searchTermString.split(" "); final int wordCount = words.length; - final ArrayList values = mOriginalValues; + final List values = mOriginalValues; - final ArrayList newValues = new ArrayList(); + final List newValues = new ArrayList(); for (final T value : values) { final String valueText = value.toString().toLowerCase(locale); diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index 05170db2e..4a0ab4cfa 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -1013,7 +1013,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, addAttachment(stream, type); } } else { - ArrayList list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); + List list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Parcelable parcelable : list) { Uri stream = (Uri) parcelable; @@ -1155,7 +1155,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - ArrayList attachments = new ArrayList(); + List attachments = new ArrayList(); for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { View view = mAttachments.getChildAt(i); Attachment attachment = (Attachment) view.getTag(); @@ -1164,7 +1164,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, outState.putInt(STATE_KEY_NUM_ATTACHMENTS_LOADING, mNumAttachmentsLoading); outState.putString(STATE_KEY_WAITING_FOR_ATTACHMENTS, mWaitingForAttachments.name()); - outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, attachments); + outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, Utility.toArrayList(attachments)); outState.putBoolean(STATE_KEY_CC_SHOWN, mCcWrapper.getVisibility() == View.VISIBLE); outState.putBoolean(STATE_KEY_BCC_SHOWN, mBccWrapper.getVisibility() == View.VISIBLE); outState.putSerializable(STATE_KEY_QUOTED_TEXT_MODE, mQuotedTextMode); @@ -1199,7 +1199,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, "\" from saved instance state", e); } - ArrayList attachments = savedInstanceState.getParcelableArrayList(STATE_KEY_ATTACHMENTS); + List attachments = savedInstanceState.getParcelableArrayList(STATE_KEY_ATTACHMENTS); for (Attachment attachment : attachments) { addAttachmentView(attachment); if (attachment.loaderId > mMaxLoaderId) { @@ -1808,7 +1808,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, String[] emailsArray = null; if (mEncryptCheckbox.isChecked()) { // get emails as array - ArrayList emails = new ArrayList(); + List emails = new ArrayList(); for (Address address : getRecipientAddresses()) { emails.add(address.getAddress()); diff --git a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java index a740768c6..9a070ed39 100644 --- a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java +++ b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java @@ -1,6 +1,7 @@ package com.fsck.k9.activity; import java.util.ArrayList; +import java.util.List; import android.app.Activity; import android.app.AlertDialog; @@ -14,6 +15,7 @@ import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.R; +import com.fsck.k9.helper.Utility; import com.fsck.k9.service.NotificationActionService; public class NotificationDeleteConfirmation extends Activity { @@ -23,12 +25,12 @@ public class NotificationDeleteConfirmation extends Activity { private final static int DIALOG_CONFIRM = 1; private Account mAccount; - private ArrayList mMessageRefs; + private List mMessageRefs; - public static PendingIntent getIntent(Context context, final Account account, final ArrayList refs) { + public static PendingIntent getIntent(Context context, final Account account, final List refs) { Intent i = new Intent(context, NotificationDeleteConfirmation.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, refs); + i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); return PendingIntent.getActivity(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index d71c06997..49ecfea36 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -299,8 +299,8 @@ public class MessagingController implements Runnable { * * @return Message reference list */ - public ArrayList getAllMessageRefs() { - ArrayList refs = new ArrayList(); + public List getAllMessageRefs() { + List refs = new ArrayList(); for (Message m : messages) { refs.add(m.makeMessageReference()); } @@ -993,7 +993,7 @@ public class MessagingController implements Runnable { localFolder.open(Folder.OPEN_MODE_RW); localFolder.updateLastUid(); Message[] localMessages = localFolder.getMessages(null); - HashMap localUidMap = new HashMap(); + Map localUidMap = new HashMap(); for (Message message : localMessages) { localUidMap.put(message.getUid(), message); } @@ -1059,8 +1059,8 @@ public class MessagingController implements Runnable { } Message[] remoteMessageArray = EMPTY_MESSAGE_ARRAY; - final ArrayList remoteMessages = new ArrayList(); - HashMap remoteUidMap = new HashMap(); + final List remoteMessages = new ArrayList(); + Map remoteUidMap = new HashMap(); if (K9.DEBUG) Log.v(K9.LOG_TAG, "SYNC: Remote message count for folder " + folder + " is " + remoteMessageCount); @@ -1117,7 +1117,7 @@ public class MessagingController implements Runnable { * Remove any messages that are in the local store but no longer on the remote store or are too old */ if (account.syncRemoteDeletions()) { - ArrayList destroyMessages = new ArrayList(); + List destroyMessages = new ArrayList(); for (Message localMessage : localMessages) { if (remoteUidMap.get(localMessage.getUid()) == null) { destroyMessages.add(localMessage); @@ -1280,7 +1280,7 @@ public class MessagingController implements Runnable { Log.e(K9.LOG_TAG, "Unable to getUnreadMessageCount for account: " + account, e); } - ArrayList syncFlagMessages = new ArrayList(); + List syncFlagMessages = new ArrayList(); List unsyncedMessages = new ArrayList(); final AtomicInteger newMessages = new AtomicInteger(0); @@ -1300,8 +1300,8 @@ public class MessagingController implements Runnable { Log.d(K9.LOG_TAG, "SYNC: Have " + unsyncedMessages.size() + " unsynced messages"); messages.clear(); - final ArrayList largeMessages = new ArrayList(); - final ArrayList smallMessages = new ArrayList(); + final List largeMessages = new ArrayList(); + final List smallMessages = new ArrayList(); if (!unsyncedMessages.isEmpty()) { /* @@ -1416,7 +1416,7 @@ public class MessagingController implements Runnable { final Folder remoteFolder, final Account account, final List unsyncedMessages, - final ArrayList syncFlagMessages, + final List syncFlagMessages, boolean flagSyncOnly) throws MessagingException { if (message.isSet(Flag.DELETED)) { syncFlagMessages.add(message); @@ -1475,8 +1475,8 @@ public class MessagingController implements Runnable { private void fetchUnsyncedMessages(final Account account, final Folder remoteFolder, final LocalFolder localFolder, List unsyncedMessages, - final ArrayList smallMessages, - final ArrayList largeMessages, + final List smallMessages, + final List largeMessages, final AtomicInteger progress, final int todo, FetchProfile fp) throws MessagingException { @@ -1611,7 +1611,7 @@ public class MessagingController implements Runnable { private void downloadSmallMessages(final Account account, final Folder remoteFolder, final LocalFolder localFolder, - ArrayList smallMessages, + List smallMessages, final AtomicInteger progress, final int unreadBeforeStart, final AtomicInteger newMessages, @@ -1690,7 +1690,7 @@ public class MessagingController implements Runnable { private void downloadLargeMessages(final Account account, final Folder remoteFolder, final LocalFolder localFolder, - ArrayList largeMessages, + List largeMessages, final AtomicInteger progress, final int unreadBeforeStart, final AtomicInteger newMessages, @@ -1815,7 +1815,7 @@ public class MessagingController implements Runnable { private void refreshLocalMessageFlags(final Account account, final Folder remoteFolder, final LocalFolder localFolder, - ArrayList syncFlagMessages, + List syncFlagMessages, final AtomicInteger progress, final int todo ) throws MessagingException { @@ -1952,7 +1952,7 @@ public class MessagingController implements Runnable { private void processPendingCommandsSynchronous(Account account) throws MessagingException { LocalStore localStore = account.getLocalStore(); - ArrayList commands = localStore.getPendingCommands(); + List commands = localStore.getPendingCommands(); int progress = 0; int todo = commands.size(); @@ -4863,7 +4863,7 @@ public class MessagingController implements Runnable { String accountDescr = (account.getDescription() != null) ? account.getDescription() : account.getEmail(); - final ArrayList allRefs = data.getAllMessageRefs(); + final List allRefs = data.getAllMessageRefs(); if (platformSupportsExtendedNotifications() && !privacyModeEnabled) { if (newMessages > 1) { @@ -5424,7 +5424,7 @@ public class MessagingController implements Runnable { return taccount.getDescription() + ":" + tfolderName; } static class MemorizingListener extends MessagingListener { - HashMap memories = new HashMap(31); + Map memories = new HashMap(31); Memory getMemory(Account account, String folderName) { Memory memory = memories.get(getMemoryKey(account, folderName)); diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index e72da130d..b73bfa495 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -2995,8 +2995,8 @@ public class MessageListFragment extends Fragment implements OnItemClickListener super.onStop(); } - public ArrayList getMessageReferences() { - ArrayList messageRefs = new ArrayList(); + public List getMessageReferences() { + List messageRefs = new ArrayList(); for (int i = 0, len = mAdapter.getCount(); i < len; i++) { Cursor cursor = (Cursor) mAdapter.getItem(i); diff --git a/src/com/fsck/k9/helper/Contacts.java b/src/com/fsck/k9/helper/Contacts.java index 56866c21c..75c084aba 100644 --- a/src/com/fsck/k9/helper/Contacts.java +++ b/src/com/fsck/k9/helper/Contacts.java @@ -13,6 +13,7 @@ import com.fsck.k9.K9; import com.fsck.k9.mail.Address; import java.util.ArrayList; +import java.util.List; /** * Helper class to access the contacts stored on the device. @@ -276,7 +277,7 @@ public class Contacts { */ public ContactItem extractInfoFromContactPickerIntent(final Intent intent) { Cursor cursor = null; - ArrayList email = new ArrayList(); + List email = new ArrayList(); try { Uri result = intent.getData(); diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java index ae8d9bb71..c450ad448 100644 --- a/src/com/fsck/k9/helper/Utility.java +++ b/src/com/fsck/k9/helper/Utility.java @@ -20,10 +20,13 @@ import com.fsck.k9.mail.filter.Base64; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.Serializable; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -704,4 +707,23 @@ public class Utility { } return sMainThreadHandler; } + + public static Serializable toSerializableList(List list) { + return list instanceof Serializable ? + (Serializable) list : + new ArrayList(list); + } + + public static ArrayList toArrayList(List list) { + return list instanceof ArrayList ? + (ArrayList) list : + new ArrayList(list); + } + + + public static Serializable toSerializableConcurrentMap(ConcurrentMap list) { + return list instanceof ConcurrentHashMap ? + (ConcurrentHashMap) list : + new ConcurrentHashMap(list); + } } diff --git a/src/com/fsck/k9/mail/Address.java b/src/com/fsck/k9/mail/Address.java index b5bdcc854..ef79b3790 100644 --- a/src/com/fsck/k9/mail/Address.java +++ b/src/com/fsck/k9/mail/Address.java @@ -315,7 +315,7 @@ public class Address { if (addressList == null) { return new Address[] { }; } - ArrayList
addresses = new ArrayList
(); + List
addresses = new ArrayList
(); int length = addressList.length(); int pairStartIndex = 0; int pairEndIndex = 0; diff --git a/src/com/fsck/k9/mail/Multipart.java b/src/com/fsck/k9/mail/Multipart.java index 88651485a..567b0902d 100644 --- a/src/com/fsck/k9/mail/Multipart.java +++ b/src/com/fsck/k9/mail/Multipart.java @@ -13,7 +13,7 @@ import com.fsck.k9.mail.internet.TextBody; public abstract class Multipart implements CompositeBody { private Part mParent; - private final ArrayList mParts = new ArrayList(); + private final List mParts = new ArrayList(); private String mContentType; diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java index 659b81161..5be7d7011 100644 --- a/src/com/fsck/k9/mail/Store.java +++ b/src/com/fsck/k9/mail/Store.java @@ -3,7 +3,9 @@ package com.fsck.k9.mail; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import android.app.Application; import android.content.Context; @@ -33,19 +35,19 @@ public abstract class Store { /** * Remote stores indexed by Uri. */ - private static HashMap sStores = new HashMap(); + private static Map sStores = new HashMap(); /** * Local stores indexed by UUID because the Uri may change due to migration to/from SD-card. */ - private static ConcurrentHashMap sLocalStores = new ConcurrentHashMap(); + private static ConcurrentMap sLocalStores = new ConcurrentHashMap(); /** * Lock objects indexed by account UUID. * * @see #getLocalInstance(Account, Application) */ - private static ConcurrentHashMap sAccountLocks = new ConcurrentHashMap(); + private static ConcurrentMap sAccountLocks = new ConcurrentHashMap(); /** * Get an instance of a remote mail store. diff --git a/src/com/fsck/k9/mail/internet/MimeHeader.java b/src/com/fsck/k9/mail/internet/MimeHeader.java index dd6445755..12bd5fd31 100644 --- a/src/com/fsck/k9/mail/internet/MimeHeader.java +++ b/src/com/fsck/k9/mail/internet/MimeHeader.java @@ -36,7 +36,7 @@ public class MimeHeader { HEADER_ANDROID_ATTACHMENT_STORE_DATA }; - private ArrayList mFields = new ArrayList(); + private List mFields = new ArrayList(); private String mCharset = null; public void clear() { @@ -72,7 +72,7 @@ public class MimeHeader { } public String[] getHeader(String name) { - ArrayList values = new ArrayList(); + List values = new ArrayList(); for (Field field : mFields) { if (field.name.equalsIgnoreCase(name)) { values.add(field.value); @@ -85,7 +85,7 @@ public class MimeHeader { } public void removeHeader(String name) { - ArrayList removeFields = new ArrayList(); + List removeFields = new ArrayList(); for (Field field : mFields) { if (field.name.equalsIgnoreCase(name)) { removeFields.add(field); diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index f66215e0b..1987e0b5a 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -1356,9 +1356,9 @@ public class ImapStore extends Store { private List search(ImapSearcher searcher, MessageRetrievalListener listener) throws MessagingException { checkOpen(); //only need READ access - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); try { - ArrayList uids = new ArrayList(); + List uids = new ArrayList(); List responses = searcher.search(); // for (ImapResponse response : responses) { if (response.mTag == null) { @@ -1403,11 +1403,11 @@ public class ImapStore extends Store { public Message[] getMessages(String[] uids, MessageRetrievalListener listener) throws MessagingException { checkOpen(); //only need READ access - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); try { if (uids == null) { List responses = executeSimpleCommand("UID SEARCH 1:* NOT DELETED"); - ArrayList tempUids = new ArrayList(); + List tempUids = new ArrayList(); for (ImapResponse response : responses) { if (ImapResponseParser.equalsIgnoreCase(response.get(0), "SEARCH")) { for (int i = 1, count = response.size(); i < count; i++) { @@ -1441,7 +1441,7 @@ public class ImapStore extends Store { } checkOpen(); //only need READ access List uids = new ArrayList(messages.length); - HashMap messageMap = new HashMap(); + Map messageMap = new HashMap(); for (Message msg : messages) { String uid = msg.getUid(); uids.add(uid); @@ -2089,7 +2089,7 @@ public class ImapStore extends Store { } private String combineFlags(Flag[] flags) { - ArrayList flagNames = new ArrayList(); + List flagNames = new ArrayList(); for (Flag flag : flags) { if (flag == Flag.SEEN) { flagNames.add("\\Seen"); @@ -2733,10 +2733,10 @@ public class ImapStore extends Store { return response; } - protected ArrayList readStatusResponse(String tag, + protected List readStatusResponse(String tag, String commandToLog, UntaggedHandler untaggedHandler) throws IOException, MessagingException { - ArrayList responses = new ArrayList(); + List responses = new ArrayList(); ImapResponse response; do { response = mParser.readResponse(); @@ -3552,9 +3552,9 @@ public class ImapStore extends Store { } private static class FetchBodyCallback implements ImapResponseParser.IImapResponseCallback { - private HashMap mMessageMap; + private Map mMessageMap; - FetchBodyCallback(HashMap mesageMap) { + FetchBodyCallback(Map mesageMap) { mMessageMap = mesageMap; } diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index fa2c7049c..414b334b2 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -196,7 +196,7 @@ public class Pop3Store extends Store { private String mClientCertificateAlias; private AuthType mAuthType; private ConnectionSecurity mConnectionSecurity; - private HashMap mFolders = new HashMap(); + private Map mFolders = new HashMap(); private Pop3Capabilities mCapabilities; /** @@ -274,9 +274,9 @@ public class Pop3Store extends Store { private Socket mSocket; private InputStream mIn; private OutputStream mOut; - private HashMap mUidToMsgMap = new HashMap(); - private HashMap mMsgNumToMsgMap = new HashMap(); - private HashMap mUidToMsgNumMap = new HashMap(); + private Map mUidToMsgMap = new HashMap(); + private Map mMsgNumToMsgMap = new HashMap(); + private Map mUidToMsgNumMap = new HashMap(); private String mName; private int mMessageCount; @@ -577,7 +577,7 @@ public class Pop3Store extends Store { } catch (IOException ioe) { throw new MessagingException("getMessages", ioe); } - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); int i = 0; for (int msgNum = start; msgNum <= end; msgNum++) { Pop3Message message = mMsgNumToMsgMap.get(msgNum); @@ -686,7 +686,7 @@ public class Pop3Store extends Store { } } - private void indexUids(ArrayList uids) + private void indexUids(List uids) throws MessagingException, IOException { Set unindexedUids = new HashSet(); for (String uid : uids) { @@ -764,7 +764,7 @@ public class Pop3Store extends Store { if (messages == null || messages.length == 0) { return; } - ArrayList uids = new ArrayList(); + List uids = new ArrayList(); for (Message message : messages) { uids.add(message.getUid()); } @@ -988,7 +988,7 @@ public class Pop3Store extends Store { */ return; } - ArrayList uids = new ArrayList(); + List uids = new ArrayList(); try { for (Message message : messages) { uids.add(message.getUid()); diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 1148927bb..650be8812 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -293,7 +293,7 @@ public class WebDavStore extends Store { private String mCachedLoginUrl; private Folder mSendFolder = null; - private HashMap mFolderList = new HashMap(); + private Map mFolderList = new HashMap(); public WebDavStore(Account account) throws MessagingException { @@ -363,7 +363,7 @@ public class WebDavStore extends Store { @Override public List getPersonalNamespaces(boolean forceListAll) throws MessagingException { - LinkedList folderList = new LinkedList(); + List folderList = new LinkedList(); /** * We have to check authentication here so we have the proper URL stored */ @@ -373,13 +373,13 @@ public class WebDavStore extends Store { * Firstly we get the "special" folders list (inbox, outbox, etc) * and setup the account accordingly */ - HashMap headers = new HashMap(); + Map headers = new HashMap(); DataSet dataset = new DataSet(); headers.put("Depth", "0"); headers.put("Brief", "t"); dataset = processRequest(this.mUrl, "PROPFIND", getSpecialFoldersList(), headers); - HashMap specialFoldersMap = dataset.getSpecialFolderToUrl(); + Map specialFoldersMap = dataset.getSpecialFolderToUrl(); String folderName = getFolderName(specialFoldersMap.get(DAV_MAIL_INBOX_FOLDER)); if (folderName != null) { mAccount.setAutoExpandFolderName(folderName); @@ -825,7 +825,7 @@ public class WebDavStore extends Store { request.setMethod("POST"); // Build the POST data. - ArrayList pairs = new ArrayList(); + List pairs = new ArrayList(); pairs.add(new BasicNameValuePair("destination", mUrl)); pairs.add(new BasicNameValuePair("username", mUsername)); pairs.add(new BasicNameValuePair("password", mPassword)); @@ -1037,7 +1037,7 @@ public class WebDavStore extends Store { } private InputStream sendRequest(String url, String method, StringEntity messageBody, - HashMap headers, boolean tryAuth) + Map headers, boolean tryAuth) throws MessagingException { InputStream istream = null; @@ -1115,12 +1115,12 @@ public class WebDavStore extends Store { * not all requests will need them. There are two signatures to support calls that don't require parsing of the * response. */ - private DataSet processRequest(String url, String method, String messageBody, HashMap headers) + private DataSet processRequest(String url, String method, String messageBody, Map headers) throws MessagingException { return processRequest(url, method, messageBody, headers, true); } - private DataSet processRequest(String url, String method, String messageBody, HashMap headers, + private DataSet processRequest(String url, String method, String messageBody, Map headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); @@ -1294,8 +1294,8 @@ public class WebDavStore extends Store { uids[i] = messages[i].getUid(); } String messageBody = ""; - HashMap headers = new HashMap(); - HashMap uidToUrl = getMessageUrls(uids); + Map headers = new HashMap(); + Map uidToUrl = getMessageUrls(uids); String[] urls = new String[uids.length]; for (int i = 0, count = uids.length; i < count; i++) { @@ -1320,7 +1320,7 @@ public class WebDavStore extends Store { private int getMessageCount(boolean read) throws MessagingException { String isRead; int messageCount = 0; - HashMap headers = new HashMap(); + Map headers = new HashMap(); String messageBody; if (read) { @@ -1406,9 +1406,9 @@ public class WebDavStore extends Store { @Override public Message[] getMessages(int start, int end, Date earliestDate, MessageRetrievalListener listener) throws MessagingException { - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); String[] uids; - HashMap headers = new HashMap(); + Map headers = new HashMap(); int uidsLength = -1; String messageBody; @@ -1434,7 +1434,7 @@ public class WebDavStore extends Store { DataSet dataset = processRequest(this.mFolderUrl, "SEARCH", messageBody, headers); uids = dataset.getUids(); - HashMap uidToUrl = dataset.getUidToUrl(); + Map uidToUrl = dataset.getUidToUrl(); uidsLength = uids.length; for (int i = 0; i < uidsLength; i++) { @@ -1460,7 +1460,7 @@ public class WebDavStore extends Store { @Override public Message[] getMessages(String[] uids, MessageRetrievalListener listener) throws MessagingException { - ArrayList messageList = new ArrayList(); + List messageList = new ArrayList(); Message[] messages; if (uids == null || @@ -1485,8 +1485,8 @@ public class WebDavStore extends Store { return messages; } - private HashMap getMessageUrls(String[] uids) throws MessagingException { - HashMap headers = new HashMap(); + private Map getMessageUrls(String[] uids) throws MessagingException { + Map headers = new HashMap(); String messageBody; /** Retrieve and parse the XML entity for our messages */ @@ -1494,7 +1494,7 @@ public class WebDavStore extends Store { headers.put("Brief", "t"); DataSet dataset = processRequest(this.mFolderUrl, "SEARCH", messageBody, headers); - HashMap uidToUrl = dataset.getUidToUrl(); + Map uidToUrl = dataset.getUidToUrl(); return uidToUrl; } @@ -1650,7 +1650,7 @@ public class WebDavStore extends Store { * we do a series of medium calls instead of one large massive call or a large number of smaller calls. */ private void fetchFlags(Message[] startMessages, MessageRetrievalListener listener) throws MessagingException { - HashMap headers = new HashMap(); + Map headers = new HashMap(); String messageBody = ""; Message[] messages = new Message[20]; String[] uids; @@ -1689,7 +1689,7 @@ public class WebDavStore extends Store { throw new MessagingException("Data Set from request was null"); } - HashMap uidToReadStatus = dataset.getUidToRead(); + Map uidToReadStatus = dataset.getUidToRead(); for (int i = 0, count = messages.length; i < count; i++) { if (!(messages[i] instanceof WebDavMessage)) { @@ -1720,7 +1720,7 @@ public class WebDavStore extends Store { */ private void fetchEnvelope(Message[] startMessages, MessageRetrievalListener listener) throws MessagingException { - HashMap headers = new HashMap(); + Map headers = new HashMap(); String messageBody = ""; String[] uids; Message[] messages = new Message[10]; @@ -1802,8 +1802,8 @@ public class WebDavStore extends Store { private void markServerMessagesRead(String[] uids, boolean read) throws MessagingException { String messageBody = ""; - HashMap headers = new HashMap(); - HashMap uidToUrl = getMessageUrls(uids); + Map headers = new HashMap(); + Map uidToUrl = getMessageUrls(uids); String[] urls = new String[uids.length]; for (int i = 0, count = uids.length; i < count; i++) { @@ -1818,10 +1818,10 @@ public class WebDavStore extends Store { } private void deleteServerMessages(String[] uids) throws MessagingException { - HashMap uidToUrl = getMessageUrls(uids); + Map uidToUrl = getMessageUrls(uids); for (String uid : uids) { - HashMap headers = new HashMap(); + Map headers = new HashMap(); String url = uidToUrl.get(uid); String destinationUrl = generateDeleteUrl(url); @@ -2005,7 +2005,7 @@ public class WebDavStore extends Store { public void setNewHeaders(ParsedMessageEnvelope envelope) throws MessagingException { String[] headers = envelope.getHeaderList(); - HashMap messageHeaders = envelope.getMessageHeaders(); + Map messageHeaders = envelope.getMessageHeaders(); for (String header : headers) { String headerValue = messageHeaders.get(header); @@ -2107,8 +2107,8 @@ public class WebDavStore extends Store { private boolean mReadStatus = false; private String mUid = ""; - private HashMap mMessageHeaders = new HashMap(); - private ArrayList mHeaders = new ArrayList(); + private Map mMessageHeaders = new HashMap(); + private List mHeaders = new ArrayList(); public void addHeader(String field, String value) { String headerName = HEADER_MAPPINGS.get(field); @@ -2119,7 +2119,7 @@ public class WebDavStore extends Store { } } - public HashMap getMessageHeaders() { + public Map getMessageHeaders() { return this.mMessageHeaders; } @@ -2151,9 +2151,9 @@ public class WebDavStore extends Store { * depending on the accessor calls made. */ public class DataSet { - private HashMap> mData = new HashMap>(); + private Map> mData = new HashMap>(); private StringBuilder mUid = new StringBuilder(); - private HashMap mTempData = new HashMap(); + private Map mTempData = new HashMap(); public void addValue(String value, String tagName) { if (tagName.equals("uid")) { @@ -2185,9 +2185,9 @@ public class WebDavStore extends Store { /** * Returns a hashmap of special folder name => special folder url */ - public HashMap getSpecialFolderToUrl() { + public Map getSpecialFolderToUrl() { // We return the first (and only) map - for (HashMap folderMap : mData.values()) { + for (Map folderMap : mData.values()) { return folderMap; } return new HashMap(); @@ -2196,11 +2196,11 @@ public class WebDavStore extends Store { /** * Returns a hashmap of Message UID => Message Url */ - public HashMap getUidToUrl() { - HashMap uidToUrl = new HashMap(); + public Map getUidToUrl() { + Map uidToUrl = new HashMap(); for (String uid : mData.keySet()) { - HashMap data = mData.get(uid); + Map data = mData.get(uid); String value = data.get("href"); if (value != null && !value.equals("")) { @@ -2214,11 +2214,11 @@ public class WebDavStore extends Store { /** * Returns a hashmap of Message UID => Read Status */ - public HashMap getUidToRead() { - HashMap uidToRead = new HashMap(); + public Map getUidToRead() { + Map uidToRead = new HashMap(); for (String uid : mData.keySet()) { - HashMap data = mData.get(uid); + Map data = mData.get(uid); String readStatus = data.get("read"); if (readStatus != null && !readStatus.equals("")) { Boolean value = !readStatus.equals("0"); @@ -2238,10 +2238,10 @@ public class WebDavStore extends Store { * Returns an array of all hrefs (urls) that were received */ public String[] getHrefs() { - ArrayList hrefs = new ArrayList(); + List hrefs = new ArrayList(); for (String uid : mData.keySet()) { - HashMap data = mData.get(uid); + Map data = mData.get(uid); String href = data.get("href"); hrefs.add(href); } @@ -2253,7 +2253,7 @@ public class WebDavStore extends Store { * Return an array of all Message UIDs that were received */ public String[] getUids() { - ArrayList uids = new ArrayList(); + List uids = new ArrayList(); for (String uid : mData.keySet()) { uids.add(uid); @@ -2274,7 +2274,7 @@ public class WebDavStore extends Store { int messageCount = 0; for (String uid : mData.keySet()) { - HashMap data = mData.get(uid); + Map data = mData.get(uid); String count = data.get("visiblecount"); if (count != null && @@ -2288,14 +2288,14 @@ public class WebDavStore extends Store { } /** - * Returns a HashMap of message UID => ParsedMessageEnvelope + * Returns a Map of message UID => ParsedMessageEnvelope */ - public HashMap getMessageEnvelopes() { - HashMap envelopes = new HashMap(); + public Map getMessageEnvelopes() { + Map envelopes = new HashMap(); for (String uid : mData.keySet()) { ParsedMessageEnvelope envelope = new ParsedMessageEnvelope(); - HashMap data = mData.get(uid); + Map data = mData.get(uid); if (data != null) { for (Map.Entry entry : data.entrySet()) { diff --git a/src/com/fsck/k9/mail/store/imap/ImapUtility.java b/src/com/fsck/k9/mail/store/imap/ImapUtility.java index b7312eae7..51d1aa070 100644 --- a/src/com/fsck/k9/mail/store/imap/ImapUtility.java +++ b/src/com/fsck/k9/mail/store/imap/ImapUtility.java @@ -48,7 +48,7 @@ public class ImapUtility { * list is returned. */ public static List getImapSequenceValues(String set) { - ArrayList list = new ArrayList(); + List list = new ArrayList(); if (set != null) { String[] setItems = set.split(","); for (String item : setItems) { @@ -83,7 +83,7 @@ public class ImapUtility { * is returned. */ public static List getImapRangeValues(String range) { - ArrayList list = new ArrayList(); + List list = new ArrayList(); try { if (range != null) { int colonPos = range.indexOf(':'); diff --git a/src/com/fsck/k9/mail/store/local/LocalFolder.java b/src/com/fsck/k9/mail/store/local/LocalFolder.java index 009d630ae..627c4977c 100644 --- a/src/com/fsck/k9/mail/store/local/LocalFolder.java +++ b/src/com/fsck/k9/mail/store/local/LocalFolder.java @@ -971,7 +971,7 @@ public class LocalFolder extends Folder implements Serializable { if (uids == null) { return getMessages(listener); } - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); for (String uid : uids) { Message message = getMessage(uid); if (message != null) { diff --git a/src/com/fsck/k9/mail/store/local/LocalMessage.java b/src/com/fsck/k9/mail/store/local/LocalMessage.java index f7630a364..474a4c849 100644 --- a/src/com/fsck/k9/mail/store/local/LocalMessage.java +++ b/src/com/fsck/k9/mail/store/local/LocalMessage.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Set; import android.content.ContentValues; @@ -492,7 +493,7 @@ public class LocalMessage extends MimeMessage { } private void loadHeaders() throws UnavailableStorageException { - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); messages.add(this); mHeadersLoaded = true; // set true before calling populate headers to stop recursion ((LocalFolder) mFolder).populateHeaders(messages); diff --git a/src/com/fsck/k9/mail/store/local/LocalStore.java b/src/com/fsck/k9/mail/store/local/LocalStore.java index 17b9fac68..92525d708 100644 --- a/src/com/fsck/k9/mail/store/local/LocalStore.java +++ b/src/com/fsck/k9/mail/store/local/LocalStore.java @@ -425,10 +425,10 @@ public class LocalStore extends Store implements Serializable { }); } - public ArrayList getPendingCommands() throws UnavailableStorageException { - return database.execute(false, new DbCallback>() { + public List getPendingCommands() throws UnavailableStorageException { + return database.execute(false, new DbCallback>() { @Override - public ArrayList doDbWork(final SQLiteDatabase db) throws WrappedException { + public List doDbWork(final SQLiteDatabase db) throws WrappedException { Cursor cursor = null; try { cursor = db.query("pending_commands", @@ -438,7 +438,7 @@ public class LocalStore extends Store implements Serializable { null, null, "id ASC"); - ArrayList commands = new ArrayList(); + List commands = new ArrayList(); while (cursor.moveToNext()) { PendingCommand command = new PendingCommand(); command.mId = cursor.getLong(0); @@ -559,7 +559,7 @@ public class LocalStore extends Store implements Serializable { final LocalFolder folder, final String queryString, final String[] placeHolders ) throws MessagingException { - final ArrayList messages = new ArrayList(); + final List messages = new ArrayList(); final int j = database.execute(false, new DbCallback() { @Override public Integer doDbWork(final SQLiteDatabase db) throws WrappedException { diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index bd50419f1..428c0dce2 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -256,7 +256,7 @@ public class SmtpTransport extends Transport { } } - HashMap extensions = sendHello(localHost); + Map extensions = sendHello(localHost); m8bitEncodingAllowed = extensions.containsKey("8BITMIME"); @@ -419,7 +419,7 @@ public class SmtpTransport extends Transport { * @param host * The EHLO/HELO parameter as defined by the RFC. * - * @return A (possibly empty) {@code HashMap} of extensions (upper case) and + * @return A (possibly empty) {@code Map} of extensions (upper case) and * their parameters (possibly 0 length) as returned by the EHLO command * * @throws IOException @@ -427,8 +427,8 @@ public class SmtpTransport extends Transport { * @throws MessagingException * In case of a malformed response. */ - private HashMap sendHello(String host) throws IOException, MessagingException { - HashMap extensions = new HashMap(); + private Map sendHello(String host) throws IOException, MessagingException { + Map extensions = new HashMap(); try { List results = executeSimpleCommand("EHLO " + host); // Remove the EHLO greeting response @@ -453,7 +453,7 @@ public class SmtpTransport extends Transport { @Override public void sendMessage(Message message) throws MessagingException { - ArrayList
addresses = new ArrayList
(); + List
addresses = new ArrayList
(); { addresses.addAll(Arrays.asList(message.getRecipients(RecipientType.TO))); addresses.addAll(Arrays.asList(message.getRecipients(RecipientType.CC))); @@ -461,12 +461,12 @@ public class SmtpTransport extends Transport { } message.setRecipients(RecipientType.BCC, null); - HashMap> charsetAddressesMap = - new HashMap>(); + Map> charsetAddressesMap = + new HashMap>(); for (Address address : addresses) { String addressString = address.getAddress(); String charset = MimeUtility.getCharsetFromAddress(addressString); - ArrayList addressesOfCharset = charsetAddressesMap.get(charset); + List addressesOfCharset = charsetAddressesMap.get(charset); if (addressesOfCharset == null) { addressesOfCharset = new ArrayList(); charsetAddressesMap.put(charset, addressesOfCharset); @@ -474,16 +474,16 @@ public class SmtpTransport extends Transport { addressesOfCharset.add(addressString); } - for (Map.Entry> charsetAddressesMapEntry : + for (Map.Entry> charsetAddressesMapEntry : charsetAddressesMap.entrySet()) { String charset = charsetAddressesMapEntry.getKey(); - ArrayList addressesOfCharset = charsetAddressesMapEntry.getValue(); + List addressesOfCharset = charsetAddressesMapEntry.getValue(); message.setCharset(charset); sendMessageTo(addressesOfCharset, message); } } - private void sendMessageTo(ArrayList addresses, Message message) + private void sendMessageTo(List addresses, Message message) throws MessagingException { boolean possibleSend = false; diff --git a/src/com/fsck/k9/preferences/Editor.java b/src/com/fsck/k9/preferences/Editor.java index 88479d0e2..fdbc5d3eb 100644 --- a/src/com/fsck/k9/preferences/Editor.java +++ b/src/com/fsck/k9/preferences/Editor.java @@ -5,14 +5,15 @@ import com.fsck.k9.K9; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Editor implements android.content.SharedPreferences.Editor { private Storage storage; - private HashMap changes = new HashMap(); - private ArrayList removals = new ArrayList(); + private Map changes = new HashMap(); + private List removals = new ArrayList(); private boolean removeAll = false; Map snapshot = new HashMap(); diff --git a/src/com/fsck/k9/preferences/Storage.java b/src/com/fsck/k9/preferences/Storage.java index e88a9b6c3..f4c4c4d0e 100644 --- a/src/com/fsck/k9/preferences/Storage.java +++ b/src/com/fsck/k9/preferences/Storage.java @@ -15,16 +15,18 @@ import com.fsck.k9.helper.Utility; import java.net.URI; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; public class Storage implements SharedPreferences { - private static ConcurrentHashMap storages = + private static ConcurrentMap storages = new ConcurrentHashMap(); - private volatile ConcurrentHashMap storage = new ConcurrentHashMap(); + private volatile ConcurrentMap storage = new ConcurrentHashMap(); private CopyOnWriteArrayList listeners = new CopyOnWriteArrayList(); @@ -32,11 +34,11 @@ public class Storage implements SharedPreferences { private int DB_VERSION = 2; private String DB_NAME = "preferences_storage"; - private ThreadLocal> workingStorage - = new ThreadLocal>(); + private ThreadLocal> workingStorage + = new ThreadLocal>(); private ThreadLocal workingDB = new ThreadLocal(); - private ThreadLocal> workingChangedKeys = new ThreadLocal>(); + private ThreadLocal> workingChangedKeys = new ThreadLocal>(); private Context context = null; @@ -202,7 +204,7 @@ public class Storage implements SharedPreferences { } private void keyChange(String key) { - ArrayList changedKeys = workingChangedKeys.get(); + List changedKeys = workingChangedKeys.get(); if (!changedKeys.contains(key)) { changedKeys.add(key); } @@ -259,14 +261,14 @@ public class Storage implements SharedPreferences { } protected void doInTransaction(Runnable dbWork) { - ConcurrentHashMap newStorage = new ConcurrentHashMap(); + ConcurrentMap newStorage = new ConcurrentHashMap(); newStorage.putAll(storage); workingStorage.set(newStorage); SQLiteDatabase mDb = openDB(); workingDB.set(mDb); - ArrayList changedKeys = new ArrayList(); + List changedKeys = new ArrayList(); workingChangedKeys.set(changedKeys); mDb.beginTransaction(); @@ -294,7 +296,11 @@ public class Storage implements SharedPreferences { //@Override public boolean contains(String key) { - return storage.contains(key); + // TODO this used to be ConcurrentHashMap#contains which is + // actually containsValue. But looking at the usage of this method, + // it's clear that containsKey is what's intended. Investigate if this + // was a bug previously. Looks like it was only used once, when upgrading + return storage.containsKey(key); } //@Override diff --git a/src/com/fsck/k9/search/ConditionsTreeNode.java b/src/com/fsck/k9/search/ConditionsTreeNode.java index 2db7eef47..3299c744e 100644 --- a/src/com/fsck/k9/search/ConditionsTreeNode.java +++ b/src/com/fsck/k9/search/ConditionsTreeNode.java @@ -256,7 +256,7 @@ public class ConditionsTreeNode implements Parcelable { * @return List of all nodes in subtree in preorder. */ public List preorder() { - ArrayList result = new ArrayList(); + List result = new ArrayList(); Stack stack = new Stack(); stack.push(this); diff --git a/src/com/fsck/k9/search/LocalSearch.java b/src/com/fsck/k9/search/LocalSearch.java index 0dbf861c3..68dddbf89 100644 --- a/src/com/fsck/k9/search/LocalSearch.java +++ b/src/com/fsck/k9/search/LocalSearch.java @@ -252,7 +252,7 @@ public class LocalSearch implements SearchSpecification { * real searches because of possible extra conditions to a folder requirement. */ public List getFolderNames() { - ArrayList results = new ArrayList(); + List results = new ArrayList(); for (ConditionsTreeNode node : mLeafSet) { if (node.mCondition.field == Searchfield.FOLDER && node.mCondition.attribute == Attribute.EQUALS) { diff --git a/src/com/fsck/k9/service/NotificationActionService.java b/src/com/fsck/k9/service/NotificationActionService.java index 791db4257..e4cad21c9 100644 --- a/src/com/fsck/k9/service/NotificationActionService.java +++ b/src/com/fsck/k9/service/NotificationActionService.java @@ -1,6 +1,7 @@ package com.fsck.k9.service; import java.util.ArrayList; +import java.util.List; import com.fsck.k9.Account; import com.fsck.k9.K9; @@ -8,6 +9,7 @@ import com.fsck.k9.Preferences; import com.fsck.k9.activity.MessageCompose; import com.fsck.k9.activity.MessageReference; import com.fsck.k9.controller.MessagingController; +import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Message; @@ -36,12 +38,12 @@ public class NotificationActionService extends CoreService { } public static PendingIntent getReadAllMessagesIntent(Context context, final Account account, - final ArrayList refs) { + final List refs) { Intent i = new Intent(context, NotificationActionService.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, refs); + i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); i.setAction(READ_ALL_ACTION); - + return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); } @@ -54,10 +56,10 @@ public class NotificationActionService extends CoreService { } public static Intent getDeleteAllMessagesIntent(Context context, final Account account, - final ArrayList refs) { + final List refs) { Intent i = new Intent(context, NotificationActionService.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, refs); + i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); i.setAction(DELETE_ALL_ACTION); return i; @@ -77,7 +79,7 @@ public class NotificationActionService extends CoreService { if (K9.DEBUG) Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read"); - ArrayList refs = + List refs = intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST); for (MessageReference ref : refs) { controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true); @@ -86,9 +88,9 @@ public class NotificationActionService extends CoreService { if (K9.DEBUG) Log.i(K9.LOG_TAG, "NotificationActionService deleting messages"); - ArrayList refs = + List refs = intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST); - ArrayList messages = new ArrayList(); + List messages = new ArrayList(); for (MessageReference ref : refs) { Message m = ref.restoreToLocalMessage(this); @@ -121,7 +123,7 @@ public class NotificationActionService extends CoreService { } else { Log.w(K9.LOG_TAG, "Could not find account for notification action."); } - + return START_NOT_STICKY; } } diff --git a/src/com/fsck/k9/service/PollService.java b/src/com/fsck/k9/service/PollService.java index f24f761de..0fbe8d4c0 100644 --- a/src/com/fsck/k9/service/PollService.java +++ b/src/com/fsck/k9/service/PollService.java @@ -12,6 +12,7 @@ import com.fsck.k9.helper.power.TracingPowerManager; import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock; import java.util.HashMap; +import java.util.Map; public class PollService extends CoreService { private static String START_SERVICE = "com.fsck.k9.service.PollService.startService"; @@ -77,7 +78,7 @@ public class PollService extends CoreService { } class Listener extends MessagingListener { - HashMap accountsChecked = new HashMap(); + Map accountsChecked = new HashMap(); private TracingWakeLock wakeLock = null; private int startId = -1; diff --git a/src/com/fsck/k9/view/NonLockingScrollView.java b/src/com/fsck/k9/view/NonLockingScrollView.java index 38e479ef8..5897c3b22 100644 --- a/src/com/fsck/k9/view/NonLockingScrollView.java +++ b/src/com/fsck/k9/view/NonLockingScrollView.java @@ -28,6 +28,7 @@ import android.webkit.WebView; import android.widget.ScrollView; import java.util.ArrayList; +import java.util.List; /** * A {@link ScrollView} that will never lock scrolling in a particular direction. @@ -59,7 +60,7 @@ public class NonLockingScrollView extends ScrollView { /** * The list of children who should always receive touch events, and not have them intercepted. */ - private final ArrayList mChildrenNeedingAllTouches = new ArrayList(); + private final List mChildrenNeedingAllTouches = new ArrayList(); private boolean mSkipWebViewScroll = true; @@ -122,7 +123,7 @@ public class NonLockingScrollView extends ScrollView { } private final Rect sHitFrame = new Rect(); - private boolean isEventOverChild(MotionEvent ev, ArrayList children) { + private boolean isEventOverChild(MotionEvent ev, List children) { final int actionIndex = ev.getActionIndex(); final float x = ev.getX(actionIndex) + getScrollX(); final float y = ev.getY(actionIndex) + getScrollY();