mirror of https://github.com/M66B/FairEmail.git
Moved outbox to unified folders
This commit is contained in:
parent
e7ef17be72
commit
7b9d21325d
|
@ -772,11 +772,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
}
|
||||
});
|
||||
|
||||
ibExpanderFolder.setVisibility(View.GONE);
|
||||
db.folder().liveNavigation().observe(owner, new Observer<List<TupleFolderNav>>() {
|
||||
@Override
|
||||
public void onChanged(List<TupleFolderNav> folders) {
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
ibExpanderFolder.setVisibility(folders.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
adapterNavFolder.set(folders, nav_expanded);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.ViewHolder> {
|
||||
private Context context;
|
||||
|
@ -89,11 +90,17 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
|
|||
private void bindTo(TupleFolderUnified folder) {
|
||||
if (EntityFolder.INBOX.equals(folder.type))
|
||||
ivItem.setImageResource(R.drawable.twotone_all_inbox_24);
|
||||
else
|
||||
else if (EntityFolder.OUTBOX.equals(folder.type)) {
|
||||
if ("syncing".equals(folder.sync_state))
|
||||
ivItem.setImageResource(R.drawable.twotone_compare_arrows_24);
|
||||
else
|
||||
ivItem.setImageResource(EntityFolder.getIcon(folder.type));
|
||||
} else
|
||||
ivItem.setImageResource(EntityFolder.getIcon(folder.type));
|
||||
|
||||
long count;
|
||||
if (EntityFolder.DRAFTS.equals(folder.type))
|
||||
if (EntityFolder.DRAFTS.equals(folder.type) ||
|
||||
EntityFolder.OUTBOX.equals(folder.type))
|
||||
count = folder.messages;
|
||||
else
|
||||
count = folder.unseen;
|
||||
|
@ -223,7 +230,7 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
|
|||
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
||||
TupleFolderUnified f1 = prev.get(oldItemPosition);
|
||||
TupleFolderUnified f2 = next.get(newItemPosition);
|
||||
return (f1.messages == f2.messages && f1.unseen == f2.unseen);
|
||||
return f1.equals(f2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,8 +125,7 @@ public interface DaoFolder {
|
|||
" FROM folder" +
|
||||
" LEFT JOIN account ON account.id = folder.account" +
|
||||
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||
" WHERE account.id IS NULL" +
|
||||
" OR (account.`synchronize` AND folder.navigation)" +
|
||||
" WHERE (account.`synchronize` AND folder.navigation)" +
|
||||
" GROUP BY folder.id")
|
||||
LiveData<List<TupleFolderNav>> liveNavigation();
|
||||
|
||||
|
@ -189,10 +188,11 @@ public interface DaoFolder {
|
|||
@Query("SELECT folder.type" +
|
||||
", COUNT(message.id) AS messages" +
|
||||
", SUM(CASE WHEN NOT message.ui_seen THEN 1 ELSE 0 END) AS unseen" +
|
||||
", CASE WHEN folder.account IS NULL THEN folder.sync_state ELSE NULL END AS sync_state" +
|
||||
" FROM folder" +
|
||||
" 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" +
|
||||
" WHERE account.synchronize" +
|
||||
" WHERE (account.id IS NULL OR account.synchronize)" +
|
||||
" AND folder.type <> '" + EntityFolder.SYSTEM + "'" +
|
||||
" AND folder.type <> '" + EntityFolder.USER + "'" +
|
||||
" GROUP BY folder.type")
|
||||
|
|
|
@ -19,8 +19,23 @@ package eu.faircode.email;
|
|||
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TupleFolderUnified {
|
||||
public String type;
|
||||
public int messages;
|
||||
public int unseen;
|
||||
public String sync_state;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TupleFolderUnified) {
|
||||
TupleFolderUnified other = (TupleFolderUnified) obj;
|
||||
return (Objects.equals(this.type, other.type) &&
|
||||
this.messages == other.messages &&
|
||||
this.unseen == other.unseen &&
|
||||
Objects.equals(this.sync_state, other.sync_state));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue