Skip to content

Commit

Permalink
docs: update to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
hyb1996 committed May 28, 2018
1 parent 7cb7703 commit 0ffb8d1
Show file tree
Hide file tree
Showing 11 changed files with 986 additions and 53 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.autojs.autojs"
minSdkVersion 17
targetSdkVersion 23
versionCode 400
versionName "4.0.0 Alpha"
versionCode 401
versionName "4.0.0 Alpha1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {
Expand Down
509 changes: 486 additions & 23 deletions app/src/main/assets/docs/all.html

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions app/src/main/assets/docs/canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ <h1>Auto.js 3.0.0 文档</h1>
<div id="toc">
<h2>目录</h2>
<ul>
<li><span class="stability_undefined"><a href="#canvas_canvas">Canvas</a></span></li>
<li><span class="stability_undefined"><a href="#canvas_canvas">Canvas</a></span><ul>
<li><span class="stability_undefined"><a href="#canvas_canvas_drawargb_a_r_g_b">canvas.drawARGB(a, r, g, b)</a></span></li>
<li><span class="stability_undefined"><a href="#canvas_canvas_draw">canvas.draw</a></span></li>
</ul>
</li>
</ul>

</div>
Expand All @@ -100,7 +104,10 @@ <h1>Canvas<span><a class="mark" href="#canvas_canvas" id="canvas_canvas">#</a></
paint.setColor(colors.RED);
//绘制一个从坐标(0, 0)到坐标(100, 100)的正方形
canvas.drawRect(0, 0, 100, 100, paint);
</code></pre>
</code></pre><p>结合画笔canvas可以绘制基本图形、图片等。</p>
<h2>canvas.drawARGB(a, r, g, b)<span><a class="mark" href="#canvas_canvas_drawargb_a_r_g_b" id="canvas_canvas_drawargb_a_r_g_b">#</a></span></h2>
<h2>canvas.draw<span><a class="mark" href="#canvas_canvas_draw" id="canvas_canvas_draw">#</a></span></h2>

</div>
</div>
</div>
Expand Down
315 changes: 315 additions & 0 deletions app/src/main/assets/docs/dialogs.html

Large diffs are not rendered by default.

