1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

remove controversial methods

This commit is contained in:
Art O Cathain 2014-10-12 08:54:44 +01:00
parent 5dc1b82340
commit ba26cfce90
5 changed files with 22 additions and 40 deletions

View File

@ -122,7 +122,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>();
@ -497,7 +500,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() {

View File

@ -1,5 +1,6 @@
package com.fsck.k9.activity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ -25,15 +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;
/**
* @param refs must be Serializable
*/
public static PendingIntent getIntent(Context context, final Account account, final List<MessageReference> refs) {
public static <T extends List<MessageReference> & Serializable> PendingIntent getIntent(Context context, final Account account, final T 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);

View File

@ -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;
@ -295,17 +296,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;
}
/**
@ -4863,7 +4861,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) {

View File

@ -708,17 +708,4 @@ public class Utility {
return sMainThreadHandler;
}
/**
* @return the supplied list casted to Serializable.
*
* See https://github.com/k9mail/k9mail_pgp_mime/pull/12#issuecomment-58767082
*/
public static <T> Serializable toSerializableList(List<T> list) {
return (Serializable) list;
}
public static <T, U> Serializable toSerializableConcurrentMap(ConcurrentMap<T, U> map) {
return (ConcurrentHashMap<T, U>) map;
}
}

View File

@ -1,5 +1,6 @@
package com.fsck.k9.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ -37,14 +38,11 @@ public class NotificationActionService extends CoreService {
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
}
/**
* @param refs must be Serializable
*/
public static PendingIntent getReadAllMessagesIntent(Context context, final Account account,
final List<MessageReference> refs) {
public static <T extends List<MessageReference> & Serializable> PendingIntent getReadAllMessagesIntent(Context context, final Account account,
final T 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);
@ -58,14 +56,11 @@ public class NotificationActionService extends CoreService {
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
}
/**
* @param refs must be Serializable
*/
public static Intent getDeleteAllMessagesIntent(Context context, final Account account,
final List<MessageReference> refs) {
public static <T extends List<MessageReference> & Serializable> Intent getDeleteAllMessagesIntent(Context context, final Account account,
final T 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;