|
|
@ -174,11 +174,14 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
|
|
|
case R.id.action_thread:
|
|
|
|
|
|
|
|
onActionThread(id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
case R.id.action_seen:
|
|
|
|
case R.id.action_seen:
|
|
|
|
onActionSeen(id);
|
|
|
|
onActionSeen(id);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
case R.id.action_thread:
|
|
|
|
case R.id.action_edit:
|
|
|
|
onActionThread(id);
|
|
|
|
onActionEdit(id);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
case R.id.action_forward:
|
|
|
|
case R.id.action_forward:
|
|
|
|
onActionForward(id);
|
|
|
|
onActionForward(id);
|
|
|
@ -218,6 +221,7 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
// Initialize
|
|
|
|
// Initialize
|
|
|
|
grpAddress.setVisibility(View.GONE);
|
|
|
|
grpAddress.setVisibility(View.GONE);
|
|
|
|
grpAttachments.setVisibility(View.GONE);
|
|
|
|
grpAttachments.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
top_navigation.setVisibility(View.GONE);
|
|
|
|
bottom_navigation.setVisibility(View.GONE);
|
|
|
|
bottom_navigation.setVisibility(View.GONE);
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
@ -251,10 +255,6 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
if (FragmentMessage.this.isVisible())
|
|
|
|
if (FragmentMessage.this.isVisible())
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
final boolean inbox = EntityFolder.TYPE_INBOX.equals(message.folderType);
|
|
|
|
|
|
|
|
final boolean outbox = EntityFolder.TYPE_INBOX.equals(message.folderType);
|
|
|
|
|
|
|
|
final boolean archive = EntityFolder.TYPE_ARCHIVE.equals(message.folderType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName));
|
|
|
|
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName));
|
|
|
|
|
|
|
|
|
|
|
|
tvFrom.setText(message.from == null ? null : TextUtils.join(", ", message.from));
|
|
|
|
tvFrom.setText(message.from == null ? null : TextUtils.join(", ", message.from));
|
|
|
@ -287,11 +287,6 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_thread).setVisible(message.count > 1);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_seen).setVisible(!outbox);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_forward).setVisible(!outbox);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!outbox);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen);
|
|
|
|
MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen);
|
|
|
|
actionSeen.setIcon(message.ui_seen
|
|
|
|
actionSeen.setIcon(message.ui_seen
|
|
|
|
? R.drawable.baseline_visibility_off_24
|
|
|
|
? R.drawable.baseline_visibility_off_24
|
|
|
@ -308,6 +303,11 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
|
|
|
|
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onChanged(@Nullable final List<TupleFolderEx> folders) {
|
|
|
|
public void onChanged(@Nullable final List<TupleFolderEx> folders) {
|
|
|
|
|
|
|
|
boolean inbox = EntityFolder.TYPE_INBOX.equals(message.folderType);
|
|
|
|
|
|
|
|
boolean outbox = EntityFolder.TYPE_OUTBOX.equals(message.folderType);
|
|
|
|
|
|
|
|
boolean archive = EntityFolder.TYPE_ARCHIVE.equals(message.folderType);
|
|
|
|
|
|
|
|
boolean trash = EntityFolder.TYPE_TRASH.equals(message.folderType);
|
|
|
|
|
|
|
|
|
|
|
|
boolean hasTrash = false;
|
|
|
|
boolean hasTrash = false;
|
|
|
|
boolean hasJunk = false;
|
|
|
|
boolean hasJunk = false;
|
|
|
|
boolean hasArchive = false;
|
|
|
|
boolean hasArchive = false;
|
|
|
@ -323,6 +323,13 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
hasUser = true;
|
|
|
|
hasUser = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_thread).setVisible(message.count > 1);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_seen).setVisible(!outbox);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_edit).setVisible(trash);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_forward).setVisible(!outbox);
|
|
|
|
|
|
|
|
top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!outbox);
|
|
|
|
|
|
|
|
top_navigation.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!outbox && hasTrash);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(!outbox && hasTrash);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(!outbox && hasJunk);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(!outbox && hasJunk);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(!outbox && (!inbox || hasUser));
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(!outbox && (!inbox || hasUser));
|
|
|
@ -361,6 +368,18 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
grpAddress.setVisibility(grpAddress.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
|
|
|
|
grpAddress.setVisibility(grpAddress.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionThread(long id) {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("thread", id); // message ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentMessages fragment = new FragmentMessages();
|
|
|
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("thread");
|
|
|
|
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionSeen(final long id) {
|
|
|
|
private void onActionSeen(final long id) {
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -379,16 +398,30 @@ public class FragmentMessage extends FragmentEx {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionThread(long id) {
|
|
|
|
private void onActionEdit(final long id) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
args.putLong("thread", id); // message ID
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
FragmentMessages fragment = new FragmentMessages();
|
|
|
|
try {
|
|
|
|
fragment.setArguments(args);
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
|
|
|
|
EntityMessage draft = db.message().getMessage(id);
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
EntityFolder drafts = db.folder().getFolderByType(draft.account, EntityFolder.TYPE_DRAFTS);
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("thread");
|
|
|
|
if (drafts == null)
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
drafts = db.folder().getLocalDrafts();
|
|
|
|
|
|
|
|
if (drafts == null)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
draft.id = null;
|
|
|
|
|
|
|
|
draft.folder = drafts.id;
|
|
|
|
|
|
|
|
draft.id = db.message().insertMessage(draft);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getContext().startActivity(
|
|
|
|
|
|
|
|
new Intent(getContext(), ActivityCompose.class)
|
|
|
|
|
|
|
|
.putExtra("id", draft.id));
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionForward(long id) {
|
|
|
|
private void onActionForward(long id) {
|
|
|
|