mirror of https://github.com/M66B/FairEmail.git
Auto save after dots
This commit is contained in:
parent
3206a3ae3d
commit
e0d5331c29
|
@ -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) {
|
||||
|
|
|
@ -461,17 +461,28 @@
|
|||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoSave"
|
||||
android:id="@+id/swAutoSaveParagraph"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_advanced_auto_save"
|
||||
android:text="@string/title_advanced_auto_save_paragraph"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionMessage"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoSaveDot"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_auto_save_dot"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoSaveParagraph"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvComposeFont"
|
||||
android:layout_width="0dp"
|
||||
|
@ -483,7 +494,7 @@
|
|||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoSave" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoSaveDot" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spComposeFont"
|
||||
|
|
|
@ -394,7 +394,8 @@
|
|||
<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_auto_save">Automatically save after new paragraphs</string>
|
||||
<string name="title_advanced_auto_save_paragraph">Automatically save after new paragraphs</string>
|
||||
<string name="title_advanced_auto_save_dot">Automatically save after entering dots</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_prefix_once">Prefix subject only once on replying or forwarding</string>
|
||||
|
|
Loading…
Reference in New Issue