Added Script file chooser. Fixed the issue that background image setting not working
This commit is contained in:
@@ -11,14 +11,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
<com.stardust.theme.widget.ThemeColorToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
</com.stardust.theme.widget.ThemeColorToolbar>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.scriptdroid.ui.main.my_script_list.ScriptAndFolderListRecyclerView
|
||||
<com.stardust.scriptdroid.ui.main.script_list.ScriptListWithProgressBarView
|
||||
android:id="@+id/script_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
90
app/src/main/res/layout/air_activity_issue_reporter.xml
Normal file
90
app/src/main/res/layout/air_activity_issue_reporter.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ MIT License
|
||||
~
|
||||
~ Copyright (c) 2017 Jan Heinrich Reimer
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
~ of this software and associated documentation files (the "Software"), to deal
|
||||
~ in the Software without restriction, including without limitation the rights
|
||||
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
~ copies of the Software, and to permit persons to whom the Software is
|
||||
~ furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all
|
||||
~ copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
~ SOFTWARE.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/air_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?actionBarSize"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/air_baseline_card"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<include
|
||||
layout="@layout/air_card_report"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<include
|
||||
layout="@layout/air_card_login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/air_card_margin_top"/>
|
||||
|
||||
<android.support.v4.widget.Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_margin="@dimen/air_baseline"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/air_buttonSend"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/air_baseline"
|
||||
app:srcCompat="@drawable/air_ic_send_light"
|
||||
app:backgroundTint="?colorAccent"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -63,6 +63,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:baselineAligned="false"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.scriptdroid.ui.main.my_script_list.ScriptAndFolderListRecyclerView
|
||||
<com.stardust.scriptdroid.ui.main.script_list.ScriptListWithProgressBarView
|
||||
android:id="@+id/script_list"
|
||||
android:background="#fafafa"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
@@ -22,19 +21,4 @@
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="true"
|
||||
android:visibility="gone">
|
||||
|
||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"/>
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -16,9 +16,6 @@
|
||||
android:id="@+id/tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:elevation="10dp"
|
||||
app:elevation="10dp"
|
||||
android:outlineProvider="bounds"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="@color/colorAccent"
|
||||
app:tabMode="fixed"
|
||||
|
||||
26
app/src/main/res/layout/script_and_folder_list_view.xml
Normal file
26
app/src/main/res/layout/script_and_folder_list_view.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.stardust.scriptdroid.ui.main.script_list.ScriptAndFolderListRecyclerView
|
||||
android:id="@+id/script_list_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#fafafa"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="true"
|
||||
android:visibility="gone">
|
||||
|
||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"/>
|
||||
</FrameLayout>
|
||||
</merge>
|
||||
@@ -1,85 +0,0 @@
|
||||
### 一、语法
|
||||
本软件使用JavaScript语言([ECMAscript E5/E5.1](http://www.ecma-international.org/ecma-262/5.1/)),基于[Duktape](http://www.duktape.org/)引擎拓展一些自动操作(点击、长按、滑动等)函数。因而语法参见JavaScript(例如[w3cschool教程](http://www.w3school.com.cn/js/))。
|
||||
### 二、自动操作函数
|
||||
**自动操作的函数都需要开启"自动操作服务"才能执行,否则执行到相应函数时脚本会停止运行。**
|
||||
* `click(text, i)` 点击第i个文本text所在的区域,并返回是否点击成功。i从0开始,当不指定时点击所有区域。当前界面没有出现该文本或者该文本所在区域不可点击时返回false。例如`click("发现")`,是点击"发现"。如果要点击"发现"直至点击成功可以用`while(!click("发现"))`。
|
||||
> 文本所在区域指的是,从文本处向其父视图寻找,直至发现一个可点击的部件为止。
|
||||
* `click(left, top, bottom, right)`
|
||||
> 有些按钮或者部件是图标而不是文字(例如发送朋友圈的照相机图标以及QQ下方的消息、联系人、动态图标),这时不能通过`click(text)`来点击,只能通过描述图标所在的区域来点击。left, bottom, top, right描述的就是点击的区域。至于要定位点击的区域,可以在侧拉菜单开启"点击区域辅助"(或者安卓7.0以上在通知栏点击"修改"添加点击区域辅助快捷设定图标),之后每次点击或长按都会提示这次点击或长按的区域并自动保存,可以在编辑器的右侧拉菜单中插入。
|
||||
|
||||
点击与长方形范围严格匹配的区域,并返回是否点击成功。其中left为长方形左边与屏幕左边的像素距离,top为上边与屏幕上边的像素距离,right为右边与**屏幕左边**的像素距离, bottom为下边与**屏幕上边**的距离。区域严格匹配。
|
||||
> 以下的longClick、select、scrollUp、scrollDown的参数均与click类似,不再赘述。
|
||||
* `longClick` 长按
|
||||
* `select` 选择
|
||||
* `scrollUp` 上滑。不加参数时会寻找"最大"的可滑动的控件上滑,例如微信消息列表等; 参数为一个整数i时会找到第i个可滑动控件滑动。
|
||||
* `scrollDown` 下滑。不加参数时与scrollUp类似。
|
||||
* `input(text)` 把所有输入框的文本都置为text。例如input("测试")。
|
||||
* `input(i, text)` 把第i个输入框的文本设为text。i从0开始。
|
||||
* `addAccessibilityDelegate(function)` 增加一个AccessibilityEvent处理代理。这可以实现很多强大的功能,但需要熟悉安卓的AccessibilityEvent。例如:
|
||||
```
|
||||
addAccessibilityDelegate(function(service, event){
|
||||
//do something
|
||||
});
|
||||
```
|
||||
### 三、其他函数
|
||||
|
||||
* `sleep(n)` 暂停执行n**毫秒**时间。
|
||||
* `toast(text)` 显示提示文本。
|
||||
* `launch(packageName)` 运行包名为packageName的应用。例如launch("com.tencent.mm")是运行微信,应用包名可以通过一些工具获取;获取通过函数launchApp代替
|
||||
* `launch(packageName, className)` 运行包名为packageName,类名(Activity)为className的应用。
|
||||
* `launchApp(appName)` 运存应用名称为appName的应用。例如launchApp("QQ")。不同应用名称可能相同,这时只运行其中某一个应用。
|
||||
* `notStopped` 若当前脚本处于运行状态时返回`true`, 否则返回`false`。对于某些循环, 例如`while(true)`,请用`while(notStopped())`代替,以免死循环造成的脚本无法正常停止。
|
||||
* `isStoppd` 若当前脚本处于停止状态时返回`true`, 否则返回`false`。
|
||||
* `shell(cmd, root=false)` 执行shell命令cmd, 其中参数root表示是否以root权限执行,默认为false。例如`shell("input keyevent 26", true); //锁屏`。
|
||||
* `getTexts()` 获取屏幕上的文字列表, 返回一个java.util.List<String>。例如:
|
||||
* `getPackageName` 获取正在运行的应用包名
|
||||
* `getActivityName` 获取正在运行的Activity名称
|
||||
* `setClip(text)` 设置剪贴板文本
|
||||
```
|
||||
launchApp("微信");
|
||||
while(!click("通讯录"));
|
||||
var texts = getTexts();
|
||||
for(var i = 0; i < texts.size(); i++){
|
||||
log(texts.get(i));
|
||||
}
|
||||
openConsole();
|
||||
```
|
||||
|
||||
### 四、全局变量
|
||||
* `context` ApplicationContext,参见安卓[android.content.Context](https://developer.android.com/reference/android/content/Context.html)
|
||||
> 这里的context由于是ApplicationContext,是不可见的,不能用于dialog和其他UI相关。如果要显示弹窗或者视图,请启动UI模式(代码的第一行为`"ui";`既可)并使用activity代替。
|
||||
* `activity` UI模式下会启动一个Activity来运行脚本,并在UI线程下运行。可通过该变量来获取该activity。
|
||||
### 五、控制台
|
||||
* `openConsole()` 打开控制台。
|
||||
* `clearConsole()` 清空控制台。
|
||||
* `log(text)` 在控制台中输出日志,以例如`log("Hello world");`。
|
||||
* `err(text)` 在控制台中输出错误信息,以红色字体显示,例如:
|
||||
```
|
||||
try{
|
||||
//do something
|
||||
}catch(e){
|
||||
err("错误);
|
||||
err(e);
|
||||
openConsole();
|
||||
}
|
||||
```
|
||||
### 六、运行模式
|
||||
* UI模式 在脚本第一行加上`"ui;"`。UI模式下会启动一个Activity来运行脚本,并在UI线程下运行。
|
||||
* 驻留模式 在脚本第一行加上`"stay;"`,驻留模式下代码运行结束后不会马上退出,只有"关闭所有正在运行的脚本"或者调用`stop()`才会停止。适用于诸如addAccessibilityDelegate的代理后台运行。
|
||||
### 七、在脚本中调用Java
|
||||
使用importClass来引入要使用的库,例如:
|
||||
```javascript
|
||||
importClass("android.view.View.OnClickListener")
|
||||
view.setOnClickListener(new OnClickListener(function(){
|
||||
Toast.makeText(activity, "Button1 Clicked", Toast.LENGTH_SHORT).show();
|
||||
var intent = new Intent(activity, "com.furture.react.activity.DetailActivity");
|
||||
activity.startActivity(intent);
|
||||
}));
|
||||
|
||||
view2.setOnClickListener(new OnClickListener({
|
||||
onClick: function(){
|
||||
Toast.makeText(activity, "Button2 Clicked", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}));
|
||||
```
|
||||
详细文档参见[DuktapeJava Java Docs](http://gubaojian.github.io/DuktapeJava/javadoc/)。
|
||||
@@ -155,6 +155,8 @@
|
||||
<string name="summary_command_run_mode">If the app responses slowly when running script, choose Thread Pool or Create Thread. But it may causes rebooting of the device</string>
|
||||
<string name="text_on">ON</string>
|
||||
<string name="text_off">OFF</string>
|
||||
<string name="text_please_choose_file_to_import">请选择要导入的脚本</string>
|
||||
<string name="text_refresh">刷新</string>
|
||||
<string-array name="record_control_keys">
|
||||
<item>None</item>
|
||||
<item>Volume Up</item>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<string name="air_dialog_description_failed_issues_not_available">Issues不可用,请联系软件开发者.</string>
|
||||
<string name="air_dialog_description_failed_unknown">未知错误</string>
|
||||
<string name="air_dialog_action_failed">OK</string>
|
||||
<plurals key="air_error_short_description">
|
||||
<plurals name="air_error_short_description" key="air_error_short_description">
|
||||
<item quantity="one">描述至少要 %d 个字.</item>
|
||||
<item quantity="other">描述至少要 %d 个字.</item>
|
||||
</plurals>
|
||||
|
||||
@@ -185,6 +185,8 @@
|
||||
<string name="text_import_fail">导入失败</string>
|
||||
<string name="delete_confirm">确定要删除吗</string>
|
||||
<string name="text_no_brower">没有浏览器耶o(╯□╰)o快去安装一个吧</string>
|
||||
<string name="text_please_choose_file_to_import">请选择要导入的脚本</string>
|
||||
<string name="text_refresh">刷新</string>
|
||||
|
||||
<string-array name="record_control_keys">
|
||||
<item>无</item>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.FullScreen" parent="AppTheme">
|
||||
@@ -16,7 +15,6 @@
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Splash" parent="AppTheme">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="windowNoTitle">true</item>
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
@@ -28,13 +26,14 @@
|
||||
<item name="android:textColorSecondary">#c4c4c4</item>
|
||||
</style>
|
||||
|
||||
<style name="IssueReportTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="cardBackgroundColor">#FFFFFF</item>
|
||||
<item name="colorButtonNormal">?colorAccent</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<style name="IssueReporterTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="cardBackgroundColor">#FFFFFF</item>
|
||||
<item name="colorButtonNormal">?colorAccent</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
@@ -44,6 +43,6 @@
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user