Process inferiors

pull/174/head
M66B 5 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) 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() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override

@ -1297,14 +1297,26 @@ class Core {
Map<String, List<EntityFolder>> parentFolders = new HashMap<>(); Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
for (Folder ifolder : ifolders) { for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName(); String fullName = ifolder.getFullName();
String[] attr = ((IMAPFolder) ifolder).getAttributes(); String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attr, fullName, false); String type = EntityFolder.getType(attrs, fullName, false);
boolean subscribed = subscription.contains(fullName); 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 + boolean selectable = true;
" type=" + type + " attrs=" + TextUtils.join(" ", attr)); 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) { if (type != null) {
local.remove(fullName); local.remove(fullName);
@ -1325,6 +1337,7 @@ class Core {
folder.sync_days = EntityFolder.DEFAULT_SYNC; folder.sync_days = EntityFolder.DEFAULT_SYNC;
folder.keep_days = EntityFolder.DEFAULT_KEEP; folder.keep_days = EntityFolder.DEFAULT_KEEP;
folder.selectable = selectable; folder.selectable = selectable;
folder.inferiors = inferiors;
folder.id = db.folder().insertFolder(folder); folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type); Log.i(folder.name + " added type=" + folder.type);
} else { } else {
@ -1336,6 +1349,9 @@ class Core {
if (folder.selectable != selectable) if (folder.selectable != selectable)
db.folder().setFolderSelectable(folder.id, selectable); db.folder().setFolderSelectable(folder.id, selectable);
if (folder.inferiors != inferiors)
db.folder().setFolderInferiors(folder.id, inferiors);
// Compatibility // Compatibility
if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type)) if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type))
db.folder().setFolderType(folder.id, 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 // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 143, version = 144,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -1379,6 +1379,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `operation` ADD COLUMN `tries` INTEGER NOT NULL DEFAULT 0"); 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") @Query("UPDATE folder SET selectable = :selectable WHERE id = :id")
int setFolderSelectable(long id, Boolean selectable); 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") @Query("UPDATE folder SET type = :type WHERE id = :id")
int setFolderType(long id, String type); int setFolderType(long id, String type);

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

Loading…
Cancel
Save