From 958982481dc2146aadfe274342e4a83879ba8598 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 22 Jul 2019 14:42:03 +0200 Subject: [PATCH] Allow refreshing unified system folders --- app/src/main/java/eu/faircode/email/DaoFolder.java | 5 +++-- app/src/main/java/eu/faircode/email/FragmentFolders.java | 2 +- app/src/main/java/eu/faircode/email/FragmentMessages.java | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoFolder.java b/app/src/main/java/eu/faircode/email/DaoFolder.java index 3dbec90685..e84b9ee4a8 100644 --- a/app/src/main/java/eu/faircode/email/DaoFolder.java +++ b/app/src/main/java/eu/faircode/email/DaoFolder.java @@ -53,8 +53,9 @@ public interface DaoFolder { @Query("SELECT folder.* FROM folder" + " JOIN account ON account.id = folder.account" + " WHERE account.synchronize" + - " AND folder.synchronize AND unified") - List getFoldersSynchronizingUnified(); + " AND folder.synchronize" + + " AND ((:type IS NULL AND folder.unified) OR folder.type = :type)") + List getFoldersSynchronizingUnified(String type); @Query("SELECT folder.* FROM folder" + " JOIN account ON account.id = folder.account" + diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index b52a73552d..61d074d0b2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -317,7 +317,7 @@ public class FragmentFolders extends FragmentBase { if (aid < 0) { // Unified inbox - List folders = db.folder().getFoldersSynchronizingUnified(); + List folders = db.folder().getFoldersSynchronizingUnified(null); for (EntityFolder folder : folders) { EntityOperation.sync(context, folder.id, true); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index d381c68c43..550fc93019 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -903,8 +903,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. swipeRefresh.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() { @Override public boolean canChildScrollUp(@NonNull SwipeRefreshLayout parent, @Nullable View child) { - if (type != null) - return true; if (viewType != AdapterMessage.ViewType.UNIFIED && viewType != AdapterMessage.ViewType.FOLDER) return true; if (!prefs.getBoolean("pull", true)) @@ -988,6 +986,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private void onSwipeRefresh() { Bundle args = new Bundle(); args.putLong("folder", folder); + args.putString("type", type); new SimpleTask() { @Override @@ -998,6 +997,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. @Override protected Void onExecute(Context context, Bundle args) { long fid = args.getLong("folder"); + String type = args.getString("type"); if (!ConnectionHelper.getNetworkState(context).isSuitable()) throw new IllegalStateException(context.getString(R.string.title_no_internet)); @@ -1010,7 +1010,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. List folders = new ArrayList<>(); if (fid < 0) - folders.addAll(db.folder().getFoldersSynchronizingUnified()); + folders.addAll(db.folder().getFoldersSynchronizingUnified(type)); else { EntityFolder folder = db.folder().getFolder(fid); if (folder != null)