Process inferiors

pull/174/head
M66B 4 years ago
parent 70250dcc08
commit 54746fa785

File diff suppressed because it is too large Load Diff

@ -471,7 +471,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
popupMenu.getMenu().add(Menu.NONE, R.string.title_create_sub_folder, 16, R.string.title_create_sub_folder);
popupMenu.getMenu().add(Menu.NONE, R.string.title_create_sub_folder, 16, R.string.title_create_sub_folder)
.setEnabled(folder.inferiors);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override

@ -1297,14 +1297,26 @@ class Core {
Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName();
String[] attr = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attr, fullName, false);
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attrs, fullName, false);
boolean subscribed = subscription.contains(fullName);
boolean selectable = !Arrays.asList(attr).contains("\\Noselect") &&
((ifolder.getType() & IMAPFolder.HOLDS_MESSAGES) != 0);
Log.i(account.name + ":" + fullName + " subscribed=" + subscribed +
" type=" + type + " attrs=" + TextUtils.join(" ", attr));
boolean selectable = true;
boolean inferiors = true;
for (String attr : attrs) {
if (attr.equalsIgnoreCase("\\NoSelect"))
selectable = false;
if (attr.equalsIgnoreCase("\\NoInferiors"))
inferiors = false;
}
selectable = selectable && ((ifolder.getType() & IMAPFolder.HOLDS_MESSAGES) != 0);
inferiors = inferiors && ((ifolder.getType() & IMAPFolder.HOLDS_FOLDERS) != 0);
Log.i(account.name + ":" + fullName + " type=" + type +
" subscribed=" + subscribed +
" selectable=" + selectable +
" inferiors=" + inferiors +
" attrs=" + TextUtils.join(" ", attrs));
if (type != null) {
local.remove(fullName);
@ -1325,6 +1337,7 @@ class Core {
folder.sync_days = EntityFolder.DEFAULT_SYNC;
folder.keep_days = EntityFolder.DEFAULT_KEEP;
folder.selectable = selectable;
folder.inferiors = inferiors;
folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type);
} else {
@ -1336,6 +1349,9 @@ class Core {
if (folder.selectable != selectable)
db.folder().setFolderSelectable(folder.id, selectable);
if (folder.inferiors != inferiors)
db.folder().setFolderInferiors(folder.id, inferiors);
// Compatibility
if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type))
db.folder().setFolderType(folder.id, type);

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 143,
version = 144,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1379,6 +1379,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `operation` ADD COLUMN `tries` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(143, 144) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `inferiors` INTEGER NOT NULL DEFAULT 1");
}
});
}

@ -233,6 +233,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET selectable = :selectable WHERE id = :id")
int setFolderSelectable(long id, Boolean selectable);
@Query("UPDATE folder SET inferiors = :inferiors WHERE id = :id")
int setFolderInferiors(long id, Boolean inferiors);
@Query("UPDATE folder SET type = :type WHERE id = :id")
int setFolderType(long id, String type);

@ -113,6 +113,8 @@ public class EntityFolder extends EntityOrder implements Serializable {
public Boolean read_only = false;
@NonNull
public Boolean selectable = true;
@NonNull
public Boolean inferiors = true;
public String error;
public Long last_sync;
@ -129,14 +131,14 @@ public class EntityFolder extends EntityOrder implements Serializable {
// https://tools.ietf.org/html/rfc6154
// https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml
private static final List<String> SYSTEM_FOLDER_ATTR = Collections.unmodifiableList(Arrays.asList(
"All",
"Archive",
"Drafts",
"Trash",
"Junk",
"Sent",
"Important",
"Flagged"
"all",
"archive",
"drafts",
"trash",
"junk",
"sent",
"important",
"flagged"
));
private static final List<String> SYSTEM_FOLDER_TYPE = Collections.unmodifiableList(Arrays.asList(
ARCHIVE, // All
@ -293,11 +295,11 @@ public class EntityFolder extends EntityOrder implements Serializable {
// https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml
for (String attr : attrs) {
if ((selectable && "\\Noselect".equals(attr)) || "\\NonExistent".equals(attr))
if ((selectable && "\\NoSelect".equalsIgnoreCase(attr)) || "\\NonExistent".equalsIgnoreCase(attr))
return null;
if (attr.startsWith("\\")) {
int index = SYSTEM_FOLDER_ATTR.indexOf(attr.substring(1));
int index = SYSTEM_FOLDER_ATTR.indexOf(attr.substring(1).toLowerCase());
if (index >= 0)
return SYSTEM_FOLDER_TYPE.get(index);
}

Loading…
Cancel
Save