mirror of https://github.com/M66B/FairEmail.git
Handled inbox sub folders
This commit is contained in:
parent
d243222f51
commit
14bc4bd7b6
|
@ -40,12 +40,8 @@ import android.widget.TextView;
|
|||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
|
@ -392,37 +388,23 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
set(account, all);
|
||||
}
|
||||
|
||||
public void set(long account, @NonNull List<TupleFolderEx> folders) {
|
||||
Log.i(Helper.TAG, "Set account=" + account + " folders=" + folders.size());
|
||||
public void set(long account, @NonNull List<TupleFolderEx> _folders) {
|
||||
Log.i(Helper.TAG, "Set account=" + account + " folders=" + _folders.size());
|
||||
|
||||
this.account = account;
|
||||
|
||||
final Collator collator = Collator.getInstance(Locale.getDefault());
|
||||
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
||||
List<EntityFolder> folders = new ArrayList<>();
|
||||
folders.addAll(_folders);
|
||||
EntityFolder.sort(folders);
|
||||
|
||||
Collections.sort(folders, new Comparator<TupleFolderEx>() {
|
||||
@Override
|
||||
public int compare(TupleFolderEx f1, TupleFolderEx f2) {
|
||||
int s = Integer.compare(
|
||||
EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type),
|
||||
EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type));
|
||||
if (s != 0)
|
||||
return s;
|
||||
int c = -f1.synchronize.compareTo(f2.synchronize);
|
||||
if (c != 0)
|
||||
return c;
|
||||
return collator.compare(
|
||||
f1.name == null ? "" : f1.name,
|
||||
f2.name == null ? "" : f2.name);
|
||||
}
|
||||
});
|
||||
|
||||
all = folders;
|
||||
all.clear();
|
||||
for (EntityFolder folder : folders)
|
||||
all.add((TupleFolderEx) folder);
|
||||
|
||||
List<TupleFolderEx> shown = new ArrayList<>();
|
||||
for (TupleFolderEx folder : folders)
|
||||
for (EntityFolder folder : folders)
|
||||
if (!folder.hide || showAll)
|
||||
shown.add(folder);
|
||||
shown.add((TupleFolderEx) folder);
|
||||
|
||||
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new MessageDiffCallback(filtered, shown));
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ public class EntityFolder implements Serializable {
|
|||
public String error;
|
||||
|
||||
static final String INBOX = "Inbox";
|
||||
static final String INBOX_SUB = "Inbox_sub";
|
||||
static final String OUTBOX = "Outbox";
|
||||
static final String ARCHIVE = "All";
|
||||
static final String DRAFTS = "Drafts";
|
||||
|
@ -125,6 +126,7 @@ public class EntityFolder implements Serializable {
|
|||
|
||||
static final List<String> FOLDER_SORT_ORDER = Arrays.asList(
|
||||
INBOX,
|
||||
INBOX_SUB,
|
||||
OUTBOX,
|
||||
DRAFTS,
|
||||
SENT,
|
||||
|
@ -265,9 +267,9 @@ public class EntityFolder implements Serializable {
|
|||
Collections.sort(folders, new Comparator<EntityFolder>() {
|
||||
@Override
|
||||
public int compare(EntityFolder f1, EntityFolder f2) {
|
||||
int s = Integer.compare(
|
||||
EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type),
|
||||
EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type));
|
||||
int i1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
|
||||
int i2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);
|
||||
int s = Integer.compare(i1, i2);
|
||||
if (s != 0)
|
||||
return s;
|
||||
int c = -f1.synchronize.compareTo(f2.synchronize);
|
||||
|
|
|
@ -1941,6 +1941,12 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
}
|
||||
}
|
||||
|
||||
// Special case
|
||||
if (type == null) {
|
||||
if (ifolder.getFullName().startsWith("INBOX" /*+ separator*/))
|
||||
type = EntityFolder.INBOX_SUB;
|
||||
}
|
||||
|
||||
if (selectable) {
|
||||
String fullName = ifolder.getFullName();
|
||||
int level = EntityFolder.getLevel(separator, fullName);
|
||||
|
@ -1961,7 +1967,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
names.remove(folder.name);
|
||||
Log.i(Helper.TAG, folder.name + " exists");
|
||||
db.folder().setFolderLevel(folder.id, level);
|
||||
if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type))
|
||||
if (EntityFolder.USER.equals(folder.type) &&
|
||||
(EntityFolder.INBOX_SUB.equals(type) || EntityFolder.SYSTEM.equals(type)))
|
||||
db.folder().setFolderType(folder.id, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,6 +220,7 @@
|
|||
|
||||
<string name="title_folder_unified">Unified inbox</string>
|
||||
<string name="title_folder_inbox">Inbox</string>
|
||||
<string name="title_folder_inbox_sub">Inbox child</string>
|
||||
<string name="title_folder_outbox">Outbox</string>
|
||||
<string name="title_folder_all">Archive</string>
|
||||
<string name="title_folder_drafts">Drafts</string>
|
||||
|
|
Loading…
Reference in New Issue