mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 00:53:26 +02:00
Auto save after dots
This commit is contained in:
@@ -396,7 +396,8 @@ public class FragmentCompose extends FragmentBase {
|
||||
resolver = getContext().getContentResolver();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
final boolean auto_save = prefs.getBoolean("auto_save", true);
|
||||
final boolean auto_save_paragraph = prefs.getBoolean("auto_save_paragraph", true);
|
||||
final boolean auto_save_dot = prefs.getBoolean("auto_save_dot", false);
|
||||
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);
|
||||
@@ -646,7 +647,8 @@ public class FragmentCompose extends FragmentBase {
|
||||
if (count - before == 1 && index > 0) {
|
||||
char c = text.charAt(index);
|
||||
char b = text.charAt(index - 1);
|
||||
save = (c == '\n' && b != '\n') || (isDot(c) && !isDot(b));
|
||||
save = (auto_save_paragraph && c == '\n' && b != '\n') ||
|
||||
(auto_save_dot && Helper.isDot(c) && !Helper.isDot(b));
|
||||
if (save)
|
||||
Log.i("Save=" + index);
|
||||
|
||||
@@ -800,7 +802,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
translated = null;
|
||||
}
|
||||
|
||||
if (save && auto_save)
|
||||
if (save)
|
||||
try {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
Bundle extras = new Bundle();
|
||||
@@ -814,11 +816,6 @@ public class FragmentCompose extends FragmentBase {
|
||||
if (lp != null)
|
||||
TextUtils.dumpSpans(text, lp, "---after>");
|
||||
}
|
||||
|
||||
private boolean isDot(char c) {
|
||||
return BuildConfig.DEBUG &&
|
||||
(c == '.' /* Latin */ || c == '。' /* Chinese */);
|
||||
}
|
||||
});
|
||||
|
||||
tvSignature.setTypeface(StyleHelper.getTypeface(compose_font, getContext()));
|
||||
|
||||
@@ -75,7 +75,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
private SwitchCompat swSendPending;
|
||||
private Button btnSound;
|
||||
|
||||
private SwitchCompat swAutoSave;
|
||||
private SwitchCompat swAutoSaveParagraph;
|
||||
private SwitchCompat swAutoSaveDot;
|
||||
private Spinner spComposeFont;
|
||||
private SwitchCompat swSeparateReply;
|
||||
private SwitchCompat swExtendedReply;
|
||||
@@ -108,7 +109,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
"alt_re", "alt_fwd",
|
||||
"send_reminders", "send_chips", "send_delayed",
|
||||
"attach_new", "answer_action", "send_pending", "sound_sent",
|
||||
"auto_save", "compose_font", "prefix_once", "prefix_count", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
|
||||
"auto_save_paragraph", "auto_save_dot",
|
||||
"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",
|
||||
"discard_delete", "reply_move",
|
||||
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
|
||||
@@ -146,7 +148,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
swSendPending = view.findViewById(R.id.swSendPending);
|
||||
btnSound = view.findViewById(R.id.btnSound);
|
||||
|
||||
swAutoSave = view.findViewById(R.id.swAutoSave);
|
||||
swAutoSaveParagraph = view.findViewById(R.id.swAutoSaveParagraph);
|
||||
swAutoSaveDot = view.findViewById(R.id.swAutoSaveDot);
|
||||
spComposeFont = view.findViewById(R.id.spComposeFont);
|
||||
swSeparateReply = view.findViewById(R.id.swSeparateReply);
|
||||
swExtendedReply = view.findViewById(R.id.swExtendedReply);
|
||||
@@ -361,10 +364,17 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
}
|
||||
});
|
||||
|
||||
swAutoSave.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swAutoSaveParagraph.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("auto_save", checked).apply();
|
||||
prefs.edit().putBoolean("auto_save_paragraph", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAutoSaveDot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("auto_save_dot", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -651,7 +661,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
|
||||
|
||||
swSendPending.setChecked(prefs.getBoolean("send_pending", true));
|
||||
|
||||
swAutoSave.setChecked(prefs.getBoolean("auto_save", true));
|
||||
swAutoSaveParagraph.setChecked(prefs.getBoolean("auto_save_paragraph", true));
|
||||
swAutoSaveDot.setChecked(prefs.getBoolean("auto_save_dot", false));
|
||||
|
||||
String compose_font = prefs.getString("compose_font", "");
|
||||
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
|
||||
|
||||
@@ -1861,6 +1861,10 @@ public class Helper {
|
||||
};
|
||||
}
|
||||
|
||||
static boolean isDot(char c) {
|
||||
return (c == '.' /* Latin */ || c == '。' /* Chinese */);
|
||||
}
|
||||
|
||||
// Files
|
||||
|
||||
static String sanitizeFilename(String name) {
|
||||
|
||||
Reference in New Issue
Block a user