com.afollestad.materialdialogs.StackingBehavior Java Examples

The following examples show how to use com.afollestad.materialdialogs.StackingBehavior. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectActivity.java    From homeassist with Apache License 2.0 5 votes vote down vote up
private void sendEmail(final String content, final Throwable throwable) {
    final File bootstrapFile = writeToSDFile(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    throwable.printStackTrace(pw);
    final String sStackTrace = sw.toString(); // stack trace as a string
    //System.out.println(sStackTrace);

    new MaterialDialog.Builder(this)
            .title(R.string.title_send_crash_report)
            .content(R.string.message_crash_report)
            .negativeText(getString(R.string.action_dont_send_report))
            .positiveText(getString(R.string.action_send_report))
            .negativeColorRes(R.color.md_blue_500)
            .stackingBehavior(StackingBehavior.ADAPTIVE)
            .positiveColorRes(R.color.md_red_500)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                    emailIntent.setData(Uri.parse("mailto:"));
                    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "HomeAssist Bootstrap Crash Report");
                    emailIntent.putExtra(Intent.EXTRA_TEXT, sStackTrace);

                    Uri uri = Uri.fromFile(bootstrapFile);
                    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    startActivity(Intent.createChooser(emailIntent, getString(R.string.title_send_email)));
                }
            })
            .show();
}