Renamed enum SORT_TYPE to SortType

This commit is contained in:
cketti 2012-04-08 23:17:06 +02:00
parent 24c172add0
commit d6a1f2e95c
4 changed files with 44 additions and 44 deletions

View File

@ -7,7 +7,7 @@ import android.net.ConnectivityManager;
import android.net.Uri; import android.net.Uri;
import android.util.Log; 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.Apg;
import com.fsck.k9.crypto.CryptoProvider; import com.fsck.k9.crypto.CryptoProvider;
import com.fsck.k9.helper.Utility; 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_EMAIL_KEY = "email";
public static final String IDENTITY_DESCRIPTION_KEY = "description"; 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; public static final boolean DEFAULT_SORT_ASCENDING = false;
@ -125,7 +125,7 @@ public class Account implements BaseAccount {
private boolean mSaveAllHeaders; private boolean mSaveAllHeaders;
private boolean mPushPollOnConnect; private boolean mPushPollOnConnect;
private boolean mNotifySync; private boolean mNotifySync;
private SORT_TYPE mSortType; private SortType mSortType;
private boolean mSortAscending; private boolean mSortAscending;
private ShowPictures mShowPictures; private ShowPictures mShowPictures;
private boolean mEnableMoveButtons; private boolean mEnableMoveButtons;
@ -342,10 +342,10 @@ public class Account implements BaseAccount {
0xff000000); 0xff000000);
try { try {
mSortType = SORT_TYPE.valueOf(prefs.getString(mUuid + ".sortTypeEnum", mSortType = SortType.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
SORT_TYPE.SORT_DATE.name())); SortType.SORT_DATE.name()));
} catch (Exception e) { } catch (Exception e) {
mSortType = SORT_TYPE.SORT_DATE; mSortType = SortType.SORT_DATE;
} }
mSortAscending = prefs.getBoolean(mUuid + ".sortAscending", false); mSortAscending = prefs.getBoolean(mUuid + ".sortAscending", false);
@ -1034,11 +1034,11 @@ public class Account implements BaseAccount {
this.mNotifySync = showOngoing; this.mNotifySync = showOngoing;
} }
public synchronized SORT_TYPE getSortType() { public synchronized SortType getSortType() {
return mSortType; return mSortType;
} }
public synchronized void setSortType(SORT_TYPE sortType) { public synchronized void setSortType(SortType sortType) {
mSortType = sortType; mSortType = sortType;
} }

View File

