Fixed removing prefix

pull/162/head
M66B 5 years ago
parent cd4cb88192
commit b1d50b4343

@ -2261,13 +2261,13 @@ public class FragmentCompose extends FragmentBase {
if ("reply".equals(action) || "reply_all".equals(action)) { if ("reply".equals(action) || "reply_all".equals(action)) {
if (prefix_once) { if (prefix_once) {
String re = context.getString(R.string.title_subject_reply, ""); String re = context.getString(R.string.title_subject_reply, "");
subject = subject.replaceAll("(?i)" + Pattern.quote(re.trim()), "").trim(); subject = unprefix(subject, re);
} }
data.draft.subject = context.getString(R.string.title_subject_reply, subject); data.draft.subject = context.getString(R.string.title_subject_reply, subject);
} else if ("forward".equals(action)) { } else if ("forward".equals(action)) {
if (prefix_once) { if (prefix_once) {
String fwd = context.getString(R.string.title_subject_forward, ""); String fwd = context.getString(R.string.title_subject_forward, "");
subject = subject.replaceAll("(?i)" + Pattern.quote(fwd.trim()), "").trim(); subject = unprefix(subject, fwd);
} }
data.draft.subject = context.getString(R.string.title_subject_forward, subject); data.draft.subject = context.getString(R.string.title_subject_forward, subject);
} else if ("editasnew".equals(action)) { } else if ("editasnew".equals(action)) {
@ -3154,6 +3154,14 @@ public class FragmentCompose extends FragmentBase {
} }
}; };
private String unprefix(String subject, String prefix) {
subject = subject.trim();
prefix = prefix.trim().toLowerCase(Locale.ROOT);
while (subject.toLowerCase(Locale.ROOT).startsWith(prefix))
subject = subject.substring(prefix.length()).trim();
return subject;
}
private void showDraft(long id) { private void showDraft(long id) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);

Loading…
Cancel
Save