Browse Source

Folder checks

main
M66B 6 years ago
parent
commit
157b37144d
4 changed files with 38 additions and 17 deletions
  1. +28
    -7
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +1
    -1
      app/src/main/java/eu/faircode/email/FragmentCompose.java
  3. +8
    -9
      app/src/main/java/eu/faircode/email/FragmentMessages.java
  4. +1
    -0
      app/src/main/res/values/strings.xml

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

@ -394,13 +394,16 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
@Override @Override
public void onChanged(@Nullable List<TupleFolderEx> folders) { public void onChanged(@Nullable List<TupleFolderEx> folders) {
if (bnvActions.hasTransientState()) { if (bnvActions.hasTransientState()) {
boolean hasJunk = false;
boolean hasTrash = false; boolean hasTrash = false;
boolean hasArchive = false; boolean hasArchive = false;
boolean hasUser = false; boolean hasUser = false;
if (folders != null) if (folders != null)
for (EntityFolder folder : folders) { for (EntityFolder folder : folders) {
if (EntityFolder.TRASH.equals(folder.type))
if (EntityFolder.JUNK.equals(folder.type))
hasJunk = true;
else if (EntityFolder.TRASH.equals(folder.type))
hasTrash = true; hasTrash = true;
else if (EntityFolder.ARCHIVE.equals(folder.type)) else if (EntityFolder.ARCHIVE.equals(folder.type))
hasArchive = true; hasArchive = true;
@ -414,6 +417,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
boolean inTrash = EntityFolder.TRASH.equals(message.folderType); boolean inTrash = EntityFolder.TRASH.equals(message.folderType);
ActionData data = new ActionData(); ActionData data = new ActionData();
data.hasJunk = hasJunk;
data.delete = (inTrash || !hasTrash || inOutbox); data.delete = (inTrash || !hasTrash || inOutbox);
data.message = message; data.message = message;
bnvActions.setTag(data); bnvActions.setTag(data);
@ -421,7 +425,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
bnvActions.getMenu().findItem(R.id.action_delete).setVisible((message.uid != null && hasTrash) || (inOutbox && !TextUtils.isEmpty(message.error))); bnvActions.getMenu().findItem(R.id.action_delete).setVisible((message.uid != null && hasTrash) || (inOutbox && !TextUtils.isEmpty(message.error)));
bnvActions.getMenu().findItem(R.id.action_move).setVisible(message.uid != null && (!inInbox || hasUser)); bnvActions.getMenu().findItem(R.id.action_move).setVisible(message.uid != null && (!inInbox || hasUser));
bnvActions.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inArchive && hasArchive); bnvActions.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inArchive && hasArchive);
bnvActions.getMenu().findItem(R.id.action_reply).setVisible(message.content && !inOutbox);
bnvActions.getMenu().findItem(R.id.action_reply).setEnabled(message.content);
bnvActions.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox);
bnvActions.setVisibility(View.VISIBLE); bnvActions.setVisibility(View.VISIBLE);
vSeparatorBody.setVisibility(View.GONE); vSeparatorBody.setVisibility(View.GONE);
@ -758,6 +764,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
} }
private class ActionData { private class ActionData {
boolean hasJunk;
boolean delete; boolean delete;
TupleMessageEx message; TupleMessageEx message;
} }
@ -1033,12 +1040,26 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
View anchor = bnvActions.findViewById(R.id.action_more); View anchor = bnvActions.findViewById(R.id.action_more);
PopupMenu popupMenu = new PopupMenu(context, anchor); PopupMenu popupMenu = new PopupMenu(context, anchor);
popupMenu.inflate(R.menu.menu_message); popupMenu.inflate(R.menu.menu_message);
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(data.message.content && !inOutbox);
popupMenu.getMenu().findItem(R.id.menu_junk).setVisible(data.message.uid != null && data.hasJunk && !inOutbox);
popupMenu.getMenu().findItem(R.id.menu_forward).setEnabled(data.message.content);
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(!inOutbox);
popupMenu.getMenu().findItem(R.id.menu_reply_all).setEnabled(data.message.content);
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(!inOutbox);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers); popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(data.message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(data.message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_show_html).setEnabled(data.message.content && Helper.classExists("android.webkit.WebView")); popupMenu.getMenu().findItem(R.id.menu_show_html).setEnabled(data.message.content && Helper.classExists("android.webkit.WebView"));
popupMenu.getMenu().findItem(R.id.menu_flag).setChecked(data.message.uid != null && data.message.unflagged != 1);
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(data.message.content && !inOutbox);
popupMenu.getMenu().findItem(R.id.menu_flag).setChecked(data.message.unflagged != 1);
popupMenu.getMenu().findItem(R.id.menu_flag).setVisible(data.message.uid != null && !inOutbox);
popupMenu.getMenu().findItem(R.id.menu_unseen).setVisible(data.message.uid != null && !inOutbox);
popupMenu.getMenu().findItem(R.id.menu_answer).setEnabled(data.message.content);
popupMenu.getMenu().findItem(R.id.menu_answer).setVisible(!inOutbox);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
@ -1202,7 +1223,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
folders.add(0, sent); folders.add(0, sent);
EntityFolder inbox = db.folder().getFolderByType(message.account, EntityFolder.INBOX); EntityFolder inbox = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
if (!message.folder.equals(inbox.id))
if (inbox != null && !message.folder.equals(inbox.id))
folders.add(0, inbox); folders.add(0, inbox);
return folders; return folders;


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

@ -844,7 +844,7 @@ public class FragmentCompose extends FragmentEx {
if (drafts == null) if (drafts == null)
drafts = db.folder().getPrimaryDrafts(); drafts = db.folder().getPrimaryDrafts();
if (drafts == null) if (drafts == null)
throw new IllegalArgumentException("no drafts folder");
throw new IllegalArgumentException(getString(R.string.title_no_drafts));
String body = ""; String body = "";


+ 8
- 9
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -338,21 +338,20 @@ public class FragmentMessages extends FragmentEx {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
EntityFolder folder = db.folder().getFolder(message.folder); EntityFolder folder = db.folder().getFolder(message.folder);
if (swipeTarget >= 0 && direction == ItemTouchHelper.RIGHT)
target = db.folder().getFolder(swipeTarget);
if (target == null || !target.account.equals((message.account))) {
if (swipeTarget < 0 || direction == ItemTouchHelper.LEFT) {
if (EntityFolder.ARCHIVE.equals(folder.type) || EntityFolder.TRASH.equals(folder.type)) if (EntityFolder.ARCHIVE.equals(folder.type) || EntityFolder.TRASH.equals(folder.type))
target = db.folder().getFolderByType(message.account, EntityFolder.INBOX); target = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
else { else {
if (direction == ItemTouchHelper.RIGHT) if (direction == ItemTouchHelper.RIGHT)
target = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE); target = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE);
if (direction == ItemTouchHelper.LEFT || target == null)
else if (direction == ItemTouchHelper.LEFT)
target = db.folder().getFolderByType(message.account, EntityFolder.TRASH); target = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (target == null)
target = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
} }
}
} else
target = db.folder().getFolder(swipeTarget);
if (target == null || !target.account.equals((message.account)))
throw new IllegalArgumentException(getString(R.string.title_no_target));
result.target = target.name; result.target = target.name;
result.display = (target.display == null ? target.name : target.display); result.display = (target.display == null ? target.name : target.display);
@ -816,7 +815,7 @@ public class FragmentMessages extends FragmentEx {
folders.add(0, sent); folders.add(0, sent);
EntityFolder inbox = db.folder().getFolderByType(folder.account, EntityFolder.INBOX); EntityFolder inbox = db.folder().getFolderByType(folder.account, EntityFolder.INBOX);
if (!inbox.id.equals(fid))
if (inbox != null && !inbox.id.equals(fid))
folders.add(0, inbox); folders.add(0, inbox);
return folders; return folders;


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

@ -126,6 +126,7 @@
<string name="title_no_password">Password missing</string> <string name="title_no_password">Password missing</string>
<string name="title_no_drafts">No primary account or no drafts folder</string> <string name="title_no_drafts">No primary account or no drafts folder</string>
<string name="title_no_archive">No primary account or no archive folder</string> <string name="title_no_archive">No primary account or no archive folder</string>
<string name="title_no_target">Target folder not set or missing</string>
<string name="title_no_idle">This provider does not support push messages. Reception of new messages can be delayed.</string> <string name="title_no_idle">This provider does not support push messages. Reception of new messages can be delayed.</string>
<string name="title_no_uidplus">IMAP UIDPLUS not supported, see the FAQ</string> <string name="title_no_uidplus">IMAP UIDPLUS not supported, see the FAQ</string>
<string name="title_account_delete">Delete this account permanently?</string> <string name="title_account_delete">Delete this account permanently?</string>


Loading…
Cancel
Save