Dying again
This commit is contained in:
1 parent
5a0095f70d
commit
37b5108637
51 files changed
+569
-146
No files matched your search
+3
-4
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.stardust.scriptdroid"
|
applicationId "com.stardust.scriptdroid"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 118
|
versionCode 119
|
||||||
versionName "2.0.8Alpha"
|
versionName "2.0.8 Beta"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
@@ -68,14 +68,13 @@ dependencies {
|
|||||||
compile group: "pl.openrnd.android", name: "multi-level-listview", version: "1.0.1"
|
compile group: "pl.openrnd.android", name: "multi-level-listview", version: "1.0.1"
|
||||||
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
|
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
|
||||||
compile 'io.mattcarroll.hover:hover:0.9.7'
|
compile 'io.mattcarroll.hover:hover:0.9.7'
|
||||||
compile 'org.greenrobot:eventbus:3.0.0'
|
|
||||||
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
|
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
|
||||||
compile 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'
|
compile 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'
|
||||||
compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
|
compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
|
||||||
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
|
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
|
||||||
compile group:'com.twofortyfouram', name:'android-plugin-client-sdk-for-locale', version:'[4.0.2, 5.0['
|
compile group:'com.twofortyfouram', name:'android-plugin-client-sdk-for-locale', version:'[4.0.2, 5.0['
|
||||||
compile 'com.android.volley:volley:1.0.0'
|
compile 'com.android.volley:volley:1.0.0'
|
||||||
compile 'com.github.hyb1996:EnhancedFloaty:0.11'
|
compile 'com.github.hyb1996:EnhancedFloaty:0.12'
|
||||||
compile 'com.android.support:multidex:1.0.1'
|
compile 'com.android.support:multidex:1.0.1'
|
||||||
compile(name: 'libtermexec-release', ext: 'aar')
|
compile(name: 'libtermexec-release', ext: 'aar')
|
||||||
compile(name: 'emulatorview-release', ext: 'aar')
|
compile(name: 'emulatorview-release', ext: 'aar')
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
android:theme="@style/IssueReporterTheme"/>
|
android:theme="@style/IssueReporterTheme"/>
|
||||||
|
|
||||||
<service android:name="com.stardust.view.Floaty$FloatHeadService"/>
|
<service android:name="com.stardust.view.Floaty$FloatHeadService"/>
|
||||||
<service android:name="com.stardust.scriptdroid.external.floating_window.HoverMenuService"/>
|
<service android:name="com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService"/>
|
||||||
|
|
||||||
<activity android:name=".external.tasker.TaskPrefEditActivity"/>
|
<activity android:name=".external.tasker.TaskPrefEditActivity"/>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
"path":"documentation"
|
"path":"documentation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "驻留模式与无障碍服务委托",
|
"title": "模块与第三方jar",
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"path":"documentation"
|
"path":"documentation"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
### loadJar(path)
|
||||||
|
* path \<String\> jar文件路径
|
||||||
|
|
||||||
|
载入jar文件。之后改文件的所有类均可直接使用。这在使用第三方库时十分方便。
|
||||||
|
|
||||||
|
### require(path)
|
||||||
|
* path \<String\> js文件的相对路径
|
||||||
|
|
||||||
|
载入js文件并返回该模块。模块文件应该有module.exports语句指定模块的输出对象。
|
||||||
|
|
||||||
|
例如test.js:
|
||||||
|
```
|
||||||
|
function sayHello(name){
|
||||||
|
print("Hello, " + name);
|
||||||
|
}
|
||||||
|
module.exports = sayHello;
|
||||||
|
```
|
||||||
|
同一个目录下的test_module.js:
|
||||||
|
```
|
||||||
|
var sayHello = require("test");
|
||||||
|
sayHello("AutoJs");
|
||||||
|
```
|
||||||
|
运行这个脚本将在控制台输出"Hello, AutoJs"
|
||||||
@@ -14,20 +14,34 @@ gravity
|
|||||||
weight
|
weight
|
||||||
|
|
||||||
|
|
||||||
|
var ui = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.layout = function(xml){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ui.layout(
|
ui.layout(
|
||||||
<linear orientation="vertical" w="fill" h="300" bg="#ff0000" gravity="center">
|
<linear orientation="vertical" w="fill" h="300" bg="#ff0000" gravity="center" layout_gravity="center">
|
||||||
<text text="测试" size="18" color="#000000"/>
|
<text text="测试" size="18" color="#000000" id="adasd"/>
|
||||||
<button id="btn" text="按钮"/>
|
<button id="btn" text="按钮"/>
|
||||||
</linear>
|
</linear>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vat text = ui.asadsad;
|
||||||
|
|
||||||
<relative>
|
<relative>
|
||||||
|
|
||||||
</relative>
|
</relative>
|
||||||
|
|
||||||
<horizon>
|
<horizon>
|
||||||
|
|
||||||
</horiz>
|
</horizon>
|
||||||
|
|
||||||
<vertical>
|
<vertical>
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
log("Hello world!!!");
|
log("Hello world!!!");
|
||||||
|
toast("Hello, AutoJs!");
|
||||||
openConsole();
|
openConsole();
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//文件路径
|
||||||
|
var path = "/sdcard/1.txt";
|
||||||
|
//要写入的文件内容
|
||||||
|
var text = "Hello, AutoJs";
|
||||||
|
//以写入模式打开文件
|
||||||
|
var file = open(path, "w");
|
||||||
|
//写入文件
|
||||||
|
file.write(text);
|
||||||
|
//关闭文件
|
||||||
|
file.close();
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
convert("/sdcard/1.txt", "utf-8", "/sdcard/2.txt", "gbk");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fromFile: 源文件路径
|
||||||
|
* fromEncoding: 源文件编码
|
||||||
|
* toFile: 输出文件路径
|
||||||
|
* toEncoding: 输出文件编码
|
||||||
|
*/
|
||||||
|
function convert(fromFile, fromEncoding, toFile, toEncoding){
|
||||||
|
fromFile = open(fromFile, "r", fromEncoding);
|
||||||
|
toFile = open(toFile, "w", toEncoding);
|
||||||
|
while(true){
|
||||||
|
var line = fromFile.readline();
|
||||||
|
if(!line)
|
||||||
|
break;
|
||||||
|
toFile.writeline(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
//以UTF-8编码打开SD卡上的1.txt文件
|
||||||
|
var in = open("/sdcard/1.txt", "r", "utf-8");
|
||||||
|
//读取文件所有内容
|
||||||
|
var text = in.read();
|
||||||
|
//关闭文件
|
||||||
|
in.close();
|
||||||
|
//以gbk编码打开SD卡上的2.txt文件
|
||||||
|
var out = open("/sdcard/2.txt", "w", "gbk");
|
||||||
|
//写入内容
|
||||||
|
out.write(text);
|
||||||
|
//关闭文件
|
||||||
|
out.close();
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//以写入模式打开SD卡根目录文件1.txt
|
||||||
|
var file = open("/sdcard/1.txt", "w")
|
||||||
|
//写入aaaa
|
||||||
|
file.write("aaaa");
|
||||||
|
//写入bbbbb后换行
|
||||||
|
file.writeline("bbbbb");
|
||||||
|
//写入ccc与ddd两行
|
||||||
|
file.writelines(["ccc", "ddd"]);
|
||||||
|
//关闭文件
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
//以附加模式打开文件
|
||||||
|
file = open("/sdcard/1.txt", "a");
|
||||||
|
//附加一行"啦啦啦啦"
|
||||||
|
file.writeline("啦啦啦啦");
|
||||||
|
//附加一行"哈哈哈哈"
|
||||||
|
file.writeline("哈哈哈哈");
|
||||||
|
//附加两行ccc, ddd
|
||||||
|
file.writelines(["ccc", "ddd"]);
|
||||||
|
//输出缓冲区
|
||||||
|
file.flush();
|
||||||
|
//关闭文件
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
|
||||||
|
//以读取模式打开文件
|
||||||
|
file = open("/sdcard/test.txt", "r")
|
||||||
|
//读取一行并打印
|
||||||
|
print(file.readline());
|
||||||
|
//读取剩余所有行并打印
|
||||||
|
for each(line in file.readlines()){
|
||||||
|
print(line)
|
||||||
|
}
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
//显示控制台
|
||||||
|
console.show()
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
//文件路径
|
||||||
|
var path = "/sdcard/1.txt";
|
||||||
|
//打开文件
|
||||||
|
var file = open(path);
|
||||||
|
//读取文件的所有内容
|
||||||
|
var text = file.read();
|
||||||
|
//打印到控制台
|
||||||
|
print(text);
|
||||||
|
//关闭文件
|
||||||
|
file.close();
|
||||||
|
console.show();
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
"auto";
|
||||||
|
|
||||||
|
var 延迟 = 0;
|
||||||
|
|
||||||
|
function 点赞(){
|
||||||
|
className("AbsListView").findOne()
|
||||||
|
.children().each(function(ss){
|
||||||
|
try{
|
||||||
|
var 一行 = 找到图标那一行(ss);
|
||||||
|
if(一行){
|
||||||
|
一行.child(1).click();
|
||||||
|
if(延迟 > 0){
|
||||||
|
sleep(延迟);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function 找到图标那一行(s){
|
||||||
|
for(let i = 0; i < s.getChildCount(); i++){
|
||||||
|
var child = s.child(i);
|
||||||
|
if(child && child.className()
|
||||||
|
.endsWith("RelativeLayout") &&
|
||||||
|
child.getChildCount() >= 4){
|
||||||
|
if(是图片(child.child(1)) &&
|
||||||
|
是图片(child.child(2)) &&
|
||||||
|
是图片(child.child(3))){
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function 是图片(item){
|
||||||
|
return item &&
|
||||||
|
item.className().endsWith("ImageView");
|
||||||
|
}
|
||||||
|
|
||||||
|
function 下滑(){
|
||||||
|
className("AbsListView").findOne()
|
||||||
|
.scrollForward();
|
||||||
|
}
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
点赞();
|
||||||
|
下滑();
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
"auto";
|
||||||
|
|
||||||
|
//清空酷安动态
|
||||||
|
//需要酷安客户端支持
|
||||||
|
//务必谨慎使用!!!
|
||||||
|
//by dazhang32552732
|
||||||
|
toast("正在启动酷安");
|
||||||
|
launch("com.coolapk.market");
|
||||||
|
sleep(2000);
|
||||||
|
while(!click("酷市场"));
|
||||||
|
while(!click("我"));
|
||||||
|
while(!click("动态"));
|
||||||
|
toast("请注意,即将开始删除酷安动态,这将不可恢复,请谨慎操作!");
|
||||||
|
sleep(3000);
|
||||||
|
toast("操作将在十秒后自动进行,请谨慎操作!");
|
||||||
|
sleep(5000);
|
||||||
|
toast("操作将在五秒后自动进行,请谨慎操作!");
|
||||||
|
sleep(5000);
|
||||||
|
toast("操作开始!");
|
||||||
|
while(true){
|
||||||
|
id("more_view").click();
|
||||||
|
while(!click("删除"));
|
||||||
|
while(!click("确定"));
|
||||||
|
sleep(1000);
|
||||||
|
}
|
||||||
Vendored
+2
-1
@@ -6,6 +6,7 @@ import android.os.Build;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.App;
|
import com.stardust.scriptdroid.App;
|
||||||
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.util.IntentUtil;
|
import com.stardust.util.IntentUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +15,7 @@ import com.stardust.util.IntentUtil;
|
|||||||
|
|
||||||
public class FloatingWindowManger {
|
public class FloatingWindowManger {
|
||||||
|
|
||||||
public static void showFloatingWindow() {
|
public static void showHoverMenu() {
|
||||||
if (!HoverMenuService.isServiceRunning()) {
|
if (!HoverMenuService.isServiceRunning()) {
|
||||||
if (!hasFloatingWindowPermission()) {
|
if (!hasFloatingWindowPermission()) {
|
||||||
goToFloatingWindowPermissionSetting();
|
goToFloatingWindowPermissionSetting();
|
||||||
|
|||||||
+14
-8
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window;
|
package com.stardust.scriptdroid.external.floating_window.console;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
@@ -6,21 +6,28 @@ import android.support.annotation.Nullable;
|
|||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.stardust.enhancedfloaty.ResizableExpandableFloaty;
|
||||||
|
import com.stardust.enhancedfloaty.ResizableExpandableFloatyService;
|
||||||
import com.stardust.enhancedfloaty.ResizableFloaty;
|
import com.stardust.enhancedfloaty.ResizableFloaty;
|
||||||
import com.stardust.enhancedfloaty.ResizableFloatyService;
|
import com.stardust.enhancedfloaty.ResizableFloatyService;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/4/20.
|
* Created by Stardust on 2017/4/20.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ConsoleFloaty extends ResizableFloaty {
|
public class ConsoleFloaty extends ResizableExpandableFloaty {
|
||||||
|
|
||||||
private ContextWrapper mContextWrapper;
|
private ContextWrapper mContextWrapper;
|
||||||
private View mResizer, mMoveCursor;
|
private View mResizer, mMoveCursor;
|
||||||
|
|
||||||
|
public ConsoleFloaty() {
|
||||||
|
setShouldRequestFocusWhenExpand(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View inflateCollapsedView(ResizableFloatyService service) {
|
public View inflateCollapsedView(ResizableExpandableFloatyService service) {
|
||||||
ensureContextWrapper(service);
|
ensureContextWrapper(service);
|
||||||
return View.inflate(mContextWrapper, R.layout.floating_window_collapse, null);
|
return View.inflate(mContextWrapper, R.layout.floating_window_collapse, null);
|
||||||
}
|
}
|
||||||
@@ -32,28 +39,27 @@ public class ConsoleFloaty extends ResizableFloaty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View inflateExpandedView(ResizableFloatyService service) {
|
public View inflateExpandedView(ResizableExpandableFloatyService service) {
|
||||||
ensureContextWrapper(service);
|
ensureContextWrapper(service);
|
||||||
View view = View.inflate(mContextWrapper, R.layout.floating_console_expand, null);
|
View view = View.inflate(mContextWrapper, R.layout.floating_console_expand, null);
|
||||||
setListeners(view, service);
|
setListeners(view, service);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListeners(final View view, final ResizableFloatyService service) {
|
private void setListeners(final View view, final ResizableExpandableFloatyService service) {
|
||||||
view.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
service.stopSelf();
|
service.stopSelf();
|
||||||
service.stopForeground(true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.findViewById(R.id.move_or_resize).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.move_or_resize).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(mMoveCursor.getVisibility() == View.VISIBLE){
|
if (mMoveCursor.getVisibility() == View.VISIBLE) {
|
||||||
mMoveCursor.setVisibility(View.GONE);
|
mMoveCursor.setVisibility(View.GONE);
|
||||||
mResizer.setVisibility(View.GONE);
|
mResizer.setVisibility(View.GONE);
|
||||||
}else {
|
} else {
|
||||||
mMoveCursor.setVisibility(View.VISIBLE);
|
mMoveCursor.setVisibility(View.VISIBLE);
|
||||||
mResizer.setVisibility(View.VISIBLE);
|
mResizer.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
+3
-2
@@ -1,7 +1,8 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window;
|
package com.stardust.scriptdroid.external.floating_window.console;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.stardust.enhancedfloaty.ResizableExpandableFloatyService;
|
||||||
import com.stardust.enhancedfloaty.ResizableFloatyService;
|
import com.stardust.enhancedfloaty.ResizableFloatyService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +12,6 @@ import com.stardust.enhancedfloaty.ResizableFloatyService;
|
|||||||
public class FloatingConsole {
|
public class FloatingConsole {
|
||||||
|
|
||||||
public static void startFloatingService(Context context) {
|
public static void startFloatingService(Context context) {
|
||||||
ResizableFloatyService.startService(context, new ConsoleFloaty());
|
ResizableExpandableFloatyService.startService(context, new ConsoleFloaty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package com.stardust.scriptdroid.external.floating_window.console;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/4/30.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FloatingConsoleService {
|
||||||
|
}
|
||||||
app/src/main/java/com/stardust/scriptdroid/external/floating_window/console/FloatingConsoleView.java
Vendored
+40
@@ -0,0 +1,40 @@
|
|||||||
|
package com.stardust.scriptdroid.external.floating_window.console;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.jraska.console.Console;
|
||||||
|
import com.stardust.scriptdroid.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/4/30.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FloatingConsoleView extends Console {
|
||||||
|
public FloatingConsoleView(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloatingConsoleView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloatingConsoleView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloatingConsoleView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
findViewById(R.id.console_scroll_view).setBackground(getBackground());
|
||||||
|
((TextView) findViewById(R.id.console_text)).setTextIsSelectable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window;
|
package com.stardust.scriptdroid.external.floating_window.menu;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -16,9 +16,9 @@ import android.util.TypedValue;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.external.floating_window.content.MainMenuNavigatorContent;
|
import com.stardust.scriptdroid.external.floating_window.menu.content.MainMenuNavigatorContent;
|
||||||
import com.stardust.scriptdroid.external.floating_window.content.RecordNavigatorContent;
|
import com.stardust.scriptdroid.external.floating_window.menu.content.RecordNavigatorContent;
|
||||||
import com.stardust.scriptdroid.external.floating_window.content.ScriptListNavigatorContent;
|
import com.stardust.scriptdroid.external.floating_window.menu.content.ScriptListNavigatorContent;
|
||||||
import com.stardust.theme.ThemeColorManagerCompat;
|
import com.stardust.theme.ThemeColorManagerCompat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window;
|
package com.stardust.scriptdroid.external.floating_window.menu;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@@ -17,9 +17,9 @@ import com.stardust.hover.SimpleHoverMenuTransitionListener;
|
|||||||
import com.stardust.hover.WindowHoverMenu;
|
import com.stardust.hover.WindowHoverMenu;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floating_window.view.FloatingLayoutBoundsView;
|
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
||||||
import com.stardust.scriptdroid.external.floating_window.view.FloatingLayoutHierarchyView;
|
import com.stardust.scriptdroid.external.floating_window.menu.view.FloatingLayoutBoundsView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.LayoutInspector;
|
import com.stardust.scriptdroid.external.floating_window.menu.view.FloatingLayoutHierarchyView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
||||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||||
import com.stardust.theme.ThemeColorManagerCompat;
|
import com.stardust.theme.ThemeColorManagerCompat;
|
||||||
+2
-4
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window.content;
|
package com.stardust.scriptdroid.external.floating_window.menu.content;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -11,9 +11,7 @@ import android.widget.Toast;
|
|||||||
import com.stardust.scriptdroid.App;
|
import com.stardust.scriptdroid.App;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.view.accessibility.AccessibilityInfoProvider;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
|
||||||
import com.stardust.scriptdroid.layout_inspector.LayoutInspector;
|
|
||||||
import com.stardust.util.ClipboardUtil;
|
import com.stardust.util.ClipboardUtil;
|
||||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||||
import com.stardust.util.MessageEvent;
|
import com.stardust.util.MessageEvent;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window.content;
|
package com.stardust.scriptdroid.external.floating_window.menu.content;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@@ -14,7 +14,7 @@ import com.stardust.scriptdroid.Pref;
|
|||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.accessibility.AccessibilityEventHelper;
|
import com.stardust.scriptdroid.accessibility.AccessibilityEventHelper;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.record.Recorder;
|
import com.stardust.scriptdroid.record.Recorder;
|
||||||
import com.stardust.scriptdroid.record.accessibility.AccessibilityActionRecorder;
|
import com.stardust.scriptdroid.record.accessibility.AccessibilityActionRecorder;
|
||||||
import com.stardust.scriptdroid.record.inputevent.InputEventConverter;
|
import com.stardust.scriptdroid.record.inputevent.InputEventConverter;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window.content;
|
package com.stardust.scriptdroid.external.floating_window.menu.content;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@@ -10,7 +10,7 @@ import android.view.ViewGroup;
|
|||||||
import com.stardust.autojs.script.FileScriptSource;
|
import com.stardust.autojs.script.FileScriptSource;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.scripts.ScriptFile;
|
import com.stardust.scriptdroid.scripts.ScriptFile;
|
||||||
import com.stardust.scriptdroid.scripts.StorageScriptProvider;
|
import com.stardust.scriptdroid.scripts.StorageScriptProvider;
|
||||||
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
||||||
+2
-5
@@ -1,21 +1,18 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window.view;
|
package com.stardust.scriptdroid.external.floating_window.menu.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.afollestad.materialdialogs.Theme;
|
import com.afollestad.materialdialogs.Theme;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.LayoutBoundsView;
|
import com.stardust.scriptdroid.layout_inspector.view.LayoutBoundsView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.NodeInfoView;
|
import com.stardust.scriptdroid.layout_inspector.view.NodeInfoView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.OnNodeInfoSelectListener;
|
import com.stardust.scriptdroid.layout_inspector.view.OnNodeInfoSelectListener;
|
||||||
import com.stardust.util.MessageEvent;
|
import com.stardust.util.MessageEvent;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/3/12.
|
* Created by Stardust on 2017/3/12.
|
||||||
*/
|
*/
|
||||||
+2
-8
@@ -1,24 +1,18 @@
|
|||||||
package com.stardust.scriptdroid.external.floating_window.view;
|
package com.stardust.scriptdroid.external.floating_window.menu.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.afollestad.materialdialogs.Theme;
|
import com.afollestad.materialdialogs.Theme;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
|
||||||
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.LayoutHierarchyView;
|
import com.stardust.scriptdroid.layout_inspector.view.LayoutHierarchyView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.NodeInfoView;
|
import com.stardust.scriptdroid.layout_inspector.view.NodeInfoView;
|
||||||
import com.stardust.scriptdroid.layout_inspector.view.OnNodeInfoSelectListener;
|
import com.stardust.scriptdroid.layout_inspector.view.OnNodeInfoSelectListener;
|
||||||
import com.stardust.util.MessageEvent;
|
import com.stardust.util.MessageEvent;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/3/12.
|
* Created by Stardust on 2017/3/12.
|
||||||
*/
|
*/
|
||||||
+12
-12
@@ -16,6 +16,8 @@ import com.stardust.scriptdroid.layout_inspector.NodeInfo;
|
|||||||
import com.stardust.util.ViewUtil;
|
import com.stardust.util.ViewUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,33 +101,31 @@ public class LayoutBoundsView extends View {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN && mRootNode != null) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN && mRootNode != null) {
|
||||||
NodeInfo nodeInfo = findNodeAt(mRootNode, (int) event.getRawX(), (int) event.getRawY());
|
ArrayList<NodeInfo> list = new ArrayList<>();
|
||||||
onNodeInfoClick(nodeInfo);
|
findNodeAt(mRootNode, (int) event.getRawX(), (int) event.getRawY(), list);
|
||||||
|
showNodeInfoList(list);
|
||||||
}
|
}
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showNodeInfoList(ArrayList<NodeInfo> list) {
|
||||||
|
onNodeInfoClick(list.get(list.size() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
private void onNodeInfoClick(NodeInfo nodeInfo) {
|
private void onNodeInfoClick(NodeInfo nodeInfo) {
|
||||||
if (mOnNodeInfoSelectListener != null) {
|
if (mOnNodeInfoSelectListener != null) {
|
||||||
mOnNodeInfoSelectListener.onNodeSelect(nodeInfo);
|
mOnNodeInfoSelectListener.onNodeSelect(nodeInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<NodeInfo> findNodeAt(NodeInfo node, int x, int y) {
|
private void findNodeAt(NodeInfo node, int x, int y, List<NodeInfo> list) {
|
||||||
List<NodeInfo> list = null;
|
|
||||||
for (NodeInfo child : node.getChildren()) {
|
for (NodeInfo child : node.getChildren()) {
|
||||||
if (child != null && child.getBoundsInScreen().contains(x, y)) {
|
if (child != null && child.getBoundsInScreen().contains(x, y)) {
|
||||||
if (list == null)
|
list.add(child);
|
||||||
list = findNodeAt(child, x, y);
|
findNodeAt(child, x, y, list);
|
||||||
else
|
|
||||||
list.addAll(findNodeAt(child, x, y));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list == null)
|
|
||||||
list = new ArrayList<>();
|
|
||||||
list.add(node);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,6 @@ import android.content.IntentFilter;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.view.GravityCompat;
|
|
||||||
import android.support.v4.widget.DrawerLayout;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -22,16 +20,11 @@ import com.jecelyin.editor.v2.core.widget.TextView;
|
|||||||
import com.jecelyin.editor.v2.ui.EditorDelegate;
|
import com.jecelyin.editor.v2.ui.EditorDelegate;
|
||||||
import com.jecelyin.editor.v2.view.EditorView;
|
import com.jecelyin.editor.v2.view.EditorView;
|
||||||
import com.jecelyin.editor.v2.view.menu.MenuDef;
|
import com.jecelyin.editor.v2.view.menu.MenuDef;
|
||||||
import com.stardust.autojs.ScriptExecutionListener;
|
|
||||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
|
||||||
import com.stardust.autojs.script.FileScriptSource;
|
import com.stardust.autojs.script.FileScriptSource;
|
||||||
import com.stardust.autojs.script.JsBeautifier;
|
import com.stardust.autojs.script.JsBeautifier;
|
||||||
import com.stardust.autojs.script.ScriptSource;
|
|
||||||
import com.stardust.autojs.script.StringScriptSource;
|
import com.stardust.autojs.script.StringScriptSource;
|
||||||
import com.stardust.scriptdroid.App;
|
|
||||||
import com.stardust.scriptdroid.Pref;
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.external.floating_window.console.FloatingConsole;
|
||||||
import com.stardust.scriptdroid.scripts.ScriptFile;
|
import com.stardust.scriptdroid.scripts.ScriptFile;
|
||||||
import com.stardust.scriptdroid.tool.JsBeautifierFactory;
|
import com.stardust.scriptdroid.tool.JsBeautifierFactory;
|
||||||
import com.stardust.scriptdroid.tool.MaterialDialogFactory;
|
import com.stardust.scriptdroid.tool.MaterialDialogFactory;
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import com.stardust.app.Fragment;
|
import com.stardust.app.Fragment;
|
||||||
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.view.ViewBinding;
|
import com.stardust.view.ViewBinding;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.ui.console.ConsoleActivity;
|
import com.stardust.scriptdroid.ui.console.ConsoleActivity;
|
||||||
@@ -98,7 +98,7 @@ public class EditSideMenuFragment extends Fragment {
|
|||||||
@ViewBinding.Check(R.id.sw_floating_window)
|
@ViewBinding.Check(R.id.sw_floating_window)
|
||||||
private void setFloatingWindowEnable(boolean enable) {
|
private void setFloatingWindowEnable(boolean enable) {
|
||||||
if (enable && !FloatingWindowManger.isFloatingWindowShowing()) {
|
if (enable && !FloatingWindowManger.isFloatingWindowShowing()) {
|
||||||
FloatingWindowManger.showFloatingWindow();
|
FloatingWindowManger.showHoverMenu();
|
||||||
} else if (!enable && FloatingWindowManger.isFloatingWindowShowing()) {
|
} else if (!enable && FloatingWindowManger.isFloatingWindowShowing()) {
|
||||||
FloatingWindowManger.hideFloatingWindow();
|
FloatingWindowManger.hideFloatingWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.stardust.app.Fragment;
|
import com.stardust.app.Fragment;
|
||||||
import com.stardust.scriptdroid.App;
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
||||||
import com.stardust.scriptdroid.external.floating_window.HoverMenuService;
|
import com.stardust.scriptdroid.external.floating_window.menu.HoverMenuService;
|
||||||
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
|
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
|
||||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||||
import com.stardust.scriptdroid.ui.console.ConsoleActivity;
|
import com.stardust.scriptdroid.ui.console.ConsoleActivity;
|
||||||
@@ -110,7 +109,7 @@ public class SlideMenuFragment extends Fragment {
|
|||||||
@ViewBinding.Check(R.id.sw_floating_window)
|
@ViewBinding.Check(R.id.sw_floating_window)
|
||||||
private void setFloatingWindowEnable(boolean enable) {
|
private void setFloatingWindowEnable(boolean enable) {
|
||||||
if (enable && !FloatingWindowManger.isFloatingWindowShowing()) {
|
if (enable && !FloatingWindowManger.isFloatingWindowShowing()) {
|
||||||
FloatingWindowManger.showFloatingWindow();
|
FloatingWindowManger.showHoverMenu();
|
||||||
} else if (!enable && FloatingWindowManger.isFloatingWindowShowing()) {
|
} else if (!enable && FloatingWindowManger.isFloatingWindowShowing()) {
|
||||||
FloatingWindowManger.hideFloatingWindow();
|
FloatingWindowManger.hideFloatingWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -1,10 +1,9 @@
|
|||||||
package com.stardust.scriptdroid.ui.main.operation;
|
package com.stardust.scriptdroid.ui.main.operation;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
|
|
||||||
import com.squareup.haha.perflib.Main;
|
|
||||||
import com.stardust.autojs.ScriptExecutionListener;
|
import com.stardust.autojs.ScriptExecutionListener;
|
||||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||||
import com.stardust.autojs.script.FileScriptSource;
|
import com.stardust.autojs.script.FileScriptSource;
|
||||||
@@ -19,9 +18,7 @@ import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
|||||||
import com.stardust.scriptdroid.scripts.ScriptFile;
|
import com.stardust.scriptdroid.scripts.ScriptFile;
|
||||||
import com.stardust.scriptdroid.scripts.sample.Sample;
|
import com.stardust.scriptdroid.scripts.sample.Sample;
|
||||||
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
||||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
import com.stardust.util.AssetsCache;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/1/23.
|
* Created by Stardust on 2017/1/23.
|
||||||
@@ -77,6 +74,10 @@ public abstract class ScriptFileOperation {
|
|||||||
AutoJs.getInstance().getScriptEngineService().execute(new FileScriptSource(file));
|
AutoJs.getInstance().getScriptEngineService().execute(new FileScriptSource(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void run(Context context, Sample file) {
|
||||||
|
AutoJs.getInstance().getScriptEngineService().execute(new StringScriptSource(file.name, AssetsCache.get(context.getAssets(), file.path)));
|
||||||
|
}
|
||||||
|
|
||||||
public static void runOnEditView(ScriptSource scriptSource) {
|
public static void runOnEditView(ScriptSource scriptSource) {
|
||||||
AutoJs.getInstance().getScriptEngineService().execute(scriptSource, SCRIPT_EXECUTION_LISTENER);
|
AutoJs.getInstance().getScriptEngineService().execute(scriptSource, SCRIPT_EXECUTION_LISTENER);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-9
@@ -14,6 +14,7 @@ import com.stardust.scriptdroid.scripts.sample.Sample;
|
|||||||
import com.stardust.scriptdroid.scripts.sample.SampleFileManager;
|
import com.stardust.scriptdroid.scripts.sample.SampleFileManager;
|
||||||
import com.stardust.scriptdroid.ui.edit.ViewSampleActivity;
|
import com.stardust.scriptdroid.ui.edit.ViewSampleActivity;
|
||||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||||
|
import com.stardust.scriptdroid.ui.main.operation.ScriptFileOperation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -53,11 +54,15 @@ public class SampleScriptListFragment extends Fragment {
|
|||||||
private void showMenuDialog(final Sample sample) {
|
private void showMenuDialog(final Sample sample) {
|
||||||
new MaterialDialog.Builder(getActivity())
|
new MaterialDialog.Builder(getActivity())
|
||||||
.title(sample.name)
|
.title(sample.name)
|
||||||
.items(getString(R.string.text_copy_to_my_scripts))
|
.items(getString(R.string.text_run), getString(R.string.text_copy_to_my_scripts))
|
||||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
|
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
|
||||||
copySampleToMyScripts(sample);
|
if (position == 0) {
|
||||||
|
ScriptFileOperation.run(getActivity(), sample);
|
||||||
|
} else {
|
||||||
|
copySampleToMyScripts(sample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -66,13 +71,6 @@ public class SampleScriptListFragment extends Fragment {
|
|||||||
|
|
||||||
private void copySampleToMyScripts(Sample sample) {
|
private void copySampleToMyScripts(Sample sample) {
|
||||||
MainActivity.importSample(getActivity(), sample);
|
MainActivity.importSample(getActivity(), sample);
|
||||||
try {
|
|
||||||
((MainActivity) getActivity()).getMyScriptListFragment().
|
|
||||||
importFile(sample.name, getActivity().getAssets().open(sample.path));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Snackbar.make(mSampleScriptListRecyclerView, R.string.text_import_fail, Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void viewSample(Sample sample) {
|
private void viewSample(Sample sample) {
|
||||||
|
|||||||
+7
-2
@@ -28,6 +28,9 @@ import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
|
|||||||
|
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/3/27.
|
* Created by Stardust on 2017/3/27.
|
||||||
*/
|
*/
|
||||||
@@ -131,6 +134,7 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
|||||||
private StorageScriptProvider mStorageScriptProvider;
|
private StorageScriptProvider mStorageScriptProvider;
|
||||||
private FileProcessListener mFileProcessListener;
|
private FileProcessListener mFileProcessListener;
|
||||||
private boolean mScriptFileOperationEnabled = true;
|
private boolean mScriptFileOperationEnabled = true;
|
||||||
|
private Executor mFileListingExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
public ScriptAndFolderListRecyclerView(Context context) {
|
public ScriptAndFolderListRecyclerView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -153,7 +157,7 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
|||||||
if (mFileProcessListener != null) {
|
if (mFileProcessListener != null) {
|
||||||
mFileProcessListener.onFilesListing();
|
mFileProcessListener.onFilesListing();
|
||||||
}
|
}
|
||||||
new Thread(new Runnable() {
|
mFileListingExecutor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final ScriptFile[] scriptFiles = mStorageScriptProvider.getDirectoryScriptFiles(directory);
|
final ScriptFile[] scriptFiles = mStorageScriptProvider.getDirectoryScriptFiles(directory);
|
||||||
@@ -163,10 +167,11 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
|||||||
mAdapter.setScripts(scriptFiles);
|
mAdapter.setScripts(scriptFiles);
|
||||||
if (mFileProcessListener != null)
|
if (mFileProcessListener != null)
|
||||||
mFileProcessListener.onFileListed();
|
mFileProcessListener.onFileListed();
|
||||||
|
smoothScrollToPosition(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentDirectory(final ScriptFile directory) {
|
public void setCurrentDirectory(final ScriptFile directory) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.stardust.scriptdroid.ui.main.task;
|
package com.stardust.scriptdroid.ui.main.task;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.IntDef;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@@ -75,19 +76,24 @@ public class TaskListRecyclerView extends ThemeColorRecyclerView implements Java
|
|||||||
setAdapter(mAdapter);
|
setAdapter(mAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEngineList() {
|
public void updateEngineList() {
|
||||||
mScriptEngines.clear();
|
mScriptEngines.clear();
|
||||||
mScriptEngines.addAll(ScriptEngineService.getInstance().getEngines());
|
mScriptEngines.addAll(ScriptEngineService.getInstance().getEngines());
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAttachedToWindow() {
|
protected void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
updateEngineList();
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
ScriptEngineService.getInstance().registerEngineLifecycleCallback(this);
|
ScriptEngineService.getInstance().registerEngineLifecycleCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onWindowVisibilityChanged(int visibility) {
|
||||||
|
super.onWindowVisibilityChanged(visibility);
|
||||||
|
updateEngineList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.stardust.scriptdroid.ui.main.task;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -56,6 +57,19 @@ public class TaskManagerFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
final SwipeRefreshLayout swipeRefreshLayout = $(R.id.swipe_refresh_layout);
|
||||||
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
mTaskListRecyclerView.updateEngineList();
|
||||||
|
mTaskListRecyclerView.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
}
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBinding.Click(R.id.close_all)
|
@ViewBinding.Click(R.id.close_all)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 90 B |
@@ -8,12 +8,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="12dp"
|
android:layout_margin="12dp"
|
||||||
android:background="@drawable/floating_console_bg_bottom"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/floating_console_bg_top"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
@@ -22,13 +22,25 @@
|
|||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
app:title="@string/_app_name">
|
app:title="@string/text_console">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="right">
|
android:layout_gravity="right">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/minimize"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:paddingTop="26dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/ic_remove_white_24dp"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/move_or_resize"
|
android:id="@+id/move_or_resize"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
@@ -52,11 +64,11 @@
|
|||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<view
|
<com.stardust.scriptdroid.external.floating_window.console.FloatingConsoleView
|
||||||
android:id="@+id/console"
|
android:id="@+id/console"
|
||||||
class="com.stardust.scriptdroid.ui.console.ConsoleActivity$ConsoleView"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/floating_console_bg_bottom"
|
||||||
android:minHeight="200dp"/>
|
android:minHeight="200dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,18 @@
|
|||||||
android:textSize="16sp"/>
|
android:textSize="16sp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.stardust.scriptdroid.ui.main.task.TaskListRecyclerView
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/task_list"
|
android:id="@+id/swipe_refresh_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.stardust.scriptdroid.ui.main.task.TaskListRecyclerView
|
||||||
|
android:id="@+id/task_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -214,6 +214,7 @@
|
|||||||
<string name="text_guard_mode">保护模式</string>
|
<string name="text_guard_mode">保护模式</string>
|
||||||
<string name="summary_guard_mode">在本软件界面无法运行自动操作命令以免误触</string>
|
<string name="summary_guard_mode">在本软件界面无法运行自动操作命令以免误触</string>
|
||||||
<string name="key_guard_mode">key_guard_mode</string>
|
<string name="key_guard_mode">key_guard_mode</string>
|
||||||
|
<string name="text_console_floating_window">控制台悬浮窗</string>
|
||||||
|
|
||||||
<string-array name="record_control_keys">
|
<string-array name="record_control_keys">
|
||||||
<item>无</item>
|
<item>无</item>
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import static org.junit.Assert.assertTrue;
|
|||||||
*/
|
*/
|
||||||
public class ExampleUnitTest {
|
public class ExampleUnitTest {
|
||||||
// TODO: 2017/3/3 自定义函数
|
// TODO: 2017/3/3 自定义函数
|
||||||
// TODO: 2017/3/19 exist函数
|
// TODO: 2017/3/19 exist函数 √
|
||||||
// TODO: 2017/3/23 tasker插件
|
// TODO: 2017/3/23 tasker插件 √
|
||||||
// TODO: 2017/3/23 任务管理与控制台
|
// TODO: 2017/3/23 任务管理与控制台 √
|
||||||
// TODO: 2017/3/23 悬浮窗加入控制台
|
// TODO: 2017/3/23 悬浮窗加入控制台
|
||||||
// TODO: 2017/3/24 文件读写api
|
// TODO: 2017/3/24 文件读写api
|
||||||
// TODO: 2017/3/24 网络读写api
|
// TODO: 2017/3/24 网络读写api
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ dependencies {
|
|||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||||
compile 'com.github.hyb1996:node-android-lib:1.0.14'
|
compile 'com.github.hyb1996:node-android-lib:1.0.14'
|
||||||
|
compile 'org.greenrobot:eventbus:3.0.0'
|
||||||
compile project(path: ':common')
|
compile project(path: ':common')
|
||||||
compile project(path: ':automator')
|
compile project(path: ':automator')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ import android.util.Log;
|
|||||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||||
import com.stardust.autojs.engine.JavaScriptEngineManager;
|
import com.stardust.autojs.engine.JavaScriptEngineManager;
|
||||||
import com.stardust.autojs.engine.ScriptExecuteActivity;
|
import com.stardust.autojs.engine.ScriptExecuteActivity;
|
||||||
|
import com.stardust.autojs.runtime.ScriptInterrupptedException;
|
||||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||||
import com.stardust.autojs.runtime.api.Console;
|
import com.stardust.autojs.runtime.api.Console;
|
||||||
import com.stardust.autojs.script.ScriptSource;
|
import com.stardust.autojs.script.ScriptSource;
|
||||||
|
import com.stardust.lang.ThreadCompat;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -23,6 +28,7 @@ import java.util.Set;
|
|||||||
public class ScriptEngineService {
|
public class ScriptEngineService {
|
||||||
|
|
||||||
private static final String LOG_TAG = "ScriptEngineService";
|
private static final String LOG_TAG = "ScriptEngineService";
|
||||||
|
private static final EventBus EVENT_BUS = new EventBus();
|
||||||
private static ScriptEngineService instance;
|
private static ScriptEngineService instance;
|
||||||
|
|
||||||
public static ScriptEngineService getInstance() {
|
public static ScriptEngineService getInstance() {
|
||||||
@@ -33,27 +39,26 @@ public class ScriptEngineService {
|
|||||||
instance = service;
|
instance = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ScriptExecutionListener DEFAULT_LISTENER = new SimpleScriptExecutionListener() {
|
||||||
|
@Override
|
||||||
|
public void onStart(JavaScriptEngine engine, ScriptSource source) {
|
||||||
|
EVENT_BUS.post(new ScriptExecutionEvent(ScriptExecutionEvent.ON_START, source.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(JavaScriptEngine engine, ScriptSource source, Exception e) {
|
||||||
|
if (!causedByInterrupted(e)) {
|
||||||
|
EVENT_BUS.post(new ScriptExecutionEvent(ScriptExecutionEvent.ON_EXCEPTION, e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private final ScriptRuntime mRuntime;
|
private final ScriptRuntime mRuntime;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Console mConsole;
|
private final Console mConsole;
|
||||||
private final JavaScriptEngineManager mJavaScriptEngineManager;
|
private final JavaScriptEngineManager mJavaScriptEngineManager;
|
||||||
private final EngineLifecycleObserver mEngineLifecycleObserver = new EngineLifecycleObserver();
|
private final EngineLifecycleObserver mEngineLifecycleObserver = new EngineLifecycleObserver();
|
||||||
private final ScriptExecutionListener mDefaultListener = new SimpleScriptExecutionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart(JavaScriptEngine engine, ScriptSource source) {
|
|
||||||
mConsole.v(DateFormat.getTimeInstance().format(new Date()) + " " + mContext.getString(R.string.text_start_running) + " " + source);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onException(JavaScriptEngine engine, ScriptSource source, Exception e) {
|
|
||||||
if (!causedByInterruptedException(e)) {
|
|
||||||
mRuntime.toast(mContext.getString(R.string.text_error) + ": " + e.getMessage());
|
|
||||||
mConsole.e(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ScriptEngineService(ScriptEngineServiceBuilder builder) {
|
ScriptEngineService(ScriptEngineServiceBuilder builder) {
|
||||||
mRuntime = builder.mRuntime;
|
mRuntime = builder.mRuntime;
|
||||||
@@ -61,6 +66,7 @@ public class ScriptEngineService {
|
|||||||
mJavaScriptEngineManager = builder.mJavaScriptEngineManager;
|
mJavaScriptEngineManager = builder.mJavaScriptEngineManager;
|
||||||
mConsole = builder.mConsole;
|
mConsole = builder.mConsole;
|
||||||
mJavaScriptEngineManager.setEngineLifecycleCallback(mEngineLifecycleObserver);
|
mJavaScriptEngineManager.setEngineLifecycleCallback(mEngineLifecycleObserver);
|
||||||
|
EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptRuntime getRuntime() {
|
public ScriptRuntime getRuntime() {
|
||||||
@@ -72,12 +78,12 @@ public class ScriptEngineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ScriptExecutionListener getDefaultListener() {
|
public ScriptExecutionListener getDefaultListener() {
|
||||||
return mDefaultListener;
|
return DEFAULT_LISTENER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaScriptEngine createScriptEngine() {
|
public JavaScriptEngine createScriptEngine() {
|
||||||
JavaScriptEngine engine = mJavaScriptEngineManager.createEngine();
|
JavaScriptEngine engine = mJavaScriptEngineManager.createEngine();
|
||||||
Log.i(LOG_TAG, Arrays.toString(Thread.currentThread().getStackTrace()));
|
Log.d(LOG_TAG, Arrays.toString(Thread.currentThread().getStackTrace()));
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,18 +95,12 @@ public class ScriptEngineService {
|
|||||||
mEngineLifecycleObserver.unregisterCallback(engineLifecycleCallback);
|
mEngineLifecycleObserver.unregisterCallback(engineLifecycleCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean causedByInterruptedException(Throwable e) {
|
public static boolean causedByInterrupted(Throwable e) {
|
||||||
while (e != null) {
|
return e.getCause() instanceof ScriptInterrupptedException;
|
||||||
if (e instanceof InterruptedException) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
e = e.getCause();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptExecution execute(ScriptExecutionTask task) {
|
public ScriptExecution execute(ScriptExecutionTask task) {
|
||||||
ScriptExecutionListener listener = task.getExecutionListenerOrDefault(mDefaultListener);
|
ScriptExecutionListener listener = task.getExecutionListenerOrDefault(DEFAULT_LISTENER);
|
||||||
ScriptSource source = task.getSource();
|
ScriptSource source = task.getSource();
|
||||||
int mode = source.getExecutionMode();
|
int mode = source.getExecutionMode();
|
||||||
if ((mode & ScriptSource.EXECUTION_MODE_UI) != 0) {
|
if ((mode & ScriptSource.EXECUTION_MODE_UI) != 0) {
|
||||||
@@ -109,7 +109,7 @@ public class ScriptEngineService {
|
|||||||
} else {
|
} else {
|
||||||
RunnableScriptExecution scriptExecution = new RunnableScriptExecution(source, listener, task.getConfig());
|
RunnableScriptExecution scriptExecution = new RunnableScriptExecution(source, listener, task.getConfig());
|
||||||
if (task.getConfig().runInNewThread) {
|
if (task.getConfig().runInNewThread) {
|
||||||
new Thread(scriptExecution).start();
|
new ThreadCompat(scriptExecution).start();
|
||||||
} else {
|
} else {
|
||||||
scriptExecution.run();
|
scriptExecution.run();
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,17 @@ public class ScriptEngineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ScriptExecution execute(ScriptSource source) {
|
public ScriptExecution execute(ScriptSource source) {
|
||||||
return execute(source, mDefaultListener, ExecutionConfig.getDefault());
|
return execute(source, DEFAULT_LISTENER, ExecutionConfig.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onScriptExecution(ScriptExecutionEvent event) {
|
||||||
|
if (event.getCode() == ScriptExecutionEvent.ON_START) {
|
||||||
|
mConsole.v(DateFormat.getTimeInstance().format(new Date()) + " " + mContext.getString(R.string.text_start_running) + " " + event.getMessage());
|
||||||
|
} else if (event.getCode() == ScriptExecutionEvent.ON_EXCEPTION) {
|
||||||
|
mRuntime.toast(mContext.getString(R.string.text_error) + ": " + event.getMessage());
|
||||||
|
mConsole.e(event.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int stopAll() {
|
public int stopAll() {
|
||||||
@@ -209,4 +219,28 @@ public class ScriptEngineService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class ScriptExecutionEvent {
|
||||||
|
|
||||||
|
static final int ON_START = "Eating...".hashCode();
|
||||||
|
static final int ON_SUCCESS = "I...lov...".hashCode();
|
||||||
|
static final int ON_EXCEPTION = "...Sorry...I should not have said it...".hashCode();
|
||||||
|
|
||||||
|
private final int mCode;
|
||||||
|
private final String mMessage;
|
||||||
|
|
||||||
|
ScriptExecutionEvent(int code, String message) {
|
||||||
|
mCode = code;
|
||||||
|
mMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return mCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return mMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.stardust.autojs;
|
package com.stardust.autojs;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||||
import com.stardust.autojs.script.ScriptSource;
|
import com.stardust.autojs.script.ScriptSource;
|
||||||
@@ -12,6 +14,8 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
public class ScriptExecutionTask implements Serializable {
|
public class ScriptExecutionTask implements Serializable {
|
||||||
|
|
||||||
|
private static final String TAG = "ScriptExecutionTask";
|
||||||
|
|
||||||
private ScriptSource mScriptSource;
|
private ScriptSource mScriptSource;
|
||||||
private ScriptExecutionListener mExecutionListener;
|
private ScriptExecutionListener mExecutionListener;
|
||||||
private ExecutionConfig mExecutionConfig;
|
private ExecutionConfig mExecutionConfig;
|
||||||
@@ -43,8 +47,10 @@ public class ScriptExecutionTask implements Serializable {
|
|||||||
engine.setTag("script", mScriptSource);
|
engine.setTag("script", mScriptSource);
|
||||||
mExecutionListener.onSuccess(engine, mScriptSource, engine.execute(mScriptSource));
|
mExecutionListener.onSuccess(engine, mScriptSource, engine.execute(mScriptSource));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
mExecutionListener.onException(engine, mScriptSource, e);
|
mExecutionListener.onException(engine, mScriptSource, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
Log.d(TAG, "Engine destroy");
|
||||||
engine.destroy();
|
engine.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.stardust.autojs.rhino_android.AndroidContextFactory;
|
import com.stardust.autojs.rhino_android.AndroidContextFactory;
|
||||||
import com.stardust.autojs.rhino_android.RhinoAndroidHelper;
|
import com.stardust.autojs.rhino_android.RhinoAndroidHelper;
|
||||||
|
import com.stardust.autojs.runtime.ScriptInterrupptedException;
|
||||||
import com.stardust.autojs.runtime.ScriptStopException;
|
import com.stardust.autojs.runtime.ScriptStopException;
|
||||||
import com.stardust.autojs.script.ScriptSource;
|
import com.stardust.autojs.script.ScriptSource;
|
||||||
import com.stardust.view.accessibility.AccessibilityNodeInfoAllocator;
|
import com.stardust.view.accessibility.AccessibilityNodeInfoAllocator;
|
||||||
@@ -59,6 +60,7 @@ public class RhinoJavaScriptEngine implements JavaScriptEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forceStop() {
|
public void forceStop() {
|
||||||
|
Log.d(LOG_TAG, "forceStop: interrupt Thread: " + mThread);
|
||||||
mThread.interrupt();
|
mThread.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +70,7 @@ public class RhinoJavaScriptEngine implements JavaScriptEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void destroy() {
|
public synchronized void destroy() {
|
||||||
|
Log.d(LOG_TAG, "on destroy");
|
||||||
Context.exit();
|
Context.exit();
|
||||||
// TODO: 2017/4/6 XXX :在这里回收内存池并不好
|
// TODO: 2017/4/6 XXX :在这里回收内存池并不好
|
||||||
final AccessibilityNodeInfoAllocator allocator = (AccessibilityNodeInfoAllocator) getTag("allocator");
|
final AccessibilityNodeInfoAllocator allocator = (AccessibilityNodeInfoAllocator) getTag("allocator");
|
||||||
@@ -138,7 +141,7 @@ public class RhinoJavaScriptEngine implements JavaScriptEngine {
|
|||||||
protected void observeInstructionCount(Context cx, int instructionCount) {
|
protected void observeInstructionCount(Context cx, int instructionCount) {
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
Context.exit();
|
Context.exit();
|
||||||
throw new ScriptStopException(new InterruptedException());
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.stardust.autojs.rhino_android;
|
package com.stardust.autojs.rhino_android;
|
||||||
|
|
||||||
|
|
||||||
|
import com.stardust.autojs.runtime.ScriptInterrupptedException;
|
||||||
import com.stardust.autojs.runtime.ScriptStopException;
|
import com.stardust.autojs.runtime.ScriptStopException;
|
||||||
|
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
@@ -39,7 +40,7 @@ public class AndroidContextFactory extends ContextFactory {
|
|||||||
@Override
|
@Override
|
||||||
protected void observeInstructionCount(Context cx, int instructionCount) {
|
protected void observeInstructionCount(Context cx, int instructionCount) {
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
throw new ScriptStopException(new InterruptedException());
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.stardust.autojs.runtime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/4/30.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ScriptInterrupptedException extends ScriptStopException {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -78,7 +78,7 @@ public class ScriptRuntime {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(millis);
|
Thread.sleep(millis);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new ScriptStopException(e);
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +142,6 @@ public class ScriptRuntime {
|
|||||||
Thread.interrupted();
|
Thread.interrupted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stoppedByInterrupted(InterruptedException e) {
|
|
||||||
throw new ScriptStopException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ensureAccessibilityServiceEnabled() {
|
public void ensureAccessibilityServiceEnabled() {
|
||||||
mAccessibilityBridge.ensureServiceEnabled();
|
mAccessibilityBridge.ensureServiceEnabled();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.webkit.WebView;
|
|||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
|
||||||
|
import com.stardust.autojs.runtime.ScriptInterrupptedException;
|
||||||
import com.stardust.autojs.runtime.ScriptStopException;
|
import com.stardust.autojs.runtime.ScriptStopException;
|
||||||
|
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
@@ -107,7 +108,7 @@ public class InjectableWebClient extends WebViewClient {
|
|||||||
try {
|
try {
|
||||||
ScriptBridge.this.wait();
|
ScriptBridge.this.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new ScriptStopException(e);
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
@@ -131,7 +132,7 @@ public class InjectableWebClient extends WebViewClient {
|
|||||||
try {
|
try {
|
||||||
this.wait();
|
this.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new ScriptStopException(e);
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
|||||||
|
|
||||||
import com.stardust.autojs.runtime.AccessibilityBridge;
|
import com.stardust.autojs.runtime.AccessibilityBridge;
|
||||||
import com.stardust.autojs.runtime.JavascriptInterface;
|
import com.stardust.autojs.runtime.JavascriptInterface;
|
||||||
|
import com.stardust.autojs.runtime.ScriptInterrupptedException;
|
||||||
import com.stardust.autojs.runtime.ScriptStopException;
|
import com.stardust.autojs.runtime.ScriptStopException;
|
||||||
import com.stardust.automator.AccessibilityEventCommandHost;
|
import com.stardust.automator.AccessibilityEventCommandHost;
|
||||||
import com.stardust.automator.ActionArgument;
|
import com.stardust.automator.ActionArgument;
|
||||||
@@ -118,7 +119,7 @@ public class UiSelector extends UiGlobalSelector {
|
|||||||
do {
|
do {
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
Log.d(TAG, "Thread isInterrupted");
|
Log.d(TAG, "Thread isInterrupted");
|
||||||
throw new ScriptStopException(new InterruptedException());
|
throw new ScriptInterrupptedException();
|
||||||
}
|
}
|
||||||
uiObjectCollection = find();
|
uiObjectCollection = find();
|
||||||
} while (uiObjectCollection == null || uiObjectCollection.size() == 0);
|
} while (uiObjectCollection == null || uiObjectCollection.size() == 0);
|
||||||
|
|||||||
+2
-2
@@ -189,7 +189,7 @@ public class SimpleActionAutomator {
|
|||||||
private boolean performAction(SimpleAction simpleAction) {
|
private boolean performAction(SimpleAction simpleAction) {
|
||||||
ensureAccessibilityServiceEnabled();
|
ensureAccessibilityServiceEnabled();
|
||||||
if (AutomatorConfig.isUnintendedGuardEnabled() && isRunningPackageSelf()) {
|
if (AutomatorConfig.isUnintendedGuardEnabled() && isRunningPackageSelf()) {
|
||||||
Log.i(TAG, "performAction: running package is self. return false");
|
Log.d(TAG, "performAction: running package is self. return false");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AccessibilityService service = mAccessibilityBridge.getService();
|
AccessibilityService service = mAccessibilityBridge.getService();
|
||||||
@@ -200,7 +200,7 @@ public class SimpleActionAutomator {
|
|||||||
return false;
|
return false;
|
||||||
AccessibilityNodeInfoAllocator allocator = new AccessibilityNodeInfoAllocator();
|
AccessibilityNodeInfoAllocator allocator = new AccessibilityNodeInfoAllocator();
|
||||||
simpleAction.setAllocator(allocator);
|
simpleAction.setAllocator(allocator);
|
||||||
Log.i("Automator", "performAction: " + simpleAction + " root = " + root);
|
Log.v(TAG, "performAction: " + simpleAction + " root = " + root);
|
||||||
boolean result = simpleAction.perform(root);
|
boolean result = simpleAction.perform(root);
|
||||||
allocator.recycleAll();
|
allocator.recycleAll();
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+7
-2
@@ -102,7 +102,7 @@ public class AccessibilityNodeInfoAllocator {
|
|||||||
} catch (IllegalStateException ignored) {
|
} catch (IllegalStateException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Total: " + size + " Not recycled: " + notRecycledCount);
|
Log.v(TAG, "Total: " + size + " Not recycled: " + notRecycledCount);
|
||||||
return notRecycledCount;
|
return notRecycledCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,12 @@ public class AccessibilityNodeInfoAllocator {
|
|||||||
public static void recycleList(AccessibilityNodeInfo root, List<AccessibilityNodeInfo> list) {
|
public static void recycleList(AccessibilityNodeInfo root, List<AccessibilityNodeInfo> list) {
|
||||||
for (AccessibilityNodeInfo nodeInfo : list) {
|
for (AccessibilityNodeInfo nodeInfo : list) {
|
||||||
if (nodeInfo != root) {
|
if (nodeInfo != root) {
|
||||||
nodeInfo.recycle();
|
try {
|
||||||
|
nodeInfo.recycle();
|
||||||
|
}catch (IllegalStateException e){
|
||||||
|
// FIXME: 2017/4/30
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.stardust.lang;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/4/30.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ThreadCompat extends Thread {
|
||||||
|
|
||||||
|
private static volatile WeakHashMap<Thread, Boolean> interruptStatus = new WeakHashMap<>();
|
||||||
|
|
||||||
|
public ThreadCompat() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
interruptStatus.put(this, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(Runnable target) {
|
||||||
|
super(target);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(ThreadGroup group, Runnable target) {
|
||||||
|
super(group, target);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(String name) {
|
||||||
|
super(name);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(ThreadGroup group, String name) {
|
||||||
|
super(group, name);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(Runnable target, String name) {
|
||||||
|
super(target, name);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(ThreadGroup group, Runnable target, String name) {
|
||||||
|
super(group, target, name);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThreadCompat(ThreadGroup group, Runnable target, String name, long stackSize) {
|
||||||
|
super(group, target, name, stackSize);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
super.run();
|
||||||
|
interruptStatus.remove(this);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
interruptStatus.remove(this);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInterrupted() {
|
||||||
|
Boolean isInterrupted = interruptStatus.get(this);
|
||||||
|
return super.isInterrupted() || isInterrupted == null || isInterrupted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void interrupt() {
|
||||||
|
super.interrupt();
|
||||||
|
interruptStatus.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user