Added option to skip printing header

pull/189/head
M66B 5 years ago
parent 13c2ee5b30
commit 6f9d962c2b

@ -6601,17 +6601,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Bundle args = getArguments();
final Context context = getContext(); final Context context = getContext();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_print, null); View dview = LayoutInflater.from(context).inflate(R.layout.dialog_print, null);
CheckBox cbHeader = dview.findViewById(R.id.cbHeader);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
cbHeader.setChecked(prefs.getBoolean("print_html_header", true));
cbHeader.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("print_html_header", isChecked).apply();
}
});
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("print_html_confirmed", isChecked).apply(); prefs.edit().putBoolean("print_html_confirmed", isChecked).apply();
} }
}); });

@ -7133,7 +7133,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return null; return null;
Document document = JsoupEx.parse(file); Document document = JsoupEx.parse(file);
HtmlHelper.truncate(document, false);
HtmlHelper.embedInlineImages(context, id, document, true); HtmlHelper.embedInlineImages(context, id, document, true);
// Prevent multiple pages for Microsoft Office // Prevent multiple pages for Microsoft Office
@ -7141,6 +7140,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (section == null) if (section == null)
section = document.body(); section = document.body();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean print_html_header = prefs.getBoolean("print_html_header", true);
if (print_html_header) {
Element header = document.createElement("p"); Element header = document.createElement("p");
if (message.from != null && message.from.length > 0) { if (message.from != null && message.from.length > 0) {
@ -7221,8 +7223,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (hasAttachments) if (hasAttachments)
section.appendChild(footer); section.appendChild(footer);
}
return new String[]{message.subject, document.html()}; return new String[]{message.subject, section.html()};
} }
@Override @Override

@ -31,6 +31,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" /> app:layout_constraintTop_toBottomOf="@id/tvMessage" />
<CheckBox
android:id="@+id/cbHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_print_header"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" />
<CheckBox <CheckBox
android:id="@+id/cbNotAgain" android:id="@+id/cbNotAgain"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -39,6 +49,6 @@
android:text="@string/title_no_ask_again" android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" /> app:layout_constraintTop_toBottomOf="@id/cbHeader" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx> </eu.faircode.email.ScrollViewEx>

@ -836,6 +836,7 @@
<string name="title_event">Add to calendar</string> <string name="title_event">Add to calendar</string>
<string name="title_pin">Add shortcut</string> <string name="title_pin">Add shortcut</string>
<string name="title_print">Print</string> <string name="title_print">Print</string>
<string name="title_print_header">Print header</string>
<string name="title_show_headers">Show headers</string> <string name="title_show_headers">Show headers</string>
<string name="title_raw_save">Save raw message</string> <string name="title_raw_save">Save raw message</string>
<string name="title_raw_send">Send as attachment</string> <string name="title_raw_send">Send as attachment</string>

Loading…
Cancel
Save