Disable message action in outbox

This commit is contained in:
M66B 2018-10-18 07:01:35 +00:00
parent 17d83b8d4f
commit e0a3ea189e
1 changed files with 35 additions and 33 deletions

View File

@ -386,46 +386,48 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
bodyTask.load(context, owner, args); bodyTask.load(context, owner, args);
} }
bnvActions.setHasTransientState(true); if (!EntityFolder.OUTBOX.equals(message.folderType)) {
db.folder().liveFolders(message.account).observe(owner, new Observer<List<TupleFolderEx>>() { bnvActions.setHasTransientState(true);
@Override db.folder().liveFolders(message.account).observe(owner, new Observer<List<TupleFolderEx>>() {
public void onChanged(@Nullable List<TupleFolderEx> folders) { @Override
if (bnvActions.hasTransientState()) { public void onChanged(@Nullable List<TupleFolderEx> folders) {
boolean hasTrash = false; if (bnvActions.hasTransientState()) {
boolean hasArchive = false; boolean hasTrash = false;
boolean hasUser = false; boolean hasArchive = 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.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;
else if (EntityFolder.USER.equals(folder.type)) else if (EntityFolder.USER.equals(folder.type))
hasUser = true; hasUser = true;
} }
boolean inInbox = EntityFolder.INBOX.equals(message.folderType); boolean inInbox = EntityFolder.INBOX.equals(message.folderType);
boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType); boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType);
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType); boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
boolean inTrash = EntityFolder.TRASH.equals(message.folderType); boolean inTrash = EntityFolder.TRASH.equals(message.folderType);
ActionData data = new ActionData(); ActionData data = new ActionData();
data.delete = (inTrash || !hasTrash || inOutbox); data.delete = (inTrash || !hasTrash || inOutbox);
data.message = message; data.message = message;
bnvActions.setTag(data); bnvActions.setTag(data);
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).setVisible(message.content && !inOutbox);
bnvActions.setVisibility(View.VISIBLE); bnvActions.setVisibility(View.VISIBLE);
bnvActions.setHasTransientState(false); bnvActions.setHasTransientState(false);
}
} }
} });
}); }
// Observe attachments // Observe attachments
db.attachment().liveAttachments(message.id).observe(owner, db.attachment().liveAttachments(message.id).observe(owner,