Optionally print headers

pull/168/head
M66B 5 years ago
parent d58f112b72
commit e67bc5e370

@ -3476,23 +3476,23 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onMenuPrint(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("headers", properties.getValue("headers", message.id));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean("print_html_confirmed", false)) {
Bundle args = new Bundle();
args.putLong("id", message.id);
Intent data = new Intent();
data.putExtra("args", args);
parentFragment.onActivityResult(FragmentMessages.REQUEST_PRINT, RESULT_OK, data);
return;
}
Bundle aargs = new Bundle();
aargs.putString("question", context.getString(R.string.title_ask_show_html));
aargs.putString("notagain", "print_html_confirmed");
aargs.putLong("id", message.id);
args.putString("question", context.getString(R.string.title_ask_show_html));
args.putString("notagain", "print_html_confirmed");
FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs);
ask.setArguments(args);
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_PRINT);
ask.show(parentFragment.getParentFragmentManager(), "message:print");
}

@ -4895,15 +4895,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onPrint(Bundle args) {
Bundle pargs = new Bundle();
pargs.putLong("id", args.getLong("id"));
new SimpleTask<String[]>() {
private WebView printWebView = null;
@Override
protected String[] onExecute(Context context, Bundle args) throws IOException {
long id = args.getLong("id");
boolean headers = args.getBoolean("headers");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
@ -4969,6 +4967,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
p.appendChild(span);
}
if (headers && message.headers != null) {
p.appendElement("hr");
Element pre = document.createElement("pre");
pre.text(message.headers);
p.appendChild(pre);
}
p.appendElement("hr").appendElement("br");
document.prependChild(p);
@ -5024,7 +5029,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, pargs, "message:print");
}.execute(this, args, "message:print");
}
private void onEmptyFolder(Bundle args) {

Loading…
Cancel
Save