doc: update to lastest

This commit is contained in:
hyb1996
2018-04-13 22:31:02 +08:00
parent 2162bd5b28
commit a00bd293b3
7 changed files with 6098 additions and 43 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.stardust.scriptdroid"
minSdkVersion 17
targetSdkVersion 23
versionCode 261
versionName "3.1.1 Alpha5"
versionCode 262
versionName "3.1.1 Alpha6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Index | Auto.js 3.0.0 文档</title>
<title>Canvas | Auto.js 3.0.0 文档</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
@@ -73,11 +73,34 @@
<div id="toc">
<h2>目录</h2>
<ul>
<li><span class="stability_undefined"><a href="#canvas_canvas">Canvas</a></span></li>
</ul>
</div>
<div id="apicontent">
<h1>Canvas<span><a class="mark" href="#canvas_canvas" id="canvas_canvas">#</a></span></h1>
<p>canvas提供了使用画布进行2D画图的支持可用于简单的小游戏开发或者图片编辑。使用canvas可以轻松地在一张图片或一个界面上绘制各种线与图形。</p>
<p>canvas的坐标系为平面直角坐标系以屏幕左上角为原点屏幕上边为x轴正方向屏幕左边为y轴正方向。例如分辨率为1920*1080的屏幕上画一条从屏幕左上角到屏幕右下角的线段为:</p>
<pre><code>canvas.drawLine(0, 0, 1080, 1920, paint);
</code></pre><p>canvas的绘制依赖于画笔Paint, 通过设置画笔的粗细、颜色、填充等可以改变绘制出来的图形。例如绘制一个红色实心正方形为:</p>
<pre><code>var paint = new Paint();
//设置画笔为填充,则绘制出来的图形都是实心的
paint.setStyle(Paint.STYLE.FILL);
//设置画笔颜色为红色
paint.setColor(colors.RED);
//绘制一个从坐标(0, 0)到坐标(100, 100)的正方形
canvas.drawRect(0, 0, 100, 100, paint);
</code></pre><p>如果要绘制正方形的边框则通过设置画笔的Style来实现</p>
<pre><code>var paint = new Paint();
//设置画笔为描边,则绘制出来的图形都是轮廓
paint.setStyle(Paint.STYLE.STROKE);
//设置画笔颜色为红色
paint.setColor(colors.RED);
//绘制一个从坐标(0, 0)到坐标(100, 100)的正方形
canvas.drawRect(0, 0, 100, 100, paint);
</code></pre>
</div>
</div>
</div>

View File

