mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Merge pull request #12 from k9mail/art/warn-if-not-serializable
Art/warn if not serializable
This commit is contained in:
commit
0f70d5db40
@ -117,7 +117,10 @@ 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 ConcurrentMap<String, AccountStats> accountStats = new ConcurrentHashMap<String, AccountStats>();
|
||||
/*
|
||||
* Must be serializable hence implementation class used for declaration.
|
||||
*/
|
||||
private ConcurrentHashMap<String, AccountStats> accountStats = new ConcurrentHashMap<String, AccountStats>();
|
||||
|
||||
private ConcurrentMap<BaseAccount, String> pendingWork = new ConcurrentHashMap<BaseAccount, String>();
|
||||
|
||||
@ -492,7 +495,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, Utility.toSerializableConcurrentMap(accountStats));
|
||||
outState.putSerializable(ACCOUNT_STATS, accountStats);
|
||||
}
|
||||
|
||||
private StorageManager.StorageListener storageListener = new StorageManager.StorageListener() {
|
||||
|
@ -1154,7 +1154,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
List<Attachment> attachments = new ArrayList<Attachment>();
|
||||
ArrayList<Attachment> attachments = new ArrayList<Attachment>();
|
||||
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
|
||||
View view = mAttachments.getChildAt(i);
|
||||
Attachment attachment = (Attachment) view.getTag();
|
||||
@ -1163,7 +1163,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, Utility.toArrayList(attachments));
|
||||
outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, 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);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fsck.k9.activity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -25,12 +26,12 @@ public class NotificationDeleteConfirmation extends Activity {
|
||||
private final static int DIALOG_CONFIRM = 1;
|
||||
|
||||
private Account mAccount;
|
||||
private List<MessageReference> mMessageRefs;
|
||||
private ArrayList<MessageReference> mMessageRefs;
|
||||
|
||||
public static PendingIntent getIntent(Context context, final Account account, final List<MessageReference> refs) {
|
||||
public static PendingIntent getIntent(Context context, final Account account, final Serializable refs) {
|
||||
Intent i = new Intent(context, NotificationDeleteConfirmation.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs));
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, refs);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
return PendingIntent.getActivity(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
@ -2,6 +2,7 @@ package com.fsck.k9.controller;
|
||||
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -286,17 +287,14 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of references for all pending messages for the notification.
|
||||
*
|
||||
* @return Message reference list
|
||||
* Adds a list of references for all pending messages for the notification to the supplied
|
||||
* List.
|
||||
*/
|
||||
public List<MessageReference> getAllMessageRefs() {
|
||||
List<MessageReference> refs = new ArrayList<MessageReference>();
|
||||
public void supplyAllMessageRefs(List<MessageReference> refs) {
|
||||
for (Message m : messages) {
|
||||
refs.add(m.makeMessageReference());
|
||||
}
|
||||
refs.addAll(droppedMessages);
|
||||
return refs;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4844,7 +4842,8 @@ public class MessagingController implements Runnable {
|
||||
|
||||
String accountDescr = (account.getDescription() != null) ?
|
||||
account.getDescription() : account.getEmail();
|
||||
final List<MessageReference> allRefs = data.getAllMessageRefs();
|
||||
final ArrayList<MessageReference> allRefs = new ArrayList<MessageReference>();
|
||||
data.supplyAllMessageRefs(allRefs);
|
||||
|
||||
if (platformSupportsExtendedNotifications() && !privacyModeEnabled) {
|
||||
if (newMessages > 1) {
|
||||
|
@ -724,22 +724,4 @@ public class Utility {
|
||||
return sMainThreadHandler;
|
||||
}
|
||||
|
||||
public static <T> Serializable toSerializableList(List<T> list) {
|
||||
return list instanceof Serializable ?
|
||||
(Serializable) list :
|
||||
new ArrayList<T>(list);
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> toArrayList(List<T> list) {
|
||||
return list instanceof ArrayList ?
|
||||
(ArrayList<T>) list :
|
||||
new ArrayList<T>(list);
|
||||
}
|
||||
|
||||
|
||||
public static <T,U> Serializable toSerializableConcurrentMap(ConcurrentMap<T,U> list) {
|
||||
return list instanceof ConcurrentHashMap ?
|
||||
(ConcurrentHashMap<T,U>) list :
|
||||
new ConcurrentHashMap<T,U>(list);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fsck.k9.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -37,11 +38,10 @@ public class NotificationActionService extends CoreService {
|
||||
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
public static PendingIntent getReadAllMessagesIntent(Context context, final Account account,
|
||||
final List<MessageReference> refs) {
|
||||
public static PendingIntent getReadAllMessagesIntent(Context context, final Account account, final Serializable refs) {
|
||||
Intent i = new Intent(context, NotificationActionService.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs));
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, refs);
|
||||
i.setAction(READ_ALL_ACTION);
|
||||
|
||||
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
@ -55,11 +55,10 @@ public class NotificationActionService extends CoreService {
|
||||
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
public static Intent getDeleteAllMessagesIntent(Context context, final Account account,
|
||||
final List<MessageReference> refs) {
|
||||
public static Intent getDeleteAllMessagesIntent(Context context, final Account account, final Serializable refs) {
|
||||
Intent i = new Intent(context, NotificationActionService.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs));
|
||||
i.putExtra(EXTRA_MESSAGE_LIST, refs);
|
||||
i.setAction(DELETE_ALL_ACTION);
|
||||
|
||||
return i;
|
||||
|
Loading…
Reference in New Issue
Block a user