Added menu item to show/hide child folders in the nav menu

pull/209/head
M66B 2 years ago
parent ea38516978
commit 0e9eb66491

@ -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);

@ -1146,6 +1146,7 @@
<string name="title_hide_seen_folder_hint">Only in the folder list shown on the start screen</string>
<string name="title_unified_folder">Show in unified inbox</string>
<string name="title_navigation_folder">Show in navigation menu</string>
<string name="title_navigation_folder_hide">Hide in navigation menu</string>
<string name="title_synchronize_folder">Synchronize (receive messages)</string>
<string name="title_poll_folder">Check periodically instead of continuous synchronize</string>
<string name="title_poll_folder_remark">Most email servers allow push messages for a handful of folders only!</string>

Loading…
Cancel
Save