From 713978a2ae3a56688ab086041a62f03df7c12ad8 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 19 Oct 2019 20:22:47 +0200 Subject: [PATCH] Added batch folder poll --- app/src/main/java/eu/faircode/email/DaoFolder.java | 7 ++++--- .../main/java/eu/faircode/email/FragmentFolders.java | 8 +++++++- app/src/main/res/layout/dialog_folder_all.xml | 11 ++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java index 98e967ccd5..55f16c7813 100644 --- a/app/src/main/java/eu/faircode/email/DaoFolder.java +++ b/app/src/main/java/eu/faircode/email/DaoFolder.java @@ -264,11 +264,12 @@ public interface DaoFolder { int sync_days, int keep_days, boolean auto_delete); @Query("UPDATE folder" + - " SET `sync_days` = :sync_days" + - ", `keep_days` = :keep_days" + + " SET poll = :poll" + + ", sync_days = :sync_days" + + ", keep_days = :keep_days" + " WHERE account = :account" + " AND type = '" + EntityFolder.USER + "'") - int setFolderProperties(long account, int sync_days, int keep_days); + int setFolderProperties(long account, boolean poll, int sync_days, int keep_days); @Query("UPDATE folder SET keywords = :keywords WHERE id = :id") int setFolderKeywords(long id, String keywords); diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index 70ccbd9d02..ffe28833b2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -622,6 +622,7 @@ public class FragmentFolders extends FragmentBase { @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_folder_all, null); + final CheckBox cbPoll = view.findViewById(R.id.cbPoll); final EditText etSyncDays = view.findViewById(R.id.etSyncDays); final EditText etKeepDays = view.findViewById(R.id.etKeepDays); final CheckBox cbKeepAll = view.findViewById(R.id.cbKeepAll); @@ -639,6 +640,7 @@ public class FragmentFolders extends FragmentBase { @Override public void onClick(DialogInterface dialog, int which) { Bundle args = getArguments(); + args.putBoolean("poll", cbPoll.isChecked()); args.putString("sync", etSyncDays.getText().toString()); args.putString("keep", cbKeepAll.isChecked() ? Integer.toString(Integer.MAX_VALUE) @@ -648,6 +650,7 @@ public class FragmentFolders extends FragmentBase { @Override protected Void onExecute(Context context, Bundle args) throws Throwable { long account = args.getLong("account"); + boolean poll = args.getBoolean("poll"); String sync = args.getString("sync"); String keep = args.getString("keep"); @@ -658,7 +661,10 @@ public class FragmentFolders extends FragmentBase { DB db = DB.getInstance(context); db.folder().setFolderProperties( - account, Integer.parseInt(sync), Integer.parseInt(keep)); + account, + poll, + Integer.parseInt(sync), + Integer.parseInt(keep)); return null; } diff --git a/app/src/main/res/layout/dialog_folder_all.xml b/app/src/main/res/layout/dialog_folder_all.xml index d95e472134..c3c0f5a5a5 100644 --- a/app/src/main/res/layout/dialog_folder_all.xml +++ b/app/src/main/res/layout/dialog_folder_all.xml @@ -25,6 +25,15 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvCaption" /> + + + app:layout_constraintTop_toBottomOf="@id/cbPoll" />