Search in sources :

Example 1 with KMLExport

use of ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport in project network-monitor by caarmen.

the class DBOpIntentService method handleActionExport.

private void handleActionExport(ExportFormat exportFileFormat, Bundle extras) {
    Log.d(TAG, "handleActionExport() called with exportFileFormat = [" + exportFileFormat + "]");
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    if (notificationManager == null)
        return;
    FileExport fileExport;
    switch(exportFileFormat) {
        case CSV:
            fileExport = new CSVExport(this);
            break;
        case DB:
            fileExport = new DBExport(this);
            break;
        case EXCEL:
            fileExport = new ExcelExport(this);
            break;
        case HTML:
            fileExport = new HTMLExport(this);
            break;
        case KML:
            String placemarkColumnName = extras.getString(EXTRA_EXPORT_KML_PLACEMARK_COLUMN_NAME);
            fileExport = new KMLExport(this, placemarkColumnName);
            break;
        case GNUPLOT:
            fileExport = new GnuplotExport(this);
            break;
        case SUMMARY:
        default:
            fileExport = null;
    }
    mDBOperation = fileExport;
    File file = null;
    if (fileExport != null) {
        fileExport.execute(mExportProgressListener);
        file = fileExport.getFile();
    }
    // Start the summary report
    Intent shareIntent = FileExport.getShareIntent(this, file);
    // All done
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    final NotificationCompat.Builder notificationBuilder;
    if (fileExport != null && fileExport.isCanceled()) {
        notificationBuilder = prepareFileExportNotification(getString(R.string.export_notif_canceled_title), getString(R.string.export_notif_canceled_content), pendingIntent);
    } else {
        notificationBuilder = prepareFileExportNotification(getString(R.string.export_notif_complete_title), getString(R.string.export_notif_complete_content), pendingIntent);
    }
    notificationBuilder.addAction(R.drawable.ic_pref_share, getString(R.string.action_share), pendingIntent);
    notificationManager.notify(FileExport.class.hashCode(), notificationBuilder.build());
}
Also used : HTMLExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.HTMLExport) NotificationManager(android.app.NotificationManager) ExcelExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.ExcelExport) CSVExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.CSVExport) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) DBExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.DBExport) KMLExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport) GnuplotExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.GnuplotExport) FileExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.FileExport) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) File(java.io.File)

Example 2 with KMLExport

use of ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport in project network-monitor by caarmen.

the class ReportEmailer method createAttachment.

/**
 * @param fileType one of the file types the user selected in the preference
 * @return the BodyPart containing the exported file of this type.
 */
private File createAttachment(String fileType) {
    Log.v(TAG, "createAttachment: fileType = " + fileType);
    // Get the FileExport instance which can export mContext file type.
    final FileExport fileExport;
    switch(fileType) {
        case "csv":
            fileExport = new CSVExport(mContext);
            break;
        case "html":
            fileExport = new HTMLExport(mContext);
            break;
        case "excel":
            fileExport = new ExcelExport(mContext);
            break;
        case "kml":
            fileExport = new KMLExport(mContext, NetMonColumns.SOCKET_CONNECTION_TEST);
            break;
        case "gnuplot":
            fileExport = new GnuplotExport(mContext);
            break;
        case "db":
        default:
            fileExport = new DBExport(mContext);
            break;
    }
    fileExport.execute(null);
    return fileExport.getFile();
}
Also used : KMLExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport) HTMLExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.HTMLExport) ExcelExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.ExcelExport) GnuplotExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.GnuplotExport) FileExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.FileExport) CSVExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.CSVExport) DBExport(ca.rmen.android.networkmonitor.app.dbops.backend.export.DBExport)

Aggregations

CSVExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.CSVExport)2 DBExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.DBExport)2 ExcelExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.ExcelExport)2 FileExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.FileExport)2 GnuplotExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.GnuplotExport)2 HTMLExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.HTMLExport)2 KMLExport (ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport)2 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 File (java.io.File)1