Allow hiding read-only subfolders

pull/210/head
M66B 2 years ago
parent c9bf0a966e
commit 72ffc19adb

@ -655,6 +655,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
(folder.selectable && (debug || BuildConfig.DEBUG)))
popupMenu.getMenu().add(Menu.NONE, R.string.title_export_messages, order++, R.string.title_export_messages);
if (!folder.selectable)
popupMenu.getMenu()
.add(Menu.NONE, R.string.title_hide_folder, order++, R.string.title_hide_folder)
.setCheckable(true)
.setChecked(folder.hide);
int childs = 0;
if (folder.child_refs != null)
for (TupleFolderEx child : folder.child_refs)
@ -769,6 +775,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
onActionDeleteChannel();
return true;
} else if (itemId == R.string.title_hide_folder) {
onActionHide();
return true;
} else if (itemId == R.string.title_create_sub_folder) {
onActionCreateFolder();
return true;
@ -1212,6 +1221,30 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
folder.deleteNotificationChannel(context);
}
private void onActionHide() {
Bundle args = new Bundle();
args.putLong("id", folder.id);
args.putBoolean("hide", !folder.hide);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
boolean hide = args.getBoolean("hide");
DB db = DB.getInstance(context);
db.folder().setFolderHide(id, hide);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "folder:hide");
}
private void onActionCreateFolder() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(

@ -411,6 +411,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET download = :download WHERE id = :id AND NOT (download IS :download)")
int setFolderDownload(long id, boolean download);
@Query("UPDATE folder SET hide = :hide WHERE id = :id AND NOT (hide IS :hide)")
int setFolderHide(long id, boolean hide);
@Query("UPDATE folder" +
" SET auto_classify_source = :source, auto_classify_target = :target" +
" WHERE id = :id" +

Loading…
Cancel
Save