@ -63,7 +63,7 @@ import com.fsck.k9.activity.setup.AccountSettings;
import com.fsck.k9.activity.setup.FolderSettings; import com.fsck.k9.activity.setup.FolderSettings;
import com.fsck.k9.activity.setup.Prefs; import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.controller.MessagingController; 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.controller.MessagingListener;
import com.fsck.k9.helper.MessageHelper; import com.fsck.k9.helper.MessageHelper;
import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.Utility;
@ -233,21 +233,21 @@ public class MessageList
private static final String EXTRA_RETURN_FROM_MESSAGE_VIEW = "returnFromMessageView"; 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 { static {
// fill the mapping at class time loading // fill the mapping at class time loading
final Map<SORT_TYPE, Comparator<MessageInfoHolder>> map = new EnumMap<SORT_TYPE, Comparator<MessageInfoHolder>>(SORT_TYPE.class); final Map<SortType, Comparator<MessageInfoHolder>> map = new EnumMap<SortType, Comparator<MessageInfoHolder>>(SortType.class);
map.put(SORT_TYPE.SORT_ATTACHMENT, new AttachmentComparator()); map.put(SortType.SORT_ATTACHMENT, new AttachmentComparator());
map.put(SORT_TYPE.SORT_DATE, new DateComparator()); map.put(SortType.SORT_DATE, new DateComparator());
map.put(SORT_TYPE.SORT_ARRIVAL, new ArrivalComparator()); map.put(SortType.SORT_ARRIVAL, new ArrivalComparator());
map.put(SORT_TYPE.SORT_FLAGGED, new FlaggedComparator()); map.put(SortType.SORT_FLAGGED, new FlaggedComparator());
map.put(SORT_TYPE.SORT_SENDER, new SenderComparator()); map.put(SortType.SORT_SENDER, new SenderComparator());
map.put(SORT_TYPE.SORT_SUBJECT, new SubjectComparator()); map.put(SortType.SORT_SUBJECT, new SubjectComparator());
map.put(SORT_TYPE.SORT_UNREAD, new UnreadComparator()); map.put(SortType.SORT_UNREAD, new UnreadComparator());
// make it immutable to prevent accidental alteration (content is immutable already) // make it immutable to prevent accidental alteration (content is immutable already)
SORT_COMPARATORS = Collections.unmodifiableMap(map); SORT_COMPARATORS = Collections.unmodifiableMap(map);
@ -292,7 +292,7 @@ public class MessageList
private MessageListHandler mHandler = new MessageListHandler(); 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 sortAscending = true;
private boolean sortDateAscending = false; private boolean sortDateAscending = false;
@ -472,8 +472,8 @@ public class MessageList
{ {
// add the date comparator if not already specified // add the date comparator if not already specified
if (sortType != SORT_TYPE.SORT_DATE && sortType != SORT_TYPE.SORT_ARRIVAL) { if (sortType != SortType.SORT_DATE && sortType != SortType.SORT_ARRIVAL) {
final Comparator<MessageInfoHolder> comparator = SORT_COMPARATORS.get(SORT_TYPE.SORT_DATE); final Comparator<MessageInfoHolder> comparator = SORT_COMPARATORS.get(SortType.SORT_DATE);
if (sortDateAscending) { if (sortDateAscending) {
chain.add(comparator); chain.add(comparator);
} else { } else {
@ -825,7 +825,7 @@ public class MessageList
mController.setSortType(sortType); mController.setSortType(sortType);
sortAscending = mAccount.isSortAscending(); sortAscending = mAccount.isSortAscending();
mController.setSortAscending(sortType, sortAscending); mController.setSortAscending(sortType, sortAscending);
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE); sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
mController.addListener(mAdapter.mListener); mController.addListener(mAdapter.mListener);
@ -1209,14 +1209,14 @@ public class MessageList
AccountSettings.actionSettings(this, mAccount); AccountSettings.actionSettings(this, mAccount);
} }
private void changeSort(SORT_TYPE newSortType) { private void changeSort(SortType newSortType) {
if (sortType == newSortType) { if (sortType == newSortType) {
onToggleSortAscending(); onToggleSortAscending();
} else { } else {
sortType = newSortType; sortType = newSortType;
mController.setSortType(sortType); mController.setSortType(sortType);
sortAscending = mController.isSortAscending(sortType); sortAscending = mController.isSortAscending(sortType);
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE); sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
mAccount.setSortType(sortType); mAccount.setSortType(sortType);
mAccount.setSortAscending(sortAscending); mAccount.setSortAscending(sortAscending);
@ -1235,7 +1235,7 @@ public class MessageList
} }
private void onCycleSort() { private void onCycleSort() {
SORT_TYPE[] sorts = SORT_TYPE.values(); SortType[] sorts = SortType.values();
int curIndex = 0; int curIndex = 0;
for (int i = 0; i < sorts.length; i++) { for (int i = 0; i < sorts.length; i++) {
@ -1258,7 +1258,7 @@ public class MessageList
mController.setSortAscending(sortType, !sortAscending); mController.setSortAscending(sortType, !sortAscending);
sortAscending = mController.isSortAscending(sortType); sortAscending = mController.isSortAscending(sortType);
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE); sortDateAscending = mController.isSortAscending(SortType.SORT_DATE);
mAccount.setSortAscending( sortAscending); mAccount.setSortAscending( sortAscending);
mAccount.save(Preferences.getPreferences(this)); mAccount.save(Preferences.getPreferences(this));
@ -1473,31 +1473,31 @@ public class MessageList
return true; return true;
} }
case R.id.set_sort_date: { case R.id.set_sort_date: {
changeSort(SORT_TYPE.SORT_DATE); changeSort(SortType.SORT_DATE);
return true; return true;
} }
case R.id.set_sort_arrival: { case R.id.set_sort_arrival: {
changeSort(SORT_TYPE.SORT_ARRIVAL); changeSort(SortType.SORT_ARRIVAL);
return true; return true;
} }
case R.id.set_sort_subject: { case R.id.set_sort_subject: {
changeSort(SORT_TYPE.SORT_SUBJECT); changeSort(SortType.SORT_SUBJECT);
return true; return true;
} }
case R.id.set_sort_sender: { case R.id.set_sort_sender: {
changeSort(SORT_TYPE.SORT_SENDER); changeSort(SortType.SORT_SENDER);
return true; return true;
} }
case R.id.set_sort_flag: { case R.id.set_sort_flag: {
changeSort(SORT_TYPE.SORT_FLAGGED); changeSort(SortType.SORT_FLAGGED);
return true; return true;
} }
case R.id.set_sort_unread: { case R.id.set_sort_unread: {
changeSort(SORT_TYPE.SORT_UNREAD); changeSort(SortType.SORT_UNREAD);
return true; return true;
} }
case R.id.set_sort_attach: { case R.id.set_sort_attach: {
changeSort(SORT_TYPE.SORT_ATTACHMENT); changeSort(SortType.SORT_ATTACHMENT);
return true; return true;
} }
case R.id.select_all: case R.id.select_all:

View File

@ -136,7 +136,7 @@ public class MessagingController implements Runnable {
private Thread mThread; private Thread mThread;
private Set<MessagingListener> mListeners = new CopyOnWriteArraySet<MessagingListener>(); 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>(); 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(); 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_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_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), 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 int descendingToast;
private boolean defaultAscending; private boolean defaultAscending;
SORT_TYPE(int ascending, int descending, boolean ndefaultAscending) { SortType(int ascending, int descending, boolean ndefaultAscending) {
ascendingToast = ascending; ascendingToast = ascending;
descendingToast = descending; descendingToast = descending;
defaultAscending = ndefaultAscending; 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; private MessagingListener checkMailListener = null;
@ -4362,22 +4362,22 @@ public class MessagingController implements Runnable {
} }
} }
public SORT_TYPE getSortType() { public SortType getSortType() {
return sortType; return sortType;
} }
public void setSortType(SORT_TYPE sortType) { public void setSortType(SortType sortType) {
this.sortType = sortType; this.sortType = sortType;
} }
public boolean isSortAscending(SORT_TYPE sortType) { public boolean isSortAscending(SortType sortType) {
Boolean sortAsc = sortAscending.get(sortType); Boolean sortAsc = sortAscending.get(sortType);
if (sortAsc == null) { if (sortAsc == null) {
return sortType.isDefaultAscending(); return sortType.isDefaultAscending();
} else return sortAsc; } else return sortAsc;
} }
public void setSortAscending(SORT_TYPE sortType, boolean nsortAscending) { public void setSortAscending(SortType sortType, boolean nsortAscending) {
sortAscending.put(sortType, nsortAscending); sortAscending.put(sortType, nsortAscending);
} }

View File

@ -12,7 +12,7 @@ import com.fsck.k9.Account;
import com.fsck.k9.K9; import com.fsck.k9.K9;
import com.fsck.k9.R; import com.fsck.k9.R;
import com.fsck.k9.Account.FolderMode; 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.crypto.Apg;
import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.preferences.Settings.*; import com.fsck.k9.preferences.Settings.*;
@ -161,7 +161,7 @@ public class AccountSettings {
new V(1, new StringSetting("Sent")) new V(1, new StringSetting("Sent"))
)); ));
s.put("sortTypeEnum", Settings.versions( 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( s.put("sortAscending", Settings.versions(
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING)) new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))