|
|
@ -1334,74 +1334,6 @@ public class FragmentMessages extends FragmentEx {
|
|
|
|
trashes.add(folder.account);
|
|
|
|
trashes.add(folder.account);
|
|
|
|
|
|
|
|
|
|
|
|
loadMessages();
|
|
|
|
loadMessages();
|
|
|
|
|
|
|
|
|
|
|
|
if (actionbar && viewType == AdapterMessage.ViewType.THREAD) {
|
|
|
|
|
|
|
|
boolean hasTrash = false;
|
|
|
|
|
|
|
|
boolean hasArchive = false;
|
|
|
|
|
|
|
|
for (EntityFolder folder : folders)
|
|
|
|
|
|
|
|
if (EntityFolder.TRASH.equals(folder.type))
|
|
|
|
|
|
|
|
hasTrash = true;
|
|
|
|
|
|
|
|
else if (EntityFolder.ARCHIVE.equals(folder.type))
|
|
|
|
|
|
|
|
hasArchive = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
|
|
|
|
|
|
|
ViewModelMessages.Target[] pn = model.getPrevNext(thread);
|
|
|
|
|
|
|
|
bottom_navigation.setTag(pn);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("account", account);
|
|
|
|
|
|
|
|
args.putString("thread", thread);
|
|
|
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
args.putBoolean("hasTrash", hasTrash);
|
|
|
|
|
|
|
|
args.putBoolean("hasArchive", hasArchive);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Boolean[]>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Boolean[] onLoad(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long account = args.getLong("account");
|
|
|
|
|
|
|
|
String thread = args.getString("thread");
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityMessage> messages = db.message().getMessageByThread(
|
|
|
|
|
|
|
|
account, thread, threading ? null : id, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean trashable = false;
|
|
|
|
|
|
|
|
boolean archivable = false;
|
|
|
|
|
|
|
|
for (EntityMessage message : messages) {
|
|
|
|
|
|
|
|
EntityFolder folder = db.folder().getFolder(message.folder);
|
|
|
|
|
|
|
|
if (!EntityFolder.DRAFTS.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.OUTBOX.equals(folder.type) &&
|
|
|
|
|
|
|
|
// allow sent
|
|
|
|
|
|
|
|
!EntityFolder.TRASH.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.JUNK.equals(folder.type))
|
|
|
|
|
|
|
|
trashable = true;
|
|
|
|
|
|
|
|
if (!EntityFolder.isOutgoing(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.TRASH.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.JUNK.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.ARCHIVE.equals(folder.type))
|
|
|
|
|
|
|
|
archivable = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Boolean[]{trashable, archivable};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onLoaded(Bundle args, Boolean[] data) {
|
|
|
|
|
|
|
|
boolean hasTrash = args.getBoolean("hasTrash");
|
|
|
|
|
|
|
|
boolean hasArchive = args.getBoolean("hasArchive");
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(hasTrash && data[0]);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(hasArchive && data[1]);
|
|
|
|
|
|
|
|
bottom_navigation.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(FragmentMessages.this, args);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1863,6 +1795,63 @@ public class FragmentMessages extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (actionbar) {
|
|
|
|
|
|
|
|
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
|
|
|
|
|
|
|
ViewModelMessages.Target[] pn = model.getPrevNext(thread);
|
|
|
|
|
|
|
|
bottom_navigation.setTag(pn);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("account", account);
|
|
|
|
|
|
|
|
args.putString("thread", thread);
|
|
|
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Boolean[]>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Boolean[] onLoad(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long account = args.getLong("account");
|
|
|
|
|
|
|
|
String thread = args.getString("thread");
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityMessage> messages = db.message().getMessageByThread(
|
|
|
|
|
|
|
|
account, thread, threading ? null : id, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean trashable = false;
|
|
|
|
|
|
|
|
boolean archivable = false;
|
|
|
|
|
|
|
|
for (EntityMessage message : messages) {
|
|
|
|
|
|
|
|
EntityFolder folder = db.folder().getFolder(message.folder);
|
|
|
|
|
|
|
|
if (!EntityFolder.DRAFTS.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.OUTBOX.equals(folder.type) &&
|
|
|
|
|
|
|
|
// allow sent
|
|
|
|
|
|
|
|
!EntityFolder.TRASH.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.JUNK.equals(folder.type))
|
|
|
|
|
|
|
|
trashable = true;
|
|
|
|
|
|
|
|
if (!EntityFolder.isOutgoing(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.TRASH.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.JUNK.equals(folder.type) &&
|
|
|
|
|
|
|
|
!EntityFolder.ARCHIVE.equals(folder.type))
|
|
|
|
|
|
|
|
archivable = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Boolean[]{trashable, archivable};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onLoaded(Bundle args, Boolean[] data) {
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(trashes.size() > 0 && data[0]);
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(archives.size() > 0 && data[1]);
|
|
|
|
|
|
|
|
bottom_navigation.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(FragmentMessages.this, args);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
|
|
|
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
|
|
|
model.setMessages(messages);
|
|
|
|
model.setMessages(messages);
|
|
|
|