From ec5709bdc8ddc2e4eeb3313a4d0f1af8aa09fc53 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 3 Aug 2019 14:39:26 +0200 Subject: [PATCH] Improved re/fwd once, default enabled --- .../eu/faircode/email/FragmentCompose.java | 22 +++++++++---------- .../faircode/email/FragmentOptionsSend.java | 2 +- .../main/res/layout/fragment_options_send.xml | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 69624a1756..be65884d60 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -226,7 +226,7 @@ public class FragmentCompose extends FragmentBase { super.onCreate(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - prefix_once = prefs.getBoolean("prefix_once", false); + prefix_once = prefs.getBoolean("prefix_once", true); monospaced = prefs.getBoolean("monospaced", false); style = prefs.getBoolean("style_toolbar", true); } @@ -2072,17 +2072,17 @@ public class FragmentCompose extends FragmentBase { String subject = (ref.subject == null ? "" : ref.subject); if ("reply".equals(action) || "reply_all".equals(action) || "participation".equals(action)) { - String re = context.getString(R.string.title_subject_reply, ""); - if (!prefix_once || !subject.startsWith(re)) - draft.subject = context.getString(R.string.title_subject_reply, subject); - else - draft.subject = ref.subject; + if (prefix_once) { + String re = context.getString(R.string.title_subject_reply, ""); + subject = subject.replace(re.trim(), "").trim(); + } + draft.subject = context.getString(R.string.title_subject_reply, subject); } else if ("forward".equals(action)) { - String fwd = context.getString(R.string.title_subject_forward, ""); - if (!prefix_once || !subject.startsWith(fwd.trim())) - draft.subject = context.getString(R.string.title_subject_forward, subject); - else - draft.subject = ref.subject; + if (prefix_once) { + String fwd = context.getString(R.string.title_subject_forward, ""); + subject = subject.replace(fwd.trim(), "").trim(); + } + draft.subject = context.getString(R.string.title_subject_forward, subject); } else if ("editasnew".equals(action)) { draft.subject = ref.subject; if (ref.content) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index f0aca15d83..a9746b79f8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -195,7 +195,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); swKeyboard.setChecked(prefs.getBoolean("keyboard", true)); - swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false)); + swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true)); swPlainOnly.setChecked(prefs.getBoolean("plain_only", false)); swAutoResize.setChecked(prefs.getBoolean("autoresize", true)); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 0ef3b450f9..1871efcdfb 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -36,6 +36,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_prefix_once" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"