mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 05:44:51 +02:00
Added menu items to enable/disable downloads for child folders
This commit is contained in:
@@ -681,6 +681,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
submenu.add(Menu.FIRST, R.string.title_navigation_folder, 6, 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_synchronize_more, 8, 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_disable, 10, R.string.title_download_batch_disable);
|
||||
}
|
||||
|
||||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
|
||||
@@ -728,6 +730,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
} else if (itemId == R.string.title_synchronize_more) {
|
||||
onActionSyncMore(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_download_batch_enable) {
|
||||
onActionEnableDownload(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_download_batch_disable) {
|
||||
onActionEnableDownload(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1037,6 +1045,42 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
sync.show(parentFragment.getParentFragmentManager(), "folder:months");
|
||||
}
|
||||
|
||||
private void onActionEnableDownload(boolean enabled) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", folder.id);
|
||||
args.putBoolean("enabled", enabled);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
||||
long id = args.getLong("id");
|
||||
boolean enabled = args.getBoolean("enabled");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
List<EntityFolder> children = db.folder().getChildFolders(id);
|
||||
if (children == null)
|
||||
return null;
|
||||
|
||||
for (EntityFolder child : children)
|
||||
db.folder().setFolderDownload(child.id, enabled);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(context, owner, args, "children:download");
|
||||
}
|
||||
|
||||
private void onActionProperty(int property, boolean enabled) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", folder.id);
|
||||
|
||||
@@ -1251,6 +1251,8 @@
|
||||
<string name="title_synchronize_batch_disable">Disable synchronization</string>
|
||||
<string name="title_notify_batch_enable">Enable new message notifications</string>
|
||||
<string name="title_notify_batch_disable">Disable new message notifications</string>
|
||||
<string name="title_download_batch_enable">Download texts and attachments</string>
|
||||
<string name="title_download_batch_disable">Download headers only</string>
|
||||
<string name="title_delete_local">Delete local messages</string>
|
||||
<string name="title_delete_browsed">Delete browsed/searched messages</string>
|
||||
<string name="title_expunge">Expunge</string>
|
||||
|
||||
Reference in New Issue
Block a user