Take hidden folders into account for collapsible

pull/156/head
M66B 6 years ago
parent 6e5aba2535
commit e5d91ac619

@ -76,6 +76,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private int level; private int level;
private EntityFolder parent; private EntityFolder parent;
private boolean collapsable; private boolean collapsable;
private boolean collapsable_hidden;
private IProperties properties; private IProperties properties;
private boolean subscriptions; private boolean subscriptions;
private boolean debug; private boolean debug;
@ -228,12 +229,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivReadOnly.setVisibility(folder.read_only ? View.VISIBLE : View.GONE); ivReadOnly.setVisibility(folder.read_only ? View.VISIBLE : View.GONE);
boolean folder_collapsible = (show_hidden ? collapsable : collapsable_hidden);
ViewGroup.LayoutParams lp = vwLevel.getLayoutParams(); ViewGroup.LayoutParams lp = vwLevel.getLayoutParams();
lp.width = (account < 0 || !collapsable ? 1 : level) * dp12; lp.width = (account < 0 || !folder_collapsible ? 1 : level) * dp12;
vwLevel.setLayoutParams(lp); vwLevel.setLayoutParams(lp);
ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */); ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */);
ivExpander.setVisibility(account < 0 || !collapsable ? View.GONE : (folder.childs > 0 ? View.VISIBLE : View.INVISIBLE)); ivExpander.setVisibility(account < 0 || !folder_collapsible ? View.GONE : (folder.childs > 0 ? View.VISIBLE : View.INVISIBLE));
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE); ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
ivSubscribed.setVisibility(subscriptions && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE); ivSubscribed.setVisibility(subscriptions && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE);
@ -707,14 +710,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (parent == null) { if (parent == null) {
this.collapsable = false; this.collapsable = false;
this.collapsable_hidden = false;
for (TupleFolderEx folder : folders) for (TupleFolderEx folder : folders)
if (folder.childs > 0) { if (folder.childs > 0) {
this.collapsable = true; this.collapsable = true;
this.collapsable_hidden = (folder.childs - folder.hidden_childs > 0);
break; break;
} }
} else } else {
this.collapsable = true; this.collapsable = true;
this.collapsable_hidden = true;
}
final Collator collator = Collator.getInstance(Locale.getDefault()); final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc

@ -57,6 +57,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" + " LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
@ -75,6 +76,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" + " FROM folder" +
" JOIN account ON account.id = folder.account" + " JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" + " LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
@ -115,6 +117,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" + ", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" + " LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +

@ -40,6 +40,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
public int unseen; public int unseen;
public int executing; public int executing;
public int childs; public int childs;
public int hidden_childs;
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@ -53,7 +54,8 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
this.content == other.content && this.content == other.content &&
this.unseen == other.unseen && this.unseen == other.unseen &&
this.executing == other.executing && this.executing == other.executing &&
this.childs == other.childs); this.childs == other.childs &&
this.hidden_childs == other.hidden_childs);
} else } else
return false; return false;
} }

Loading…
Cancel
Save