diff --git a/autojs/src/main/assets/modules/__app__.js b/autojs/src/main/assets/modules/__app__.js index 355b1784..f0b16fb2 100644 --- a/autojs/src/main/assets/modules/__app__.js +++ b/autojs/src/main/assets/modules/__app__.js @@ -65,7 +65,7 @@ module.exports = function(runtime, global){ app.sendEmail = function(options){ options = options || {}; - var i = new Intent(Intent.ACTION_SENDTO); + var i = new Intent(Intent.ACTION_SEND); if(options.email){ i.putExtra(Intent.EXTRA_EMAIL, toArray(options.email)); } @@ -84,21 +84,26 @@ module.exports = function(runtime, global){ if(options.attachment){ i.putExtra(Intent.EXTRA_STREAM, android.content.Uri.parse("file://" + options.attachment)); } + i.setType("message/rfc822"); context.startActivity(Intent.createChooser(i, "发送邮件").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } + function toArray(arg){ + if(typeof(arg) == 'string'){ + arg = [arg]; + } + let arr = util.java.array("string", arg.length); + for(let i = 0; i < arg.length; i++){ + arr[i] = arg; + } + return arr; + } + app.getUriForFile = function(file){ return android.support.v4.content.FileProvider.getUriForFile(context, "org.autojs.autojs.fileprovider", new java.io.File(files.path(path))); }; - function toArray(arg){ - if(typeof(arg) == 'string'){ - return [arg]; - } - return arg; - } - app.launch = app.launchPackage; app.versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; diff --git a/autojs/src/main/assets/modules/__java_util__.js b/autojs/src/main/assets/modules/__java_util__.js index 3e906fb2..12f79d24 100644 --- a/autojs/src/main/assets/modules/__java_util__.js +++ b/autojs/src/main/assets/modules/__java_util__.js @@ -8,15 +8,18 @@ function typeToClass(type) { if (typeof(type) != 'string') { return type; } + if(type == 'string'){ + return java.lang.String; + } var types = { "int": "Integer", "long": "Long", - "string": "String", "double": "Double", "char": "Character", "byte": "Byte", "float": "Float" }; + if (types[type]) { return Packages["java.lang." + types[type]].TYPE; }