Added sort on attachments

pull/172/head
M66B 5 years ago
parent 16b42b98b0
commit 988f1c0f9f

@ -886,7 +886,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvFrom.setText(MessageHelper.formatAddresses(addresses, name_email, false)); tvFrom.setText(MessageHelper.formatAddresses(addresses, name_email, false));
tvFrom.setPaintFlags(tvFrom.getPaintFlags() & ~Paint.UNDERLINE_TEXT_FLAG); tvFrom.setPaintFlags(tvFrom.getPaintFlags() & ~Paint.UNDERLINE_TEXT_FLAG);
tvSize.setText(message.totalSize == null ? null : Helper.humanReadableByteCount(message.totalSize, true)); tvSize.setText(message.totalSize == null ? null : Helper.humanReadableByteCount(message.totalSize, true));
tvSize.setVisibility(message.totalSize != null && "size".equals(sort) ? View.VISIBLE : View.GONE); tvSize.setVisibility(
message.totalSize != null && ("size".equals(sort) || "attachments".equals(sort))
? View.VISIBLE : View.GONE);
tvTime.setText(date && "time".equals(sort) tvTime.setText(date && "time".equals(sort)
? TF.format(message.received) ? TF.format(message.received)
: Helper.getRelativeTimeSpanString(context, message.received)); : Helper.getRelativeTimeSpanString(context, message.received));

@ -82,6 +82,7 @@ public interface DaoMessage {
" WHEN 'sender' = :sort THEN LOWER(message.sender)" + " WHEN 'sender' = :sort THEN LOWER(message.sender)" +
" WHEN 'subject' = :sort THEN LOWER(message.subject)" + " WHEN 'subject' = :sort THEN LOWER(message.subject)" +
" WHEN 'size' = :sort THEN -SUM(message.total)" + " WHEN 'size' = :sort THEN -SUM(message.total)" +
" WHEN 'attachments' = :sort THEN -SUM(message.attachments)" +
" WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" ELSE 0" + " ELSE 0" +
" END, CASE WHEN :ascending THEN message.received ELSE -message.received END") " END, CASE WHEN :ascending THEN message.received ELSE -message.received END")
@ -129,6 +130,7 @@ public interface DaoMessage {
" WHEN 'sender' = :sort THEN LOWER(message.sender)" + " WHEN 'sender' = :sort THEN LOWER(message.sender)" +
" WHEN 'subject' = :sort THEN LOWER(message.subject)" + " WHEN 'subject' = :sort THEN LOWER(message.subject)" +
" WHEN 'size' = :sort THEN -SUM(message.total)" + " WHEN 'size' = :sort THEN -SUM(message.total)" +
" WHEN 'attachments' = :sort THEN -SUM(message.attachments)" +
" WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" + " WHEN 'snoozed' = :sort THEN SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) = 0" +
" ELSE 0" + " ELSE 0" +
" END, CASE WHEN :ascending THEN message.received ELSE -message.received END") " END, CASE WHEN :ascending THEN message.received ELSE -message.received END")

@ -3029,6 +3029,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_sort_on_sender).setVisible(false); menu.findItem(R.id.menu_sort_on_sender).setVisible(false);
menu.findItem(R.id.menu_sort_on_subject).setVisible(false); menu.findItem(R.id.menu_sort_on_subject).setVisible(false);
menu.findItem(R.id.menu_sort_on_size).setVisible(false); menu.findItem(R.id.menu_sort_on_size).setVisible(false);
menu.findItem(R.id.menu_sort_on_attachments).setVisible(false);
menu.findItem(R.id.menu_sort_on_snoozed).setVisible(false); menu.findItem(R.id.menu_sort_on_snoozed).setVisible(false);
} }
@ -3044,6 +3045,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_sort_on_subject).setChecked(true); menu.findItem(R.id.menu_sort_on_subject).setChecked(true);
else if ("size".equals(sort)) else if ("size".equals(sort))
menu.findItem(R.id.menu_sort_on_size).setChecked(true); menu.findItem(R.id.menu_sort_on_size).setChecked(true);
else if ("attachments".equals(sort))
menu.findItem(R.id.menu_sort_on_attachments).setChecked(true);
else if ("snoozed".equals(sort)) else if ("snoozed".equals(sort))
menu.findItem(R.id.menu_sort_on_snoozed).setChecked(true); menu.findItem(R.id.menu_sort_on_snoozed).setChecked(true);
menu.findItem(R.id.menu_ascending).setChecked(ascending); menu.findItem(R.id.menu_ascending).setChecked(ascending);
@ -3121,6 +3124,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuSort("size"); onMenuSort("size");
return true; return true;
case R.id.menu_sort_on_attachments:
item.setChecked(true);
onMenuSort("attachments");
return true;
case R.id.menu_sort_on_snoozed: case R.id.menu_sort_on_snoozed:
item.setChecked(true); item.setChecked(true);
onMenuSort("snoozed"); onMenuSort("snoozed");

@ -40,6 +40,9 @@
<item <item
android:id="@+id/menu_sort_on_size" android:id="@+id/menu_sort_on_size"
android:title="@string/title_sort_on_size" /> android:title="@string/title_sort_on_size" />
<item
android:id="@+id/menu_sort_on_attachments"
android:title="@string/title_sort_on_attachments" />
<item <item
android:id="@+id/menu_sort_on_snoozed" android:id="@+id/menu_sort_on_snoozed"
android:title="@string/title_sort_on_hidden" /> android:title="@string/title_sort_on_hidden" />

Loading…
Cancel
Save