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) { 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); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean("print_html_confirmed", false)) { if (prefs.getBoolean("print_html_confirmed", false)) {
Bundle args = new Bundle();
args.putLong("id", message.id);
Intent data = new Intent(); Intent data = new Intent();
data.putExtra("args", args); data.putExtra("args", args);
parentFragment.onActivityResult(FragmentMessages.REQUEST_PRINT, RESULT_OK, data); parentFragment.onActivityResult(FragmentMessages.REQUEST_PRINT, RESULT_OK, data);
return; return;
} }
Bundle aargs = new Bundle(); args.putString("question", context.getString(R.string.title_ask_show_html));
aargs.putString("question", context.getString(R.string.title_ask_show_html)); args.putString("notagain", "print_html_confirmed");
aargs.putString("notagain", "print_html_confirmed");
aargs.putLong("id", message.id);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(args);
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_PRINT); ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_PRINT);
ask.show(parentFragment.getParentFragmentManager(), "message:print"); ask.show(parentFragment.getParentFragmentManager(), "message:print");
} }

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

Loading…
Cancel
Save