Added subject translation

pull/194/merge
M66B 3 years ago
parent 44317fa0b9
commit dfb43001de

@ -7557,12 +7557,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected String onExecute(Context context, Bundle args) throws Throwable { protected String onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id"); long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
File file = EntityMessage.getFile(context, id); File file = EntityMessage.getFile(context, id);
String html = Helper.readText(file); String html = Helper.readText(file);
Document d = HtmlHelper.sanitizeCompose(context, html, false); Document d = HtmlHelper.sanitizeCompose(context, html, false);
d.select("blockquote").remove(); d.select("blockquote").remove();
HtmlHelper.truncate(d, HtmlHelper.MAX_TRANSLATABLE_TEXT_SIZE); HtmlHelper.truncate(d, HtmlHelper.MAX_TRANSLATABLE_TEXT_SIZE);
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, d, null, null); SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, d, null, null);
if (message != null && message.subject != null) {
ssb.insert(0, "\n\n");
ssb.insert(0, message.subject);
}
return ssb.toString() return ssb.toString()
.replace("\uFFFC", "") // Object replacement character .replace("\uFFFC", "") // Object replacement character
.replaceAll("\n\\s+\n", "\n") .replaceAll("\n\\s+\n", "\n")

Loading…
Cancel
Save