mirror of https://github.com/M66B/FairEmail.git
Fixed folder states
This commit is contained in:
parent
e970e54b6a
commit
794e05df64
|
@ -238,8 +238,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
|
||||
PopupMenu popupMenu = new PopupMenu(context, itemView);
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, action_synchronize_now, 1, R.string.title_synchronize_now)
|
||||
.setEnabled(folder.account != null || "connected".equals(folder.state) /* outbox */);
|
||||
popupMenu.getMenu().add(Menu.NONE, action_synchronize_now, 1, R.string.title_synchronize_now);
|
||||
|
||||
if (folder.account != null)
|
||||
popupMenu.getMenu().add(Menu.NONE, action_delete_local, 2, R.string.title_delete_local);
|
||||
|
@ -303,8 +302,11 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
boolean now;
|
||||
if (aid < 0) {
|
||||
// Outbox
|
||||
now = internet;
|
||||
EntityOperation.sync(context, db, fid);
|
||||
if (internet) {
|
||||
now = true;
|
||||
EntityOperation.sync(context, db, fid);
|
||||
} else
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_internet));
|
||||
} else {
|
||||
EntityAccount account = db.account().getAccount(aid);
|
||||
if (account.ondemand) {
|
||||
|
|
|
@ -50,7 +50,9 @@ public interface DaoFolder {
|
|||
" AND (:search OR (account.synchronize AND account.browse))")
|
||||
EntityFolder getBrowsableFolder(long folder, boolean search);
|
||||
|
||||
@Query("SELECT folder.*, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
|
||||
@Query("SELECT folder.*" +
|
||||
", account.name AS accountName, account.color AS accountColor" +
|
||||
", account.state AS accountState, account.ondemand AS accountOnDemand" +
|
||||
", COUNT(message.id) AS messages" +
|
||||
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
|
||||
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
|
||||
|
@ -64,7 +66,9 @@ public interface DaoFolder {
|
|||
" GROUP BY folder.id")
|
||||
LiveData<List<TupleFolderEx>> liveFolders(Long account);
|
||||
|
||||
@Query("SELECT folder.*, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
|
||||
@Query("SELECT folder.*" +
|
||||
", account.name AS accountName, account.color AS accountColor" +
|
||||
", account.state AS accountState, account.ondemand AS accountOnDemand" +
|
||||
", COUNT(message.id) AS messages" +
|
||||
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
|
||||
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
|
||||
|
@ -81,7 +85,9 @@ public interface DaoFolder {
|
|||
" WHERE `primary` AND type = '" + EntityFolder.DRAFTS + "'")
|
||||
LiveData<EntityFolder> livePrimaryDrafts();
|
||||
|
||||
@Query("SELECT folder.*, account.name AS accountName, account.color AS accountColor, account.state AS accountState" +
|
||||
@Query("SELECT folder.*" +
|
||||
", account.name AS accountName, account.color AS accountColor" +
|
||||
", account.state AS accountState, account.ondemand AS accountOnDemand" +
|
||||
", COUNT(message.id) AS messages" +
|
||||
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
|
||||
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
|
||||
|
|
|
@ -516,8 +516,11 @@ public class FragmentMessages extends FragmentBase {
|
|||
for (EntityFolder folder : folders)
|
||||
if (folder.account == null) {
|
||||
// Outbox
|
||||
now = internet;
|
||||
EntityOperation.sync(context, db, folder.id);
|
||||
if (internet) {
|
||||
now = true;
|
||||
EntityOperation.sync(context, db, folder.id);
|
||||
} else
|
||||
nointernet = true;
|
||||
} else {
|
||||
EntityAccount account = db.account().getAccount(folder.account);
|
||||
if (account.ondemand) {
|
||||
|
@ -1555,7 +1558,7 @@ public class FragmentMessages extends FragmentBase {
|
|||
|
||||
boolean refreshing = false;
|
||||
for (TupleFolderEx folder : folders)
|
||||
if (folder.sync_state != null && "connected".equals(folder.accountState)) {
|
||||
if (folder.isSynchronizing()) {
|
||||
refreshing = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1585,10 +1588,7 @@ public class FragmentMessages extends FragmentBase {
|
|||
}
|
||||
}
|
||||
|
||||
swipeRefresh.setRefreshing(
|
||||
folder != null && folder.sync_state != null &&
|
||||
"connected".equals(EntityFolder.OUTBOX.equals(folder.type)
|
||||
? folder.state : folder.accountState));
|
||||
swipeRefresh.setRefreshing(folder != null && folder.isSynchronizing());
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
|
|
@ -185,6 +185,7 @@ public class ServiceSend extends LifecycleService {
|
|||
Log.e(outbox.name, ex);
|
||||
db.folder().setFolderError(outbox.id, Helper.formatThrowable(ex, true));
|
||||
} finally {
|
||||
db.folder().setFolderState(outbox.id, null);
|
||||
db.folder().setFolderSyncState(outbox.id, null);
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -306,6 +306,9 @@ public class ServiceUI extends IntentService {
|
|||
}
|
||||
|
||||
public static void sync(Context context, long folder) {
|
||||
DB db = DB.getInstance(context);
|
||||
db.folder().setFolderSyncState(folder, "requested");
|
||||
|
||||
context.startService(
|
||||
new Intent(context, ServiceUI.class)
|
||||
.setAction("synchronize:" + folder));
|
||||
|
|
|
@ -25,10 +25,17 @@ public class TupleFolderEx extends EntityFolder {
|
|||
public String accountName;
|
||||
public Integer accountColor;
|
||||
public String accountState;
|
||||
public Boolean accountOnDemand;
|
||||
public int messages;
|
||||
public int content;
|
||||
public int unseen;
|
||||
|
||||
boolean isSynchronizing() {
|
||||
return (sync_state != null &&
|
||||
(EntityFolder.OUTBOX.equals(type) ||
|
||||
accountOnDemand || "connected".equals(accountState)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TupleFolderEx) {
|
||||
|
@ -37,6 +44,7 @@ public class TupleFolderEx extends EntityFolder {
|
|||
Objects.equals(accountName, other.accountName) &&
|
||||
Objects.equals(this.accountColor, other.accountColor) &&
|
||||
Objects.equals(accountState, other.accountState) &&
|
||||
Objects.equals(this.accountOnDemand, other.accountOnDemand) &&
|
||||
this.messages == other.messages &&
|
||||
this.content == other.content &&
|
||||
this.unseen == other.unseen);
|
||||
|
|
Loading…
Reference in New Issue