mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 05:44:51 +02:00
Added options to select alt re/fwd
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -326,6 +327,42 @@ public class EntityMessage implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
static String collapsePrefixes(Context context, String language, String subject, boolean forward) {
|
||||
List<Pair<String, Boolean>> prefixes = new ArrayList<>();
|
||||
for (String re : Helper.getStrings(context, language, R.string.title_subject_reply, ""))
|
||||
prefixes.add(new Pair<>(re.trim().toLowerCase(), false));
|
||||
for (String re : Helper.getStrings(context, language, R.string.title_subject_reply_alt, ""))
|
||||
prefixes.add(new Pair<>(re.trim().toLowerCase(), false));
|
||||
for (String fwd : Helper.getStrings(context, language, R.string.title_subject_forward, ""))
|
||||
prefixes.add(new Pair<>(fwd.trim().toLowerCase(), true));
|
||||
for (String fwd : Helper.getStrings(context, language, R.string.title_subject_forward_alt, ""))
|
||||
prefixes.add(new Pair<>(fwd.trim().toLowerCase(), true));
|
||||
|
||||
List<Boolean> scanned = new ArrayList<>();
|
||||
subject = subject.trim();
|
||||
while (true) {
|
||||
boolean found = false;
|
||||
for (Pair<String, Boolean> prefix : prefixes)
|
||||
if (subject.toLowerCase().startsWith(prefix.first)) {
|
||||
found = true;
|
||||
int count = scanned.size();
|
||||
if (!prefix.second.equals(count == 0 ? forward : scanned.get(count - 1)))
|
||||
scanned.add(prefix.second);
|
||||
subject = subject.substring(prefix.first.length()).trim();
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
break;
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < scanned.size(); i++)
|
||||
result.append(context.getString(scanned.get(i) ? R.string.title_subject_forward : R.string.title_subject_reply, ""));
|
||||
result.append(subject);
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
Element getReplyHeader(Context context, Document document, boolean separate, boolean extended) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean language_detection = prefs.getBoolean("language_detection", false);
|
||||
|
||||
Reference in New Issue
Block a user