This commit is contained in:
hyb1996 2017-12-11 19:10:01 +08:00
parent 6e6cefbb24
commit 25e9c90bf4
4 changed files with 36 additions and 4 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "com.stardust.scriptdroid"
minSdkVersion 17
targetSdkVersion 23
versionCode 234
versionName "3.0.0 Alpha34"
versionCode 236
versionName "3.0.0 Alpha36"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {

View File

@ -144,7 +144,7 @@
},
{
"key": "hide",
"url": "",
"url": "console.html#console_console_hide",
"summary": "隐藏"
},
{

View File

@ -1,5 +1,6 @@
module.exports = function(__runtime__, scope){
importClass(android.content.Intent);
var app = Object.create(__runtime__.app);
var context = scope.context;
@ -38,6 +39,37 @@ module.exports = function(__runtime__, scope){
context.sendBroadcast(app.intent(i));
}
app.sendEmail = function(options){
options = options || {};
var i = new Intent(ACTION_SENDTO);
if(options.email){
i.putExtra(Intent.EXTRA_EMAIL, toArray(options.email));
}
if(options.cc){
i.putExtra(Intent.EXTRA_CC, toArray(options.cc));
}
if(options.bcc){
i.putExtra(Intent.EXTRA_BCC, toArray(options.bcc));
}
if(options.subject){
i.putExtra(Intent.EXTRA_SUBJECT, options.subject);
}
if(options.text){
i.putExtra(Intent.EXTRA_TEXT, options.text);
}
if(options.attachment){
i.putExtra(Intent.EXTRA_STREAM, android.content.Uri.parse("file://" + options.attachment));
}
context.startActivity(Intent.createChooser(i, "发送邮件").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
function toArray(arg){
if(typeof(arg) == 'string'){
return [arg];
}
return arg;
}
app.launch = app.launchPackage;
scope.__asGlobal__(app, ['launchPackage', 'launch', 'launchApp', 'getPackageName', 'getAppName', 'openAppSetting']);

View File

@ -48,7 +48,7 @@ public class AppUtils {
@ScriptInterface
public boolean launchApp(String appName) {
String pkg = getPackageName(appName);
if(pkg == null)
if (pkg == null)
return false;
return launchPackage(pkg);
}