Disable message action in outbox

pull/146/head
M66B 7 years ago
parent 17d83b8d4f
commit e0a3ea189e

@ -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)
for (EntityFolder folder : folders) { if (folders != null)
if (EntityFolder.TRASH.equals(folder.type)) for (EntityFolder folder : folders) {
hasTrash = true; if (EntityFolder.TRASH.equals(folder.type))
else if (EntityFolder.ARCHIVE.equals(folder.type)) hasTrash = true;
hasArchive = true; else if (EntityFolder.ARCHIVE.equals(folder.type))
else if (EntityFolder.USER.equals(folder.type)) hasArchive = true;
hasUser = true; else if (EntityFolder.USER.equals(folder.type))
} 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,

Loading…
Cancel
Save