fix crash on android5.1 and add console api
This commit is contained in:
BIN
app/src/main/res/drawable/ic_console_green.png
Normal file
BIN
app/src/main/res/drawable/ic_console_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 37 KiB |
29
app/src/main/res/layout/activity_console.xml
Normal file
29
app/src/main/res/layout/activity_console.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<view
|
||||
android:id="@+id/console"
|
||||
class="com.stardust.scriptdroid.droid.ConsoleActivity$ConsoleView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -5,6 +5,28 @@
|
||||
android:orientation="vertical"
|
||||
android:textSize="16sp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/console"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_console_green"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_console"
|
||||
android:textColor="@android:color/primary_text_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/syntax_and_api"
|
||||
android:layout_width="match_parent"
|
||||
@@ -27,6 +49,7 @@
|
||||
android:textColor="@android:color/primary_text_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/assist_service"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -5,6 +5,28 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/console"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_console_green"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_console"
|
||||
android:textColor="@android:color/primary_text_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/syntax_and_api"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
9
app/src/main/res/menu/menu_console.xml
Normal file
9
app/src/main/res/menu/menu_console.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/text_clear"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
@@ -12,7 +12,7 @@
|
||||
> 以下的longClick、select、scrollUp、scrollDown的参数均与click类似,不再赘述。
|
||||
* `longClick` 长按
|
||||
* `select` 选择
|
||||
* `scrollUp` 上滑。不加参数时会寻找"最大"的可滑动的控件上滑,例如微信消息列表等。
|
||||
* `scrollUp` 上滑。不加参数时会寻找"最大"的可滑动的控件上滑,例如微信消息列表等; 参数为一个整数i时会找到第i个可滑动控件滑动。
|
||||
* `scrollDown` 下滑。不加参数时与scrollUp类似。
|
||||
* `input(text)` 把所有输入框的文本都置为text。例如input("测试")。
|
||||
* `input(i, text)` 把第i个输入框的文本设为text。i从0开始。
|
||||
@@ -28,7 +28,23 @@
|
||||
* `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。
|
||||
###五、在脚本中调用Java
|
||||
###五、控制台
|
||||
* `openConsole()` 打开控制台。
|
||||
* `clearConsole()` 清空控制台。
|
||||
* `log(text)` 在控制台中输出日志,以例如`log("Hello world");`。
|
||||
* `err(text)` 在控制台中输出错误信息,以红色字体显示,例如:
|
||||
|
||||
```
|
||||
try{
|
||||
//do something
|
||||
}catch(e){
|
||||
err("错误);
|
||||
err(e);
|
||||
openConsole();
|
||||
}
|
||||
```
|
||||
|
||||
###六、在脚本中调用Java
|
||||
使用importClass来引入要使用的库,例如:
|
||||
```javascript
|
||||
importClass("android.view.View.OnClickListener")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">免Root脚本机器人</string>
|
||||
<string name="version">Version 0.17.0205</string>
|
||||
<string name="version">Version 1.17.0212</string>
|
||||
<string name="action_settings">设置</string>
|
||||
<string name="action_disable_service">关闭服务</string>
|
||||
<string name="text_accessibility_service_description">使脚本自动操作(点击、长按、滑动等)所需,若关闭则只能执行不涉及自动操作的脚本。</string>
|
||||
@@ -93,4 +93,6 @@
|
||||
<string name="text_re_import_samples">重新导入示例脚本文件</string>
|
||||
<string name="text_re_import_succeed">导入成功,重新打开应用生效</string>
|
||||
<string name="text_fail">失败</string>
|
||||
<string name="text_clear">清空</string>
|
||||
<string name="text_console">控制台</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user