Skip to content

Commit

Permalink
add check for e-mail support in DB export
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarlsen committed Dec 12, 2012
1 parent 7744f0e commit 8f79605
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Resources/main_windows/settings.js
Expand Up @@ -315,22 +315,35 @@ function addExportDbRow(label)
Ti.API.info('In the about row click event');

var emailDialog = Titanium.UI.createEmailDialog();
emailDialog.barColor = orangeColor;

emailDialog.subject = "Mobile Logger Database";
//emailDialog.toRecipients = ['foo@yahoo.com'];
emailDialog.messageBody = 'Attached is the sqlite database file from Mobile Logger.';
// Compress the newly created temp file
var zipFilePath = Ti.Compression.compressFile(f.path);
Ti.API.info('zip file path: '+zipFilePath);

if(zipFilePath) { // it was successful, attach this
emailDialog.addAttachment(Ti.Filesystem.getFile(zipFilePath));

// alert if email is not supported (eg. don't have an e-mail acconut set up)
if(emailDialog.isSupported()) {
emailDialog.barColor = orangeColor;

emailDialog.subject = "Mobile Logger Database";
//emailDialog.toRecipients = ['foo@yahoo.com'];
emailDialog.messageBody = 'Attached is the sqlite database file from Mobile Logger.';
// Compress the newly created temp file
var zipFilePath = Ti.Compression.compressFile(f.path);
Ti.API.info('zip file path: '+zipFilePath);

if(zipFilePath) { // it was successful, attach this
emailDialog.addAttachment(Ti.Filesystem.getFile(zipFilePath));
}
else {
emailDialog.addAttachment(f);
}
emailDialog.open();
Ti.API.info('Email dialog should have opened');
}
else {
emailDialog.addAttachment(f);
// alert
var dialog = Ti.UI.createAlertDialog({
title: 'Cannot Export',
message: 'Please set up a default e-mail account.',
ok: 'OK'
}).show();
}
emailDialog.open();

// clean up:
activityIndicator.hide();
Expand Down

0 comments on commit 8f79605

Please sign in to comment.