just to save works and use another computer to code
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.getkeepsafe.dexcount'
|
|
||||||
def AAVersion = '4.3.1'
|
def AAVersion = '4.3.1'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -9,8 +8,8 @@ android {
|
|||||||
applicationId "com.stardust.scriptdroid"
|
applicationId "com.stardust.scriptdroid"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 222
|
versionCode 223
|
||||||
versionName "3.0.0 Alpha22"
|
versionName "3.0.0 Alpha23"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
ndk {
|
ndk {
|
||||||
@@ -125,6 +124,10 @@ dependencies {
|
|||||||
exclude group: 'com.android.support'
|
exclude group: 'com.android.support'
|
||||||
})
|
})
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
|
||||||
|
//stor
|
||||||
|
compile 'com.pushtorefresh.storio2:sqlite:2.1.0'
|
||||||
|
compile 'com.pushtorefresh.storio2:sqlite-annotations:2.1.0'
|
||||||
|
annotationProcessor 'com.pushtorefresh.storio2:sqlite-annotations-processor:2.1.0'
|
||||||
// Tasker Plugin
|
// Tasker Plugin
|
||||||
compile 'com.twofortyfouram:android-plugin-client-sdk-for-locale:4.0.3'
|
compile 'com.twofortyfouram:android-plugin-client-sdk-for-locale:4.0.3'
|
||||||
compile 'com.flurry.android:analytics:7.0.0@aar'
|
compile 'com.flurry.android:analytics:7.0.0@aar'
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.stardust.autojs.core.image.ScreenCaptureRequestActivity"
|
android:name="com.stardust.autojs.core.image.ScreenCaptureRequestActivity"
|
||||||
android:taskAffinity="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
|
android:taskAffinity="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
|
||||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
|
android:theme="@style/AppTheme.Transparent"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.error.IssueReporterActivity"
|
android:name=".ui.error.IssueReporterActivity"
|
||||||
android:theme="@style/IssueReporterTheme"/>
|
android:theme="@style/IssueReporterTheme"/>
|
||||||
@@ -206,6 +206,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service android:name=".timing.TimedTaskService"/>
|
||||||
|
|
||||||
<receiver android:name=".external.widget.ScriptWidget">
|
<receiver android:name=".external.widget.ScriptWidget">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
||||||
@@ -216,6 +218,18 @@
|
|||||||
android:resource="@xml/script_widget_config"/>
|
android:resource="@xml/script_widget_config"/>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver android:name=".timing.TaskReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.stardust.autojs.action.task"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
<receiver android:name=".timing.TaskSchedulerReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.stardust.autojs.action.check_task"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<!-- 声明广告SDK所需要的组件 -->
|
<!-- 声明广告SDK所需要的组件 -->
|
||||||
<service
|
<service
|
||||||
android:name="com.qq.e.comm.DownloadService"
|
android:name="com.qq.e.comm.DownloadService"
|
||||||
|
|||||||
145
app/src/main/assets/docs/dialogs.html
Normal file
145
app/src/main/assets/docs/dialogs.html
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Dialogs | 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">
|
||||||
|
<link rel="canonical" href="https://nodejs.org/api/dialogs.html">
|
||||||
|
</head>
|
||||||
|
<body class="alt apidoc" id="api-section-dialogs">
|
||||||
|
<div id="content" class="clearfix">
|
||||||
|
<div id="column2" class="interior">
|
||||||
|
<div id="intro" class="interior">
|
||||||
|
<a href="/" title="返回首页">
|
||||||
|
Auto.js
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-documentation" href="documentation.html">关于本文档</a></li>
|
||||||
|
<li><a class="nav-synopsis" href="synopsis.html">如何阅读本文档</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="line"></div>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
|
||||||
|
<li><a class="nav-qa" href="qa.html">Q&A - 常见问题</a></li>
|
||||||
|
<li><a class="nav-globals" href="globals.html">Globals - 一般全局函数</a></li>
|
||||||
|
<li><a class="nav-widgets-based-automation" href="widgets-based-automation.html">WidgetsBasedAutomation - 基于控件的触摸模拟</a></li>
|
||||||
|
<li><a class="nav-coordinates-based-automation" href="coordinates-based-automation.html">CoordinatesBasedAutomation - 基于坐标的触摸模拟</a></li>
|
||||||
|
<li><a class="nav-images" href="images.html">Images - 图片与图色处理</a></li>
|
||||||
|
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
|
||||||
|
<li><a class="nav-events" href="events.html">Events - 事件与监听</a></li>
|
||||||
|
<li><a class="nav-timers" href="timers.html">Timers - 定时器</a></li>
|
||||||
|
<li><a class="nav-shell" href="shell.html">Shell - Shell命令</a></li>
|
||||||
|
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
|
||||||
|
<li><a class="nav-files" href="files.html">Files - 文件系统</a></li>
|
||||||
|
<li><a class="nav-dialogs active" href="dialogs.html">Dialogs - 对话框</a></li>
|
||||||
|
<li><a class="nav-http" href="http.html">Http - HTTP</a></li>
|
||||||
|
<li><a class="nav-app" href="app.html">App - 应用</a></li>
|
||||||
|
<li><a class="nav-engines" href="engines.html">Engines - 脚本引擎</a></li>
|
||||||
|
<li><a class="nav-modules" href="modules.html">Modules - 模块</a></li>
|
||||||
|
<li><a class="nav-work-with-java" href="work-with-java.html">Work with Java - 调用Java API</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="line"></div>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-https-github-com-hyb1996-NoRootScriptDroid" href="https://github.com/hyb1996/NoRootScriptDroid">GitHub项目 & Issue提交</a></li>
|
||||||
|
<li><a class="nav-http-autojs-org" href="http://autojs.org">Auto.js交流社区</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="column1" data-id="dialogs" class="interior">
|
||||||
|
<header>
|
||||||
|
<h1>Auto.js 3.0.0 文档</h1>
|
||||||
|
<div id="gtoc">
|
||||||
|
<p>
|
||||||
|
<a href="index.html" name="toc">索引</a> |
|
||||||
|
<a href="all.html">查看全部</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div id="toc">
|
||||||
|
<h2>目录</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span class="stability_2"><a href="#dialogs_dialogs">Dialogs</a></span><ul>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_rawinput_title_default">dialogs.rawInput(title[, default])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_input_title_default">dialogs.input(title[, default])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_prompt_title_default">dialogs.prompt(title[, default])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_alert_title_content">dialogs.alert(title[, content])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_confirm_title_content">dialogs.confirm(title[, content])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_select_title_items">dialogs.select(title, items)</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_singlechoice_title_items_index">dialogs.singleChoice(title, items[, index])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#dialogs_dialogs_multichoice_title_items_indexes">dialogs.multiChoice(title, items[, indexes])</a></span></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="apicontent">
|
||||||
|
<h1>Dialogs<span><a class="mark" href="#dialogs_dialogs" id="dialogs_dialogs">#</a></span></h1>
|
||||||
|
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><p>dialogs 模块允许用户通过对话框与脚本进行交互。</p>
|
||||||
|
<h2>dialogs.rawInput(title[, default])<span><a class="mark" href="#dialogs_dialogs_rawinput_title_default" id="dialogs_dialogs_rawinput_title_default">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>default</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 可选,对话框内输入框的初始内容。默认为 <code>""</code> 。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个包含输入框的对话框。如果指定了 <code>default</code> ,那么对话框显示时输入框的内容就为该值。</p>
|
||||||
|
<p>该函数也可通过 <code>rawInput(title[, default])</code> 、 <code>prompt(title[, default])</code> 或者 <code>dialogs.prompt(title[, default])</code> 来调用。调用时脚本将阻塞直至对话框被关闭。如果用户输入内容并点击确定,函数将返回输入的内容;否则返回 <code>null</code> 。</p>
|
||||||
|
<h2>dialogs.input(title[, default])<span><a class="mark" href="#dialogs_dialogs_input_title_default" id="dialogs_dialogs_input_title_default">#</a></span></h2>
|
||||||
|
<p>等效于 <code>eval(dialogs.rawInput(title, default))</code> </p>
|
||||||
|
<h2>dialogs.prompt(title[, default])<span><a class="mark" href="#dialogs_dialogs_prompt_title_default" id="dialogs_dialogs_prompt_title_default">#</a></span></h2>
|
||||||
|
<p>见 dialogs.rawInput</p>
|
||||||
|
<h2>dialogs.alert(title[, content])<span><a class="mark" href="#dialogs_dialogs_alert_title_content" id="dialogs_dialogs_alert_title_content">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>content</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 可选,对话框的内容。默认为空。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个只包含“确定”按钮的提示对话框。</p>
|
||||||
|
<p>该函数也可通过 <code>alert(title[, content])</code> 来调用。调用时脚本将阻塞直至对话框被关闭。该函数无返回值。</p>
|
||||||
|
<h2>dialogs.confirm(title[, content])<span><a class="mark" href="#dialogs_dialogs_confirm_title_content" id="dialogs_dialogs_confirm_title_content">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>content</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 可选,对话框的内容。默认为空。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个包含“确定”和“取消”按钮的提示对话框。</p>
|
||||||
|
<p>该函数也可通过 <code>confirm(title[, content])</code> 来调用。调用时脚本将阻塞直至对话框被关闭。如果用户点击“确定”则返回 <code>true</code> ,否则返回 <code>false</code> 。</p>
|
||||||
|
<h2>dialogs.select(title, items)<span><a class="mark" href="#dialogs_dialogs_select_title_items" id="dialogs_dialogs_select_title_items">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>items</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 对话框的选项列表,是一个字符串数组。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个带有选项列表的对话框。</p>
|
||||||
|
<p>该函数也可通过 <code>dialogs.select(title, ...items)</code> 来调用。<br>例如: <code>dialogs.select("标题", ["A", "B", "C"])</code> 可以用 <code>dialogs.select("标题", "A", "B", "C")</code> 替代。</p>
|
||||||
|
<p>调用时脚本将阻塞直至对话框被关闭。如果用户点击了对话框中的某个选项,该函数会返回该选项的位置(选中第一个选项返回0,第二个选项返回1,以此类推),否则返回-1。</p>
|
||||||
|
<h2>dialogs.singleChoice(title, items[, index])<span><a class="mark" href="#dialogs_dialogs_singlechoice_title_items_index" id="dialogs_dialogs_singlechoice_title_items_index">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>items</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 对话框的选项列表,是一个字符串数组。</li>
|
||||||
|
<li><code>index</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> 可选,对话框的默认选项的位置。默认为0。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个带有单选框选项列表的对话框。</p>
|
||||||
|
<p>调用时脚本将阻塞直至对话框被关闭。如果用户选中了对话框中的某个选项并点击“确定”,该函数会返回该选项的位置(选中第一个选项返回0,第二个选项返回1,以此类推),否则返回-1。</p>
|
||||||
|
<h2>dialogs.multiChoice(title, items[, indexes])<span><a class="mark" href="#dialogs_dialogs_multichoice_title_items_indexes" id="dialogs_dialogs_multichoice_title_items_indexes">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>title</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 对话框的标题。</li>
|
||||||
|
<li><code>items</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 对话框的选项列表,是一个字符串数组。</li>
|
||||||
|
<li><code>indexes</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 可选,对话框的默认选项的位置数组。默认为空数组。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>显示一个带有多选框选项列表的对话框。</p>
|
||||||
|
<p>调用时脚本将阻塞直至对话框被关闭。如果用户点击“确定”按钮,该函数会返回所有已选选项的位置组成的数组,否则返回空数组。</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/sh_main.js"></script>
|
||||||
|
<script src="assets/sh_javascript.min.js"></script>
|
||||||
|
<script>highlight(undefined, undefined, 'pre');</script>
|
||||||
|
<!-- __TRACKING__ -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
257
app/src/main/assets/docs/http.html
Normal file
257
app/src/main/assets/docs/http.html
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>HTTP | 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">
|
||||||
|
<link rel="canonical" href="https://nodejs.org/api/http.html">
|
||||||
|
</head>
|
||||||
|
<body class="alt apidoc" id="api-section-http">
|
||||||
|
<div id="content" class="clearfix">
|
||||||
|
<div id="column2" class="interior">
|
||||||
|
<div id="intro" class="interior">
|
||||||
|
<a href="/" title="返回首页">
|
||||||
|
Auto.js
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-documentation" href="documentation.html">关于本文档</a></li>
|
||||||
|
<li><a class="nav-synopsis" href="synopsis.html">如何阅读本文档</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="line"></div>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-overview" href="overview.html">Overview - 综述</a></li>
|
||||||
|
<li><a class="nav-qa" href="qa.html">Q&A - 常见问题</a></li>
|
||||||
|
<li><a class="nav-globals" href="globals.html">Globals - 一般全局函数</a></li>
|
||||||
|
<li><a class="nav-widgets-based-automation" href="widgets-based-automation.html">WidgetsBasedAutomation - 基于控件的触摸模拟</a></li>
|
||||||
|
<li><a class="nav-coordinates-based-automation" href="coordinates-based-automation.html">CoordinatesBasedAutomation - 基于坐标的触摸模拟</a></li>
|
||||||
|
<li><a class="nav-images" href="images.html">Images - 图片与图色处理</a></li>
|
||||||
|
<li><a class="nav-console" href="console.html">Console - 控制台</a></li>
|
||||||
|
<li><a class="nav-events" href="events.html">Events - 事件与监听</a></li>
|
||||||
|
<li><a class="nav-timers" href="timers.html">Timers - 定时器</a></li>
|
||||||
|
<li><a class="nav-shell" href="shell.html">Shell - Shell命令</a></li>
|
||||||
|
<li><a class="nav-ui" href="ui.html">UI - 用户界面</a></li>
|
||||||
|
<li><a class="nav-files" href="files.html">Files - 文件系统</a></li>
|
||||||
|
<li><a class="nav-dialogs" href="dialogs.html">Dialogs - 对话框</a></li>
|
||||||
|
<li><a class="nav-http active" href="http.html">Http - HTTP</a></li>
|
||||||
|
<li><a class="nav-app" href="app.html">App - 应用</a></li>
|
||||||
|
<li><a class="nav-engines" href="engines.html">Engines - 脚本引擎</a></li>
|
||||||
|
<li><a class="nav-modules" href="modules.html">Modules - 模块</a></li>
|
||||||
|
<li><a class="nav-work-with-java" href="work-with-java.html">Work with Java - 调用Java API</a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="line"></div>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a class="nav-https-github-com-hyb1996-NoRootScriptDroid" href="https://github.com/hyb1996/NoRootScriptDroid">GitHub项目 & Issue提交</a></li>
|
||||||
|
<li><a class="nav-http-autojs-org" href="http://autojs.org">Auto.js交流社区</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="column1" data-id="http" class="interior">
|
||||||
|
<header>
|
||||||
|
<h1>Auto.js 3.0.0 文档</h1>
|
||||||
|
<div id="gtoc">
|
||||||
|
<p>
|
||||||
|
<a href="index.html" name="toc">索引</a> |
|
||||||
|
<a href="all.html">查看全部</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div id="toc">
|
||||||
|
<h2>目录</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span class="stability_2"><a href="#http_http">HTTP</a></span><ul>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_http_get_url_options_callback">http.get(url[, options, callback])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_http_post_url_data_options_callback">http.post(url, data[, options, callback])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_http_postjson_url_data_options_callback">http.postJson(url[, data, options, callback])</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_http_request_url_options_callback">http.request(url[, options, callback])</a></span></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response">Response</a></span><ul>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_statuscode">Response.statusCode</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_statusmessage">Response.statusMessage</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_headers">Response.headers</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_body">Response.body</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_request">Response.request</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_url">Response.url</a></span></li>
|
||||||
|
<li><span class="stability_undefined"><a href="#http_response_method">Response.method</a></span></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="apicontent">
|
||||||
|
<h1>HTTP<span><a class="mark" href="#http_http" id="http_http">#</a></span></h1>
|
||||||
|
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - Stable</div><p>http模块提供一些进行http请求的函数。</p>
|
||||||
|
<h2>http.get(url[, options, callback])<span><a class="mark" href="#http_http_get_url_options_callback" id="http_http_get_url_options_callback">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>url</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 请求的URL地址,需要以"<a href="http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。">http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。</a></li>
|
||||||
|
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 请求选项。参见[http.request()][]。</li>
|
||||||
|
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 回调函数,可选,其参数是一个[Response][]对象。如果不加回调函数,则该请求将阻塞、同步地执行。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>对地址url进行一次HTTP GET 请求。如果没有回调函数,则在请求完成或失败时返回此次请求的响应(参见[Response][])。</p>
|
||||||
|
<p>最简单GET请求如下:</p>
|
||||||
|
<pre><code>console.show();
|
||||||
|
var r = http.get("www.baidu.com");
|
||||||
|
log("code = " + r.statusCode);
|
||||||
|
log("html = " + r.body.string());
|
||||||
|
</code></pre><p>采用回调形式的GET请求如下:</p>
|
||||||
|
<pre><code>console.show();
|
||||||
|
http.get("www.baidu.com", {}, function(res, err){
|
||||||
|
if(err){
|
||||||
|
console.error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log("code = " + r.statusCode);
|
||||||
|
log("html = " + r.body.string());
|
||||||
|
});
|
||||||
|
</code></pre><p>如果要增加HTTP头部信息,则在options参数中添加,例如:</p>
|
||||||
|
<pre><code>console.show();
|
||||||
|
var r = http.get("www.baidu.com", {
|
||||||
|
headers: {
|
||||||
|
"Accept-Language": "zh-cn,zh;q=0.5",
|
||||||
|
"User-Agent: "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"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
log("code = " + r.statusCode);
|
||||||
|
log("html = " + r.body.string());
|
||||||
|
</code></pre><p>一个请求天气并解析返回的天气JSON结果的例子如下:</p>
|
||||||
|
<pre><code>var city = "广州";
|
||||||
|
var res = http.get("http://www.sojson.com/open/api/weather/json.shtml?city=" + city);
|
||||||
|
if(res.statusCode != 200){
|
||||||
|
toast("请求失败: " + res.statusCode + " " + res.statusMessage);
|
||||||
|
}else{
|
||||||
|
var weather = res.body.json();
|
||||||
|
log(weather);
|
||||||
|
toast(util.format("温度: %s 湿度: %s 空气质量: %s", weather.data.wendu,
|
||||||
|
weather.data.shidu, weather.quality));
|
||||||
|
}
|
||||||
|
</code></pre><h2>http.post(url, data[, options, callback])<span><a class="mark" href="#http_http_post_url_data_options_callback" id="http_http_post_url_data_options_callback">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>url</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 请求的URL地址,需要以"<a href="http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。">http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。</a></li>
|
||||||
|
<li><code>data</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> POST数据。</li>
|
||||||
|
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 请求选项。</li>
|
||||||
|
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 回调,其参数是一个[Response][]对象。如果不加回调参数,则该请求将阻塞、同步地执行。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>对地址url进行一次HTTP POST 请求。如果没有回调函数,则在请求完成或失败时返回此次请求的响应(参见[Response][])。</p>
|
||||||
|
<p>其中POST数据可以是字符串或键值对。具体含义取决于options.contentType的值。默认为"application/x-www-form-urlencoded"(表单提交), 这种方式是JQuery的ajax函数的默认方式。</p>
|
||||||
|
<p>一个模拟表单提交登录淘宝的例子如下:</p>
|
||||||
|
<pre><code>var url = "https://login.taobao.com/member/login.jhtml";
|
||||||
|
var username = "你的用户名";
|
||||||
|
var password = "你的密码";
|
||||||
|
var res = http.post(url, {
|
||||||
|
"TPL_username": username,
|
||||||
|
"TPL_password": password
|
||||||
|
});
|
||||||
|
var html = res.body.string();
|
||||||
|
if(html.contains("页面跳转中")){
|
||||||
|
toast("登录成功");
|
||||||
|
}else{
|
||||||
|
toast("登录失败");
|
||||||
|
}
|
||||||
|
</code></pre><h2>http.postJson(url[, data, options, callback])<span><a class="mark" href="#http_http_postjson_url_data_options_callback" id="http_http_postjson_url_data_options_callback">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>url</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 请求的URL地址,需要以"<a href="http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。">http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。</a></li>
|
||||||
|
<li><code>data</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> POST数据。</li>
|
||||||
|
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 请求选项。</li>
|
||||||
|
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 回调,其参数是一个[Response][]对象。如果不加回调参数,则该请求将阻塞、同步地执行。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>以JSON格式向目标Url发起POST请求。如果没有回调函数,则在请求完成或失败时返回此次请求的响应(参见[Response][])。</p>
|
||||||
|
<p>JSON格式指的是,将会调用<code>JSON.stringify()</code>把data对象转换为JSON字符串,并在HTTP头部信息中把"Content-Type"属性置为"application/json"。这种方式是AngularJS的ajax函数的默认方式。</p>
|
||||||
|
<p>一个调用图灵机器人接口的例子如下:</p>
|
||||||
|
<h2>http.request(url[, options, callback])<span><a class="mark" href="#http_http_request_url_options_callback" id="http_http_request_url_options_callback">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><code>url</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 请求的URL地址,需要以"<a href="http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。">http://"或"https://"开头。如果url没有以"http://"开头,则默认为"http://"。</a></li>
|
||||||
|
<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 请求选项。参见[http.buildRequest()][]。</li>
|
||||||
|
<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 回调,其参数是一个[Response][]对象。如果不加回调参数,则该请求将阻塞、同步地执行。</li>
|
||||||
|
</ul>
|
||||||
|
</div><p>对目标地址url发起一次HTTP请求。如果没有回调函数,则在请求完成或失败时返回此次请求的响应(参见[Response][])。</p>
|
||||||
|
<p>选项options可以包含以下属性:</p>
|
||||||
|
<ul>
|
||||||
|
<li><code>headers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 键值对形式的HTTP头部信息。有关HTTP头部信息,参见<a href="http://www.runoob.com/http/http-header-fields.html">菜鸟教程:HTTP响应头信息</a>。</li>
|
||||||
|
<li><code>method</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> HTTP请求方法。包括"GET", "POST", "PUT", "DELET", "PATCH"。</li>
|
||||||
|
<li><code>contentType</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> HTTP头部信息中的"Content-Type", 表示HTTP请求的内容类型。例如"text/plain", "application/json"。更多信息参见<a href="http://www.runoob.com/http/http-content-type.html">菜鸟教程:HTTP contentType</a>。</li>
|
||||||
|
<li><code>body</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> HTTP请求的内容。可以是一个字符串,也可以是一个字节数组;或者是一个以<a href="https://github.com/square/okio/blob/master/okio/src/main/java/okio/BufferedSink.java">BufferedSink</a>为参数的函数。</li>
|
||||||
|
</ul>
|
||||||
|
<p>该函数是get, post, postJson等函数的基础函数。因此除非是PUT, DELET等请求,或者需要更高定制的HTTP请求,否则直接使用get, post, postJson等函数会更加方便。</p>
|
||||||
|
<h1>Response<span><a class="mark" href="#http_response" id="http_response">#</a></span></h1>
|
||||||
|
<p>HTTP请求的响应。</p>
|
||||||
|
<h2>Response.statusCode<span><a class="mark" href="#http_response_statuscode" id="http_response_statuscode">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li>
|
||||||
|
</ul>
|
||||||
|
</div><p>当前响应的HTTP状态码。例如200(OK), 404(Not Found)等。</p>
|
||||||
|
<p>有关HTTP状态码的信息,参见<a href="http://www.runoob.com/http/http-status-codes.html">菜鸟教程:HTTP状态码</a>。</p>
|
||||||
|
<h2>Response.statusMessage<span><a class="mark" href="#http_response_statusmessage" id="http_response_statusmessage">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> </li>
|
||||||
|
</ul>
|
||||||
|
</div><p>当前响应的HTTP状态信息。例如"OK", "Bad Request", "Forbidden"。</p>
|
||||||
|
<p>有关HTTP状态码的信息,参见<a href="http://www.runoob.com/http/http-status-codes.html">菜鸟教程:HTTP状态码</a>。</p>
|
||||||
|
<p>例子:</p>
|
||||||
|
<pre><code>var res = http.get("www.baidu.com");
|
||||||
|
if(res.statusCode >= 200 && res.statusCode < 300){
|
||||||
|
toast("页面获取成功!");
|
||||||
|
}else if(res.statusCode == 404){
|
||||||
|
toast("页面没找到哦...");
|
||||||
|
}else{
|
||||||
|
toast("错误: " + res.statusCode + " " + res.statusMessage);
|
||||||
|
}
|
||||||
|
</code></pre><h2>Response.headers<span><a class="mark" href="#http_response_headers" id="http_response_headers">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a></li>
|
||||||
|
</ul>
|
||||||
|
</div><p>当前响应的HTTP头部信息。该对象的键是响应头名称,值是各自的响应头值。 所有响应头名称都是小写的(吗)。</p>
|
||||||
|
<p>有关HTTP头部信息,参见<a href="http://www.runoob.com/http/http-header-fields.html">菜鸟教程:HTTP响应头信息</a>。</p>
|
||||||
|
<p>例子:</p>
|
||||||
|
<pre><code>console.show();
|
||||||
|
var res = http.get("www.qq.com");
|
||||||
|
console.log("HTTP Headers:")
|
||||||
|
for(var headerName in res.headers){
|
||||||
|
console.log("%s: %s", headerName, res.headers[headerName]);
|
||||||
|
}
|
||||||
|
</code></pre><h2>Response.body<span><a class="mark" href="#http_response_body" id="http_response_body">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a></li>
|
||||||
|
</ul>
|
||||||
|
</div><p>当前响应的内容。他有以下属性和函数:</p>
|
||||||
|
<ul>
|
||||||
|
<li>bytes() <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> 以字节数组形式返回响应内容</li>
|
||||||
|
<li>string() <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 以字符串形式返回响应内容</li>
|
||||||
|
<li>json() <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 把响应内容作为JSON格式的数据并调用JSON.parse,返回解析后的对象</li>
|
||||||
|
<li>contentType <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> 当前响应的内容类型</li>
|
||||||
|
</ul>
|
||||||
|
<h2>Response.request<span><a class="mark" href="#http_response_request" id="http_response_request">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><span class="type"><Request></span>
|
||||||
|
当前响应所对应的请求。参见[Request][]。</li>
|
||||||
|
</ul>
|
||||||
|
</div><h2>Response.url<span><a class="mark" href="#http_response_url" id="http_response_url">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a>
|
||||||
|
当前响应所对应的请求URL。</li>
|
||||||
|
</ul>
|
||||||
|
</div><h2>Response.method<span><a class="mark" href="#http_response_method" id="http_response_method">#</a></span></h2>
|
||||||
|
<div class="signature"><ul>
|
||||||
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>
|
||||||
|
当前响应所对应的HTTP请求的方法。例如"GET", "POST", "PUT"等。</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/sh_main.js"></script>
|
||||||
|
<script src="assets/sh_javascript.min.js"></script>
|
||||||
|
<script>highlight(undefined, undefined, 'pre');</script>
|
||||||
|
<!-- __TRACKING__ -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.stardust.scriptdroid;
|
package com.stardust.scriptdroid;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -17,6 +20,7 @@ import com.stardust.scriptdroid.autojs.AutoJs;
|
|||||||
import com.stardust.scriptdroid.autojs.key.GlobalKeyObserver;
|
import com.stardust.scriptdroid.autojs.key.GlobalKeyObserver;
|
||||||
import com.stardust.scriptdroid.autojs.record.GlobalRecorder;
|
import com.stardust.scriptdroid.autojs.record.GlobalRecorder;
|
||||||
import com.stardust.scriptdroid.network.GlideApp;
|
import com.stardust.scriptdroid.network.GlideApp;
|
||||||
|
import com.stardust.scriptdroid.timing.TaskSchedulerReceiver;
|
||||||
import com.stardust.scriptdroid.tool.CrashHandler;
|
import com.stardust.scriptdroid.tool.CrashHandler;
|
||||||
import com.stardust.scriptdroid.tool.JsBeautifierFactory;
|
import com.stardust.scriptdroid.tool.JsBeautifierFactory;
|
||||||
import com.stardust.scriptdroid.ui.error.ErrorReportActivity;
|
import com.stardust.scriptdroid.ui.error.ErrorReportActivity;
|
||||||
@@ -74,7 +78,7 @@ public class App extends MultiDexApplication {
|
|||||||
GlobalKeyObserver.getSingleton();
|
GlobalKeyObserver.getSingleton();
|
||||||
GlobalRecorder.initSingleton(this);
|
GlobalRecorder.initSingleton(this);
|
||||||
setupDrawableImageLoader();
|
setupDrawableImageLoader();
|
||||||
|
TaskSchedulerReceiver.setupRepeating(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupDrawableImageLoader() {
|
private void setupDrawableImageLoader() {
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ public class ScriptExecutionIntentService extends IntentService {
|
|||||||
protected void onHandleIntent(@Nullable Intent intent) {
|
protected void onHandleIntent(@Nullable Intent intent) {
|
||||||
if (intent == null)
|
if (intent == null)
|
||||||
return;
|
return;
|
||||||
CommonUtils.handleIntent(this, intent);
|
ScriptIntents.handleIntent(this, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.stardust.autojs.execution.ExecutionConfig;
|
||||||
import com.stardust.autojs.script.JavaScriptFileSource;
|
import com.stardust.autojs.script.JavaScriptFileSource;
|
||||||
import com.stardust.autojs.script.ScriptSource;
|
import com.stardust.autojs.script.ScriptSource;
|
||||||
import com.stardust.autojs.script.SequenceScriptSource;
|
import com.stardust.autojs.script.SequenceScriptSource;
|
||||||
import com.stardust.autojs.script.StringScriptSource;
|
import com.stardust.autojs.script.StringScriptSource;
|
||||||
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
|
import com.stardust.scriptdroid.io.StorageFileProvider;
|
||||||
import com.stardust.scriptdroid.model.script.PathChecker;
|
import com.stardust.scriptdroid.model.script.PathChecker;
|
||||||
import com.stardust.scriptdroid.model.script.Scripts;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -17,21 +19,27 @@ import java.io.File;
|
|||||||
* Created by Stardust on 2017/4/1.
|
* Created by Stardust on 2017/4/1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommonUtils {
|
public class ScriptIntents {
|
||||||
|
|
||||||
public static final String EXTRA_KEY_PATH = "path";
|
public static final String EXTRA_KEY_PATH = "path";
|
||||||
|
|
||||||
public static final String EXTRA_KEY_PRE_EXECUTE_SCRIPT = "script";
|
public static final String EXTRA_KEY_PRE_EXECUTE_SCRIPT = "script";
|
||||||
|
public static final String EXTRA_KEY_LOOP_TIMES = "loop";
|
||||||
|
public static final String EXTRA_KEY_LOOP_INTERVAL = "interval";
|
||||||
|
public static final String EXTRA_KEY_DELAY = "delay";
|
||||||
|
|
||||||
|
|
||||||
public static boolean isTaskerBundleValid(Bundle bundle) {
|
public static boolean isTaskerBundleValid(Bundle bundle) {
|
||||||
return bundle.containsKey(CommonUtils.EXTRA_KEY_PATH) || bundle.containsKey(EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
return bundle.containsKey(ScriptIntents.EXTRA_KEY_PATH) || bundle.containsKey(EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleIntent(Context context, Intent intent) {
|
public static boolean handleIntent(Context context, Intent intent) {
|
||||||
String path = getPath(intent);
|
String path = getPath(intent);
|
||||||
String directoryPath = null;
|
String script = intent.getStringExtra(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
||||||
String script = intent.getStringExtra(CommonUtils.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
int loopTimes = intent.getIntExtra(EXTRA_KEY_LOOP_TIMES, 1);
|
||||||
|
long delay = intent.getLongExtra(EXTRA_KEY_DELAY, 0);
|
||||||
|
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
|
||||||
ScriptSource source = null;
|
ScriptSource source = null;
|
||||||
|
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
|
||||||
if (path == null && script != null) {
|
if (path == null && script != null) {
|
||||||
source = new StringScriptSource(script);
|
source = new StringScriptSource(script);
|
||||||
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
|
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
|
||||||
@@ -41,19 +49,20 @@ public class CommonUtils {
|
|||||||
} else {
|
} else {
|
||||||
source = fileScriptSource;
|
source = fileScriptSource;
|
||||||
}
|
}
|
||||||
directoryPath = new File(path).getParent();
|
config.path(new File(path).getParent(), StorageFileProvider.DEFAULT_DIRECTORY_PATH);
|
||||||
|
} else {
|
||||||
|
config.path(StorageFileProvider.DEFAULT_DIRECTORY_PATH);
|
||||||
}
|
}
|
||||||
if (source != null) {
|
if (source == null) {
|
||||||
if (directoryPath == null)
|
return false;
|
||||||
Scripts.run(source);
|
|
||||||
else
|
|
||||||
Scripts.run(source, directoryPath);
|
|
||||||
}
|
}
|
||||||
|
AutoJs.getInstance().getScriptEngineService().execute(source, config);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPath(Intent intent) {
|
private static String getPath(Intent intent) {
|
||||||
if (intent.getData() != null && intent.getData().getPath() != null)
|
if (intent.getData() != null && intent.getData().getPath() != null)
|
||||||
return intent.getData().getPath();
|
return intent.getData().getPath();
|
||||||
return intent.getStringExtra(CommonUtils.EXTRA_KEY_PATH);
|
return intent.getStringExtra(ScriptIntents.EXTRA_KEY_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,17 +5,13 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.stardust.autojs.script.StringScriptSource;
|
import com.stardust.autojs.script.StringScriptSource;
|
||||||
import com.stardust.pio.PFile;
|
|
||||||
import com.stardust.pio.PFiles;
|
import com.stardust.pio.PFiles;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.model.script.ScriptFile;
|
|
||||||
import com.stardust.scriptdroid.model.script.Scripts;
|
import com.stardust.scriptdroid.model.script.Scripts;
|
||||||
import com.stardust.scriptdroid.ui.common.ScriptOperations;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -44,7 +40,7 @@ public class RunIntentActivity extends Activity {
|
|||||||
InputStream stream = getContentResolver().openInputStream(uri);
|
InputStream stream = getContentResolver().openInputStream(uri);
|
||||||
Scripts.run(new StringScriptSource(PFiles.read(stream)));
|
Scripts.run(new StringScriptSource(PFiles.read(stream)));
|
||||||
} else {
|
} else {
|
||||||
CommonUtils.handleIntent(this, intent);
|
ScriptIntents.handleIntent(this, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import android.os.Bundle;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.model.script.PathChecker;
|
import com.stardust.scriptdroid.model.script.PathChecker;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.model.script.ScriptFile;
|
import com.stardust.scriptdroid.model.script.ScriptFile;
|
||||||
import com.stardust.scriptdroid.model.script.Scripts;
|
import com.stardust.scriptdroid.model.script.Scripts;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public class ShortcutActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
final String path = getIntent().getStringExtra(CommonUtils.EXTRA_KEY_PATH);
|
final String path = getIntent().getStringExtra(ScriptIntents.EXTRA_KEY_PATH);
|
||||||
if (new PathChecker(this).checkAndToastError(path)) {
|
if (new PathChecker(this).checkAndToastError(path)) {
|
||||||
runScriptFile(path);
|
runScriptFile(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.stardust.scriptdroid.external.shortcut;
|
package com.stardust.scriptdroid.external.shortcut;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
@@ -8,8 +7,6 @@ import android.graphics.drawable.Icon;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.App;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
|
||||||
import com.stardust.scriptdroid.external.ScriptExecutionIntentService;
|
|
||||||
import com.stardust.scriptdroid.external.open.RunIntentActivity;
|
import com.stardust.scriptdroid.external.open.RunIntentActivity;
|
||||||
import com.twofortyfouram.locale.sdk.client.receiver.AbstractPluginSettingReceiver;
|
import com.twofortyfouram.locale.sdk.client.receiver.AbstractPluginSettingReceiver;
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ public class FireSettingReceiver extends AbstractPluginSettingReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isBundleValid(@NonNull Bundle bundle) {
|
protected boolean isBundleValid(@NonNull Bundle bundle) {
|
||||||
return CommonUtils.isTaskerBundleValid(bundle);
|
return ScriptIntents.isTaskerBundleValid(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.model.script.ScriptFile;
|
import com.stardust.scriptdroid.model.script.ScriptFile;
|
||||||
import com.stardust.scriptdroid.io.StorageFileProvider;
|
import com.stardust.scriptdroid.io.StorageFileProvider;
|
||||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||||
@@ -79,30 +79,30 @@ public class TaskPrefEditActivity extends AbstractAppCompatPluginActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBundleValid(@NonNull Bundle bundle) {
|
public boolean isBundleValid(@NonNull Bundle bundle) {
|
||||||
return CommonUtils.isTaskerBundleValid(bundle);
|
return ScriptIntents.isTaskerBundleValid(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostCreateWithPreviousResult(@NonNull Bundle bundle, @NonNull String s) {
|
public void onPostCreateWithPreviousResult(@NonNull Bundle bundle, @NonNull String s) {
|
||||||
mSelectedScriptFilePath = bundle.getString(CommonUtils.EXTRA_KEY_PATH);
|
mSelectedScriptFilePath = bundle.getString(ScriptIntents.EXTRA_KEY_PATH);
|
||||||
mPreExecuteScript = bundle.getString(CommonUtils.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
mPreExecuteScript = bundle.getString(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Bundle getResultBundle() {
|
public Bundle getResultBundle() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(CommonUtils.EXTRA_KEY_PATH, mSelectedScriptFilePath);
|
bundle.putString(ScriptIntents.EXTRA_KEY_PATH, mSelectedScriptFilePath);
|
||||||
bundle.putString(CommonUtils.EXTRA_KEY_PRE_EXECUTE_SCRIPT, mPreExecuteScript);
|
bundle.putString(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT, mPreExecuteScript);
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String getResultBlurb(@NonNull Bundle bundle) {
|
public String getResultBlurb(@NonNull Bundle bundle) {
|
||||||
String blurb = bundle.getString(CommonUtils.EXTRA_KEY_PATH);
|
String blurb = bundle.getString(ScriptIntents.EXTRA_KEY_PATH);
|
||||||
if (TextUtils.isEmpty(blurb)) {
|
if (TextUtils.isEmpty(blurb)) {
|
||||||
blurb = bundle.getString(CommonUtils.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
blurb = bundle.getString(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(blurb)) {
|
if (TextUtils.isEmpty(blurb)) {
|
||||||
blurb = getString(R.string.text_path_is_empty);
|
blurb = getString(R.string.text_path_is_empty);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import android.widget.RemoteViews;
|
|||||||
|
|
||||||
import com.stardust.pio.PFiles;
|
import com.stardust.pio.PFiles;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.external.open.RunIntentActivity;
|
import com.stardust.scriptdroid.external.open.RunIntentActivity;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -48,7 +48,7 @@ public class ScriptWidget extends AppWidgetProvider {
|
|||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_script_shortcut);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_script_shortcut);
|
||||||
views.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, requestCode,
|
views.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, requestCode,
|
||||||
new Intent(context, RunIntentActivity.class)
|
new Intent(context, RunIntentActivity.class)
|
||||||
.putExtra(CommonUtils.EXTRA_KEY_PATH, path)
|
.putExtra(ScriptIntents.EXTRA_KEY_PATH, path)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
|
||||||
views.setTextViewText(R.id.name, name);
|
views.setTextViewText(R.id.name, name);
|
||||||
appWidgetManager.updateAppWidget(widgetId, views);
|
appWidgetManager.updateAppWidget(widgetId, views);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import com.stardust.autojs.script.ScriptSource;
|
|||||||
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.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.external.shortcut.Shortcut;
|
import com.stardust.scriptdroid.external.shortcut.Shortcut;
|
||||||
import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
||||||
import com.stardust.scriptdroid.io.StorageFileProvider;
|
import com.stardust.scriptdroid.io.StorageFileProvider;
|
||||||
@@ -77,7 +77,7 @@ public class Scripts {
|
|||||||
new Shortcut(App.getApp()).name(scriptFile.getSimplifiedName())
|
new Shortcut(App.getApp()).name(scriptFile.getSimplifiedName())
|
||||||
.targetClass(ShortcutActivity.class)
|
.targetClass(ShortcutActivity.class)
|
||||||
.iconRes(R.drawable.ic_node_js_black)
|
.iconRes(R.drawable.ic_node_js_black)
|
||||||
.extras(new Intent().putExtra(CommonUtils.EXTRA_KEY_PATH, scriptFile.getPath()))
|
.extras(new Intent().putExtra(ScriptIntents.EXTRA_KEY_PATH, scriptFile.getPath()))
|
||||||
.send();
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,4 +133,12 @@ public class Scripts {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void send(ScriptFile file) {
|
||||||
|
Uri uri = Uri.parse("file://" + file.getPath());
|
||||||
|
App.getApp().startActivity(new Intent(Intent.ACTION_SEND)
|
||||||
|
.setDataAndType(uri, "text/plain")
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.stardust.scriptdroid.timing;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/11/27.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TaskReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
public static final String ACTION_TASK = "com.stardust.autojs.action.task";
|
||||||
|
public static final String EXTRA_TASK_ID = "task_id";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
ScriptIntents.handleIntent(context, intent);
|
||||||
|
int id = intent.getIntExtra(EXTRA_TASK_ID, -1);
|
||||||
|
if (id >= 0) {
|
||||||
|
TimedTaskManager.getInstance().notifyTaskFinished(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.stardust.scriptdroid.timing;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/11/27.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TaskSchedulerReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
public static final String ACTION_CHECK_TASK = "com.stardust.autojs.action.check_task";
|
||||||
|
private static final String LOG_TAG = "TaskSchedulerReceiver";
|
||||||
|
private static final int REQUEST_CODE = 4056;
|
||||||
|
private static final long INTERVAL = 60 * 1000;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.d(LOG_TAG, "onReceive");
|
||||||
|
checkTasks(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkTasks(Context context) {
|
||||||
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
TimedTaskManager.getInstance().getFutureTasksInMillis(TimeUnit.HOURS.toMillis(1))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(timedTask -> scheduleTask(context, alarmManager, timedTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void scheduleTask(Context context, AlarmManager alarmManager, TimedTask timedTask) {
|
||||||
|
long millis = timedTask.getNextTime();
|
||||||
|
PendingIntent op = PendingIntent.getBroadcast(context, REQUEST_CODE + 1 + timedTask.getId(),
|
||||||
|
timedTask.createIntent().setAction(TaskReceiver.ACTION_TASK),
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
alarmManager.setExact(AlarmManager.RTC_WAKEUP, millis, op);
|
||||||
|
} else {
|
||||||
|
alarmManager.set(AlarmManager.RTC_WAKEUP, millis, op);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupRepeating(Context context) {
|
||||||
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 5000,
|
||||||
|
INTERVAL, PendingIntent.getBroadcast(context, REQUEST_CODE,
|
||||||
|
new Intent(TaskSchedulerReceiver.ACTION_CHECK_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.stardust.scriptdroid.timing;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/11/27.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TimedTask {
|
||||||
|
|
||||||
|
int mId;
|
||||||
|
|
||||||
|
boolean mDisposable;
|
||||||
|
|
||||||
|
boolean mScheduled;
|
||||||
|
|
||||||
|
public boolean isDisposable() {
|
||||||
|
return mDisposable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisposable(boolean disposable) {
|
||||||
|
mDisposable = disposable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScheduled() {
|
||||||
|
return mScheduled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScheduled(boolean scheduled) {
|
||||||
|
mScheduled = scheduled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getNextTime() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Intent createIntent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.stardust.scriptdroid.timing;
|
||||||
|
|
||||||
|
|
||||||
|
import com.pushtorefresh.storio2.sqlite.StorIOSQLite;
|
||||||
|
import com.pushtorefresh.storio2.sqlite.impl.DefaultStorIOSQLite;
|
||||||
|
import com.pushtorefresh.storio2.sqlite.queries.Query;
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/11/27.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TimedTaskManager {
|
||||||
|
|
||||||
|
static final String TABLE_NAME = "timed_tasks";
|
||||||
|
|
||||||
|
private static TimedTaskManager sInstance = new TimedTaskManager();
|
||||||
|
private StorIOSQLite mStorIOSQLite;
|
||||||
|
|
||||||
|
public static TimedTaskManager getInstance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimedTaskManager() {
|
||||||
|
/* mStorIOSQLite = DefaultStorIOSQLite.builder()
|
||||||
|
.sqliteOpenHelper()
|
||||||
|
.build();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyTaskFinished(int id) {
|
||||||
|
getTaskById(id).subscribe(timedTask -> {
|
||||||
|
if (timedTask.isDisposable()) {
|
||||||
|
removeTask(id);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<TimedTask> getTaskById(int id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeTask(int id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Observable<TimedTask> getAllTasks() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Observable<TimedTask> getFutureTasksInMillis(long millis) {
|
||||||
|
long current = System.currentTimeMillis();
|
||||||
|
return getAllTasks().filter(timedTask ->
|
||||||
|
timedTask.getNextTime() - current <= millis);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.stardust.scriptdroid.timing;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/11/27.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TimedTaskService extends Service {
|
||||||
|
|
||||||
|
private static final int REQUEST_CODE_CHECK_TASK = 4056;
|
||||||
|
|
||||||
|
private AlarmManager mAlarmManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -306,6 +306,10 @@ public class ScriptOperations {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void timedTask(ScriptFile scriptFile) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class InputCallback implements MaterialDialog.InputCallback {
|
private class InputCallback implements MaterialDialog.InputCallback {
|
||||||
|
|
||||||
@@ -322,7 +326,7 @@ public class ScriptOperations {
|
|||||||
this(ext, null);
|
this(ext, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputCallback() {
|
InputCallback() {
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.stardust.scriptdroid.BuildConfig;
|
|||||||
import com.stardust.scriptdroid.Pref;
|
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.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.ui.codegeneration.CodeGenerateDialog;
|
import com.stardust.scriptdroid.timing.TimedTaskService;
|
||||||
import com.stardust.scriptdroid.ui.common.NotAskAgainDialog;
|
import com.stardust.scriptdroid.ui.common.NotAskAgainDialog;
|
||||||
import com.stardust.scriptdroid.ui.doc.OnlineDocsFragment_;
|
import com.stardust.scriptdroid.ui.doc.OnlineDocsFragment_;
|
||||||
import com.stardust.scriptdroid.ui.floating.FloatyWindowManger;
|
import com.stardust.scriptdroid.ui.floating.FloatyWindowManger;
|
||||||
|
|||||||
@@ -234,6 +234,15 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
|||||||
Scripts.openByOtherApps(mSelectedScriptFile);
|
Scripts.openByOtherApps(mSelectedScriptFile);
|
||||||
notifyOperated();
|
notifyOperated();
|
||||||
break;
|
break;
|
||||||
|
case R.id.send:
|
||||||
|
Scripts.send(mSelectedScriptFile);
|
||||||
|
notifyOperated();
|
||||||
|
break;
|
||||||
|
case R.id.timed_task:
|
||||||
|
new ScriptOperations(getContext(), this)
|
||||||
|
.timedTask(mSelectedScriptFile);
|
||||||
|
notifyOperated();
|
||||||
|
break;
|
||||||
case R.id.action_sort_by_date:
|
case R.id.action_sort_by_date:
|
||||||
sort(ScriptList.SORT_TYPE_DATE, mDirSortMenuShowing);
|
sort(ScriptList.SORT_TYPE_DATE, mDirSortMenuShowing);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.external.CommonUtils;
|
import com.stardust.scriptdroid.external.ScriptIntents;
|
||||||
import com.stardust.scriptdroid.external.shortcut.Shortcut;
|
import com.stardust.scriptdroid.external.shortcut.Shortcut;
|
||||||
import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
||||||
import com.stardust.scriptdroid.external.shortcut.ShortcutManager;
|
import com.stardust.scriptdroid.external.shortcut.ShortcutManager;
|
||||||
@@ -100,7 +100,7 @@ public class ShortcutCreateActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
shortcut.name(mName.getText().toString())
|
shortcut.name(mName.getText().toString())
|
||||||
.targetClass(ShortcutActivity.class)
|
.targetClass(ShortcutActivity.class)
|
||||||
.extras(new Intent().putExtra(CommonUtils.EXTRA_KEY_PATH, mScriptFile.getPath()))
|
.extras(new Intent().putExtra(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath()))
|
||||||
.send();
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +114,10 @@ public class ShortcutCreateActivity extends AppCompatActivity {
|
|||||||
icon = Icon.createWithBitmap(bitmap);
|
icon = Icon.createWithBitmap(bitmap);
|
||||||
}
|
}
|
||||||
PersistableBundle extras = new PersistableBundle(1);
|
PersistableBundle extras = new PersistableBundle(1);
|
||||||
extras.putString(CommonUtils.EXTRA_KEY_PATH, mScriptFile.getPath());
|
extras.putString(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath());
|
||||||
ShortcutManager.getInstance(this).addDynamicShortcut(mName.getText(), mScriptFile.getPath(), icon,
|
ShortcutManager.getInstance(this).addDynamicShortcut(mName.getText(), mScriptFile.getPath(), icon,
|
||||||
new Intent(this, ShortcutActivity.class)
|
new Intent(this, ShortcutActivity.class)
|
||||||
.putExtra(CommonUtils.EXTRA_KEY_PATH, mScriptFile.getPath())
|
.putExtra(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath())
|
||||||
.setAction(Intent.ACTION_MAIN));
|
.setAction(Intent.ACTION_MAIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,33 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/delete"
|
android:id="@+id/delete"
|
||||||
android:title="@string/text_delete"/>
|
android:title="@string/text_delete"/>
|
||||||
<item
|
|
||||||
android:id="@+id/floating_edit"
|
|
||||||
android:title="@string/text_floating_edit"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/create_shortcut"
|
android:id="@+id/send"
|
||||||
android:title="@string/text_send_shortcut"/>
|
android:title="@string/text_send"/>
|
||||||
<item
|
|
||||||
android:id="@+id/open_by_other_apps"
|
|
||||||
android:title="@string/text_open_by_other_apps"/>
|
<item android:title="@string/text_more">
|
||||||
|
|
||||||
|
<menu>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/timed_task"
|
||||||
|
android:title="@string/text_timed_task"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/floating_edit"
|
||||||
|
android:title="@string/text_floating_edit"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/create_shortcut"
|
||||||
|
android:title="@string/text_send_shortcut"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/open_by_other_apps"
|
||||||
|
android:title="@string/text_open_by_other_apps"/>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@@ -312,4 +312,6 @@
|
|||||||
<string name="text_generate_fail">生成失败了o(╥﹏╥)o</string>
|
<string name="text_generate_fail">生成失败了o(╥﹏╥)o</string>
|
||||||
<string name="key_documentation_source">key_documentation_source</string>
|
<string name="key_documentation_source">key_documentation_source</string>
|
||||||
<string name="text_documentation_source">文档源</string>
|
<string name="text_documentation_source">文档源</string>
|
||||||
|
<string name="text_send">发送</string>
|
||||||
|
<string name="text_timed_task">定时运行</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -85,10 +85,11 @@ module.exports = function(__runtime__, scope){
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
var threshold = options.threshold || 0.9;
|
var threshold = options.threshold || 0.9;
|
||||||
var maxLevel = options.level || -1;
|
var maxLevel = options.level || -1;
|
||||||
|
var weakThreshold = options.weakThreshold || 0.7;
|
||||||
if(options.region){
|
if(options.region){
|
||||||
return rtImages.findImage(img, template, threshold, buildRegion(options, img), maxLevel);
|
return rtImages.findImage(img, template, weakThreshold, threshold, buildRegion(options, img), maxLevel);
|
||||||
}else{
|
}else{
|
||||||
return rtImages.findImage(img, template, threshold, null, maxLevel);
|
return rtImages.findImage(img, template, weakThreshold, threshold, null, maxLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ public class TemplateMatching {
|
|||||||
private static final String LOG_TAG = "TemplateMatching";
|
private static final String LOG_TAG = "TemplateMatching";
|
||||||
|
|
||||||
public static final int MAX_LEVEL_AUTO = -1;
|
public static final int MAX_LEVEL_AUTO = -1;
|
||||||
|
public static final int MATCHING_METHOD_DEFAULT = Imgproc.TM_CCOEFF_NORMED;
|
||||||
|
|
||||||
public static Point fastTemplateMatching(Mat img, Mat template, float threshold) {
|
public static Point fastTemplateMatching(Mat img, Mat template, float threshold) {
|
||||||
return fastTemplateMatching(img, template, Imgproc.TM_CCOEFF_NORMED, 0.75f, threshold, MAX_LEVEL_AUTO);
|
return fastTemplateMatching(img, template, MATCHING_METHOD_DEFAULT, 0.75f, threshold, MAX_LEVEL_AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Point fastTemplateMatching(Mat img, Mat template, int matchMethod, float weakThreshold, float strictThreshold, int maxLevel) {
|
public static Point fastTemplateMatching(Mat img, Mat template, int matchMethod, float weakThreshold, float strictThreshold, int maxLevel) {
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public class Images {
|
|||||||
private ScreenCapturer mScreenCapturer;
|
private ScreenCapturer mScreenCapturer;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Display mDisplay;
|
private Display mDisplay;
|
||||||
|
private Image mPreCapture;
|
||||||
|
private ImageWrapper mPreCaptureImage;
|
||||||
|
|
||||||
@ScriptVariable
|
@ScriptVariable
|
||||||
public final ColorFinder colorFinder;
|
public final ColorFinder colorFinder;
|
||||||
@@ -102,7 +104,13 @@ public class Images {
|
|||||||
if (mScreenCapturer == null) {
|
if (mScreenCapturer == null) {
|
||||||
throw new SecurityException("No screen capture permission");
|
throw new SecurityException("No screen capture permission");
|
||||||
}
|
}
|
||||||
return ImageWrapper.ofImage(mScreenCapturer.capture());
|
Image capture = mScreenCapturer.capture();
|
||||||
|
if (capture == mPreCapture) {
|
||||||
|
return mPreCaptureImage;
|
||||||
|
}
|
||||||
|
mPreCapture = capture;
|
||||||
|
mPreCaptureImage = ImageWrapper.ofImage(capture);
|
||||||
|
return mPreCaptureImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
@@ -195,15 +203,16 @@ public class Images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Point findImage(ImageWrapper image, ImageWrapper template, float threshold, Rect rect) {
|
public Point findImage(ImageWrapper image, ImageWrapper template, float threshold, Rect rect) {
|
||||||
return findImage(image, template, threshold, rect, TemplateMatching.MAX_LEVEL_AUTO);
|
return findImage(image, template, 0.7f, threshold, rect, TemplateMatching.MAX_LEVEL_AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point findImage(ImageWrapper image, ImageWrapper template, float threshold, Rect rect, int maxLevel) {
|
public Point findImage(ImageWrapper image, ImageWrapper template, float weakThreshold, float threshold, Rect rect, int maxLevel) {
|
||||||
Mat src = image.getMat();
|
Mat src = image.getMat();
|
||||||
if (rect != null) {
|
if (rect != null) {
|
||||||
src = new Mat(src, rect);
|
src = new Mat(src, rect);
|
||||||
}
|
}
|
||||||
org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), threshold);
|
org.opencv.core.Point point = TemplateMatching.fastTemplateMatching(src, template.getMat(), TemplateMatching.MATCHING_METHOD_DEFAULT,
|
||||||
|
weakThreshold, threshold, maxLevel);
|
||||||
if (point != null && rect != null) {
|
if (point != null && rect != null) {
|
||||||
point.x += rect.x;
|
point.x += rect.x;
|
||||||
point.y += rect.y;
|
point.y += rect.y;
|
||||||
|
|||||||
@@ -144,11 +144,13 @@ public class UiObject extends AccessibilityNodeInfoCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String className() {
|
public String className() {
|
||||||
return getClassName().toString();
|
CharSequence d = getClassName();
|
||||||
|
return d == null ? null : d.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String packageName() {
|
public String packageName() {
|
||||||
return getPackageName().toString();
|
CharSequence d = getPackageName();
|
||||||
|
return d == null ? null : d.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int depth() {
|
public int depth() {
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ buildscript {
|
|||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user