Android Open Source - slf4android Email Error Report






From Project

Back to project page slf4android.

License

The source code is released under:

MIT License

If you think the Android project slf4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package pl.brightinventions.slf4android;
/*  ww  w  . j a v a 2  s.com*/
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

class EmailErrorReport {
    private static final Logger LOG = LoggerFactory.getLogger(EmailErrorReport.class.getSimpleName());
    private final List<String> emailAddresses;
    private String message;
    private String emailSubject;
    private String emailBody;
    private List<AsyncTask<?, ?, File>> attachments = new ArrayList<AsyncTask<?, ?, File>>();

    EmailErrorReport(String message, List<String> emailAddresses, String emailSubject, String emailBody) {
        this.message = message;
        this.emailAddresses = emailAddresses;
        this.emailSubject = emailSubject;
        this.emailBody = emailBody;
    }

    public void addFileAttachmentFrom(AsyncTask<?, ?, File> attachment) {
        attachments.add(attachment);
    }

    public void configureRecipients(Intent sendEmail) {
        String[] emails = new String[emailAddresses.size()];
        emailAddresses.toArray(emails);
        sendEmail.putExtra(Intent.EXTRA_EMAIL, emails);
    }

    public void configureSubject(Intent sendEmail) {
        sendEmail.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
    }

    public void configureMessage(Intent sendEmail) {
        sendEmail.putExtra(Intent.EXTRA_TEXT, emailBody + message);
    }

    public void configureAttachments(Intent sendEmail) {
        ArrayList<Uri> attachmentsUris = new ArrayList<Uri>();
        for (AsyncTask<?, ?, File> fileAttachmentSource : attachments) {
            Uri uri = buildAttachmentUri(fileAttachmentSource);
            if (uri != null) {
                attachmentsUris.add(uri);
            }
        }
        sendEmail.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachmentsUris);
    }

    private Uri buildAttachmentUri(AsyncTask<?, ?, File> attachmentTask) {
        try {
            File file = attachmentTask.get(5, TimeUnit.SECONDS);
            if (file != null) {
                return Uri.fromFile(file);
            } else {
                LOG.warn("Attachment task {} returned null", attachmentTask.getClass().getSimpleName());
            }
        } catch (InterruptedException e) {
            LOG.warn("Interrupted while waiting for attachment", e);
        } catch (ExecutionException e) {
            LOG.warn("Error while waiting for attachment", e);
        } catch (TimeoutException e) {
            LOG.warn("Timed out while waiting for attachment", e);
        }
        return null;
    }
}




Java Source Code List

com.squareup.seismic.ShakeDetector.java
org.slf4j.impl.StaticLoggerBinder.java
pl.brightinventions.slf4android.ActivityStateListener.java
pl.brightinventions.slf4android.AndroidLoggerAdapter.java
pl.brightinventions.slf4android.AndroidLoggerFactory.java
pl.brightinventions.slf4android.AtLeastFilter.java
pl.brightinventions.slf4android.ConstLoggerValueSupplier.java
pl.brightinventions.slf4android.DateValueSupplier.java
pl.brightinventions.slf4android.Disposable.java
pl.brightinventions.slf4android.EmailErrorReport.java
pl.brightinventions.slf4android.FileHandlerExpose.java
pl.brightinventions.slf4android.FileLogHandlerConfiguration.java
pl.brightinventions.slf4android.FileLogHandler.java
pl.brightinventions.slf4android.HandlerFormatterCompiler.java
pl.brightinventions.slf4android.LevelValueSupplier.java
pl.brightinventions.slf4android.ListLogRecordFormatter.java
pl.brightinventions.slf4android.Lists.java
pl.brightinventions.slf4android.LogLevel.java
pl.brightinventions.slf4android.LogRecordFormatterUtilFormatterAdapter.java
pl.brightinventions.slf4android.LogRecordFormatter.java
pl.brightinventions.slf4android.LogRecord.java
pl.brightinventions.slf4android.LogcatHandler.java
pl.brightinventions.slf4android.LoggerConfiguration.java
pl.brightinventions.slf4android.LoggerNameValueSupplier.java
pl.brightinventions.slf4android.LoggerPatternConfiguration.java
pl.brightinventions.slf4android.LoggerPatternValueSupplier.java
pl.brightinventions.slf4android.LoggerPattern.java
pl.brightinventions.slf4android.MakeScreenShotAsyncTask.java
pl.brightinventions.slf4android.MessageValueSupplier.java
pl.brightinventions.slf4android.NotifyDeveloperDialogDisplayActivity.java
pl.brightinventions.slf4android.NotifyDeveloperHandler.java
pl.brightinventions.slf4android.ReadLogcatEntriesAsyncTask.java
pl.brightinventions.slf4android.ThreadValueSupplier.java
pl.brightinventions.slf4android.androidTest.FileHandlerTests.java
pl.brightinventions.slf4android.androidTest.LoggerAdapterTests.java
pl.brightinventions.slf4android.androidTest.NotifyDeveloperHandlerTests.java
pl.brightinventions.slf4android.androidTest.TestActivity.java
pl.brightinventions.slf4android.roboelectric.HandlerFormatterCompilerTests.java
pl.brightinventions.slf4android.roboelectric.MessageValueSupplierTests.java
pl.brightinventions.slf4android.roboelectric.RoboelectricTest.java
pl.brightinventions.slf4android.roboelectric.RobolectricTestRunner.java