add: LICENSE, ui mode
This commit is contained in:
@@ -19,21 +19,11 @@ var launchApp = function(appName){
|
||||
droid.launchApp(appName);
|
||||
}
|
||||
|
||||
|
||||
var text = function(str){
|
||||
return droid.text(str);
|
||||
}
|
||||
|
||||
var bounds = function(left, top, right, bottom){
|
||||
return droid.bounds(left, top, right, bottom);
|
||||
}
|
||||
|
||||
|
||||
function performAction(action, args){
|
||||
if(args.length == 4){
|
||||
return action(bounds(args[0], args[1], args[2], args[3]));
|
||||
return action(droid.bounds(args[0], args[1], args[2], args[3]));
|
||||
}else{
|
||||
return action(text(args[0]));
|
||||
return action(droid.text(args[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,17 +39,9 @@ var longClick = function(a, b, c, d){
|
||||
}, arguments);
|
||||
}
|
||||
|
||||
var scrollAllUp = function(){
|
||||
droid.scrollAllUp();
|
||||
}
|
||||
|
||||
var scrollAllDown = function(){
|
||||
droid.scrollAllDown();
|
||||
}
|
||||
|
||||
var scrollUp = function(a, b, c, d){
|
||||
if(arguments.length == 0)
|
||||
return scrollAllUp();
|
||||
return droid.scrollAllUp();
|
||||
return performAction(function(target){
|
||||
return droid.scrollUp(target);
|
||||
}, arguments);
|
||||
@@ -67,7 +49,7 @@ var scrollUp = function(a, b, c, d){
|
||||
|
||||
var scrollDown = function(a, b, c, d){
|
||||
if(arguments.length == 0)
|
||||
return scrollAllDown();
|
||||
return droid.scrollAllDown();
|
||||
return performAction(function(target){
|
||||
return droid.scrollDown(target);
|
||||
}, arguments);
|
||||
@@ -95,10 +77,6 @@ var editable = function(i){
|
||||
return droid.editable(i);
|
||||
}
|
||||
|
||||
var setText = function(target, str){
|
||||
return droid.setText(target, str);
|
||||
}
|
||||
|
||||
var input = function(a, b){
|
||||
if(arguments.length == 1){
|
||||
return droid.setText(editable(-1), a);
|
||||
@@ -111,9 +89,11 @@ var sleep = function(millis){
|
||||
droid.sleep(millis);
|
||||
}
|
||||
|
||||
var isStopped = function(){
|
||||
return droid.isStopped();
|
||||
}
|
||||
|
||||
importClass("java.lang.Runnable");
|
||||
var notStopped = function(){
|
||||
return !isStopped();
|
||||
}
|
||||
|
||||
var ui = function(action){
|
||||
droid.ui(new Runnable(action));
|
||||
}
|
||||
22
app/src/main/assets/sample_force_qq_chat.js
Normal file
22
app/src/main/assets/sample_force_qq_chat.js
Normal file
@@ -0,0 +1,22 @@
|
||||
"ui";
|
||||
|
||||
importClass("android.widget.EditText");
|
||||
importClass("android.widget.Button");
|
||||
importClass("android.widget.LinearLayout");
|
||||
importClass("android.view.View.OnClickListener");
|
||||
importClass("android.content.Intent");
|
||||
importClass("android.net.Uri");
|
||||
|
||||
var qq = new EditText(activity);
|
||||
qq.setHint("请输入QQ号");
|
||||
var btnOk = new Button(activity);
|
||||
btnOk.setText("确定");
|
||||
var container = new LinearLayout(activity);
|
||||
container.addView(qq);
|
||||
container.addView(btnOk);
|
||||
activity.setContentView(container);
|
||||
|
||||
btnOk.setOnClickListener(new OnClickListener(function(view){
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + qq.getText())));
|
||||
activity.finish();
|
||||
}));
|
||||
@@ -1,4 +0,0 @@
|
||||
toast("大姐姐好")
|
||||
for(var i = 0; i < 10; i++){
|
||||
toast("大姐姐今年有" + i + "块钱~");
|
||||
}
|
||||
13
app/src/main/assets/sample_qq_hongbao.js
Normal file
13
app/src/main/assets/sample_qq_hongbao.js
Normal file
@@ -0,0 +1,13 @@
|
||||
launch("com.tencent.mobileqq");
|
||||
toast("请打开一个聊天窗口");
|
||||
toast("出现红包时将会自动拆开并关闭");
|
||||
while(!isStopped()){
|
||||
if(click("点击拆开")){
|
||||
//拆开红包后尝试10次关闭红包页面
|
||||
for(var i = 0; i < 10; i++){
|
||||
sleep(300);
|
||||
if(click("关闭"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
"ui";
|
||||
|
||||
importClass("com.afollestad.materialdialogs.MaterialDialog.Builder");
|
||||
importClass("com.afollestad.materialdialogs.MaterialDialog.InputCallback");
|
||||
importClass("android.content.DialogInterface.OnDismissListener");
|
||||
|
||||
new Builder(context)
|
||||
.title("请输入算式")
|
||||
.content("测试")
|
||||
new Builder(activity)
|
||||
.title("简单计算器")
|
||||
.input("请输入算式", "1+1", new InputCallback(function(dialog, input){
|
||||
eval("var ans = (" + input + ")");
|
||||
toast(ans);
|
||||
}))
|
||||
.positiveText("计算")
|
||||
.dismissListener(new OnDismissListener(function(dialog){
|
||||
activity.finish();
|
||||
}))
|
||||
.show();
|
||||
Reference in New Issue
Block a user