From 5caba684ca5fe5a1c9a99c7aa4ee280e46d1c997 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Jul 2024 19:40:13 +0200 Subject: [PATCH] Swipe snooze ask when default is zero --- .../eu/faircode/email/FragmentMessages.java | 68 ++++++++++++------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 69899775e6..44ccafce46 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3312,12 +3312,7 @@ public class FragmentMessages extends FragmentBase int importance = (message.importance == null ? EntityMessage.PRIORITIY_NORMAL : message.importance); onActionSetImportanceSelection((importance + 1) % 3, message.id, false); } else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action)) - if (ActivityBilling.isPro(getContext())) - onActionSnooze(message); - else { - redraw(viewHolder); - startActivity(new Intent(getContext(), ActivityBilling.class)); - } + onSwipeSnooze(message, viewHolder); else if (EntityMessage.SWIPE_ACTION_HIDE.equals(action)) onActionHide(message); else if (EntityMessage.SWIPE_ACTION_MOVE.equals(action)) { @@ -3561,6 +3556,48 @@ public class FragmentMessages extends FragmentBase }); } + private void onSwipeSnooze(TupleMessageEx message, RecyclerView.ViewHolder viewHolder) { + if (!ActivityBilling.isPro(getContext())) { + redraw(viewHolder); + startActivity(new Intent(getContext(), ActivityBilling.class)); + return; + } + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + long duration = prefs.getInt("default_snooze", 1) * 3600 * 1000L; + + if (duration == 0) { + redraw(viewHolder); + Bundle args = new Bundle(); + args.putString("title", getString(R.string.title_snooze)); + args.putLong("account", message.account); + args.putLong("folder", message.folder); + args.putString("thread", message.thread); + args.putLong("id", message.id); + if (message.ui_snoozed != null) + args.putLong("time", message.ui_snoozed); + + FragmentDialogDuration fragment = new FragmentDialogDuration(); + fragment.setArguments(args); + fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_SNOOZE); + fragment.show(getParentFragmentManager(), "message:snooze"); + } else { + Bundle args = new Bundle(); + args.putLong("account", message.account); + args.putString("thread", message.thread); + args.putLong("id", message.id); + if (message.ui_snoozed == null) { + args.putLong("duration", duration); + args.putLong("time", new Date().getTime() + duration); + } else { + args.putLong("duration", 0); + args.putLong("time", 0); + } + + onSnoozeOrHide(args); + } + } + private void onSwipeMove(final @NonNull TupleMessageEx message) { Bundle args = new Bundle(); args.putInt("icon", R.drawable.twotone_drive_file_move_24); @@ -4594,25 +4631,6 @@ public class FragmentMessages extends FragmentBase }.execute(this, args, "messages:seen"); } - private void onActionSnooze(TupleMessageEx message) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - long duration = prefs.getInt("default_snooze", 1) * 3600 * 1000L; - - Bundle args = new Bundle(); - args.putLong("account", message.account); - args.putString("thread", message.thread); - args.putLong("id", message.id); - if (message.ui_snoozed == null) { - args.putLong("duration", duration); - args.putLong("time", new Date().getTime() + duration); - } else { - args.putLong("duration", 0); - args.putLong("time", 0); - } - - onSnoozeOrHide(args); - } - private void onActionHide(TupleMessageEx message) { Bundle args = new Bundle(); args.putLong("account", message.account);