Apply monospaced/pre to plain text only messages in original message view

pull/194/merge
M66B 3 years ago
parent 5d0a15ef16
commit 150cc965de

@ -2642,6 +2642,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.appendElement("em")
.text(context.getString(R.string.title_truncated));
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
if (Boolean.TRUE.equals(message.plain_only) && monospaced_pre)
HtmlHelper.restorePre(document);
HtmlHelper.guessSchemes(document);
HtmlHelper.autoLink(document);
@ -4633,11 +4637,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
long id = args.getLong("id");
File file = EntityMessage.getFile(context, id);
Document document = JsoupEx.parse(file);
if (Boolean.TRUE.equals(message.plain_only) && monospaced_pre)
HtmlHelper.restorePre(document);
HtmlHelper.cleanup(document);
HtmlHelper.setViewport(document, overview_mode);
HtmlHelper.embedInlineImages(context, message.id, document, true);

@ -8689,6 +8689,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return null;
Document document = JsoupEx.parse(file);
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
if (Boolean.TRUE.equals(message.plain_only) && monospaced_pre)
HtmlHelper.restorePre(document);
HtmlHelper.embedInlineImages(context, id, document, true);
// onPageFinished will not be called if not all images can be loaded

@ -1951,6 +1951,12 @@ public class HtmlHelper {
return sb.toString();
}
static void restorePre(Document document) {
document.select("div[x-plain=true]")
.tagName("pre")
.removeAttr("x-plain");
}
static void removeTrackingPixels(Context context, Document document) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean disconnect_images = prefs.getBoolean("disconnect_images", false);

Loading…
Cancel
Save