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

View File

@ -98,6 +98,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Spinner spAutoResize;
private TextView tvAutoResize;
private SwitchCompat swSender;
private SwitchCompat swPrefixOnce;
private SwitchCompat swAutoSend;
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",
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
"autoresize", "sender", "autosend",
"autoresize", "sender", "prefix_once", "autosend",
"notify_preview", "search_local", "light", "sound",
"authentication", "paranoid", "english", "updates", "debug",
"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);
tvAutoResize = view.findViewById(R.id.tvAutoResize);
swSender = view.findViewById(R.id.swSender);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swAutoSend = view.findViewById(R.id.swAutoSend);
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() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -681,6 +690,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
spAutoResize.setEnabled(swAutoResize.isChecked());
swSender.setChecked(prefs.getBoolean("sender", false));
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", false));
swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swBadge.setChecked(prefs.getBoolean("badge", true));

View File

@ -701,6 +701,18 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/swAutoSend"
android:layout_width="match_parent"
@ -710,7 +722,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_autosend"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSenderHint"
app:layout_constraintTop_toBottomOf="@id/swPrefixOnce"
app:switchPadding="12dp" />
<TextView

View File

@ -188,6 +188,7 @@
<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_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_badge">Show launcher icon with number of new messages</string>