@@ -125,10 +125,8 @@ http.get(&quot;www.baidu.com&quot;, {}, function(res, err){
<pre><code>console.show();
var r = http.get(&quot;www.baidu.com&quot;, {
headers: {
&quot;Accept-Language&quot;: &quot;zh-cn,zh;q=0.5&quot;,
&quot;User-Agent: &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X
10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56
Safari/535.11&quot;
&#39;Accept-Language&#39;: &#39;zh-cn,zh;q=0.5&#39;,
&#39;User-Agent&#39;: &#39;Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11&#39;
}
});
log(&quot;code = &quot; + r.statusCode);

View File

@@ -75,11 +75,11 @@
<h2>目录</h2>
<ul>
<li><span class="stability_2"><a href="#shell_shell">shell函数</a></span><ul>
<li><span class="stability_undefined"><a href="#shell_shell_cmd_root_false">shell(cmd[, root = false])</a></span></li>
<li><span class="stability_undefined"><a href="#shell_shell_cmd_root">shell(cmd[, root])</a></span></li>
</ul>
</li>
<li><span class="stability_2"><a href="#shell_shell_1">Shell</a></span><ul>
<li><span class="stability_undefined"><a href="#shell_shell_root_false">Shell(root = false)</a></span></li>
<li><span class="stability_undefined"><a href="#shell_new_shell_root">new Shell(root)</a></span></li>
<li><span class="stability_undefined"><a href="#shell_shell_exec_cmd">Shell.exec(cmd)</a></span></li>
<li><span class="stability_undefined"><a href="#shell_shell_exit">Shell.exit()</a></span></li>
<li><span class="stability_undefined"><a href="#shell_shell_exitandwaitfor">Shell.exitAndWaitFor()</a></span></li>
@@ -155,7 +155,7 @@
<li>通过内嵌终端模拟器执行(RootAutomator, Shell等对象)</li>
</ul>
<h1>shell函数<span><a class="mark" href="#shell_shell" id="shell_shell">#</a></span></h1>
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><h2>shell(cmd[, root = false])<span><a class="mark" href="#shell_shell_cmd_root_false" id="shell_shell_cmd_root_false">#</a></span></h2>
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><h2>shell(cmd[, root])<span><a class="mark" href="#shell_shell_cmd_root" id="shell_shell_cmd_root">#</a></span></h2>
<div class="signature"><ul>
<li>cmd <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 要执行的命令</li>
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;Boolean&gt;</a> 是否以root权限运行默认为false。</li>
@@ -177,9 +177,9 @@ if(result.code == 0){
}
</code></pre><h1>Shell<span><a class="mark" href="#shell_shell_1" id="shell_shell_1">#</a></span></h1>
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><p>shell函数通过用来一次性执行单条命令并获取结果。如果有多条命令需要执行用Shell对象的效率更高。这是因为每次运行shell函数都会打开一个单独的shell进程并在运行结束后关闭他这个过程需要一定的时间而Shell对象自始至终使用同一个shell进程。</p>
<h2>Shell(root = false)<span><a class="mark" href="#shell_shell_root_false" id="shell_shell_root_false">#</a></span></h2>
<h2>new Shell(root)<span><a class="mark" href="#shell_new_shell_root" id="shell_new_shell_root">#</a></span></h2>
<div class="signature"><ul>
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;Boolean&gt;</a> 是否以root权限运行一个shell进程。这将会影响其后使用该Shell对象执行的命令的权限</li>
<li>root <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;Boolean&gt;</a> 是否以root权限运行一个shell进程默认为false。这将会影响其后使用该Shell对象执行的命令的权限</li>
</ul>
</div><p>Shell对象的&quot;构造函数&quot;</p>
<pre><code>var sh = new Shell(true);

View File

@@ -103,7 +103,7 @@ storages无法像Web开发中LocalStorage一样提供根据域名独立的存储
</ul>
</div><p>创建一个本地存储并返回一个<code>Storage</code>对象。不同名称的本地存储的数据是隔开的,而相同名称的本地存储的数据是共享的。</p>
<p>例如在一个脚本中创建名称为ABC的存储并存入a=123:</p>
<pre><code>var storage = stroages.create(&quot;ABC&quot;);
<pre><code>var storage = storages.create(&quot;ABC&quot;);
storage.put(&quot;a&quot;, 123);
</code></pre><p>而在另一个脚本中是可以获取到ABC以及a的值的</p>
<pre><code>var storage = storages.create(&quot;ABC&quot;);

View File

@@ -143,8 +143,14 @@
<li><span class="stability_undefined"><a href="#ui_circle">circle</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#ui_vertical">垂直布局: vertical</a></span></li>
<li><span class="stability_undefined"><a href="#ui_horizontal">水平布局: horizontal</a></span></li>
<li><span class="stability_undefined"><a href="#ui_vertical">垂直布局: vertical</a></span><ul>
<li><span class="stability_undefined"><a href="#ui_layout_weight">layout_weight</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#ui_horizontal">水平布局: horizontal</a></span><ul>
<li><span class="stability_undefined"><a href="#ui_layout_weight_1">layout_weight</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#ui_linear">线性布局: linear</a></span></li>
<li><span class="stability_undefined"><a href="#ui_frame">帧布局: frame</a></span></li>
<li><span class="stability_undefined"><a href="#ui_relative">相对布局: relative</a></span></li>
@@ -621,12 +627,80 @@ ui.layout(
<p>指定该图片控件的图片是否剪切为圆形显示。如果为<code>true</code>,则图片控件会使其宽高保持一致(如果宽高不一致,则保持高度等于宽度)并使圆形的半径为宽度的一半。</p>
<p>例如圆形的Auto.js图标<code>&lt;img w=&quot;100&quot; h=&quot;100&quot; circle=&quot;true&quot; bg=&quot;white&quot; src=&quot;http://www.autojs.org/assets/uploads/profile/3-profileavatar.png&quot; /&gt;</code></p>
<h1>垂直布局: vertical<span><a class="mark" href="#ui_vertical" id="ui_vertical">#</a></span></h1>
<p>垂直布局是一种比较简单的布局,会把在它里面的控件按照垂直方向依次摆放,如下图所示:</p>
<p>垂直布局:</p>
<p> —————</p>
<p>| 控件1 |</p>
<p>| 控件2 |</p>
<p>| 控件3 |</p>
<p>| ............ |</p>
<p> ——————</p>
<h2>layout_weight<span><a class="mark" href="#ui_layout_weight" id="ui_layout_weight">#</a></span></h2>
<p>垂直布局中的控件可以通过<code>layout_weight</code>属性来控制控件高度占垂直布局高度的比例。如果为一个控件指定<code>layout_weight</code>, 则这个控件的高度=垂直布局剩余高度 * layout_weight / weightSum如果不指定weightSum, 则weightSum为所有子控件的layout_weight之和。所谓&quot;剩余高度&quot;指的是垂直布局中减去没有指定layout_weight的控件的剩余高度。
例如:</p>
<pre><code>&quot;ui&quot;;
ui.layout(
&lt;vertical h=&quot;100dp&quot;&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件1&quot; bg=&quot;#ff0000&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件2&quot; bg=&quot;#00ff00&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件3&quot; bg=&quot;#0000ff&quot;/&gt;
&lt;/vertical&gt;
);
</code></pre><p>在这个布局中三个控件的layout_weight都是1也就是他们的高度都会占垂直布局高度的1/3都是33.3dp.
再例如:</p>
<pre><code>&quot;ui&quot;;
ui.layout(
&lt;vertical h=&quot;100dp&quot;&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件1&quot; bg=&quot;#ff0000&quot;/&gt;
&lt;text layout_weight=&quot;2&quot; text=&quot;控件2&quot; bg=&quot;#00ff00&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件3&quot; bg=&quot;#0000ff&quot;/&gt;
&lt;/vertical&gt;
);
</code></pre><p>在这个布局中第一个控件高度为1/4, 第二个控件为2/4, 第三个控件为1/4.
再例如:</p>
<pre><code>&quot;ui&quot;;
ui.layout(
&lt;vertical h=&quot;100dp&quot; weightSum=&quot;5&quot;&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件1&quot; bg=&quot;#ff0000&quot;/&gt;
&lt;text layout_weight=&quot;2&quot; text=&quot;控件2&quot; bg=&quot;#00ff00&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件3&quot; bg=&quot;#0000ff&quot;/&gt;
&lt;/vertical&gt;
);
</code></pre><p>在这个布局中因为指定了weightSum为5, 因此第一个控件高度为1/5, 第二个控件为2/5, 第三个控件为1/5.
再例如:</p>
<pre><code>&quot;ui&quot;;
ui.layout(
&lt;vertical h=&quot;100dp&quot;&gt;
&lt;text h=&quot;40dp&quot; text=&quot;控件1&quot; bg=&quot;#ff0000&quot;/&gt;
&lt;text layout_weight=&quot;2&quot; text=&quot;控件2&quot; bg=&quot;#00ff00&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件3&quot; bg=&quot;#0000ff&quot;/&gt;
&lt;/vertical&gt;
);
</code></pre><p>在这个布局中第一个控件并没有指定layout_weight, 而是指定高度为40dp, 因此不加入比例计算此时布局剩余高度为60dp。第二个控件高度为剩余高度的2/3也就是40dp第三个控件高度为剩余高度的1/3也就是20dp。</p>
<p>垂直布局的layout_weight属性还可以用于控制他的子控件高度占满剩余空间例如</p>
<pre><code>&quot;ui&quot;;
ui.layout(
&lt;vertical h=&quot;100dp&quot;&gt;
&lt;text h=&quot;40dp&quot; text=&quot;控件1&quot; bg=&quot;#ff0000&quot;/&gt;
&lt;text h=&quot;40dp&quot; text=&quot;控件2&quot; bg=&quot;#00ff00&quot;/&gt;
&lt;text layout_weight=&quot;1&quot; text=&quot;控件3&quot; bg=&quot;#0000ff&quot;/&gt;
&lt;/vertical&gt;
);
</code></pre><p>在这个布局中第三个控件的高度会占满除去控件1和控件2的剩余空间。</p>
<h1>水平布局: horizontal<span><a class="mark" href="#ui_horizontal" id="ui_horizontal">#</a></span></h1>
<p>水平布局是一种比较简单的布局,会把在它里面的控件按照水平方向依次摆放,如下图所示:
水平布局:
————————————————————————————</p>
<p>| 控件1 | 控件2 | 控件3 | ... |</p>
<p> ————————————————————————————</p>
<h2>layout_weight<span><a class="mark" href="#ui_layout_weight_1" id="ui_layout_weight_1">#</a></span></h2>
<p>水平布局中也可以使用layout_weight属性来控制子控件的<strong>宽度</strong>占父布局的比例。和垂直布局中类似,不再赘述。</p>
<h1>线性布局: linear<span><a class="mark" href="#ui_linear" id="ui_linear">#</a></span></h1>
<p>实际上垂直布局和水平布局都属于线性布局。线性布局有一个orientation的属性用于指定布局的方向可选的值为<code>vertical</code><code>horizontal</code></p>
<p>例如<code>&lt;linear orientation=&quot;vertical&quot;&gt;&lt;/linear&gt;</code>相当于<code>&lt;vertical&gt;&lt;/vertical&gt;</code></p>
<p>线性布局的默认方向是横向的因此一个没有指定orientation属性的线性布局就是横向布局。</p>
<h1>帧布局: frame<span><a class="mark" href="#ui_frame" id="ui_frame">#</a></span></h1>
<p>帧布局</p>
<h1>相对布局: relative<span><a class="mark" href="#ui_relative" id="ui_relative">#</a></span></h1>
<h1>勾选框控件: checkbox<span><a class="mark" href="#ui_checkbox" id="ui_checkbox">#</a></span></h1>
<h1>选择框控件: radio<span><a class="mark" href="#ui_radio" id="ui_radio">#</a></span></h1>