diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index 59f241f53f..3d21953c09 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -91,6 +91,15 @@ public class EntityMessage implements Serializable { static final Integer PRIORITIY_NORMAL = 1; static final Integer PRIORITIY_HIGH = 2; + static final Long SWIPE_ACTION_ASK = -1L; + static final Long SWIPE_ACTION_SEEN = -2L; + static final Long SWIPE_ACTION_SNOOZE = -3L; + static final Long SWIPE_ACTION_HIDE = -4L; + static final Long SWIPE_ACTION_MOVE = -5L; + static final Long SWIPE_ACTION_FLAG = -6L; + static final Long SWIPE_ACTION_DELETE = -7L; + static final Long SWIPE_ACTION_JUNK = -8L; + @PrimaryKey(autoGenerate = true) public Long id; @NonNull diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index f3e095dd8f..195725c566 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -165,15 +165,6 @@ public class FragmentAccount extends FragmentBase { private static final int REQUEST_SAVE = 2; private static final int REQUEST_DELETE = 3; - static final Long SWIPE_ACTION_ASK = -1L; - static final Long SWIPE_ACTION_SEEN = -2L; - static final Long SWIPE_ACTION_SNOOZE = -3L; - static final Long SWIPE_ACTION_HIDE = -4L; - static final Long SWIPE_ACTION_MOVE = -5L; - static final Long SWIPE_ACTION_FLAG = -6L; - static final Long SWIPE_ACTION_DELETE = -7L; - static final Long SWIPE_ACTION_JUNK = -8L; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -1774,42 +1765,42 @@ public class FragmentAccount extends FragmentBase { folders.add(none); EntityFolder ask = new EntityFolder(); - ask.id = SWIPE_ACTION_ASK; + ask.id = EntityMessage.SWIPE_ACTION_ASK; ask.name = context.getString(R.string.title_ask_what); folders.add(ask); EntityFolder seen = new EntityFolder(); - seen.id = SWIPE_ACTION_SEEN; + seen.id = EntityMessage.SWIPE_ACTION_SEEN; seen.name = context.getString(R.string.title_seen); folders.add(seen); EntityFolder flag = new EntityFolder(); - flag.id = SWIPE_ACTION_FLAG; + flag.id = EntityMessage.SWIPE_ACTION_FLAG; flag.name = context.getString(R.string.title_flag); folders.add(flag); EntityFolder snooze = new EntityFolder(); - snooze.id = SWIPE_ACTION_SNOOZE; + snooze.id = EntityMessage.SWIPE_ACTION_SNOOZE; snooze.name = context.getString(R.string.title_snooze_now); folders.add(snooze); EntityFolder hide = new EntityFolder(); - hide.id = SWIPE_ACTION_HIDE; + hide.id = EntityMessage.SWIPE_ACTION_HIDE; hide.name = context.getString(R.string.title_hide); folders.add(hide); EntityFolder move = new EntityFolder(); - move.id = SWIPE_ACTION_MOVE; + move.id = EntityMessage.SWIPE_ACTION_MOVE; move.name = context.getString(R.string.title_move); folders.add(move); EntityFolder junk = new EntityFolder(); - junk.id = SWIPE_ACTION_JUNK; + junk.id = EntityMessage.SWIPE_ACTION_JUNK; junk.name = context.getString(R.string.title_report_spam); folders.add(junk); EntityFolder delete = new EntityFolder(); - delete.id = SWIPE_ACTION_DELETE; + delete.id = EntityMessage.SWIPE_ACTION_DELETE; delete.name = context.getString(R.string.title_delete_permanently); folders.add(delete); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 6396ede86e..566b776874 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -1731,9 +1731,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (message.accountProtocol != EntityAccount.TYPE_IMAP) { if (swipes.swipe_right == null) - swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN; + swipes.swipe_right = EntityMessage.SWIPE_ACTION_SEEN; if (swipes.swipe_left == null) - swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE; + swipes.swipe_left = EntityMessage.SWIPE_ACTION_DELETE; } Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left); @@ -1747,23 +1747,23 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. int size = Helper.dp2pixels(getContext(), 24); int icon; - if (FragmentAccount.SWIPE_ACTION_ASK.equals(action)) + if (EntityMessage.SWIPE_ACTION_ASK.equals(action)) icon = R.drawable.baseline_list_24; - else if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action)) + else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action)) icon = (message.ui_seen ? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24); - else if (FragmentAccount.SWIPE_ACTION_FLAG.equals(action)) + else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action)) icon = (message.ui_flagged ? R.drawable.baseline_star_border_24 : R.drawable.baseline_star_24); - else if (FragmentAccount.SWIPE_ACTION_SNOOZE.equals(action)) + else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action)) icon = (message.ui_snoozed == null ? R.drawable.baseline_timelapse_24 : R.drawable.baseline_timer_off_24); - else if (FragmentAccount.SWIPE_ACTION_HIDE.equals(action)) + else if (EntityMessage.SWIPE_ACTION_HIDE.equals(action)) icon = (message.ui_snoozed == null ? R.drawable.baseline_visibility_off_24 : (message.ui_snoozed == Long.MAX_VALUE ? R.drawable.baseline_visibility_24 : R.drawable.baseline_timer_off_24)); - else if (FragmentAccount.SWIPE_ACTION_MOVE.equals(action)) + else if (EntityMessage.SWIPE_ACTION_MOVE.equals(action)) icon = R.drawable.baseline_folder_24; - else if (FragmentAccount.SWIPE_ACTION_JUNK.equals(action)) + else if (EntityMessage.SWIPE_ACTION_JUNK.equals(action)) icon = R.drawable.baseline_report_problem_24; - else if (FragmentAccount.SWIPE_ACTION_DELETE.equals(action) || + 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))) icon = R.drawable.baseline_delete_forever_24; @@ -1828,9 +1828,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (message.accountProtocol != EntityAccount.TYPE_IMAP) { if (swipes.swipe_right == null) - swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN; + swipes.swipe_right = EntityMessage.SWIPE_ACTION_SEEN; if (swipes.swipe_left == null) - swipes.swipe_left = FragmentAccount.SWIPE_ACTION_DELETE; + swipes.swipe_left = EntityMessage.SWIPE_ACTION_DELETE; } Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right); @@ -1842,24 +1842,24 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Log.i("Swiped dir=" + direction + " message=" + message.id); - if (FragmentAccount.SWIPE_ACTION_ASK.equals(action)) { + if (EntityMessage.SWIPE_ACTION_ASK.equals(action)) { adapter.notifyItemChanged(pos); onSwipeAsk(message, viewHolder); - } else if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action)) + } else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action)) onActionSeenSelection(!message.ui_seen, message.id); - else if (FragmentAccount.SWIPE_ACTION_FLAG.equals(action)) + else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action)) onActionFlagSelection(!message.ui_flagged, null, message.id); - else if (FragmentAccount.SWIPE_ACTION_SNOOZE.equals(action)) + else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action)) onActionSnooze(message); - else if (FragmentAccount.SWIPE_ACTION_HIDE.equals(action)) + else if (EntityMessage.SWIPE_ACTION_HIDE.equals(action)) onActionHide(message); - else if (FragmentAccount.SWIPE_ACTION_MOVE.equals(action)) { + else if (EntityMessage.SWIPE_ACTION_MOVE.equals(action)) { adapter.notifyItemChanged(pos); onSwipeMove(message); - } else if (FragmentAccount.SWIPE_ACTION_JUNK.equals(action)) { + } else if (EntityMessage.SWIPE_ACTION_JUNK.equals(action)) { adapter.notifyItemChanged(pos); onSwipeJunk(message); - } else if (FragmentAccount.SWIPE_ACTION_DELETE.equals(action) || + } 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))) { adapter.notifyItemChanged(pos); diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index 276ec43d96..dcfdf2d79e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -595,12 +595,12 @@ public class FragmentPop extends FragmentBase { EntityFolder folder = folders.get(pos); if (account == null || account.swipe_left == null - ? FragmentAccount.SWIPE_ACTION_DELETE.equals(folder.id) + ? EntityMessage.SWIPE_ACTION_DELETE.equals(folder.id) : account.swipe_left.equals(folder.id)) spLeft.setSelection(pos); if (account == null || account.swipe_right == null - ? FragmentAccount.SWIPE_ACTION_SEEN.equals(folder.id) + ? EntityMessage.SWIPE_ACTION_SEEN.equals(folder.id) : account.swipe_right.equals(folder.id)) spRight.setSelection(pos); } @@ -739,32 +739,32 @@ public class FragmentPop extends FragmentBase { List folders = new ArrayList<>(); EntityFolder ask = new EntityFolder(); - ask.id = FragmentAccount.SWIPE_ACTION_ASK; + ask.id = EntityMessage.SWIPE_ACTION_ASK; ask.name = getString(R.string.title_ask_what); folders.add(ask); EntityFolder seen = new EntityFolder(); - seen.id = FragmentAccount.SWIPE_ACTION_SEEN; + seen.id = EntityMessage.SWIPE_ACTION_SEEN; seen.name = getString(R.string.title_seen); folders.add(seen); EntityFolder flag = new EntityFolder(); - flag.id = FragmentAccount.SWIPE_ACTION_FLAG; + flag.id = EntityMessage.SWIPE_ACTION_FLAG; flag.name = getString(R.string.title_flag); folders.add(flag); EntityFolder snooze = new EntityFolder(); - snooze.id = FragmentAccount.SWIPE_ACTION_SNOOZE; + snooze.id = EntityMessage.SWIPE_ACTION_SNOOZE; snooze.name = getString(R.string.title_snooze_now); folders.add(snooze); EntityFolder hide = new EntityFolder(); - hide.id = FragmentAccount.SWIPE_ACTION_HIDE; + hide.id = EntityMessage.SWIPE_ACTION_HIDE; hide.name = getString(R.string.title_hide); folders.add(hide); EntityFolder delete = new EntityFolder(); - delete.id = FragmentAccount.SWIPE_ACTION_DELETE; + delete.id = EntityMessage.SWIPE_ACTION_DELETE; delete.name = getString(R.string.title_delete_permanently); folders.add(delete);