Skip to content

Commit

Permalink
Add: tasker plugin support, injectable webview
Browse files Browse the repository at this point in the history
  • Loading branch information
hyb1996 committed Apr 2, 2017
1 parent 121949f commit e7500e6
Show file tree
Hide file tree
Showing 127 changed files with 5,280 additions and 1,654 deletions.
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.stardust.scriptdroid"
minSdkVersion 19
targetSdkVersion 23
versionCode 110
versionName "2.0.6 Alpha2"
versionCode 113
versionName "2.0.6 Alpha3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true

Expand Down Expand Up @@ -70,9 +70,10 @@ dependencies {
compile 'io.mattcarroll.hover:hover:0.9.7'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'com.github.0xFireball:Enlightened:v31'
compile 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'
compile 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'
compile 'com.github.hyb1996:node-android-lib:1.0.13'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile group:'com.twofortyfouram', name:'android-plugin-client-sdk-for-locale', version:'[4.0.2, 5.0['
compile(name: 'libtermexec-release', ext: 'aar')
compile(name: 'emulatorview-release', ext: 'aar')
compile(name: 'term-debug', ext: 'aar')
Expand Down
29 changes: 28 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<activity android:name=".ui.console.ConsoleActivity"/>
<activity android:name=".ui.error.ErrorReportActivity"/>
<activity android:name=".ui.help.LocalWebViewActivity"/>
<activity android:name=".ui.edit.IridiumEditActivity"/>

<activity
android:name=".ui.error.IssueReportActivity"
Expand All @@ -87,6 +86,34 @@
<service android:name="com.stardust.view.ResizableFloaty$FloatingWindowService"/>
<service android:name="com.stardust.scriptdroid.external.floating_window.HoverMenuService"/>

<activity android:name=".external.tasker.TaskPrefEditActivity"/>

<activity-alias
android:name="com.stardust.scriptdroid.external.tasker.PluginActivity"
android:exported="true"
android:icon="@drawable/ic_android_eat_js"
android:label="@string/_app_name"
android:targetActivity="com.stardust.scriptdroid.external.tasker.TaskPrefEditActivity"
tools:ignore="ExportedActivity">
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING"/>
</intent-filter>
</activity-alias>


<receiver
android:name="com.stardust.scriptdroid.external.tasker.FireSettingReceiver"
android:exported="true"
android:process=":background"
tools:ignore="ExportedReceiver">

<!-- this Intent filter allows the plug-in to discovered by the host. -->
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING"/>
</intent-filter>
</receiver>


<activity
android:name=".external.open.EditIntentActivity"
android:icon="@drawable/ic_edit_green_48dp"
Expand Down
23 changes: 21 additions & 2 deletions app/src/main/assets/help/documentation/自动操作函数.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,24 @@ while(!click("扫一扫"));
返回是否输入成功。当找不到对应的文本框时返回false。
这里的输入文本的意思是,把输入框的文本置为text,而不是在原来的文本上追加。
不加参数i则会把所有输入框的文本都置为text。例如`input("测试")`
### input(i, text)
把第i + 1个输入框的文本设为text。

### back()
模拟按下返回键

### home()
模拟按下Home键

### powerDialog()
弹出电源键菜单

### notifications()
弹出通知栏

### quickSettings()
显示快速设置(下拉通知栏到底)

### recents()
显示最近任务

### splitScreen()
分屏
45 changes: 42 additions & 3 deletions app/src/main/assets/javasccript_engine_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@ var launchApp = function(appName){
droid.launchApp(appName);
}

var __this__ = this;

var back = function(){
return droid.back();
}

var home = function(){
return droid.home();
}

var powerDialog = function(){
return droid.powerDialog();
}

var notifications = function(){
return droid.notifications();
}

var quickSettings = function(){
return droid.quickSettings();
}

var recents = function(){
return droid.recents();
}

var splitScreen = function(){
return droid.splitScreen();
}


function performAction(action, args){
if(args.length == 4){
return action(droid.bounds(args[0], args[1], args[2], args[3]));
Expand Down Expand Up @@ -238,11 +269,19 @@ for(var x in __selector__){

}

var $ = function(){
return droid.selector();
var open = function(path, mode){
return com.stardust.pio.PFile.open(path, mode);
}

__importClassOld__(com.stardust.scriptdroid.droid.runtime.Shell);
__importClassOld__(com.stardust.scriptdroid.droid.runtime.api.Shell);

var newInjectableWebClient = function(){
return new com.stardust.scriptdroid.droid.runtime.api.InjectableWebClient(org.mozilla.javascript.Context.getCurrentContext(), __this__);
}

var newInjectableWebView = function(activity){
return new com.stardust.scriptdroid.droid.runtime.api.InjectableWebView(activity, org.mozilla.javascript.Context.getCurrentContext(), __this__);
}

/*
importClass("com.stardust.scriptdroid.service.AccessibilityDelegate");
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/assets/modules/ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

bg
w
h
margin
marginLeft
margin*
padding
padding*
layout_gravity="center"
gravity


weight


ui.layout(
<linear orientation="vertical" w="fill" h="300" bg="#ff0000" gravity="center">
<text text="测试" size="18" color="#000000"/>
<button id="btn" text="按钮"/>
</linear>
);

<relative>

</relative>

<horizon>

</horiz>

<vertical>

</vertical>


function ui(){

}


module.exports = ui;
6 changes: 6 additions & 0 deletions app/src/main/assets/modules/web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

module.exports = {
test: function(){
return "test";
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/stardust/app/Fragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable
public abstract View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);



}
31 changes: 31 additions & 0 deletions app/src/main/java/com/stardust/pio/PFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.stardust.pio;

/**
* Created by Stardust on 2017/4/1.
*/

public class PFile {

public static PFile open(String path, String mode) {
switch (mode){
case "r":
return new PReadableFile(path);
case "w":
return new PWritableFile();
}
return null;
}

public static void create(String path){

}

public static void createIfNotExists(String path){

}

public static void delete(String path){

}

}
106 changes: 106 additions & 0 deletions app/src/main/java/com/stardust/pio/PReadableFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.stardust.pio;

import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

/**
* Created by Stardust on 2017/4/1.
*/

public class PReadableFile extends PFile {

private BufferedReader mBufferedReader;
private FileInputStream mFileInputStream;
private int mBufferingSize;
private String mEncoding;

public PReadableFile(String path) {
this(path, Charset.defaultCharset().name());
}

public PReadableFile(String path, String encoding) {
this(path, encoding, -1);
}

public PReadableFile(String path, String encoding, int bufferingSize) {
mEncoding = encoding;
mBufferingSize = bufferingSize;
try {
mFileInputStream = new FileInputStream(path);
} catch (FileNotFoundException e) {
throw new UncheckedIOException(e);
}
}


private void ensureBufferReader() {
if (mBufferedReader == null) {
try {
if (mBufferingSize == -1)
mBufferedReader = new BufferedReader(new InputStreamReader(mFileInputStream, mEncoding));
else
mBufferedReader = new BufferedReader(new InputStreamReader(mFileInputStream, mEncoding), mBufferingSize);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

}
}

public String read() {
try {
byte[] data = new byte[mFileInputStream.available()];
mFileInputStream.read(data);
return new String(data, mEncoding);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public String read(int size) {
ensureBufferReader();
try {
char[] chars = new char[size];
int len = mBufferedReader.read(chars);
return new String(chars, 0, len);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public String readline() {
ensureBufferReader();
try {
return mBufferedReader.readLine();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public String[] readlines() {
ensureBufferReader();
List<String> lines = new ArrayList<>();
try {
while (mBufferedReader.ready()) {
lines.add(mBufferedReader.readLine());
}
return lines.toArray(new String[lines.size()]);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public void close() {
try {
if (mBufferedReader != null) {
mBufferedReader.close();
} else {
mFileInputStream.close();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/stardust/pio/PWritableFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.stardust.pio;

/**
* Created by Stardust on 2017/4/1.
*/

public class PWritableFile extends PFile {

public PWritableFile(){

}



}
14 changes: 14 additions & 0 deletions app/src/main/java/com/stardust/pio/UncheckedIOException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.stardust.pio;

import java.io.IOException;

/**
* Created by Stardust on 2017/4/1.
*/

public class UncheckedIOException extends RuntimeException {

public UncheckedIOException(IOException cause) {
super(cause);
}
}
1 change: 1 addition & 0 deletions app/src/main/java/com/stardust/scriptdroid/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.stardust.scriptdroid.droid.script.RhinoJavaScriptEngine;
import com.stardust.scriptdroid.droid.script.file.ScriptFileList;
import com.stardust.scriptdroid.droid.script.file.SharedPrefScriptFileList;
import com.stardust.scriptdroid.droid.script.file.StorageScriptFileList;
import com.stardust.scriptdroid.layout_inspector.LayoutInspector;
import com.stardust.scriptdroid.record.accessibility.AccessibilityActionRecorder;
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
Expand Down
Loading

0 comments on commit e7500e6

Please sign in to comment.