mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Improved folder attribute evaluation
This commit is contained in:
parent
3b82b65999
commit
c3b501c7b8
3 changed files with 17 additions and 14 deletions
|
@ -101,8 +101,10 @@ public class EntityFolder implements Serializable {
|
|||
static final String SYSTEM = "System";
|
||||
static final String USER = "User";
|
||||
|
||||
// https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml
|
||||
static final List<String> SYSTEM_FOLDER_ATTR = Arrays.asList(
|
||||
"All",
|
||||
"Archive",
|
||||
"Drafts",
|
||||
"Trash",
|
||||
"Junk",
|
||||
|
@ -111,6 +113,7 @@ public class EntityFolder implements Serializable {
|
|||
"Flagged"
|
||||
);
|
||||
static final List<String> SYSTEM_FOLDER_TYPE = Arrays.asList(
|
||||
ARCHIVE,
|
||||
ARCHIVE,
|
||||
DRAFTS,
|
||||
TRASH,
|
||||
|
|
|
@ -478,11 +478,11 @@ public class FragmentAccount extends FragmentEx {
|
|||
result.idle = istore.hasCapability("IDLE");
|
||||
|
||||
for (Folder ifolder : istore.getDefaultFolder().list("*")) {
|
||||
// Check folder attributes
|
||||
String type = null;
|
||||
|
||||
// First check folder attributes
|
||||
boolean selectable = true;
|
||||
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
|
||||
Log.i(Helper.TAG, ifolder.getFullName() + " attrs=" + TextUtils.join(" ", attrs));
|
||||
for (String attr : attrs) {
|
||||
if ("\\Noselect".equals(attr))
|
||||
selectable = false;
|
||||
|
@ -496,17 +496,6 @@ public class FragmentAccount extends FragmentEx {
|
|||
}
|
||||
|
||||
if (selectable) {
|
||||
// Next check folder full name
|
||||
if (type == null) {
|
||||
String fullname = ifolder.getFullName();
|
||||
for (String attr : EntityFolder.SYSTEM_FOLDER_ATTR)
|
||||
if (attr.equals(fullname)) {
|
||||
int index = EntityFolder.SYSTEM_FOLDER_ATTR.indexOf(attr);
|
||||
type = EntityFolder.SYSTEM_FOLDER_TYPE.get(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create entry
|
||||
DB db = DB.getInstance(context);
|
||||
EntityFolder folder = db.folder().getFolderByName(id, ifolder.getFullName());
|
||||
|
|
|
@ -1908,11 +1908,20 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
Log.i(Helper.TAG, "Remote folder count=" + ifolders.length + " separator=" + separator);
|
||||
|
||||
for (Folder ifolder : ifolders) {
|
||||
String type = null;
|
||||
boolean selectable = true;
|
||||
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
|
||||
Log.i(Helper.TAG, ifolder.getFullName() + " attrs=" + TextUtils.join(" ", attrs));
|
||||
for (String attr : attrs) {
|
||||
if ("\\Noselect".equals(attr))
|
||||
selectable = false;
|
||||
if (attr.startsWith("\\")) {
|
||||
int index = EntityFolder.SYSTEM_FOLDER_ATTR.indexOf(attr.substring(1));
|
||||
if (index >= 0) {
|
||||
type = EntityFolder.SYSTEM_FOLDER_TYPE.get(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectable) {
|
||||
|
@ -1923,7 +1932,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
folder = new EntityFolder();
|
||||
folder.account = account.id;
|
||||
folder.name = fullName;
|
||||
folder.type = EntityFolder.USER;
|
||||
folder.type = (type == null ? EntityFolder.USER : type);
|
||||
folder.level = level;
|
||||
folder.synchronize = false;
|
||||
folder.poll = ("imap.gmail.com".equals(account.host));
|
||||
|
@ -1935,6 +1944,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) && type != null)
|
||||
db.folder().setFolderType(folder.id, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue