mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
added sort by arrival option.
This commit is contained in:
parent
dda072eff6
commit
f9a30d1822
@ -15,6 +15,10 @@
|
||||
android:id="@+id/set_sort_date"
|
||||
android:title="@string/sort_by_date"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/set_sort_arrival"
|
||||
android:title="@string/sort_by_arrival"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/set_sort_subject"
|
||||
android:title="@string/sort_by_subject"
|
||||
|
@ -782,6 +782,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
|
||||
<string name="sort_by">Sort by...</string>
|
||||
<string name="sort_by_date">Date</string>
|
||||
<string name="sort_by_arrival">Arrival</string>
|
||||
<string name="sort_by_sender">Sender</string>
|
||||
<string name="sort_by_subject">Subject</string>
|
||||
<string name="sort_by_flag">Star</string>
|
||||
|
@ -7,6 +7,7 @@ import com.fsck.k9.mail.store.LocalStore.LocalMessage;
|
||||
public class MessageInfoHolder {
|
||||
public String date;
|
||||
public Date compareDate;
|
||||
public Date compareArrival;
|
||||
public String compareSubject;
|
||||
public CharSequence sender;
|
||||
public String senderAddress;
|
||||
|
@ -185,6 +185,15 @@ public class MessageList
|
||||
|
||||
}
|
||||
|
||||
public static class ArrivalComparator implements Comparator<MessageInfoHolder> {
|
||||
|
||||
@Override
|
||||
public int compare(MessageInfoHolder object1, MessageInfoHolder object2) {
|
||||
return object1.compareArrival.compareTo(object2.compareArrival);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SubjectComparator implements Comparator<MessageInfoHolder> {
|
||||
|
||||
@Override
|
||||
@ -234,6 +243,7 @@ public class MessageList
|
||||
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());
|
||||
@ -460,7 +470,7 @@ public class MessageList
|
||||
|
||||
{
|
||||
// add the date comparator if not already specified
|
||||
if (sortType != SORT_TYPE.SORT_DATE) {
|
||||
if (sortType != SORT_TYPE.SORT_DATE && sortType != SORT_TYPE.SORT_ARRIVAL) {
|
||||
final Comparator<MessageInfoHolder> comparator = SORT_COMPARATORS.get(SORT_TYPE.SORT_DATE);
|
||||
if (sortDateAscending) {
|
||||
chain.add(comparator);
|
||||
@ -1439,6 +1449,10 @@ public class MessageList
|
||||
changeSort(SORT_TYPE.SORT_DATE);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_arrival: {
|
||||
changeSort(SORT_TYPE.SORT_ARRIVAL);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_subject: {
|
||||
changeSort(SORT_TYPE.SORT_SUBJECT);
|
||||
return true;
|
||||
|
@ -146,6 +146,7 @@ public class MessagingController implements Runnable {
|
||||
|
||||
public enum SORT_TYPE {
|
||||
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),
|
||||
SORT_SENDER(R.string.sort_sender_alpha, R.string.sort_sender_re_alpha, true),
|
||||
SORT_UNREAD(R.string.sort_unread_first, R.string.sort_unread_last, true),
|
||||
|
@ -49,6 +49,7 @@ public class MessageHelper {
|
||||
try {
|
||||
LocalMessage message = (LocalMessage) m;
|
||||
target.message = message;
|
||||
target.compareArrival = message.getInternalDate();
|
||||
target.compareDate = message.getSentDate();
|
||||
if (target.compareDate == null) {
|
||||
target.compareDate = message.getInternalDate();
|
||||
|
Loading…
Reference in New Issue
Block a user