128 changes: 109 additions & 19 deletions app/src/main/assets/docs/floaty.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,32 @@ <h2>目录</h2>
<ul>
<li><span class="stability_undefined"><a href="#floaty_floaty">Floaty</a></span><ul>
<li><span class="stability_undefined"><a href="#floaty_floaty_window_layout">floaty.window(layout)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floaty_rawwindow_layout">floaty.rawWindow(layout)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floaty_closeall">floaty.closeAll()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow">FloatyWindow</a></span><ul>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_setadjustenabled_enabled">FloatyWindow.setAdjustEnabled(enabled)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_setposition_x_y">FloatyWindow.setPosition(x, y)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_getx">FloatyWindow.getX()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_gety">FloatyWindow.getY()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_setsize_width_height">FloatyWindow.setSize(width, height)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_getwidht">FloatyWindow.getWidht()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_getheight">FloatyWindow.getHeight()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_close">FloatyWindow.close()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_floatywindow_exitonclose">FloatyWindow.exitOnClose()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_setadjustenabled_enabled">window.setAdjustEnabled(enabled)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_setposition_x_y">window.setPosition(x, y)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getx">window.getX()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_gety">window.getY()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_setsize_width_height">window.setSize(width, height)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getwidht">window.getWidht()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getheight">window.getHeight()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_close">window.close()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_exitonclose">window.exitOnClose()</a></span></li>
</ul>
</li>
<li><span class="stability_undefined"><a href="#floaty_floatyrawwindow">FloatyRawWindow</a></span><ul>
<li><span class="stability_undefined"><a href="#floaty_window_settouchable_touchable">window.setTouchable(touchable)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_setposition_x_y_1">window.setPosition(x, y)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getx_1">window.getX()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_gety_1">window.getY()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_setsize_width_height_1">window.setSize(width, height)</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getwidht_1">window.getWidht()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_getheight_1">window.getHeight()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_close_1">window.close()</a></span></li>
<li><span class="stability_undefined"><a href="#floaty_window_exitonclose_1">window.exitOnClose()</a></span></li>
</ul>
</li>
</ul>
Expand All @@ -105,6 +118,7 @@ <h1>Floaty<span><a class="mark" href="#floaty_floaty" id="floaty_floaty">#</a></
<li><code>layout</code> <span class="type">&lt;xml&gt;</span> | <span class="type">&lt;View&gt;</span> 悬浮窗界面的XML或者View</li>
</ul>
</div><p>指定悬浮窗的布局,创建并<strong>显示</strong>一个悬浮窗,返回一个<code>FloatyWindow</code>对象。</p>
<p>该悬浮窗自带关闭、调整大小、调整位置按键,可根据需要调用<code>setAdjustEnabled()</code>函数来显示或隐藏。</p>
<p>其中layout参数可以是xml布局或者一个View,更多信息参见ui模块的说明。</p>
<p>例子:</p>
<pre><code>var w = floaty.window(
Expand All @@ -120,40 +134,116 @@ <h1>Floaty<span><a class="mark" href="#floaty_floaty" id="floaty_floaty">#</a></
<pre><code>ui.run(function(){
w.text.setText(&quot;文本&quot;);
});
</code></pre><h2>floaty.closeAll()<span><a class="mark" href="#floaty_floaty_closeall" id="floaty_floaty_closeall">#</a></span></h2>
</code></pre><p>有关返回的<code>FloatyWindow</code>对象的说明,参见下面的<code>FloatyWindow</code>章节。</p>
<h2>floaty.rawWindow(layout)<span><a class="mark" href="#floaty_floaty_rawwindow_layout" id="floaty_floaty_rawwindow_layout">#</a></span></h2>
<div class="signature"><ul>
<li><code>layout</code> <span class="type">&lt;xml&gt;</span> | <span class="type">&lt;View&gt;</span> 悬浮窗界面的XML或者View</li>
</ul>
</div><p>指定悬浮窗的布局,创建并<strong>显示</strong>一个原始悬浮窗,返回一个<code>FloatyRawWindow</code>对象。</p>
<p><code>floaty.window()</code>函数不同的是,该悬浮窗不会增加任何额外设施(例如调整大小、位置按钮),您可以根据自己需要编写任何布局。</p>
<p>而且,该悬浮窗支持完全全屏,可以覆盖状态栏,因此可以做护眼模式之类的应用。</p>
<pre><code>var w = floaty.rawWindow(
&lt;frame gravity=&quot;center&quot;&gt;
&lt;text id=&quot;text&quot;&gt;悬浮文字&lt;/text&gt;
&lt;/frame&gt;
);

w.setPosition(500, 500);

setTimeout(()=&gt;{
w.close();
}, 2000);
</code></pre><p>这段代码运行后将会在屏幕上显示悬浮文字,并在两秒后消失。</p>
<p>有关返回的<code>FloatyRawWindow</code>对象的说明,参见下面的<code>FloatyRawWindow</code>章节。</p>
<h2>floaty.closeAll()<span><a class="mark" href="#floaty_floaty_closeall" id="floaty_floaty_closeall">#</a></span></h2>
<p>关闭所有本脚本的悬浮窗。</p>
<h1>FloatyWindow<span><a class="mark" href="#floaty_floatywindow" id="floaty_floatywindow">#</a></span></h1>
<p>悬浮窗对象,可通过<code>FloatyWindow.{id}</code>获取悬浮窗界面上的元素。例如, 悬浮窗window上一个控件的id为aaa, 那么<code>window.aaa</code>即可获取到该控件,类似于ui。</p>
<h2>FloatyWindow.setAdjustEnabled(enabled)<span><a class="mark" href="#floaty_floatywindow_setadjustenabled_enabled" id="floaty_floatywindow_setadjustenabled_enabled">#</a></span></h2>
<h2>window.setAdjustEnabled(enabled)<span><a class="mark" href="#floaty_window_setadjustenabled_enabled" id="floaty_window_setadjustenabled_enabled">#</a></span></h2>
<div class="signature"><ul>
<li><code>enabled</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a> 是否启用悬浮窗调整(大小、位置)</li>
</ul>
</div><p>如果enabled为true,则在悬浮窗左上角、右上角显示可供位置、大小调整的标示,就像控制台一样;
如果enabled为false,则隐藏上述标示。</p>
<h2>FloatyWindow.setPosition(x, y)<span><a class="mark" href="#floaty_floatywindow_setposition_x_y" id="floaty_floatywindow_setposition_x_y">#</a></span></h2>
<h2>window.setPosition(x, y)<span><a class="mark" href="#floaty_window_setposition_x_y" id="floaty_window_setposition_x_y">#</a></span></h2>
<div class="signature"><ul>
<li><code>x</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> x</li>
<li><code>x</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> y</li>
</ul>
</div><p>设置悬浮窗位置。</p>
<h2>FloatyWindow.getX()<span><a class="mark" href="#floaty_floatywindow_getx" id="floaty_floatywindow_getx">#</a></span></h2>
<h2>window.getX()<span><a class="mark" href="#floaty_window_getx" id="floaty_window_getx">#</a></span></h2>
<p>返回悬浮窗位置的X坐标。</p>
<h2>FloatyWindow.getY()<span><a class="mark" href="#floaty_floatywindow_gety" id="floaty_floatywindow_gety">#</a></span></h2>
<h2>window.getY()<span><a class="mark" href="#floaty_window_gety" id="floaty_window_gety">#</a></span></h2>
<p>返回悬浮窗位置的Y坐标。</p>
<h2>FloatyWindow.setSize(width, height)<span><a class="mark" href="#floaty_floatywindow_setsize_width_height" id="floaty_floatywindow_setsize_width_height">#</a></span></h2>
<h2>window.setSize(width, height)<span><a class="mark" href="#floaty_window_setsize_width_height" id="floaty_window_setsize_width_height">#</a></span></h2>
<div class="signature"><ul>
<li><code>width</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> 宽度</li>
<li><code>height</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> 高度</li>
</ul>
</div><p>设置悬浮窗宽高。</p>
<h2>FloatyWindow.getWidht()<span><a class="mark" href="#floaty_floatywindow_getwidht" id="floaty_floatywindow_getwidht">#</a></span></h2>
<h2>window.getWidht()<span><a class="mark" href="#floaty_window_getwidht" id="floaty_window_getwidht">#</a></span></h2>
<p>返回悬浮窗宽度。</p>
<h2>window.getHeight()<span><a class="mark" href="#floaty_window_getheight" id="floaty_window_getheight">#</a></span></h2>
<p>返回悬浮窗高度。</p>
<h2>window.close()<span><a class="mark" href="#floaty_window_close" id="floaty_window_close">#</a></span></h2>
<p>关闭悬浮窗。如果悬浮窗已经是关闭状态,则此函数将不执行任何操作。</p>
<p>被关闭后的悬浮窗不能再显示。</p>
<h2>window.exitOnClose()<span><a class="mark" href="#floaty_window_exitonclose" id="floaty_window_exitonclose">#</a></span></h2>
<p>使悬浮窗被关闭时自动结束脚本运行。</p>
<h1>FloatyRawWindow<span><a class="mark" href="#floaty_floatyrawwindow" id="floaty_floatyrawwindow">#</a></span></h1>
<p>原始悬浮窗对象,可通过<code>window.{id}</code>获取悬浮窗界面上的元素。例如, 悬浮窗window上一个控件的id为aaa, 那么<code>window.aaa</code>即可获取到该控件,类似于ui。</p>
<h2>window.setTouchable(touchable)<span><a class="mark" href="#floaty_window_settouchable_touchable" id="floaty_window_settouchable_touchable">#</a></span></h2>
<div class="signature"><ul>
<li><code>touchable</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;Boolean&gt;</a> 是否可触摸</li>
</ul>
</div><p>设置悬浮窗是否可触摸,如果为true, 则悬浮窗将接收到触摸、点击等事件并且无法继续传递到悬浮窗下面;如果为false, 悬浮窗上的触摸、点击等事件将被直接传递到悬浮窗下面。处于安全考虑,被悬浮窗接收的触摸事情无法再继续传递到下层。</p>
<p>可以用此特性来制作护眼模式脚本。</p>
<pre><code>var w = floaty.rawWindow(
&lt;frame gravity=&quot;center&quot; bg=&quot;#44ffcc00&quot;/&gt;
);

w.setSize(-1, -1);
w.setTouchable(false);

setTimeout(()=&gt;{
w.close();
}, 4000);
</code></pre><h2>window.setPosition(x, y)<span><a class="mark" href="#floaty_window_setposition_x_y_1" id="floaty_window_setposition_x_y_1">#</a></span></h2>
<div class="signature"><ul>
<li><code>x</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> x</li>
<li><code>x</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> y</li>
</ul>
</div><p>设置悬浮窗位置。</p>
<h2>window.getX()<span><a class="mark" href="#floaty_window_getx_1" id="floaty_window_getx_1">#</a></span></h2>
<p>返回悬浮窗位置的X坐标。</p>
<h2>window.getY()<span><a class="mark" href="#floaty_window_gety_1" id="floaty_window_gety_1">#</a></span></h2>
<p>返回悬浮窗位置的Y坐标。</p>
<h2>window.setSize(width, height)<span><a class="mark" href="#floaty_window_setsize_width_height_1" id="floaty_window_setsize_width_height_1">#</a></span></h2>
<div class="signature"><ul>
<li><code>width</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> 宽度</li>
<li><code>height</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type">&lt;number&gt;</a> 高度</li>
</ul>
</div><p>设置悬浮窗宽高。</p>
<p>特别地,如果设置为-1,则为占满全屏;设置为-2则为根据悬浮窗内容大小而定。例如:</p>
<pre><code>var w = floaty.rawWindow(
&lt;frame gravity=&quot;center&quot; bg=&quot;#77ff0000&quot;&gt;
&lt;text id=&quot;text&quot;&gt;悬浮文字&lt;/text&gt;
&lt;/frame&gt;
);

w.setSize(-1, -1);

setTimeout(()=&gt;{
w.close();
}, 2000);
</code></pre><h2>window.getWidht()<span><a class="mark" href="#floaty_window_getwidht_1" id="floaty_window_getwidht_1">#</a></span></h2>
<p>返回悬浮窗宽度。</p>
<h2>FloatyWindow.getHeight()<span><a class="mark" href="#floaty_floatywindow_getheight" id="floaty_floatywindow_getheight">#</a></span></h2>
<h2>window.getHeight()<span><a class="mark" href="#floaty_window_getheight_1" id="floaty_window_getheight_1">#</a></span></h2>
<p>返回悬浮窗高度。</p>
<h2>FloatyWindow.close()<span><a class="mark" href="#floaty_floatywindow_close" id="floaty_floatywindow_close">#</a></span></h2>
<h2>window.close()<span><a class="mark" href="#floaty_window_close_1" id="floaty_window_close_1">#</a></span></h2>
<p>关闭悬浮窗。如果悬浮窗已经是关闭状态,则此函数将不执行任何操作。</p>
<p>被关闭后的悬浮窗不能再显示。</p>
<h2>FloatyWindow.exitOnClose()<span><a class="mark" href="#floaty_floatywindow_exitonclose" id="floaty_floatywindow_exitonclose">#</a></span></h2>
<h2>window.exitOnClose()<span><a class="mark" href="#floaty_window_exitonclose_1" id="floaty_window_exitonclose_1">#</a></span></h2>
<p>使悬浮窗被关闭时自动结束脚本运行。</p>

</div>
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/assets/docs/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h2>目录</h2>
<li><span class="stability_undefined"><a href="#globals_random">random()</a></span></li>
<li><span class="stability_undefined"><a href="#globals_requiresapi_api">requiresApi(api)</a></span></li>
<li><span class="stability_undefined"><a href="#globals_requiresautojsversion_version">requiresAutojsVersion(version)</a></span></li>
<li><span class="stability_undefined"><a href="#globals_runtime_requestpermissions_permissions">runtime.requestPermissions(permissions)</a></span></li>
<li><span class="stability_undefined"><a href="#globals_context">context</a></span></li>
</ul>
</li>
Expand Down Expand Up @@ -217,6 +218,20 @@ <h2>requiresAutojsVersion(version)<span><a class="mark" href="#globals_requiresa
<p>调用该函数时会判断运行脚本的Auto.js的版本号,如果没有达到要求则抛出异常。</p>
<p>version参数可以是整数表示版本号,例如<code>requiresAutojsVersion(250)</code>;也可以是字符串格式表示的版本,例如&quot;3.0.0 Beta&quot;, &quot;3.1.0 Alpha4&quot;, &quot;3.2.0&quot;等。</p>
<p>可以通过<code>app.autojs.versionCode</code><code>app.autojs.versionName</code>获取当前的Auto.js版本号和版本。</p>
<h2>runtime.requestPermissions(permissions)<span><a class="mark" href="#globals_runtime_requestpermissions_permissions" id="globals_runtime_requestpermissions_permissions">#</a></span></h2>
<div class="signature"><ul>
<li><code>permissions</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type">&lt;Array&gt;</a> 权限的字符串数组</li>
</ul>
</div><p>动态申请安卓的权限。例如:</p>
<pre><code>//请求GPS权限
runtime.requestPermission([&quot;access_fine_location&quot;]);
</code></pre><p>尽管安卓有很多权限,但必须写入Manifest才能动态申请,为了防止权限的滥用,目前Auto.js只能额外申请两个权限:</p>
<ul>
<li><code>access_fine_location</code> GPS权限</li>
<li><code>record_audio</code> 录音权限</li>
</ul>
<p>您可以通过APK编辑器来增加Auto.js以及Auto.js打包的应用的权限。</p>
<p>安卓所有的权限列表参见<a href="https://developer.android.com/guide/topics/permissions/overview">Permissions Overview</a>。(并没有用)</p>
<h2>context<span><a class="mark" href="#globals_context" id="globals_context">#</a></span></h2>
<p>全局变量。一个android.content.Context对象。</p>
<p>注意该对象为ApplicationContext,因此不能用于界面、对话框等的创建。</p>
Expand Down
Loading

0 comments on commit 0ffb8d1

Please sign in to comment.