From 890e0e22e3c57c0617159b8ff82cff67b3a86d5e Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Wed, 25 Sep 2013 15:20:43 +0200 Subject: [PATCH] Some assorted warning fixes. --- src/com/fsck/k9/Account.java | 24 --------- src/com/fsck/k9/PRNGFixes.java | 3 ++ .../fsck/k9/activity/FolderInfoHolder.java | 3 -- src/com/fsck/k9/activity/MessageCompose.java | 2 + src/com/fsck/k9/activity/MessageList.java | 2 - .../NotificationDeleteConfirmation.java | 2 +- .../loader/AttachmentContentLoader.java | 1 - .../activity/misc/ContactPictureLoader.java | 2 +- .../k9/controller/MessagingController.java | 2 - .../fsck/k9/fragment/MessageListFragment.java | 53 ++++++++++++------- src/com/fsck/k9/helper/Contacts.java | 1 + src/com/fsck/k9/helper/Utility.java | 1 - .../k9/service/NotificationActionService.java | 8 +-- src/com/fsck/k9/view/MessageHeader.java | 2 +- 14 files changed, 47 insertions(+), 59 deletions(-) diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index d6ea19417..25a766f65 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -218,12 +218,6 @@ public class Account implements BaseAccount { private ColorChip mFlaggedUnreadColorChip; private ColorChip mFlaggedReadColorChip; - private ColorChip mToMeUnreadColorChip; - private ColorChip mToMeReadColorChip; - private ColorChip mCcMeUnreadColorChip; - private ColorChip mCcMeReadColorChip; - private ColorChip mFromMeUnreadColorChip; - private ColorChip mFromMeReadColorChip; private ColorChip mCheckmarkChip; @@ -851,12 +845,6 @@ public class Account implements BaseAccount { public synchronized void cacheChips() { mReadColorChip = new ColorChip(mChipColor, true, ColorChip.CIRCULAR); mUnreadColorChip = new ColorChip(mChipColor, false, ColorChip.CIRCULAR); - mToMeReadColorChip = new ColorChip(mChipColor, true, ColorChip.RIGHT_POINTING); - mToMeUnreadColorChip = new ColorChip(mChipColor, false,ColorChip.RIGHT_POINTING); - mCcMeReadColorChip = new ColorChip(mChipColor, true, ColorChip.RIGHT_NOTCH); - mCcMeUnreadColorChip = new ColorChip(mChipColor, false,ColorChip.RIGHT_NOTCH); - mFromMeReadColorChip = new ColorChip(mChipColor, true, ColorChip.LEFT_POINTING); - mFromMeUnreadColorChip = new ColorChip(mChipColor, false,ColorChip.LEFT_POINTING); mFlaggedReadColorChip = new ColorChip(mChipColor, true, ColorChip.STAR); mFlaggedUnreadColorChip = new ColorChip(mChipColor, false, ColorChip.STAR); mCheckmarkChip = new ColorChip(mChipColor, true, ColorChip.CHECKMARK); @@ -878,24 +866,12 @@ public class Account implements BaseAccount { if (messageRead) { if (messageFlagged) { chip = mFlaggedReadColorChip; - // } else if (toMe) { - // chip = mToMeReadColorChip; - // } else if (ccMe) { - // chip = mCcMeReadColorChip; - // } else if (fromMe) { - // chip = mFromMeReadColorChip; } else { chip = mReadColorChip; } } else { if (messageFlagged) { chip = mFlaggedUnreadColorChip; - // } else if (toMe) { - // chip = mToMeUnreadColorChip; - // } else if (ccMe) { - // chip = mCcMeUnreadColorChip; - // } else if (fromMe) { - // chip = mFromMeUnreadColorChip; } else { chip = mUnreadColorChip; } diff --git a/src/com/fsck/k9/PRNGFixes.java b/src/com/fsck/k9/PRNGFixes.java index ea5671e45..e1b20d23b 100644 --- a/src/com/fsck/k9/PRNGFixes.java +++ b/src/com/fsck/k9/PRNGFixes.java @@ -142,6 +142,7 @@ public final class PRNGFixes { * all requests to the Linux PRNG. */ private static class LinuxPRNGSecureRandomProvider extends Provider { + private static final long serialVersionUID = 6538669771360998378L; public LinuxPRNGSecureRandomProvider() { super("LinuxPRNG", @@ -175,6 +176,8 @@ public final class PRNGFixes { * duplicated PRNG output. */ + private static final long serialVersionUID = 628140755730642770L; + private static final File URANDOM_FILE = new File("/dev/urandom"); private static final Object sLock = new Object(); diff --git a/src/com/fsck/k9/activity/FolderInfoHolder.java b/src/com/fsck/k9/activity/FolderInfoHolder.java index 4ee11fe86..67b3a87ad 100644 --- a/src/com/fsck/k9/activity/FolderInfoHolder.java +++ b/src/com/fsck/k9/activity/FolderInfoHolder.java @@ -1,13 +1,10 @@ package com.fsck.k9.activity; import android.content.Context; -import android.util.Log; import com.fsck.k9.Account; -import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.mail.Folder; -import com.fsck.k9.mail.MessagingException; public class FolderInfoHolder implements Comparable { public String name; diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index 8d6b5fb7d..059283b65 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -2157,6 +2157,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, performSave(); break; } + case NONE: + break; } } diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index af6dd6778..21574ea4e 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -163,7 +163,6 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme private LocalSearch mSearch; private boolean mSingleFolderMode; private boolean mSingleAccountMode; - private boolean mStars = true; private ProgressBar mActionBarProgress; private MenuItem mMenuButtonCheckMail; @@ -490,7 +489,6 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme @Override public void onResume() { super.onResume(); - mStars = K9.messageListStars(); if (!(this instanceof Search)) { //necessary b/c no guarantee Search.onStop will be called before MessageList.onResume diff --git a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java index b7b5be1f1..200ad84ce 100644 --- a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java +++ b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java @@ -45,7 +45,7 @@ public class NotificationDeleteConfirmation extends Activity { final Intent intent = getIntent(); mAccount = preferences.getAccount(intent.getStringExtra(EXTRA_ACCOUNT)); - mMessageRefs = (ArrayList) intent.getSerializableExtra(EXTRA_MESSAGE_LIST); + mMessageRefs = intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST); if (mAccount == null || mMessageRefs == null || mMessageRefs.isEmpty()) { finish(); diff --git a/src/com/fsck/k9/activity/loader/AttachmentContentLoader.java b/src/com/fsck/k9/activity/loader/AttachmentContentLoader.java index 7d677ecbc..fbba7196a 100644 --- a/src/com/fsck/k9/activity/loader/AttachmentContentLoader.java +++ b/src/com/fsck/k9/activity/loader/AttachmentContentLoader.java @@ -7,7 +7,6 @@ import android.util.Log; import com.fsck.k9.K9; import com.fsck.k9.activity.misc.Attachment; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import java.io.File; diff --git a/src/com/fsck/k9/activity/misc/ContactPictureLoader.java b/src/com/fsck/k9/activity/misc/ContactPictureLoader.java index 44c0b8685..383f05d55 100644 --- a/src/com/fsck/k9/activity/misc/ContactPictureLoader.java +++ b/src/com/fsck/k9/activity/misc/ContactPictureLoader.java @@ -156,7 +156,7 @@ public class ContactPictureLoader { return mDefaultBackgroundColor; } - int val = address.getAddress().toLowerCase().hashCode(); + int val = address.getAddress().toLowerCase(Locale.getDefault()).hashCode(); int rgb = CONTACT_DUMMY_COLORS_ARGB[Math.abs(val) % CONTACT_DUMMY_COLORS_ARGB.length]; return rgb; } diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index d4fe4355d..33c457353 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -91,8 +91,6 @@ import com.fsck.k9.search.ConditionsTreeNode; import com.fsck.k9.search.LocalSearch; import com.fsck.k9.search.SearchAccount; import com.fsck.k9.search.SearchSpecification; -import com.fsck.k9.search.SearchSpecification.Attribute; -import com.fsck.k9.search.SearchSpecification.Searchfield; import com.fsck.k9.search.SqlQueryBuilder; import com.fsck.k9.service.NotificationActionService; diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index 358f4b6e3..732d83cfc 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -1,5 +1,6 @@ package com.fsck.k9.fragment; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -405,7 +406,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private boolean mSingleFolderMode; private boolean mAllAccounts; - private MessageListHandler mHandler = new MessageListHandler(); + private MessageListHandler mHandler = new MessageListHandler(this); private SortType mSortType = SortType.SORT_DATE; private boolean mSortAscending = true; @@ -457,7 +458,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private boolean mInitialized = false; private ContactPictureLoader mContactsPictureLoader; - private float mScreenDensity; private LocalBroadcastManager mLocalBroadcastManager; private BroadcastReceiver mCacheBroadcastReceiver; @@ -485,7 +485,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick *

Note: If you add a method to this class make sure you don't accidentally * perform the operation in the calling thread.

*/ - class MessageListHandler extends Handler { + static class MessageListHandler extends Handler { private static final int ACTION_FOLDER_LOADING = 1; private static final int ACTION_REFRESH_TITLE = 2; private static final int ACTION_PROGRESS = 3; @@ -494,7 +494,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private static final int ACTION_RESTORE_LIST_POSITION = 6; private static final int ACTION_OPEN_MESSAGE = 7; + private WeakReference mFragment; + public MessageListHandler(MessageListFragment fragment) { + mFragment = new WeakReference(fragment); + } public void folderLoading(String folder, boolean loading) { android.os.Message msg = android.os.Message.obtain(this, ACTION_FOLDER_LOADING, (loading) ? 1 : 0, 0, folder); @@ -521,7 +525,10 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick post(new Runnable() { @Override public void run() { - MessageListFragment.this.updateFooter(message); + MessageListFragment fragment = mFragment.get(); + if (fragment != null) { + fragment.updateFooter(message); + } } }); } @@ -532,10 +539,13 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } public void restoreListPosition() { - android.os.Message msg = android.os.Message.obtain(this, ACTION_RESTORE_LIST_POSITION, - mSavedListState); - mSavedListState = null; - sendMessage(msg); + MessageListFragment fragment = mFragment.get(); + if (fragment != null) { + android.os.Message msg = android.os.Message.obtain(this, ACTION_RESTORE_LIST_POSITION, + fragment.mSavedListState); + fragment.mSavedListState = null; + sendMessage(msg); + } } public void openMessage(MessageReference messageReference) { @@ -546,16 +556,21 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick @Override public void handleMessage(android.os.Message msg) { + MessageListFragment fragment = mFragment.get(); + if (fragment == null) { + return; + } + // The following messages don't need an attached activity. switch (msg.what) { case ACTION_REMOTE_SEARCH_FINISHED: { - MessageListFragment.this.remoteSearchFinished(); + fragment.remoteSearchFinished(); return; } } // Discard messages if the fragment isn't attached to an activity anymore. - Activity activity = getActivity(); + Activity activity = fragment.getActivity(); if (activity == null) { return; } @@ -564,29 +579,29 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick case ACTION_FOLDER_LOADING: { String folder = (String) msg.obj; boolean loading = (msg.arg1 == 1); - MessageListFragment.this.folderLoading(folder, loading); + fragment.folderLoading(folder, loading); break; } case ACTION_REFRESH_TITLE: { - updateTitle(); + fragment.updateTitle(); break; } case ACTION_PROGRESS: { boolean progress = (msg.arg1 == 1); - MessageListFragment.this.progress(progress); + fragment.progress(progress); break; } case ACTION_GO_BACK: { - mFragmentListener.goBack(); + fragment.mFragmentListener.goBack(); break; } case ACTION_RESTORE_LIST_POSITION: { - mListView.onRestoreInstanceState((Parcelable) msg.obj); + fragment.mListView.onRestoreInstanceState((Parcelable) msg.obj); break; } case ACTION_OPEN_MESSAGE: { MessageReference messageReference = (MessageReference) msg.obj; - mFragmentListener.openMessage(messageReference); + fragment.mFragmentListener.openMessage(messageReference); break; } } @@ -782,7 +797,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick Context appContext = getActivity().getApplicationContext(); - mScreenDensity = appContext.getResources().getDisplayMetrics().density; mPreferences = Preferences.getPreferences(appContext); mController = MessagingController.getInstance(getActivity().getApplication()); @@ -1394,7 +1408,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } private String getDialogTag(int dialogId) { - return String.format("dialog-%d", dialogId); + return "dialog-" + dialogId; } @Override @@ -1723,7 +1737,8 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick public void remoteSearchServerQueryComplete(Account account, String folderName, int numResults) { mHandler.progress(true); if (account != null && account.getRemoteSearchNumResults() != 0 && numResults > account.getRemoteSearchNumResults()) { - mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading_limited, account.getRemoteSearchNumResults(), numResults)); + mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading_limited, + account.getRemoteSearchNumResults(), numResults)); } else { mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading, numResults)); } diff --git a/src/com/fsck/k9/helper/Contacts.java b/src/com/fsck/k9/helper/Contacts.java index 56866c21c..e0f617b23 100644 --- a/src/com/fsck/k9/helper/Contacts.java +++ b/src/com/fsck/k9/helper/Contacts.java @@ -7,6 +7,7 @@ import android.database.Cursor; import android.net.Uri; import android.content.Intent; import android.provider.ContactsContract; +import android.provider.ContactsContract.DataUsageFeedback; import android.util.Log; import com.fsck.k9.K9; diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java index 76a406d05..67646806d 100644 --- a/src/com/fsck/k9/helper/Utility.java +++ b/src/com/fsck/k9/helper/Utility.java @@ -22,7 +22,6 @@ import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/com/fsck/k9/service/NotificationActionService.java b/src/com/fsck/k9/service/NotificationActionService.java index 036e6e8c4..791db4257 100644 --- a/src/com/fsck/k9/service/NotificationActionService.java +++ b/src/com/fsck/k9/service/NotificationActionService.java @@ -77,8 +77,8 @@ public class NotificationActionService extends CoreService { if (K9.DEBUG) Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read"); - ArrayList refs = (ArrayList) - intent.getSerializableExtra(EXTRA_MESSAGE_LIST); + ArrayList refs = + intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST); for (MessageReference ref : refs) { controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true); } @@ -86,8 +86,8 @@ public class NotificationActionService extends CoreService { if (K9.DEBUG) Log.i(K9.LOG_TAG, "NotificationActionService deleting messages"); - ArrayList refs = (ArrayList) - intent.getSerializableExtra(EXTRA_MESSAGE_LIST); + ArrayList refs = + intent.getParcelableArrayListExtra(EXTRA_MESSAGE_LIST); ArrayList messages = new ArrayList(); for (MessageReference ref : refs) { diff --git a/src/com/fsck/k9/view/MessageHeader.java b/src/com/fsck/k9/view/MessageHeader.java index ec934beb0..f65e94b3c 100644 --- a/src/com/fsck/k9/view/MessageHeader.java +++ b/src/com/fsck/k9/view/MessageHeader.java @@ -276,8 +276,8 @@ public class MessageHeader extends ScrollView implements OnClickListener { mDateView.setText(dateTime); if (K9.showContactPicture()) { - mContactBadge.assignContactFromEmail(counterpartyAddress.getAddress(), true); if (counterpartyAddress != null) { + mContactBadge.assignContactFromEmail(counterpartyAddress.getAddress(), true); mContactsPictureLoader.loadContactPicture(counterpartyAddress, mContactBadge); } else { mContactBadge.setImageResource(R.drawable.ic_contact_picture);