Added POP3 swipe to hide

pull/178/head
M66B 5 years ago
parent 65a056e58a
commit 31f8c14353

@ -104,6 +104,7 @@ public interface DaoAccount {
@Query("SELECT account.id" + @Query("SELECT account.id" +
", account.swipe_left, l.type AS left_type, l.name AS left_name, l.color AS left_color" + ", account.swipe_left, l.type AS left_type, l.name AS left_name, l.color AS left_color" +
", account.swipe_right, r.type AS right_type, r.name AS right_name, r.color AS right_color" + ", account.swipe_right, r.type AS right_type, r.name AS right_name, r.color AS right_color" +
", account.leave_deleted" +
" FROM account" + " FROM account" +
" LEFT JOIN folder l ON l.id = account.swipe_left" + " LEFT JOIN folder l ON l.id = account.swipe_left" +
" LEFT JOIN folder r ON r.id = account.swipe_right" + " LEFT JOIN folder r ON r.id = account.swipe_right" +

@ -1632,13 +1632,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (EntityFolder.OUTBOX.equals(message.folderType)) if (EntityFolder.OUTBOX.equals(message.folderType))
return 0; return 0;
if (message.accountProtocol != EntityAccount.TYPE_IMAP)
return makeMovementFlags(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
TupleAccountSwipes swipes = accountSwipes.get(message.account); TupleAccountSwipes swipes = accountSwipes.get(message.account);
if (swipes == null) if (swipes == null)
return 0; return 0;
if (message.accountProtocol != EntityAccount.TYPE_IMAP)
return makeMovementFlags(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
int flags = 0; int flags = 0;
if (swipes.swipe_left != null && if (swipes.swipe_left != null &&
(swipes.swipe_left < 0 || (swipes.swipe_left < 0 ||
@ -1684,16 +1684,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (message == null) if (message == null)
return; return;
TupleAccountSwipes swipes; TupleAccountSwipes swipes = accountSwipes.get(message.account);
if (swipes == null)
return;
if (message.accountProtocol != EntityAccount.TYPE_IMAP) { if (message.accountProtocol != EntityAccount.TYPE_IMAP) {
swipes = new TupleAccountSwipes();
swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN; swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN;
swipes.swipe_left = 0L; if (swipes.leave_deleted) {
swipes.left_type = EntityFolder.TRASH; if (message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE)
} else { swipes.swipe_left = FragmentAccount.SWIPE_ACTION_HIDE; // show
swipes = accountSwipes.get(message.account); else {
if (swipes == null) swipes.swipe_left = 0L;
return; swipes.left_type = EntityFolder.TRASH; // hide
}
} else
swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE;
} }
Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left); Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left);
@ -1727,6 +1732,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
icon = R.drawable.baseline_delete_forever_24; icon = R.drawable.baseline_delete_forever_24;
else else
icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type); icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type);
Drawable d = getResources().getDrawable(icon, getContext().getTheme()).mutate(); Drawable d = getResources().getDrawable(icon, getContext().getTheme()).mutate();
d.setTint(Helper.resolveColor(getContext(), android.R.attr.textColorSecondary)); d.setTint(Helper.resolveColor(getContext(), android.R.attr.textColorSecondary));
@ -1777,19 +1783,25 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
} }
if (message.accountProtocol != EntityAccount.TYPE_IMAP)
if (direction == ItemTouchHelper.LEFT) {
adapter.notifyItemChanged(pos);
onSwipeDelete(message);
} else
onActionSeenSelection(!message.ui_seen, message.id);
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 (direction == ItemTouchHelper.LEFT) {
if (swipes.leave_deleted)
onActionHide(message);
else {
adapter.notifyItemChanged(pos);
onSwipeDelete(message);
}
} else
onActionSeenSelection(!message.ui_seen, message.id);
return;
}
Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right); Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
if (action == null) { if (action == null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();

@ -29,4 +29,5 @@ public class TupleAccountSwipes {
public String right_type; public String right_type;
public String right_name; public String right_name;
public Integer right_color; public Integer right_color;
public Boolean leave_deleted;
} }

Loading…
Cancel
Save