Added print margin of 1 cm

This commit is contained in:
M66B
2023-11-24 20:17:34 +01:00
parent 9df0947d85
commit a751f06242
3 changed files with 33 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ public class FragmentDialogPrint extends FragmentDialogBase {
CheckBox cbHeader = dview.findViewById(R.id.cbHeader);
CheckBox cbImages = dview.findViewById(R.id.cbImages);
CheckBox cbBlockQuotes = dview.findViewById(R.id.cbBlockQuotes);
CheckBox cbMargin = dview.findViewById(R.id.cbMargin);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
cbHeader.setChecked(prefs.getBoolean("print_html_header", true));
@@ -104,6 +105,14 @@ public class FragmentDialogPrint extends FragmentDialogBase {
}
});
cbMargin.setChecked(prefs.getBoolean("print_html_margins", true));
cbMargin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("print_html_margins", isChecked).apply();
}
});
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -138,10 +147,12 @@ public class FragmentDialogPrint extends FragmentDialogBase {
boolean print_html_header = prefs.getBoolean("print_html_header", true);
boolean print_html_images = prefs.getBoolean("print_html_images", true);
boolean print_html_block_quotes = prefs.getBoolean("print_html_block_quotes", true);
boolean print_html_margins = prefs.getBoolean("print_html_margins", true);
args.putBoolean("print_html_header", print_html_header);
args.putBoolean("print_html_images", print_html_images);
args.putBoolean("print_html_block_quotes", print_html_block_quotes);
args.putBoolean("print_html_margins", print_html_margins);
new SimpleTask<String[]>() {
@Override
@@ -151,6 +162,7 @@ public class FragmentDialogPrint extends FragmentDialogBase {
boolean print_html_header = args.getBoolean("print_html_header");
boolean print_html_images = args.getBoolean("print_html_images");
boolean print_html_block_quotes = args.getBoolean("print_html_block_quotes");
boolean print_html_margins = args.getBoolean("print_html_margins");
CharSequence selected = args.getCharSequence("selected");
boolean draft = args.getBoolean("draft");
@@ -193,6 +205,13 @@ public class FragmentDialogPrint extends FragmentDialogBase {
"padding-left: 0; padding-right: 0;"));
}
if (print_html_margins) {
Element body = document.body();
String style = body.attr("style");
body.attr("style", HtmlHelper.mergeStyles(style,
"margin: 1cm !important;")); // 0.4 inch
}
HtmlHelper.markText(document);
HtmlHelper.embedInlineImages(context, id, document, true);
@@ -350,7 +369,7 @@ public class FragmentDialogPrint extends FragmentDialogBase {
}
args.putLong("received", message.received);
return new String[]{message.subject, document.body().html()};
return new String[]{message.subject, document.html()};
}
@Override