Browse Source

Allow swipe if target folders exists only

main
M66B 6 years ago
parent
commit
feba289478
5 changed files with 39 additions and 13 deletions
  1. +3
    -3
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +7
    -3
      app/src/main/java/eu/faircode/email/DaoFolder.java
  3. +1
    -3
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  4. +28
    -3
      app/src/main/java/eu/faircode/email/FragmentMessages.java
  5. +0
    -1
      app/src/main/res/values/strings.xml

+ 3
- 3
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -357,7 +357,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
pbBody.setVisibility(View.GONE);
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
db.folder().liveFolders(message.account).removeObservers(owner);
db.folder().liveSystemFolders(message.account).removeObservers(owner);
db.attachment().liveAttachments(message.id).removeObservers(owner);
bnvActions.setTag(null);
@ -391,9 +391,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
if (!EntityFolder.OUTBOX.equals(message.folderType)) {
bnvActions.setHasTransientState(true);
db.folder().liveFolders(message.account).observe(owner, new Observer<List<TupleFolderEx>>() {
db.folder().liveSystemFolders(message.account).observe(owner, new Observer<List<EntityFolder>>() {
@Override
public void onChanged(@Nullable List<TupleFolderEx> folders) {
public void onChanged(@Nullable List<EntityFolder> folders) {
if (bnvActions.hasTransientState()) {
boolean hasJunk = false;
boolean hasTrash = false;


+ 7
- 3
app/src/main/java/eu/faircode/email/DaoFolder.java View File

@ -55,6 +55,11 @@ public interface DaoFolder {
" GROUP BY folder.id")
LiveData<List<TupleFolderEx>> liveFolders(long account);
@Query("SELECT * FROM folder" +
" WHERE (:account < 0 OR folder.account = :account)" +
" AND type <> '" + EntityFolder.USER + "'")
LiveData<List<EntityFolder>> liveSystemFolders(long account);
@Query("SELECT folder.*, account.name AS accountName" +
", COUNT(message.id) AS messages" +
", SUM(CASE WHEN message.content = 1 THEN 1 ELSE 0 END) AS content" +
@ -118,9 +123,8 @@ public interface DaoFolder {
@Query("UPDATE folder" +
" SET type = '" + EntityFolder.USER + "'" +
" WHERE account = :account" +
" AND type = :type")
int setFolderUser(long account, String type);
" WHERE account = :account")
int setFoldersUser(long account);
@Query("UPDATE folder" +
" SET name = :name" +


+ 1
- 3
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -628,8 +628,6 @@ public class FragmentAccount extends FragmentEx {
interval = "9";
if (synchronize && drafts == null)
throw new Throwable(getContext().getString(R.string.title_no_drafts));
if (synchronize && trash == null)
throw new Throwable(getContext().getString(R.string.title_no_trash));
if (Color.TRANSPARENT == color)
color = null;
@ -731,8 +729,8 @@ public class FragmentAccount extends FragmentEx {
folders.add(junk);
}
db.folder().setFoldersUser(account.id);
for (EntityFolder folder : folders) {
db.folder().setFolderUser(account.id, folder.type);
EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
if (existing == null) {
folder.account = account.id;


+ 28
- 3
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -88,6 +88,8 @@ public class FragmentMessages extends FragmentEx {
private long primary = -1;
private boolean connected = false;
private AdapterMessage adapter;
private List<Long> archives = new ArrayList<>();
private List<Long> trashes = new ArrayList<>();
private AdapterMessage.ViewType viewType;
private LiveData<PagedList<TupleMessageEx>> messages = null;
@ -242,7 +244,13 @@ public class FragmentMessages extends FragmentEx {
EntityFolder.OUTBOX.equals(message.folderType))
return 0;
return makeMovementFlags(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
int flags = 0;
if (archives.contains(message.account))
flags |= ItemTouchHelper.RIGHT;
if (trashes.contains(message.account))
flags |= ItemTouchHelper.LEFT;
return makeMovementFlags(0, flags);
}
@Override
@ -583,8 +591,25 @@ public class FragmentMessages extends FragmentEx {
break;
}
// Messages
loadMessages();
// Folders and messages
db.folder().liveSystemFolders(account).observe(getViewLifecycleOwner(), new Observer<List<EntityFolder>>() {
@Override
public void onChanged(List<EntityFolder> folders) {
if (folders == null)
folders = new ArrayList<>();
archives.clear();
trashes.clear();
for (EntityFolder folder : folders)
if (EntityFolder.ARCHIVE.equals(folder.type))
archives.add(folder.account);
else if (EntityFolder.TRASH.equals(folder.type))
trashes.add(folder.account);
loadMessages();
}
});
if (viewType == AdapterMessage.ViewType.THREAD) {
// Navigation


+ 0
- 1
app/src/main/res/values/strings.xml View File

@ -126,7 +126,6 @@
<string name="title_no_user">User name missing</string>
<string name="title_no_password">Password missing</string>
<string name="title_no_drafts">No drafts folder selected</string>
<string name="title_no_trash">No trash folder selected</string>
<string name="title_no_primary_drafts">No primary account or no drafts folder</string>
<string name="title_no_primary_archive">No primary account or no archive folder</string>
<string name="title_no_idle">This provider does not support push messages. Reception of new messages can be delayed.</string>


Loading…
Cancel
Save