mirror of https://github.com/M66B/FairEmail.git
Show total size when sorting on size
This commit is contained in:
parent
423d026cad
commit
6c0183d8ea
|
@ -517,8 +517,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ivExpander.setVisibility(View.GONE);
|
||||
|
||||
// Line 1
|
||||
tvSize.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
|
||||
tvSize.setVisibility(message.size == null || message.content ? View.GONE : View.VISIBLE);
|
||||
Long size = ("size".equals(sort) ? message.totalSize : message.size);
|
||||
tvSize.setText(size == null ? null : Helper.humanReadableByteCount(size, true));
|
||||
tvSize.setVisibility(size == null || (message.content && !"size".equals(sort)) ? View.GONE : View.VISIBLE);
|
||||
tvTime.setText(date && "time".equals(sort)
|
||||
? tf.format(message.received)
|
||||
: DateUtils.getRelativeTimeSpanString(context, message.received));
|
||||
|
@ -3060,7 +3061,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
void setSort(String sort) {
|
||||
if (!sort.equals(this.sort)) {
|
||||
boolean update = ("size".equals(this.sort) || "size".equals(sort));
|
||||
this.sort = sort;
|
||||
if (update)
|
||||
notifyDataSetChanged();
|
||||
// loadMessages will be called
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public interface DaoMessage {
|
|||
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
|
||||
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
|
||||
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
|
||||
", SUM(message.size) AS totalSize" +
|
||||
", MAX(CASE WHEN :found OR folder.unified THEN message.received ELSE 0 END) AS dummy" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
|
@ -98,6 +99,7 @@ public interface DaoMessage {
|
|||
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
|
||||
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
|
||||
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
|
||||
", SUM(message.size) AS totalSize" +
|
||||
", MAX(CASE WHEN folder.id = :folder THEN message.received ELSE 0 END) AS dummy" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
|
@ -132,6 +134,7 @@ public interface DaoMessage {
|
|||
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
|
||||
", CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
|
||||
", 1 AS visible" +
|
||||
", message.size AS totalSize" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" LEFT JOIN identity ON identity.id = message.identity" +
|
||||
|
@ -204,6 +207,7 @@ public interface DaoMessage {
|
|||
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
|
||||
", CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
|
||||
", 1 AS visible" +
|
||||
", message.size AS totalSize" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" LEFT JOIN identity ON identity.id = message.identity" +
|
||||
|
@ -221,6 +225,7 @@ public interface DaoMessage {
|
|||
", 0 AS attachments" +
|
||||
", 0 AS drafts" +
|
||||
", 1 AS visible" +
|
||||
", message.size AS totalSize" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" LEFT JOIN identity ON identity.id = message.identity" +
|
||||
|
|
|
@ -39,6 +39,7 @@ public class TupleMessageEx extends EntityMessage {
|
|||
public int attachments;
|
||||
public int drafts;
|
||||
public int visible;
|
||||
public Long totalSize;
|
||||
@Ignore
|
||||
public boolean duplicate;
|
||||
|
||||
|
@ -62,6 +63,7 @@ public class TupleMessageEx extends EntityMessage {
|
|||
this.attachments == other.attachments &&
|
||||
this.drafts == other.drafts &&
|
||||
this.visible == other.visible &&
|
||||
Objects.equals(this.totalSize, other.totalSize) &&
|
||||
this.duplicate == other.duplicate);
|
||||
}
|
||||
return false;
|
||||
|
@ -83,6 +85,7 @@ public class TupleMessageEx extends EntityMessage {
|
|||
this.unflagged == other.unflagged &&
|
||||
this.attachments == other.attachments &&
|
||||
this.visible == other.visible &&
|
||||
Objects.equals(this.totalSize, other.totalSize) &&
|
||||
this.duplicate == other.duplicate);
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue