Added option to disable printing images

pull/194/head
M66B 4 years ago
parent 7c1e4c64b1
commit 6c1f50dcda

@ -6923,6 +6923,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_print, null);
CheckBox cbHeader = dview.findViewById(R.id.cbHeader);
CheckBox cbImages = dview.findViewById(R.id.cbImages);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
cbHeader.setChecked(prefs.getBoolean("print_html_header", true));
@ -6933,6 +6934,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
});
cbImages.setChecked(prefs.getBoolean("print_html_images", true));
cbImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("print_html_images", isChecked).apply();
}
});
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

@ -7340,11 +7340,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onPrint(Bundle args) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean print_html_header = prefs.getBoolean("print_html_header", true);
boolean print_html_images = prefs.getBoolean("print_html_images", true);
args.putBoolean("print_html_header", print_html_header);
args.putBoolean("print_html_images", print_html_images);
new SimpleTask<String[]>() {
@Override
protected String[] onExecute(Context context, Bundle args) throws IOException {
long id = args.getLong("id");
boolean headers = args.getBoolean("headers");
boolean print_html_header = args.getBoolean("print_html_header");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
@ -7372,8 +7380,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
element.removeClass(clazz);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean print_html_header = prefs.getBoolean("print_html_header", true);
if (print_html_header) {
Element header = document.createElement("p");
@ -7469,12 +7475,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
final Context context = activity.getOriginalContext();
boolean print_html_images = args.getBoolean("print_html_images");
// https://developer.android.com/training/printing/html-docs.html
printWebView = new WebView(context);
WebSettings settings = printWebView.getSettings();
settings.setLoadsImagesAutomatically(true);
settings.setLoadsImagesAutomatically(print_html_images);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
settings.setAllowFileAccess(false);

@ -140,7 +140,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private final static String[] RESET_QUESTIONS = new String[]{
"first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync",
"crash_reports_asked", "review_asked", "review_later", "why",
"reply_hint", "html_always_images", "open_full_confirmed", "print_html_confirmed", "reformatted_hint",
"reply_hint", "html_always_images", "open_full_confirmed",
"print_html_confirmed", "print_html_header", "print_html_images",
"reformatted_hint",
"selected_folders", "move_1_confirmed", "move_n_confirmed",
"last_search_senders", "last_search_recipients", "last_search_subject", "last_search_keywords", "last_search_message", "last_search",
"identities_asked", "identities_primary_hint",

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

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

Loading…
Cancel
Save