mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Merge branch 'message-list-sender-sorting'
This commit is contained in:
commit
c7024af9a1
@ -143,11 +143,9 @@
|
||||
<item
|
||||
android:id="@+id/set_sort_subject"
|
||||
android:title="@string/sort_by_subject"/>
|
||||
<!--
|
||||
<item
|
||||
android:id="@+id/set_sort_sender"
|
||||
android:title="@string/sort_by_sender"/>
|
||||
-->
|
||||
<item
|
||||
android:id="@+id/set_sort_flag"
|
||||
android:title="@string/sort_by_flag"/>
|
||||
|
@ -735,6 +735,8 @@ Please submit bug reports, contribute new features and ask questions at
|
||||
<string name="sort_latest_first">Latest messages first</string>
|
||||
<string name="sort_subject_alpha">Subject alphabetical</string>
|
||||
<string name="sort_subject_re_alpha">Subject reverse alphabetical</string>
|
||||
<string name="sort_sender_alpha">Sender alphabetical</string>
|
||||
<string name="sort_sender_re_alpha">Sender reverse alphabetical</string>
|
||||
<string name="sort_flagged_first">Starred messages first</string>
|
||||
<string name="sort_flagged_last">Unstarred messages first</string>
|
||||
<string name="sort_unread_first">Unread messages first</string>
|
||||
@ -746,6 +748,7 @@ Please submit bug reports, contribute new features and ask questions at
|
||||
<string name="sort_by_date">Date</string>
|
||||
<string name="sort_by_arrival">Arrival</string>
|
||||
<string name="sort_by_subject">Subject</string>
|
||||
<string name="sort_by_sender">Sender</string>
|
||||
<string name="sort_by_flag">Star</string>
|
||||
<string name="sort_by_unread">Read/unread</string>
|
||||
<string name="sort_by_attach">Attachments</string>
|
||||
|
@ -106,7 +106,7 @@ public class Account implements BaseAccount {
|
||||
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_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),
|
||||
SORT_FLAGGED(R.string.sort_flagged_first, R.string.sort_flagged_last, true),
|
||||
SORT_ATTACHMENT(R.string.sort_attach_first, R.string.sort_unattached_first, true);
|
||||
|
@ -769,10 +769,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mMessageListFragment.changeSort(SortType.SORT_SUBJECT);
|
||||
return true;
|
||||
}
|
||||
// case R.id.set_sort_sender: {
|
||||
// mMessageListFragment.changeSort(SortType.SORT_SENDER);
|
||||
// return true;
|
||||
// }
|
||||
case R.id.set_sort_sender: {
|
||||
mMessageListFragment.changeSort(SortType.SORT_SENDER);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_flag: {
|
||||
mMessageListFragment.changeSort(SortType.SORT_FLAGGED);
|
||||
return true;
|
||||
|
@ -312,6 +312,25 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
}
|
||||
}
|
||||
|
||||
public static class SenderComparator implements Comparator<Cursor> {
|
||||
|
||||
@Override
|
||||
public int compare(Cursor cursor1, Cursor cursor2) {
|
||||
String sender1 = getSenderAddressFromCursor(cursor1);
|
||||
String sender2 = getSenderAddressFromCursor(cursor2);
|
||||
|
||||
if (sender1 == null && sender2 == null) {
|
||||
return 0;
|
||||
} else if (sender1 == null) {
|
||||
return 1;
|
||||
} else if (sender2 == null) {
|
||||
return -1;
|
||||
} else {
|
||||
return sender1.compareToIgnoreCase(sender2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final int ACTIVITY_CHOOSE_FOLDER_MOVE = 1;
|
||||
private static final int ACTIVITY_CHOOSE_FOLDER_COPY = 2;
|
||||
@ -340,6 +359,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
map.put(SortType.SORT_ARRIVAL, new ArrivalComparator());
|
||||
map.put(SortType.SORT_FLAGGED, new FlaggedComparator());
|
||||
map.put(SortType.SORT_SUBJECT, new SubjectComparator());
|
||||
map.put(SortType.SORT_SENDER, new SenderComparator());
|
||||
map.put(SortType.SORT_UNREAD, new UnreadComparator());
|
||||
|
||||
// make it immutable to prevent accidental alteration (content is immutable already)
|
||||
@ -1370,10 +1390,10 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
changeSort(SortType.SORT_SUBJECT);
|
||||
return true;
|
||||
}
|
||||
// case R.id.set_sort_sender: {
|
||||
// changeSort(SortType.SORT_SENDER);
|
||||
// return true;
|
||||
// }
|
||||
case R.id.set_sort_sender: {
|
||||
changeSort(SortType.SORT_SENDER);
|
||||
return true;
|
||||
}
|
||||
case R.id.set_sort_flag: {
|
||||
changeSort(SortType.SORT_FLAGGED);
|
||||
return true;
|
||||
@ -1503,7 +1523,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
}
|
||||
|
||||
|
||||
private String getSenderAddressFromCursor(Cursor cursor) {
|
||||
private static String getSenderAddressFromCursor(Cursor cursor) {
|
||||
String fromList = cursor.getString(SENDER_LIST_COLUMN);
|
||||
Address[] fromAddrs = Address.unpack(fromList);
|
||||
return (fromAddrs.length > 0) ? fromAddrs[0].getAddress() : null;
|
||||
@ -3240,11 +3260,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
sortColumn = "(" + MessageColumns.FLAGGED + " != 1)";
|
||||
break;
|
||||
}
|
||||
// case SORT_SENDER: {
|
||||
// //FIXME
|
||||
// sortColumn = MessageColumns.SENDER_LIST;
|
||||
// break;
|
||||
// }
|
||||
case SORT_SENDER: {
|
||||
//FIXME
|
||||
sortColumn = MessageColumns.SENDER_LIST;
|
||||
break;
|
||||
}
|
||||
case SORT_SUBJECT: {
|
||||
sortColumn = MessageColumns.SUBJECT + " COLLATE NOCASE";
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user