|
function shareMessage() { |
|
var shareMessageFull = $.message.text; |
|
var shareMessageEmail = shareMessageFull + "\n\nView more at http://spiritualmixapp.com"; |
|
var shareMessageTwitter = shareMessageFull.substring(0, 123) + " via @LiveLoveRaw"; |
|
if (OS_ANDROID) { |
|
try { |
|
var intTwitter = Ti.Android.createIntent({ |
|
action : Ti.Android.ACTION_SEND, |
|
packageName : "com.twitter.android", |
|
className : "com.twitter.android.PostActivity", |
|
flags : Ti.Android.FLAG_ACTIVITY_NEW_TASK, |
|
type : "text/plain" |
|
}); |
|
intTwitter.putExtra(Ti.Android.EXTRA_TEXT, shareMessageTwitter); |
|
Ti.Android.currentActivity.startActivity(intTwitter); |
|
} catch(x) { |
|
var intShare = Ti.Android.createIntent({ |
|
action : Ti.Android.ACTION_SEND, |
|
type : "text/plain" |
|
}); |
|
intShare.putExtra(Ti.Android.EXTRA_TEXT, shareMessageFull); |
|
Ti.Android.currentActivity.startActivity(intShare); |
|
} |
|
} else { |
|
var optionsDialog = Titanium.UI.createOptionDialog({ |
|
options : ["Email", "Facebook", "Twitter", "Cancel"], |
|
cancel : 3, |
|
title : "How should we share the love?" |
|
}); |
|
optionsDialog.show(); |
|
optionsDialog.addEventListener('click', function(e) { |
|
if (e.index == 0) { |
|
var emailDialog = Ti.UI.createEmailDialog() |
|
emailDialog.subject = "Here a token of love"; |
|
emailDialog.messageBody = shareMessageEmail; |
|
emailDialog.open(); |
|
} |
|
if (e.index === 2) { |
|
var Social = require("dk.napp.social"); |
|
if (Social.isTwitterSupported()) { |
|
Social.twitter({ |
|
text : shareMessageTwitter |
|
}); |
|
} else { |
|
alert(L("Sorry, looks like you don't have twitter enabled")); |
|
} |
|
} |
|
if (e.index === 1) { |
|
var Social = require("dk.napp.social"); |
|
if (Social.isFacebookSupported()) { |
|
Social.facebook({ |
|
text : shareMessageFull, |
|
url : "http://spiritualmixapp.com" |
|
}); |
|
} else { |
|
alert("Sorry, looks like you don't have Facebok enabled"); |
|
} |
|
} |
|
}); |
|
} |
|
}; |