Added show undo send option

master
M66B 2 months ago
parent eab4033818
commit de49140a25

@ -2540,8 +2540,10 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
String to = intent.getStringExtra("to"); String to = intent.getStringExtra("to");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean send_undo = prefs.getBoolean("send_undo", false);
int send_delayed = prefs.getInt("send_delayed", 0) * 1000; int send_delayed = prefs.getInt("send_delayed", 0) * 1000;
if (send_delayed == 0)
if (!send_undo || send_delayed == 0)
return; return;
long timeout = at - new Date().getTime(); long timeout = at - new Date().getTime();
@ -2563,7 +2565,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
@Override @Override
protected Long onExecute(Context context, Bundle args) throws Throwable { protected Long onExecute(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
return ActivityCompose.undoSend(id, context); return ActivityCompose.undoSend(id, context);
} }

@ -91,6 +91,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swAutoSaveDot; private SwitchCompat swAutoSaveDot;
private SwitchCompat swDiscardDelete; private SwitchCompat swDiscardDelete;
private Spinner spSendDelayed; private Spinner spSendDelayed;
private SwitchCompat swSendUndo;
private Spinner spAnswerActionSingle; private Spinner spAnswerActionSingle;
private Spinner spAnswerActionLong; private Spinner spAnswerActionLong;
private Button btnSound; private Button btnSound;
@ -142,7 +143,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"purge_contact_age", "purge_contact_freq", "purge_contact_age", "purge_contact_freq",
"send_reminders", "send_chips", "send_nav_color", "send_pending", "send_reminders", "send_chips", "send_nav_color", "send_pending",
"save_revisions", "auto_save_paragraph", "auto_save_dot", "discard_delete", "save_revisions", "auto_save_paragraph", "auto_save_dot", "discard_delete",
"send_delayed", "send_delayed", "send_undo",
"answer_single", "answer_action", "answer_single", "answer_action",
"sound_sent", "sound_sent",
"compose_color", "compose_font", "compose_monospaced", "compose_color", "compose_font", "compose_monospaced",
@ -189,6 +190,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swAutoSaveDot = view.findViewById(R.id.swAutoSaveDot); swAutoSaveDot = view.findViewById(R.id.swAutoSaveDot);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete); swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
spSendDelayed = view.findViewById(R.id.spSendDelayed); spSendDelayed = view.findViewById(R.id.spSendDelayed);
swSendUndo = view.findViewById(R.id.swSendUndo);
spAnswerActionSingle = view.findViewById(R.id.spAnswerActionSingle); spAnswerActionSingle = view.findViewById(R.id.spAnswerActionSingle);
spAnswerActionLong = view.findViewById(R.id.spAnswerActionLong); spAnswerActionLong = view.findViewById(R.id.spAnswerActionLong);
btnSound = view.findViewById(R.id.btnSound); btnSound = view.findViewById(R.id.btnSound);
@ -436,7 +438,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override @Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
int[] values = getResources().getIntArray(R.array.sendDelayedValues); 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 @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() { spAnswerActionSingle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -966,6 +977,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
break; break;
} }
swSendUndo.setChecked(prefs.getBoolean("send_undo", false));
swSendUndo.setEnabled(send_delayed > 0);
String[] answerValues = getResources().getStringArray(R.array.answerValues); String[] answerValues = getResources().getStringArray(R.array.answerValues);
String answer_default = prefs.getString("answer_single", "menu"); String answer_default = prefs.getString("answer_single", "menu");

@ -433,6 +433,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSendDelayed" /> app:layout_constraintTop_toBottomOf="@id/tvSendDelayed" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSendUndo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_send_undo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSendDelayed"
app:switchPadding="12dp" />
<TextView <TextView
android:id="@+id/tvAnswerActionSingle" android:id="@+id/tvAnswerActionSingle"
android:layout_width="0dp" android:layout_width="0dp"
@ -444,7 +456,7 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSendDelayed" /> app:layout_constraintTop_toBottomOf="@id/swSendUndo" />
<eu.faircode.email.SpinnerEx <eu.faircode.email.SpinnerEx
android:id="@+id/spAnswerActionSingle" android:id="@+id/spAnswerActionSingle"

@ -477,6 +477,7 @@
<string name="title_advanced_send_nav_color">Use the identity color for the bottom action bar</string> <string name="title_advanced_send_nav_color">Use the identity color for the bottom action bar</string>
<string name="title_advanced_send_reminders">Show reminders</string> <string name="title_advanced_send_reminders">Show reminders</string>
<string name="title_advanced_send_delayed">Delay sending messages</string> <string name="title_advanced_send_delayed">Delay sending messages</string>
<string name="title_advanced_send_undo">Show undo send option</string>
<string name="title_advanced_send_top">Show send button at the top</string> <string name="title_advanced_send_top">Show send button at the top</string>
<string name="title_advanced_attach_new">Create a new draft message for shared addresses and files</string> <string name="title_advanced_attach_new">Create a new draft message for shared addresses and files</string>
<string name="title_advanced_answer_caption">Answer button settings</string> <string name="title_advanced_answer_caption">Answer button settings</string>

Loading…
Cancel
Save