mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-01 09:16:00 +00:00
Added print margin of 1 cm
This commit is contained in:
parent
9df0947d85
commit
a751f06242
3 changed files with 33 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -77,6 +77,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvImagesRemark" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbMargin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_print_margins"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlockQuotes" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNotAgain"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -85,6 +96,6 @@
|
|||
android:text="@string/title_no_ask_again"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlockQuotes" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbMargin" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
|
@ -1440,6 +1440,7 @@
|
|||
<string name="title_print_images">Print images</string>
|
||||
<string name="title_print_images_remark">Downloading images might take some time</string>
|
||||
<string name="title_print_block_quotes">Print block quotes lines</string>
|
||||
<string name="title_print_margins">Add a margin</string>
|
||||
<string name="title_show_headers">Show headers</string>
|
||||
<string name="title_show_html">Show source</string>
|
||||
<string name="title_raw_save">Save raw message</string>
|
||||
|
|
Loading…
Reference in a new issue