|
|
@ -2092,105 +2092,109 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onSwipeAsk(final @NonNull TupleMessageEx message, @NonNull RecyclerView.ViewHolder viewHolder) {
|
|
|
|
private void onSwipeAsk(final @NonNull TupleMessageEx message, @NonNull RecyclerView.ViewHolder viewHolder) {
|
|
|
|
LinearLayoutManager llm = (LinearLayoutManager) rvMessage.getLayoutManager();
|
|
|
|
rvMessage.post(new Runnable() {
|
|
|
|
int pos = viewHolder.getAdapterPosition();
|
|
|
|
@Override
|
|
|
|
if (pos != NO_POSITION)
|
|
|
|
public void run() {
|
|
|
|
llm.scrollToPositionWithOffset(pos, 0);
|
|
|
|
try {
|
|
|
|
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), viewHolder.itemView);
|
|
|
|
|
|
|
|
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor);
|
|
|
|
if (message.ui_seen)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unseen, 1, R.string.title_unseen);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_seen, 1, R.string.title_seen);
|
|
|
|
|
|
|
|
|
|
|
|
if (message.ui_seen)
|
|
|
|
if (message.ui_flagged)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unseen, 1, R.string.title_unseen);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unflag, 2, R.string.title_unflag);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_seen, 1, R.string.title_seen);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_flag, 2, R.string.title_flag);
|
|
|
|
|
|
|
|
|
|
|
|
if (message.ui_flagged)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_snooze, 3, R.string.title_snooze);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unflag, 2, R.string.title_unflag);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_flag, 2, R.string.title_flag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_snooze, 3, R.string.title_snooze);
|
|
|
|
if (message.ui_snoozed == null)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_hide, 4, R.string.title_hide);
|
|
|
|
|
|
|
|
else if (message.ui_snoozed == Long.MAX_VALUE)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unhide, 4, R.string.title_unhide);
|
|
|
|
|
|
|
|
|
|
|
|
if (message.ui_snoozed == null)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_flag_color, 5, R.string.title_flag_color);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_hide, 4, R.string.title_hide);
|
|
|
|
if (message.accountProtocol == EntityAccount.TYPE_IMAP) {
|
|
|
|
else if (message.ui_snoozed == Long.MAX_VALUE)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_move, 6, R.string.title_move);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_unhide, 4, R.string.title_unhide);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_report_spam, 7, R.string.title_report_spam);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_permanently, 8, R.string.title_delete_permanently);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_flag_color, 5, R.string.title_flag_color);
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
if (message.accountProtocol == EntityAccount.TYPE_IMAP) {
|
|
|
|
@Override
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_move, 6, R.string.title_move);
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_report_spam, 7, R.string.title_report_spam);
|
|
|
|
switch (target.getItemId()) {
|
|
|
|
}
|
|
|
|
case R.string.title_seen:
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_permanently, 8, R.string.title_delete_permanently);
|
|
|
|
onActionSeenSelection(true, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_unseen:
|
|
|
|
|
|
|
|
onActionSeenSelection(false, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_flag:
|
|
|
|
|
|
|
|
onActionFlagSelection(true, null, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_unflag:
|
|
|
|
|
|
|
|
onActionFlagSelection(false, null, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_snooze:
|
|
|
|
|
|
|
|
onMenuSnooze();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_hide:
|
|
|
|
|
|
|
|
case R.string.title_unhide:
|
|
|
|
|
|
|
|
onActionHide(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_flag_color:
|
|
|
|
|
|
|
|
onMenuColor();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_move:
|
|
|
|
|
|
|
|
onSwipeMove(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_report_spam:
|
|
|
|
|
|
|
|
onSwipeJunk(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_delete_permanently:
|
|
|
|
|
|
|
|
onSwipeDelete(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
private void onMenuSnooze() {
|
|
|
|
@Override
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
args.putString("title", getString(R.string.title_snooze));
|
|
|
|
switch (target.getItemId()) {
|
|
|
|
args.putLong("account", message.account);
|
|
|
|
case R.string.title_seen:
|
|
|
|
args.putString("thread", message.thread);
|
|
|
|
onActionSeenSelection(true, message.id);
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
return true;
|
|
|
|
args.putBoolean("finish", false);
|
|
|
|
case R.string.title_unseen:
|
|
|
|
|
|
|
|
onActionSeenSelection(false, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_flag:
|
|
|
|
|
|
|
|
onActionFlagSelection(true, null, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_unflag:
|
|
|
|
|
|
|
|
onActionFlagSelection(false, null, message.id);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_snooze:
|
|
|
|
|
|
|
|
onMenuSnooze();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_hide:
|
|
|
|
|
|
|
|
case R.string.title_unhide:
|
|
|
|
|
|
|
|
onActionHide(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_flag_color:
|
|
|
|
|
|
|
|
onMenuColor();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_move:
|
|
|
|
|
|
|
|
onSwipeMove(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_report_spam:
|
|
|
|
|
|
|
|
onSwipeJunk(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.string.title_delete_permanently:
|
|
|
|
|
|
|
|
onSwipeDelete(message);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuSnooze() {
|
|
|
|
FragmentDialogDuration fragment = new FragmentDialogDuration();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
fragment.setArguments(args);
|
|
|
|
args.putString("title", getString(R.string.title_snooze));
|
|
|
|
fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_SNOOZE);
|
|
|
|
args.putLong("account", message.account);
|
|
|
|
fragment.show(getParentFragmentManager(), "message:snooze");
|
|
|
|
args.putString("thread", message.thread);
|
|
|
|
}
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
|
|
|
|
args.putBoolean("finish", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentDialogDuration fragment = new FragmentDialogDuration();
|
|
|
|
private void onMenuColor() {
|
|
|
|
fragment.setArguments(args);
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_SNOOZE);
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
fragment.show(getParentFragmentManager(), "message:snooze");
|
|
|
|
args.putInt("color", message.color == null ? Color.TRANSPARENT : message.color);
|
|
|
|
}
|
|
|
|
args.putString("title", getString(R.string.title_flag_color));
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuColor() {
|
|
|
|
FragmentDialogColor fragment = new FragmentDialogColor();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
fragment.setArguments(args);
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_COLOR);
|
|
|
|
args.putInt("color", message.color == null ? Color.TRANSPARENT : message.color);
|
|
|
|
fragment.show(getParentFragmentManager(), "message:color");
|
|
|
|
args.putString("title", getString(R.string.title_flag_color));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
FragmentDialogColor fragment = new FragmentDialogColor();
|
|
|
|
popupMenu.show();
|
|
|
|
fragment.setArguments(args);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_COLOR);
|
|
|
|
Log.e(ex);
|
|
|
|
fragment.show(getParentFragmentManager(), "message:color");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onSwipeMove(final @NonNull TupleMessageEx message) {
|
|
|
|
private void onSwipeMove(final @NonNull TupleMessageEx message) {
|
|
|
|