mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 14:17:03 +02:00
Added menu item to show/hide child folders in the nav menu
This commit is contained in:
@@ -662,7 +662,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
submenu.add(Menu.FIRST, R.string.title_synchronize_batch_disable, 3, R.string.title_synchronize_batch_disable);
|
||||
submenu.add(Menu.FIRST, R.string.title_notify_batch_enable, 4, R.string.title_notify_batch_enable);
|
||||
submenu.add(Menu.FIRST, R.string.title_notify_batch_disable, 5, R.string.title_notify_batch_disable);
|
||||
submenu.add(Menu.FIRST, R.string.title_synchronize_more, 6, R.string.title_synchronize_more);
|
||||
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);
|
||||
}
|
||||
|
||||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
|
||||
@@ -695,6 +697,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
} else if (itemId == R.string.title_notify_batch_disable) {
|
||||
onActionEnableNotify(false);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_navigation_folder) {
|
||||
onActionEnableNavigationMenu(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_navigation_folder_hide) {
|
||||
onActionEnableNavigationMenu(false);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_synchronize_more) {
|
||||
onActionSyncMore(true);
|
||||
return true;
|
||||
@@ -921,6 +929,42 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
}.execute(context, owner, args, "enable");
|
||||
}
|
||||
|
||||
private void onActionEnableNavigationMenu(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> childs = db.folder().getChildFolders(id);
|
||||
if (childs == null)
|
||||
return null;
|
||||
|
||||
for (EntityFolder child : childs)
|
||||
db.folder().setFolderNavigation(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, "enable");
|
||||
}
|
||||
|
||||
private void onActionSyncMore(boolean children) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder.id);
|
||||
|
||||
Reference in New Issue
Block a user