Added option to prefix subject only once

This commit is contained in:
M66B 2019-04-17 16:35:04 +02:00
parent aba949912c
commit e02c206499
4 changed files with 44 additions and 11 deletions

View File

@ -177,6 +177,8 @@ public class FragmentCompose extends FragmentBase {
private boolean autosave = false; private boolean autosave = false;
private boolean busy = false; private boolean busy = false;
private boolean sender_extra = false;
private boolean prefix_once = false;
private boolean monospaced = false; private boolean monospaced = false;
private boolean style = true; private boolean style = true;
private boolean encrypt = false; private boolean encrypt = false;
@ -191,6 +193,8 @@ public class FragmentCompose extends FragmentBase {
pro = Helper.isPro(getContext()); pro = Helper.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
sender_extra = prefs.getBoolean("sender", false);
prefix_once = prefs.getBoolean("prefix_once", false);
monospaced = prefs.getBoolean("monospaced", false); monospaced = prefs.getBoolean("monospaced", false);
style = prefs.getBoolean("style_toolbar", true); style = prefs.getBoolean("style_toolbar", true);
} }
@ -1755,12 +1759,20 @@ public class FragmentCompose extends FragmentBase {
draft.from = ref.to; draft.from = ref.to;
} }
if ("reply".equals(action) || "reply_all".equals(action)) String subject = (ref.subject == null ? "" : ref.subject);
draft.subject = context.getString(R.string.title_subject_reply, if ("reply".equals(action) || "reply_all".equals(action)) {
ref.subject == null ? "" : ref.subject); String re = context.getString(R.string.title_subject_reply, "");
else if ("forward".equals(action)) if (!prefix_once || !subject.startsWith(re))
draft.subject = context.getString(R.string.title_subject_forward, draft.subject = context.getString(R.string.title_subject_reply, subject);
ref.subject == null ? "" : ref.subject); else
draft.subject = ref.subject;
} else if ("forward".equals(action)) {
String fwd = context.getString(R.string.title_subject_forward, "");
if (!prefix_once || !subject.startsWith(fwd))
draft.subject = context.getString(R.string.title_subject_forward, subject);
else
draft.subject = ref.subject;
}
if (answer > 0) if (answer > 0)
body = EntityAnswer.getAnswerText(db, answer, draft.to) + body; body = EntityAnswer.getAnswerText(db, answer, draft.to) + body;
@ -1896,10 +1908,8 @@ public class FragmentCompose extends FragmentBase {
etTo.setTag(reference < 0 ? "" : etTo.getText().toString()); etTo.setTag(reference < 0 ? "" : etTo.getText().toString());
etSubject.setTag(reference < 0 ? "" : etSubject.getText().toString()); etSubject.setTag(reference < 0 ? "" : etSubject.getText().toString());
boolean sender = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("sender", false);
grpHeader.setVisibility(View.VISIBLE); grpHeader.setVisibility(View.VISIBLE);
grpExtra.setVisibility(sender ? View.VISIBLE : View.GONE); grpExtra.setVisibility(sender_extra ? View.VISIBLE : View.GONE);
grpAddresses.setVisibility("reply_all".equals(action) ? View.VISIBLE : View.GONE); grpAddresses.setVisibility("reply_all".equals(action) ? View.VISIBLE : View.GONE);
getActivity().invalidateOptionsMenu(); getActivity().invalidateOptionsMenu();

View File

@ -98,6 +98,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Spinner spAutoResize; private Spinner spAutoResize;
private TextView tvAutoResize; private TextView tvAutoResize;
private SwitchCompat swSender; private SwitchCompat swSender;
private SwitchCompat swPrefixOnce;
private SwitchCompat swAutoSend; private SwitchCompat swAutoSend;
private SwitchCompat swBadge; private SwitchCompat swBadge;
@ -128,7 +129,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
"startup", "date", "threading", "avatars", "identicons", "name_email", "subject_italic", "flags", "preview", "startup", "date", "threading", "avatars", "identicons", "name_email", "subject_italic", "flags", "preview",
"addresses", "monospaced", "autohtml", "autoimages", "actionbar", "addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove", "pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
"autoresize", "sender", "autosend", "autoresize", "sender", "prefix_once", "autosend",
"notify_preview", "search_local", "light", "sound", "notify_preview", "search_local", "light", "sound",
"authentication", "paranoid", "english", "updates", "debug", "authentication", "paranoid", "english", "updates", "debug",
"first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync", "first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync",
@ -180,6 +181,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
spAutoResize = view.findViewById(R.id.spAutoResize); spAutoResize = view.findViewById(R.id.spAutoResize);
tvAutoResize = view.findViewById(R.id.tvAutoResize); tvAutoResize = view.findViewById(R.id.tvAutoResize);
swSender = view.findViewById(R.id.swSender); swSender = view.findViewById(R.id.swSender);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swAutoSend = view.findViewById(R.id.swAutoSend); swAutoSend = view.findViewById(R.id.swAutoSend);
swBadge = view.findViewById(R.id.swBadge); swBadge = view.findViewById(R.id.swBadge);
@ -502,6 +504,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
} }
}); });
swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("prefix_once", checked).apply();
}
});
swAutoSend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swAutoSend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -681,6 +690,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
spAutoResize.setEnabled(swAutoResize.isChecked()); spAutoResize.setEnabled(swAutoResize.isChecked());
swSender.setChecked(prefs.getBoolean("sender", false)); swSender.setChecked(prefs.getBoolean("sender", false));
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false));
swAutoSend.setChecked(!prefs.getBoolean("autosend", false)); swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swBadge.setChecked(prefs.getBoolean("badge", true)); swBadge.setChecked(prefs.getBoolean("badge", true));

View File

@ -701,6 +701,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSender" /> app:layout_constraintTop_toBottomOf="@id/swSender" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPrefixOnce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_prefix_once"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSenderHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoSend" android:id="@+id/swAutoSend"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -710,7 +722,7 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:text="@string/title_advanced_autosend" android:text="@string/title_advanced_autosend"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSenderHint" app:layout_constraintTop_toBottomOf="@id/swPrefixOnce"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

View File

@ -188,6 +188,7 @@
<string name="title_advanced_autoresize">Automatically resize images for displaying on screens</string> <string name="title_advanced_autoresize">Automatically resize images for displaying on screens</string>
<string name="title_advanced_resize_pixels">&lt; %1$d pixels</string> <string name="title_advanced_resize_pixels">&lt; %1$d pixels</string>
<string name="title_advanced_sender">Allow editing sender address</string> <string name="title_advanced_sender">Allow editing sender address</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_autosend">Confirm sending messages</string> <string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_badge">Show launcher icon with number of new messages</string> <string name="title_advanced_badge">Show launcher icon with number of new messages</string>