() {
@Override
public Long onLoad(Bundle args) throws UnsupportedEncodingException {
DB db = DB.getInstance(getContext());
EntityFolder drafts = db.folder().getPrimaryDrafts();
if (drafts == null)
throw new IllegalArgumentException(getString(R.string.title_no_drafts));
StringBuilder info = Helper.getDebugInfo();
info.insert(0, getString(R.string.title_debug_info_remark) + "\n\n\n\n");
Address to = new InternetAddress("marcel+email@faircode.eu", "FairCode");
EntityMessage draft = new EntityMessage();
draft.account = drafts.account;
draft.folder = drafts.id;
draft.to = new Address[]{to};
draft.subject = BuildConfig.APPLICATION_ID + " debug info";
draft.body = "" + info.toString().replaceAll("\\r?\\n", "
") + "
";
draft.received = new Date().getTime();
draft.seen = false;
draft.ui_seen = false;
draft.ui_hide = false;
draft.id = db.message().insertMessage(draft);
return draft.id;
}
@Override
public void onLoaded(Bundle args, Long id) {
btnDebugInfo.setEnabled(true);
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "edit")
.putExtra("id", id));
}
@Override
public void onException(Bundle args, Throwable ex) {
btnDebugInfo.setEnabled(true);
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
}
}.load(FragmentAbout.this, ActivityView.LOADER_DEBUG_INFO, new Bundle());
}
});
return view;
}
}