diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java
index 73921af845..ec7cd1e66e 100644
--- a/app/src/main/java/eu/faircode/email/ActivityView.java
+++ b/app/src/main/java/eu/faircode/email/ActivityView.java
@@ -2540,8 +2540,10 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
String to = intent.getStringExtra("to");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean send_undo = prefs.getBoolean("send_undo", false);
int send_delayed = prefs.getInt("send_delayed", 0) * 1000;
- if (send_delayed == 0)
+
+ if (!send_undo || send_delayed == 0)
return;
long timeout = at - new Date().getTime();
@@ -2563,7 +2565,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
- protected Long onExecute(Context context, Bundle args) throws Throwable {
+ protected Long onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return ActivityCompose.undoSend(id, context);
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
index 9dd86cbf4f..8906b00f7b 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
@@ -91,6 +91,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swAutoSaveDot;
private SwitchCompat swDiscardDelete;
private Spinner spSendDelayed;
+ private SwitchCompat swSendUndo;
private Spinner spAnswerActionSingle;
private Spinner spAnswerActionLong;
private Button btnSound;
@@ -142,7 +143,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"purge_contact_age", "purge_contact_freq",
"send_reminders", "send_chips", "send_nav_color", "send_pending",
"save_revisions", "auto_save_paragraph", "auto_save_dot", "discard_delete",
- "send_delayed",
+ "send_delayed", "send_undo",
"answer_single", "answer_action",
"sound_sent",
"compose_color", "compose_font", "compose_monospaced",
@@ -189,6 +190,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swAutoSaveDot = view.findViewById(R.id.swAutoSaveDot);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
spSendDelayed = view.findViewById(R.id.spSendDelayed);
+ swSendUndo = view.findViewById(R.id.swSendUndo);
spAnswerActionSingle = view.findViewById(R.id.spAnswerActionSingle);
spAnswerActionLong = view.findViewById(R.id.spAnswerActionLong);
btnSound = view.findViewById(R.id.btnSound);
@@ -436,7 +438,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override
public void onItemSelected(AdapterView> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.sendDelayedValues);
- prefs.edit().putInt("send_delayed", values[position]).apply();
+ int send_delayed = values[position];
+ prefs.edit().putInt("send_delayed", send_delayed).apply();
+ swSendUndo.setEnabled(send_delayed > 0);
}
@Override
@@ -445,6 +449,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
+ swSendUndo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("send_undo", checked).apply();
+ }
+ });
+
spAnswerActionSingle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView> adapterView, View view, int position, long id) {
@@ -966,6 +977,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
break;
}
+ swSendUndo.setChecked(prefs.getBoolean("send_undo", false));
+ swSendUndo.setEnabled(send_delayed > 0);
+
String[] answerValues = getResources().getStringArray(R.array.answerValues);
String answer_default = prefs.getString("answer_single", "menu");
diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml
index 63b8f8a8e0..6fe1605fe5 100644
--- a/app/src/main/res/layout/fragment_options_send.xml
+++ b/app/src/main/res/layout/fragment_options_send.xml
@@ -433,6 +433,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSendDelayed" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/swSendUndo" />
Use the identity color for the bottom action bar
Show reminders
Delay sending messages
+ Show undo send option
Show send button at the top
Create a new draft message for shared addresses and files
Answer button settings