mirror of https://github.com/M66B/FairEmail.git
Added autosave option
This commit is contained in:
parent
081d0a2d90
commit
2cb7f6a111
|
@ -395,6 +395,18 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
resolver = getContext().getContentResolver();
|
resolver = getContext().getContentResolver();
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
final boolean auto_save = prefs.getBoolean("auto_save", true);
|
||||||
|
final boolean keyboard_no_fullscreen = prefs.getBoolean("keyboard_no_fullscreen", false);
|
||||||
|
final boolean suggest_names = prefs.getBoolean("suggest_names", true);
|
||||||
|
final boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
|
||||||
|
final boolean suggest_received = prefs.getBoolean("suggest_received", false);
|
||||||
|
final boolean suggest_frequently = prefs.getBoolean("suggest_frequently", false);
|
||||||
|
final boolean cc_bcc = prefs.getBoolean("cc_bcc", false);
|
||||||
|
final boolean circular = prefs.getBoolean("circular", true);
|
||||||
|
|
||||||
|
final float dp3 = Helper.dp2pixels(getContext(), 3);
|
||||||
|
|
||||||
// Wire controls
|
// Wire controls
|
||||||
spIdentity.setOnItemSelectedListener(identitySelected);
|
spIdentity.setOnItemSelectedListener(identitySelected);
|
||||||
|
|
||||||
|
@ -743,9 +755,11 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
etBody.setTag(null);
|
etBody.setTag(null);
|
||||||
|
|
||||||
Bundle extras = new Bundle();
|
if (auto_save) {
|
||||||
extras.putBoolean("silent", true);
|
Bundle extras = new Bundle();
|
||||||
onAction(R.id.action_save, extras, "paragraph");
|
extras.putBoolean("silent", true);
|
||||||
|
onAction(R.id.action_save, extras, "paragraph");
|
||||||
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -960,8 +974,6 @@ public class FragmentCompose extends FragmentBase {
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
FragmentDialogTheme.setBackground(getContext(), view, true);
|
FragmentDialogTheme.setBackground(getContext(), view, true);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
||||||
boolean keyboard_no_fullscreen = prefs.getBoolean("keyboard_no_fullscreen", false);
|
|
||||||
if (keyboard_no_fullscreen) {
|
if (keyboard_no_fullscreen) {
|
||||||
// https://developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_FLAG_NO_FULLSCREEN
|
// https://developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_FLAG_NO_FULLSCREEN
|
||||||
etExtra.setImeOptions(etExtra.getImeOptions() | IME_FLAG_NO_FULLSCREEN);
|
etExtra.setImeOptions(etExtra.getImeOptions() | IME_FLAG_NO_FULLSCREEN);
|
||||||
|
@ -1003,14 +1015,6 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
final DB db = DB.getInstance(getContext());
|
final DB db = DB.getInstance(getContext());
|
||||||
|
|
||||||
final boolean suggest_names = prefs.getBoolean("suggest_names", true);
|
|
||||||
final boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
|
|
||||||
final boolean suggest_received = prefs.getBoolean("suggest_received", false);
|
|
||||||
final boolean suggest_frequently = prefs.getBoolean("suggest_frequently", false);
|
|
||||||
final boolean cc_bcc = prefs.getBoolean("cc_bcc", false);
|
|
||||||
final boolean circular = prefs.getBoolean("circular", true);
|
|
||||||
final float dp3 = Helper.dp2pixels(getContext(), 3);
|
|
||||||
|
|
||||||
SimpleCursorAdapter cadapter = new SimpleCursorAdapter(
|
SimpleCursorAdapter cadapter = new SimpleCursorAdapter(
|
||||||
getContext(),
|
getContext(),
|
||||||
R.layout.spinner_contact,
|
R.layout.spinner_contact,
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
private SwitchCompat swSendPending;
|
private SwitchCompat swSendPending;
|
||||||
private Button btnSound;
|
private Button btnSound;
|
||||||
|
|
||||||
|
private SwitchCompat swAutoSave;
|
||||||
private Spinner spComposeFont;
|
private Spinner spComposeFont;
|
||||||
private SwitchCompat swSeparateReply;
|
private SwitchCompat swSeparateReply;
|
||||||
private SwitchCompat swExtendedReply;
|
private SwitchCompat swExtendedReply;
|
||||||
|
@ -107,7 +108,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
"alt_re", "alt_fwd",
|
"alt_re", "alt_fwd",
|
||||||
"send_reminders", "send_chips", "send_delayed",
|
"send_reminders", "send_chips", "send_delayed",
|
||||||
"attach_new", "answer_action", "send_pending", "sound_sent",
|
"attach_new", "answer_action", "send_pending", "sound_sent",
|
||||||
"compose_font", "prefix_once", "prefix_count", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
|
"auto_save", "compose_font", "prefix_once", "prefix_count", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
|
||||||
"signature_location", "signature_new", "signature_reply", "signature_reply_once", "signature_forward",
|
"signature_location", "signature_new", "signature_reply", "signature_reply_once", "signature_forward",
|
||||||
"discard_delete", "reply_move",
|
"discard_delete", "reply_move",
|
||||||
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
|
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
|
||||||
|
@ -145,6 +146,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
swSendPending = view.findViewById(R.id.swSendPending);
|
swSendPending = view.findViewById(R.id.swSendPending);
|
||||||
btnSound = view.findViewById(R.id.btnSound);
|
btnSound = view.findViewById(R.id.btnSound);
|
||||||
|
|
||||||
|
swAutoSave = view.findViewById(R.id.swAutoSave);
|
||||||
spComposeFont = view.findViewById(R.id.spComposeFont);
|
spComposeFont = view.findViewById(R.id.spComposeFont);
|
||||||
swSeparateReply = view.findViewById(R.id.swSeparateReply);
|
swSeparateReply = view.findViewById(R.id.swSeparateReply);
|
||||||
swExtendedReply = view.findViewById(R.id.swExtendedReply);
|
swExtendedReply = view.findViewById(R.id.swExtendedReply);
|
||||||
|
@ -359,6 +361,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
swAutoSave.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("auto_save", checked).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
spComposeFont.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) {
|
||||||
|
@ -649,6 +658,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||||
|
|
||||||
swSendPending.setChecked(prefs.getBoolean("send_pending", true));
|
swSendPending.setChecked(prefs.getBoolean("send_pending", true));
|
||||||
|
|
||||||
|
swAutoSave.setChecked(prefs.getBoolean("auto_save", true));
|
||||||
|
|
||||||
String compose_font = prefs.getString("compose_font", "");
|
String compose_font = prefs.getString("compose_font", "");
|
||||||
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
||||||
for (int pos = 0; pos < fonts.size(); pos++) {
|
for (int pos = 0; pos < fonts.size(); pos++) {
|
||||||
|
|
|
@ -460,6 +460,18 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swAutoSave"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/title_advanced_auto_save"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvCaptionMessage"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
android:id="@+id/tvComposeFont"
|
android:id="@+id/tvComposeFont"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -471,7 +483,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/tvCaptionMessage" />
|
app:layout_constraintTop_toBottomOf="@id/swAutoSave" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spComposeFont"
|
android:id="@+id/spComposeFont"
|
||||||
|
|
|
@ -394,6 +394,7 @@
|
||||||
<string name="title_advanced_answer_action">Long pressing on the answer button will:</string>
|
<string name="title_advanced_answer_action">Long pressing on the answer button will:</string>
|
||||||
<string name="title_advanced_send_pending">Show non-obtrusive send delayed icon</string>
|
<string name="title_advanced_send_pending">Show non-obtrusive send delayed icon</string>
|
||||||
|
|
||||||
|
<string name="title_advanced_auto_save">Automatically save after new paragraphs</string>
|
||||||
<string name="title_advanced_compose_font">Default font</string>
|
<string name="title_advanced_compose_font">Default font</string>
|
||||||
<string name="title_advanced_auto_identity">Automatically select identities for new messages</string>
|
<string name="title_advanced_auto_identity">Automatically select identities for new messages</string>
|
||||||
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
|
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
|
||||||
|
|
Loading…
Reference in New Issue