mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-11 03:24:52 +02:00
Added option to show preformatted text monospaced
This commit is contained in:
@@ -85,7 +85,7 @@ public class FragmentOptions extends FragmentBase {
|
||||
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
|
||||
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
|
||||
"message_zoom", "overview_mode", "addresses", "attachments_alt", "thumbnails",
|
||||
"contrast", "monospaced",
|
||||
"contrast", "monospaced", "monospaced_pre",
|
||||
"text_color", "text_size", "text_font", "text_align", "text_separators",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
|
||||
"autoscroll", "swipenav", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",
|
||||
|
||||
@@ -119,6 +119,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
|
||||
private SwitchCompat swContrast;
|
||||
private SwitchCompat swMonospaced;
|
||||
private SwitchCompat swMonospacedPre;
|
||||
private SwitchCompat swTextColor;
|
||||
private SwitchCompat swTextSize;
|
||||
private SwitchCompat swTextFont;
|
||||
@@ -142,7 +143,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
"keywords_header", "labels_header", "flags", "flags_background",
|
||||
"preview", "preview_italic", "preview_lines",
|
||||
"addresses",
|
||||
"message_zoom", "overview_mode", "contrast", "monospaced",
|
||||
"message_zoom", "overview_mode", "contrast", "monospaced", "monospaced_pre",
|
||||
"text_color", "text_size", "text_font", "text_align", "text_separators",
|
||||
"inline_images", "collapse_quotes", "attachments_alt", "thumbnails",
|
||||
"parse_classes", "authentication"
|
||||
@@ -213,6 +214,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
swOverviewMode = view.findViewById(R.id.swOverviewMode);
|
||||
swContrast = view.findViewById(R.id.swContrast);
|
||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||
swMonospacedPre = view.findViewById(R.id.swMonospacedPre);
|
||||
swTextColor = view.findViewById(R.id.swTextColor);
|
||||
swTextSize = view.findViewById(R.id.swTextSize);
|
||||
swTextFont = view.findViewById(R.id.swTextFont);
|
||||
@@ -716,6 +718,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
}
|
||||
});
|
||||
|
||||
swMonospacedPre.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("monospaced_pre", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swTextColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -952,6 +961,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
|
||||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||
swMonospacedPre.setChecked(prefs.getBoolean("monospaced_pre", false));
|
||||
swTextColor.setChecked(prefs.getBoolean("text_color", true));
|
||||
swTextSize.setChecked(prefs.getBoolean("text_size", true));
|
||||
swTextFont.setChecked(prefs.getBoolean("text_font", true));
|
||||
|
||||
@@ -1897,6 +1897,7 @@ public class HtmlHelper {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean debug = prefs.getBoolean("debug", false);
|
||||
boolean text_separators = prefs.getBoolean("text_separators", false);
|
||||
boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
|
||||
|
||||
final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
|
||||
final int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
@@ -2043,7 +2044,12 @@ public class HtmlHelper {
|
||||
ssb.append("[" + element.tagName() + ":" + element.attr("style") + "]");
|
||||
} else if (node instanceof TextNode) {
|
||||
tnode = (TextNode) node;
|
||||
ssb.append(tnode.getWholeText());
|
||||
String text = tnode.getWholeText();
|
||||
ssb.append(text);
|
||||
if (monospaced_pre &&
|
||||
node.parent() instanceof Element &&
|
||||
"true".equals(((Element) node.parent()).attr("x-plain")))
|
||||
setSpan(ssb, new TypefaceSpan("monospace"), ssb.length() - text.length(), ssb.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user