All child folders

pull/215/head
M66B 8 months ago
parent 433790bbd0
commit 7a066d774c

@ -708,11 +708,11 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
submenu.add(Menu.FIRST, R.string.title_notify_batch_disable, 5, R.string.title_notify_batch_disable); submenu.add(Menu.FIRST, R.string.title_notify_batch_disable, 5, R.string.title_notify_batch_disable);
submenu.add(Menu.FIRST, R.string.title_unified_inbox_add, 6, R.string.title_unified_inbox_add); submenu.add(Menu.FIRST, R.string.title_unified_inbox_add, 6, R.string.title_unified_inbox_add);
submenu.add(Menu.FIRST, R.string.title_unified_inbox_delete, 7, R.string.title_unified_inbox_delete); submenu.add(Menu.FIRST, R.string.title_unified_inbox_delete, 7, R.string.title_unified_inbox_delete);
submenu.add(Menu.FIRST, R.string.title_navigation_folder, 6, R.string.title_navigation_folder); submenu.add(Menu.FIRST, R.string.title_navigation_folder, 8, R.string.title_navigation_folder);
submenu.add(Menu.FIRST, R.string.title_navigation_folder_hide, 7, R.string.title_navigation_folder_hide); submenu.add(Menu.FIRST, R.string.title_navigation_folder_hide, 9, R.string.title_navigation_folder_hide);
submenu.add(Menu.FIRST, R.string.title_synchronize_more, 8, R.string.title_synchronize_more); submenu.add(Menu.FIRST, R.string.title_synchronize_more, 10, R.string.title_synchronize_more);
submenu.add(Menu.FIRST, R.string.title_download_batch_enable, 9, R.string.title_download_batch_enable); submenu.add(Menu.FIRST, R.string.title_download_batch_enable, 11, R.string.title_download_batch_enable);
submenu.add(Menu.FIRST, R.string.title_download_batch_disable, 10, R.string.title_download_batch_disable); submenu.add(Menu.FIRST, R.string.title_download_batch_disable, 12, R.string.title_download_batch_disable);
} }
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
@ -869,11 +869,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
EntityOperation.sync(context, folder.id, true, !children); EntityOperation.sync(context, folder.id, true, !children);
if (children) { if (children) {
List<EntityFolder> folders = db.folder().getChildFolders(folder.id); List<EntityFolder> folders = EntityFolder.getChildFolders(context, folder.id);
if (folders != null) for (EntityFolder child : folders)
for (EntityFolder child : folders) if (child.selectable)
if (child.selectable) EntityOperation.sync(context, child.id, true);
EntityOperation.sync(context, child.id, true);
} }
if (folder.account != null) { if (folder.account != null) {
@ -935,10 +934,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
return null;
List<EntityFolder> children = EntityFolder.getChildFolders(context, id);
for (EntityFolder child : children) for (EntityFolder child : children)
db.folder().setFolderSynchronize(child.id, enabled); db.folder().setFolderSynchronize(child.id, enabled);
@ -973,10 +970,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
return null;
List<EntityFolder> children = EntityFolder.getChildFolders(context, id);
for (EntityFolder child : children) for (EntityFolder child : children)
db.folder().setFolderNotify(child.id, enabled); db.folder().setFolderNotify(child.id, enabled);
@ -1009,10 +1004,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
return null;
List<EntityFolder> children = EntityFolder.getChildFolders(context, id);
for (EntityFolder child : children) for (EntityFolder child : children)
db.folder().setFolderUnified(child.id, add); db.folder().setFolderUnified(child.id, add);
@ -1045,10 +1038,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
return null;
List<EntityFolder> children = EntityFolder.getChildFolders(context, id);
for (EntityFolder child : children) for (EntityFolder child : children)
db.folder().setFolderNavigation(child.id, enabled); db.folder().setFolderNavigation(child.id, enabled);
@ -1092,10 +1083,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
return null;
List<EntityFolder> children = EntityFolder.getChildFolders(context, id);
for (EntityFolder child : children) for (EntityFolder child : children)
db.folder().setFolderDownload(child.id, enabled); db.folder().setFolderDownload(child.id, enabled);

@ -415,6 +415,16 @@ public class EntityFolder extends EntityOrder implements Serializable {
return outbox; return outbox;
} }
static List<EntityFolder> getChildFolders(Context context, long id) {
DB db = DB.getInstance(context);
List<EntityFolder> children = db.folder().getChildFolders(id);
if (children == null)
children = new ArrayList<>();
for (EntityFolder child : new ArrayList<>(children))
children.addAll(getChildFolders(context, child.id));
return children;
}
static String getNotificationChannelId(long id) { static String getNotificationChannelId(long id) {
return "notification.folder." + id; return "notification.folder." + id;
} }

@ -110,9 +110,8 @@ public class FragmentDialogSync extends FragmentDialogBase {
folders.add(folder); folders.add(folder);
if (children) { if (children) {
List<EntityFolder> sub = db.folder().getChildFolders(folder.id); List<EntityFolder> sub = EntityFolder.getChildFolders(context, folder.id);
if (sub != null) folders.addAll(sub);
folders.addAll(sub);
} }
} }

Loading…
Cancel
Save