mirror of https://github.com/M66B/FairEmail.git
Added menu items to enable/disable child folder new message notifications
This commit is contained in:
parent
85066b95e5
commit
45db3c29b5
|
@ -590,6 +590,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
submenu.add(Menu.FIRST, R.string.title_synchronize_now, 1, R.string.title_synchronize_now);
|
||||
submenu.add(Menu.FIRST, R.string.title_synchronize_batch_enable, 2, R.string.title_synchronize_batch_enable);
|
||||
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);
|
||||
}
|
||||
|
||||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
|
||||
|
@ -612,10 +614,16 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
onActionSync(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_synchronize_batch_enable) {
|
||||
onActionEnable(true);
|
||||
onActionEnableSync(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_synchronize_batch_disable) {
|
||||
onActionEnable(false);
|
||||
onActionEnableSync(false);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_notify_batch_enable) {
|
||||
onActionEnableNotify(true);
|
||||
return true;
|
||||
} else if (itemId == R.string.title_notify_batch_disable) {
|
||||
onActionEnableNotify(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -764,7 +772,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}.execute(context, owner, args, "folder:sync");
|
||||
}
|
||||
|
||||
private void onActionEnable(boolean enabled) {
|
||||
private void onActionEnableSync(boolean enabled) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", folder.id);
|
||||
args.putLong("account", folder.account);
|
||||
|
@ -804,6 +812,42 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}.execute(context, owner, args, "enable");
|
||||
}
|
||||
|
||||
private void onActionEnableNotify(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().setFolderNotify(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() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("folder", folder.id);
|
||||
|
|
|
@ -840,6 +840,8 @@
|
|||
<string name="title_synchronize_enabled">Synchronize</string>
|
||||
<string name="title_synchronize_batch_enable">Enable synchronization</string>
|
||||
<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_delete_local">Delete local messages</string>
|
||||
<string name="title_delete_browsed">Delete browsed/searched messages</string>
|
||||
<string name="title_empty_trash">Empty trash</string>
|
||||
|
|
Loading…
Reference in New Issue