Use answer name as subject

This commit is contained in:
M66B 2019-08-11 14:27:43 +02:00
parent 5f0c13f34c
commit e28bf95149
3 changed files with 17 additions and 5 deletions

View File

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@ -52,11 +54,16 @@ public class EntityAnswer implements Serializable {
@NonNull
public String text;
static String getAnswerText(DB db, long id, Address[] from) {
static String getAnswerText(Context context, long id, Address[] from) {
DB db = DB.getInstance(context);
EntityAnswer answer = db.answer().getAnswer(id);
if (answer == null)
return null;
return getAnswerText(answer, from);
}
static String getAnswerText(EntityAnswer answer, Address[] from) {
String name = null;
String email = null;
String first = null;

View File

@ -298,7 +298,7 @@ public class EntityRule {
if (identity == null)
throw new IllegalArgumentException("Rule identity not found");
String body = EntityAnswer.getAnswerText(db, aid, message.from);
String body = EntityAnswer.getAnswerText(context, aid, message.from);
if (body == null)
throw new IllegalArgumentException("Rule answer not found");

View File

@ -2016,8 +2016,13 @@ public class FragmentCompose extends FragmentBase {
body = args.getString("body", "");
body = body.replaceAll("\\r?\\n", "<br />");
if (answer > 0)
body = EntityAnswer.getAnswerText(db, answer, null) + body;
if (answer > 0) {
EntityAnswer a = db.answer().getAnswer(answer);
if (a != null) {
draft.subject = a.name;
body = EntityAnswer.getAnswerText(a, null) + body;
}
}
} else {
// Actions:
// - reply
@ -2108,7 +2113,7 @@ public class FragmentCompose extends FragmentBase {
draft.plain_only = ref.plain_only;
if (answer > 0)
body = EntityAnswer.getAnswerText(db, answer, draft.to) + body;
body = EntityAnswer.getAnswerText(context, answer, draft.to) + body;
EntityOperation.queue(context, ref, EntityOperation.SEEN, true);
}