mirror of
https://github.com/moparisthebest/k-9
synced 2024-08-13 17:03:48 -04:00
Renamed enum SORT_TYPE to SortType
This commit is contained in:
parent
24c172add0
commit
d6a1f2e95c
@ -7,7 +7,7 @@ import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||
import com.fsck.k9.controller.MessagingController.SortType;
|
||||
import com.fsck.k9.crypto.Apg;
|
||||
import com.fsck.k9.crypto.CryptoProvider;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
@ -78,7 +78,7 @@ public class Account implements BaseAccount {
|
||||
public static final String IDENTITY_EMAIL_KEY = "email";
|
||||
public static final String IDENTITY_DESCRIPTION_KEY = "description";
|
||||
|
||||
public static final SORT_TYPE DEFAULT_SORT_TYPE = SORT_TYPE.SORT_DATE;
|
||||
public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE;
|
||||
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ public class Account implements BaseAccount {
|
||||
private boolean mSaveAllHeaders;
|
||||
private boolean mPushPollOnConnect;
|
||||
private boolean mNotifySync;
|
||||
private SORT_TYPE mSortType;
|
||||
private SortType mSortType;
|
||||
private boolean mSortAscending;
|
||||
private ShowPictures mShowPictures;
|
||||
private boolean mEnableMoveButtons;
|
||||
@ -342,10 +342,10 @@ public class Account implements BaseAccount {
|
||||
0xff000000);
|
||||
|
||||
try {
|
||||
mSortType = SORT_TYPE.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
|
||||
SORT_TYPE.SORT_DATE.name()));
|
||||
mSortType = SortType.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
|
||||
SortType.SORT_DATE.name()));
|
||||
} catch (Exception e) {
|
||||
mSortType = SORT_TYPE.SORT_DATE;
|
||||
mSortType = SortType.SORT_DATE;
|
||||
}
|
||||
|
||||
mSortAscending = prefs.getBoolean(mUuid + ".sortAscending", false);
|
||||
@ -1034,11 +1034,11 @@ public class Account implements BaseAccount {
|
||||
this.mNotifySync = showOngoing;
|
||||
}
|
||||
|
||||
public synchronized SORT_TYPE getSortType() {
|
||||
public synchronized SortType getSortType() {
|
||||
return mSortType;
|
||||
}
|
||||
|
||||
public synchronized void setSortType(SORT_TYPE sortType) {
|
||||
public synchronized void setSortType(SortType sortType) {
|
||||
mSortType = sortType;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ import com.fsck.k9.activity.setup.AccountSettings;
|
||||
import com.fsck.k9.activity.setup.FolderSettings;
|
||||
import com.fsck.k9.activity.setup.Prefs;
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||
import com.fsck.k9.controller.MessagingController.SortType;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.helper.MessageHelper;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
@ -233,21 +233,21 @@ public class MessageList
|
||||
private static final String EXTRA_RETURN_FROM_MESSAGE_VIEW = "returnFromMessageView";
|
||||
|
||||
/**
|
||||
* Maps a {@link SORT_TYPE} to a {@link Comparator} implementation.
|
||||
* Maps a {@link SortType} to a {@link Comparator} implementation.
|
||||
*/
|
||||
private static final Map<SORT_TYPE, Comparator<MessageInfoHolder>> SORT_COMPARATORS;
|
||||
private static final Map<SortType, Comparator<MessageInfoHolder>> SORT_COMPARATORS;
|
||||
|
||||
static {
|
||||
// fill the mapping at class time loading
|
||||
|
||||
final Map<SORT_TYPE, Comparator<MessageInfoHolder>> map = new EnumMap<SORT_TYPE, Comparator<MessageInfoHolder>>(SORT_TYPE.class);
|
||||
map.put(SORT_TYPE.SORT_ATTACHMENT, new AttachmentComparator());
|
||||
map.put(SORT_TYPE.SORT_DATE, new DateComparator());
|
||||
map.put(SORT_TYPE.SORT_ARRIVAL, new ArrivalComparator());
|
||||
map.put(SORT_TYPE.SORT_FLAGGED, new FlaggedComparator());
|
||||
map.put(SORT_TYPE.SORT_SENDER, new SenderComparator());
|
||||
map.put(SORT_TYPE.SORT_SUBJECT, new SubjectComparator());
|
||||
map.put(SORT_TYPE.SORT_UNREAD, new UnreadComparator());
|
||||
final Map<SortType, Comparator<MessageInfoHolder>> map = new EnumMap<SortType, Comparator<MessageInfoHolder>>(SortType.class);
|
||||
map.put(SortType.SORT_ATTACHMENT, new AttachmentComparator());
|
||||
map.put(SortType.SORT_DATE, new DateComparator());
|
||||
map.put(SortType.SORT_ARRIVAL, new ArrivalComparator());
|
||||
map.put(SortType.SORT_FLAGGED, new FlaggedComparator());
|
||||
map.put(SortType.SORT_SENDER, new SenderComparator());
|
||||
map.put(SortType.SORT_SUBJECT, new SubjectComparator());
|
||||
map.put(SortType.SORT_UNREAD, new UnreadComparator());
|
||||
|
||||
// make it immutable to prevent accidental alteration (content is immutable already)
|
||||
SORT_COMPARATORS = Collections.unmodifiableMap(map);
|
||||
@ -292,7 +292,7 @@ public class MessageList
|
||||
|
||||
private MessageListHandler mHandler = new MessageListHandler();
|
||||
|
||||
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
||||
private SortType sortType = SortType.SORT_DATE;
|
||||
|
||||
private boolean sortAscending = true;
|
||||
private boolean sortDateAscending = false;
|
||||
@ -472,8 +472,8 @@ public class MessageList
|
||||
|
||||
{
|
||||
// add the date comparator if not already specified
|
||||
if (sortType != SORT_TYPE.SORT_DATE && sortType != SORT_TYPE.SORT_ARRIVAL) {
|
||||
final Comparator<MessageInfoHolder> comparator = SORT_COMPARATORS.get(SORT_TYPE.SORT_DATE);
|
||||
if (sortType != SortType.SORT_DATE && sortType != SortType.SORT_ARRIVAL) {
|
||||
final Comparator<MessageInfoHolder> comparator = SORT_COMPARATORS.get(SortType.SORT_DATE);
|
||||
if (sortDateAscending) {
|
||||
chain.add(comparator);
|
||||
} else {
|
||||
@ -825,7 +825,7 @@ public class MessageList
|
||||
mController.setSortType(sortType);
|
||||
sortAscending = mAccount.isSortAscending();
|
||||
mController.setSortAscending(sortType, sortAscending);
|
||||
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
||||
sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
|
||||
|
||||
mController.addListener(mAdapter.mListener);
|
||||
|
||||
@ -1209,14 +1209,14 @@ public class MessageList
|
||||
AccountSettings.actionSettings(this, mAccount);
|
||||
}
|
||||
|
||||
private void changeSort(SORT_TYPE newSortType) {
|
||||
private void changeSort(SortType newSortType) {
|
||||
if (sortType == newSortType) {
|
||||
onToggleSortAscending();
|
||||
} else {
|
||||
sortType = newSortType;
|
||||
mController.setSortType(sortType);
|
||||
sortAscending = mController.isSortAscending(sortType);
|
||||
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
||||
sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
|
||||
|
||||
mAccount.setSortType(sortType);
|
||||
mAccount.setSortAscending(sortAscending);
|
||||
@ -1235,7 +1235,7 @@ public class MessageList
|
||||
}
|
||||
|
||||
private void onCycleSort() {
|
||||
SORT_TYPE[] sorts = SORT_TYPE.values();
|
||||
SortType[] sorts = SortType.values();
|
||||
int curIndex = 0;
|
||||
|
||||
for (int i = 0; i < sorts.length; i++) {
|
||||
@ -1258,7 +1258,7 @@ public class MessageList
|
||||
mController.setSortAscending(sortType, !sortAscending);
|
||||
|
||||
sortAscending = mController.isSortAscending(sortType);
|
||||
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
||||
sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
|
||||
|
||||
mAccount.setSortAscending( sortAscending);
|
||||
mAccount.save(Preferences.getPreferences(this));
|
||||
@ -1473,31 +1473,31 @@ public class MessageList
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_date: {
|
||||
changeSort(SORT_TYPE.SORT_DATE);
|
||||
changeSort(SortType.SORT_DATE);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_arrival: {
|
||||
changeSort(SORT_TYPE.SORT_ARRIVAL);
|
||||
changeSort(SortType.SORT_ARRIVAL);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_subject: {
|
||||
changeSort(SORT_TYPE.SORT_SUBJECT);
|
||||
changeSort(SortType.SORT_SUBJECT);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_sender: {
|
||||
changeSort(SORT_TYPE.SORT_SENDER);
|
||||
changeSort(SortType.SORT_SENDER);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_flag: {
|
||||
changeSort(SORT_TYPE.SORT_FLAGGED);
|
||||
changeSort(SortType.SORT_FLAGGED);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_unread: {
|
||||
changeSort(SORT_TYPE.SORT_UNREAD);
|
||||
changeSort(SortType.SORT_UNREAD);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_attach: {
|
||||
changeSort(SORT_TYPE.SORT_ATTACHMENT);
|
||||
changeSort(SortType.SORT_ATTACHMENT);
|
||||
return true;
|
||||
}
|
||||
case R.id.select_all:
|
||||
|
@ -136,7 +136,7 @@ public class MessagingController implements Runnable {
|
||||
private Thread mThread;
|
||||
private Set<MessagingListener> mListeners = new CopyOnWriteArraySet<MessagingListener>();
|
||||
|
||||
private HashMap<SORT_TYPE, Boolean> sortAscending = new HashMap<SORT_TYPE, Boolean>();
|
||||
private HashMap<SortType, Boolean> sortAscending = new HashMap<SortType, Boolean>();
|
||||
|
||||
private final ConcurrentHashMap<String, AtomicInteger> sendCount = new ConcurrentHashMap<String, AtomicInteger>();
|
||||
|
||||
@ -144,7 +144,7 @@ public class MessagingController implements Runnable {
|
||||
|
||||
private final ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||
|
||||
public enum SORT_TYPE {
|
||||
public enum SortType {
|
||||
SORT_DATE(R.string.sort_earliest_first, R.string.sort_latest_first, false),
|
||||
SORT_ARRIVAL(R.string.sort_earliest_first, R.string.sort_latest_first, false),
|
||||
SORT_SUBJECT(R.string.sort_subject_alpha, R.string.sort_subject_re_alpha, true),
|
||||
@ -157,7 +157,7 @@ public class MessagingController implements Runnable {
|
||||
private int descendingToast;
|
||||
private boolean defaultAscending;
|
||||
|
||||
SORT_TYPE(int ascending, int descending, boolean ndefaultAscending) {
|
||||
SortType(int ascending, int descending, boolean ndefaultAscending) {
|
||||
ascendingToast = ascending;
|
||||
descendingToast = descending;
|
||||
defaultAscending = ndefaultAscending;
|
||||
@ -175,7 +175,7 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private SORT_TYPE sortType = Account.DEFAULT_SORT_TYPE;
|
||||
private SortType sortType = Account.DEFAULT_SORT_TYPE;
|
||||
|
||||
private MessagingListener checkMailListener = null;
|
||||
|
||||
@ -4362,22 +4362,22 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public SORT_TYPE getSortType() {
|
||||
public SortType getSortType() {
|
||||
return sortType;
|
||||
}
|
||||
|
||||
public void setSortType(SORT_TYPE sortType) {
|
||||
public void setSortType(SortType sortType) {
|
||||
this.sortType = sortType;
|
||||
}
|
||||
|
||||
public boolean isSortAscending(SORT_TYPE sortType) {
|
||||
public boolean isSortAscending(SortType sortType) {
|
||||
Boolean sortAsc = sortAscending.get(sortType);
|
||||
if (sortAsc == null) {
|
||||
return sortType.isDefaultAscending();
|
||||
} else return sortAsc;
|
||||
}
|
||||
|
||||
public void setSortAscending(SORT_TYPE sortType, boolean nsortAscending) {
|
||||
public void setSortAscending(SortType sortType, boolean nsortAscending) {
|
||||
sortAscending.put(sortType, nsortAscending);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.Account.FolderMode;
|
||||
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||
import com.fsck.k9.controller.MessagingController.SortType;
|
||||
import com.fsck.k9.crypto.Apg;
|
||||
import com.fsck.k9.mail.store.StorageManager;
|
||||
import com.fsck.k9.preferences.Settings.*;
|
||||
@ -161,7 +161,7 @@ public class AccountSettings {
|
||||
new V(1, new StringSetting("Sent"))
|
||||
));
|
||||
s.put("sortTypeEnum", Settings.versions(
|
||||
new V(9, new EnumSetting(SORT_TYPE.class, Account.DEFAULT_SORT_TYPE))
|
||||
new V(9, new EnumSetting(SortType.class, Account.DEFAULT_SORT_TYPE))
|
||||
));
|
||||
s.put("sortAscending", Settings.versions(
|
||||
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
||||
|
Loading…
Reference in New Issue
Block a user