From bae65152b856c385ba97b0eae70368eef9c30fa0 Mon Sep 17 00:00:00 2001 From: hyb1996 <946994919@qq.com> Date: Tue, 16 Oct 2018 23:06:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20app.sendEmail()=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E2=80=9C=E6=B2=A1=E6=9C=89=E5=8F=AF=E4=BB=A5=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=AD=A4=E5=8A=A8=E4=BD=9C=E7=9A=84=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E2=80=9D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autojs/src/main/assets/modules/__app__.js | 21 ++++++++++++------- .../src/main/assets/modules/__java_util__.js | 5 ++++- 2 files changed, 17 insertions(+), 9 deletions(-) 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; }