api: app
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.stardust.scriptdroid"
|
applicationId "com.stardust.scriptdroid"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 234
|
versionCode 236
|
||||||
versionName "3.0.0 Alpha34"
|
versionName "3.0.0 Alpha36"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
ndk {
|
ndk {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "hide",
|
"key": "hide",
|
||||||
"url": "",
|
"url": "console.html#console_console_hide",
|
||||||
"summary": "隐藏"
|
"summary": "隐藏"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
module.exports = function(__runtime__, scope){
|
module.exports = function(__runtime__, scope){
|
||||||
|
importClass(android.content.Intent);
|
||||||
var app = Object.create(__runtime__.app);
|
var app = Object.create(__runtime__.app);
|
||||||
var context = scope.context;
|
var context = scope.context;
|
||||||
|
|
||||||
@@ -38,6 +39,37 @@ module.exports = function(__runtime__, scope){
|
|||||||
context.sendBroadcast(app.intent(i));
|
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;
|
app.launch = app.launchPackage;
|
||||||
|
|
||||||
scope.__asGlobal__(app, ['launchPackage', 'launch', 'launchApp', 'getPackageName', 'getAppName', 'openAppSetting']);
|
scope.__asGlobal__(app, ['launchPackage', 'launch', 'launchApp', 'getPackageName', 'getAppName', 'openAppSetting']);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class AppUtils {
|
|||||||
@ScriptInterface
|
@ScriptInterface
|
||||||
public boolean launchApp(String appName) {
|
public boolean launchApp(String appName) {
|
||||||
String pkg = getPackageName(appName);
|
String pkg = getPackageName(appName);
|
||||||
if(pkg == null)
|
if (pkg == null)
|
||||||
return false;
|
return false;
|
||||||
return launchPackage(pkg);
|
return launchPackage(pkg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user