|
|
@ -2762,93 +2762,106 @@ public class FragmentMessages extends FragmentBase
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
|
|
|
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
|
|
|
int pos = viewHolder.getAdapterPosition();
|
|
|
|
try {
|
|
|
|
if (pos == NO_POSITION) {
|
|
|
|
int pos = viewHolder.getAdapterPosition();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
if (pos == NO_POSITION) {
|
|
|
|
return;
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TupleMessageEx message = getMessage(pos);
|
|
|
|
TupleMessageEx message = getMessage(pos);
|
|
|
|
if (message == null) {
|
|
|
|
if (message == null) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean expanded = iProperties.getValue("expanded", message.id);
|
|
|
|
boolean expanded = iProperties.getValue("expanded", message.id);
|
|
|
|
|
|
|
|
|
|
|
|
if (expanded && swipe_reply) {
|
|
|
|
if (expanded && swipe_reply) {
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
onMenuReply(message, "reply", null);
|
|
|
|
onMenuReply(message, "reply", null);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (EntityFolder.OUTBOX.equals(message.folderType)) {
|
|
|
|
if (EntityFolder.OUTBOX.equals(message.folderType)) {
|
|
|
|
ActivityCompose.undoSend(message.id, getContext(), getViewLifecycleOwner(), getParentFragmentManager());
|
|
|
|
ActivityCompose.undoSend(message.id, getContext(), getViewLifecycleOwner(), getParentFragmentManager());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TupleAccountSwipes swipes = accountSwipes.get(message.account);
|
|
|
|
TupleAccountSwipes swipes = accountSwipes.get(message.account);
|
|
|
|
if (swipes == null) {
|
|
|
|
if (swipes == null) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
|
|
|
|
if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
|
|
|
|
if (swipes.swipe_right == null)
|
|
|
|
if (swipes.swipe_right == null)
|
|
|
|
swipes.swipe_right = EntityMessage.SWIPE_ACTION_SEEN;
|
|
|
|
swipes.swipe_right = EntityMessage.SWIPE_ACTION_SEEN;
|
|
|
|
if (swipes.swipe_left == null)
|
|
|
|
if (swipes.swipe_left == null)
|
|
|
|
swipes.swipe_left = EntityMessage.SWIPE_ACTION_DELETE;
|
|
|
|
swipes.swipe_left = EntityMessage.SWIPE_ACTION_DELETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
|
|
|
|
Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
|
|
|
|
String actionType = (direction == ItemTouchHelper.LEFT ? swipes.left_type : swipes.right_type);
|
|
|
|
String actionType = (direction == ItemTouchHelper.LEFT ? swipes.left_type : swipes.right_type);
|
|
|
|
if (action == null) {
|
|
|
|
if (action == null) {
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.uid == null &&
|
|
|
|
if (message.uid == null &&
|
|
|
|
message.accountProtocol == EntityAccount.TYPE_IMAP &&
|
|
|
|
message.accountProtocol == EntityAccount.TYPE_IMAP &&
|
|
|
|
EntityFolder.DRAFTS.equals(message.folderType) &&
|
|
|
|
EntityFolder.DRAFTS.equals(message.folderType) &&
|
|
|
|
EntityFolder.TRASH.equals(actionType)) {
|
|
|
|
EntityFolder.TRASH.equals(actionType)) {
|
|
|
|
action = EntityMessage.SWIPE_ACTION_DELETE;
|
|
|
|
action = EntityMessage.SWIPE_ACTION_DELETE;
|
|
|
|
actionType = null;
|
|
|
|
actionType = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Swiped dir=" + direction +
|
|
|
|
Log.i("Swiped dir=" + direction +
|
|
|
|
" action=" + action +
|
|
|
|
" action=" + action +
|
|
|
|
" type=" + actionType +
|
|
|
|
" type=" + actionType +
|
|
|
|
" message=" + message.id +
|
|
|
|
" message=" + message.id +
|
|
|
|
" folder=" + message.folderType);
|
|
|
|
" folder=" + message.folderType);
|
|
|
|
|
|
|
|
|
|
|
|
if (EntityMessage.SWIPE_ACTION_ASK.equals(action)) {
|
|
|
|
if (EntityMessage.SWIPE_ACTION_ASK.equals(action)) {
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
|
|
|
|
onSwipeAsk(message, viewHolder);
|
|
|
|
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action))
|
|
|
|
|
|
|
|
onActionSeenSelection(message.unseen > 0, message.id, false);
|
|
|
|
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action))
|
|
|
|
|
|
|
|
onActionFlagSelection(!message.ui_flagged, Color.TRANSPARENT, message.id, false);
|
|
|
|
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action))
|
|
|
|
|
|
|
|
if (ActivityBilling.isPro(getContext()))
|
|
|
|
|
|
|
|
onActionSnooze(message);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
startActivity(new Intent(getContext(), ActivityBilling.class));
|
|
|
|
onSwipeAsk(message, viewHolder);
|
|
|
|
}
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action))
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_HIDE.equals(action))
|
|
|
|
onActionSeenSelection(message.unseen > 0, message.id, false);
|
|
|
|
onActionHide(message);
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action))
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_MOVE.equals(action)) {
|
|
|
|
onActionFlagSelection(!message.ui_flagged, Color.TRANSPARENT, message.id, false);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action))
|
|
|
|
onSwipeMove(message);
|
|
|
|
if (ActivityBilling.isPro(getContext()))
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_JUNK.equals(action)) {
|
|
|
|
onActionSnooze(message);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
else {
|
|
|
|
onSwipeJunk(message);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_DELETE.equals(action) ||
|
|
|
|
startActivity(new Intent(getContext(), ActivityBilling.class));
|
|
|
|
(action.equals(message.folder) && EntityFolder.TRASH.equals(message.folderType)) ||
|
|
|
|
}
|
|
|
|
(EntityFolder.TRASH.equals(actionType) && EntityFolder.JUNK.equals(message.folderType)))
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_HIDE.equals(action))
|
|
|
|
onSwipeDelete(message, pos);
|
|
|
|
onActionHide(message);
|
|
|
|
else
|
|
|
|
else if (EntityMessage.SWIPE_ACTION_MOVE.equals(action)) {
|
|
|
|
swipeFolder(message, action);
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
|
|
|
|
onSwipeMove(message);
|
|
|
|
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_JUNK.equals(action)) {
|
|
|
|
|
|
|
|
adapter.notifyItemChanged(pos);
|
|
|
|
|
|
|
|
onSwipeJunk(message);
|
|
|
|
|
|
|
|
} else if (EntityMessage.SWIPE_ACTION_DELETE.equals(action) ||
|
|
|
|
|
|
|
|
(action.equals(message.folder) && EntityFolder.TRASH.equals(message.folderType)) ||
|
|
|
|
|
|
|
|
(EntityFolder.TRASH.equals(actionType) && EntityFolder.JUNK.equals(message.folderType)))
|
|
|
|
|
|
|
|
onSwipeDelete(message, pos);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
swipeFolder(message, action);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling ...
|
|
|
|
|
|
|
|
at androidx.recyclerview.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView:3185)
|
|
|
|
|
|
|
|
at androidx.recyclerview.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeChanged(RecyclerView:5712)
|
|
|
|
|
|
|
|
at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView:12674)
|
|
|
|
|
|
|
|
at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeChanged(RecyclerView:12664)
|
|
|
|
|
|
|
|
at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemChanged(RecyclerView:7599)
|
|
|
|
|
|
|
|
at eu.faircode.email.FragmentMessages$60.onSwiped(FragmentMessages:2818)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private TupleMessageEx getMessage(int pos) {
|
|
|
|
private TupleMessageEx getMessage(int pos) {
|
|
|
|