新增 连接电脑支持运行和保存项目
This commit is contained in:
@@ -115,6 +115,10 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.model.script;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
package org.autojs.autojs.pluginclient;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.project.ProjectLauncher;
|
||||
import com.stardust.autojs.script.StringScriptSource;
|
||||
import com.stardust.io.Zip;
|
||||
import com.stardust.pio.PFiles;
|
||||
import com.stardust.util.MD5;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.model.script.Scripts;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/11.
|
||||
*/
|
||||
@@ -32,7 +45,7 @@ public class DevPluginResponseHandler implements Handler {
|
||||
String name = getName(data);
|
||||
String id = data.get("id").getAsString();
|
||||
runScript(id, name, script);
|
||||
return false;
|
||||
return true;
|
||||
})
|
||||
.handler("stop", data -> {
|
||||
String id = data.get("id").getAsString();
|
||||
@@ -43,7 +56,7 @@ public class DevPluginResponseHandler implements Handler {
|
||||
String script = data.get("script").getAsString();
|
||||
String name = getName(data);
|
||||
saveScript(name, script);
|
||||
return false;
|
||||
return true;
|
||||
})
|
||||
.handler("rerun", data -> {
|
||||
String id = data.get("id").getAsString();
|
||||
@@ -51,21 +64,54 @@ public class DevPluginResponseHandler implements Handler {
|
||||
String name = getName(data);
|
||||
stopScript(id);
|
||||
runScript(id, name, script);
|
||||
return false;
|
||||
return true;
|
||||
})
|
||||
.handler("stopAll", data -> {
|
||||
AutoJs.getInstance().getScriptEngineService().stopAllAndToast();
|
||||
return false;
|
||||
return true;
|
||||
}))
|
||||
.handler("bytes_command", new Router("command")
|
||||
.handler("run_project", data -> {
|
||||
launchProject(data.get("dir").getAsString());
|
||||
return true;
|
||||
})
|
||||
.handler("save_project", data -> {
|
||||
saveProject(data.get("name").getAsString(), data.get("dir").getAsString());
|
||||
return true;
|
||||
}));
|
||||
|
||||
|
||||
private HashMap<String, ScriptExecution> mScriptExecutions = new HashMap<>();
|
||||
private final File mCacheDir;
|
||||
|
||||
public DevPluginResponseHandler(File cacheDir) {
|
||||
mCacheDir = cacheDir;
|
||||
if (cacheDir.exists()) {
|
||||
if (cacheDir.isDirectory()) {
|
||||
PFiles.deleteFilesOfDir(cacheDir);
|
||||
} else {
|
||||
cacheDir.delete();
|
||||
cacheDir.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(JsonObject data) {
|
||||
return mRouter.handle(data);
|
||||
}
|
||||
|
||||
public Observable<File> handleBytes(JsonObject data, JsonWebSocket.Bytes bytes) {
|
||||
String id = data.get("data").getAsJsonObject().get("id").getAsString();
|
||||
String idMd5 = MD5.md5(id);
|
||||
return Observable.fromCallable(() -> {
|
||||
File dir = new File(mCacheDir, idMd5);
|
||||
Zip.unzip(new ByteArrayInputStream(bytes.byteString.toByteArray()), dir);
|
||||
return dir;
|
||||
})
|
||||
.subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
private void runScript(String viewId, String name, String script) {
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = "[" + viewId + "]";
|
||||
@@ -75,6 +121,18 @@ public class DevPluginResponseHandler implements Handler {
|
||||
mScriptExecutions.put(viewId, Scripts.run(new StringScriptSource("[remote]" + name, script)));
|
||||
}
|
||||
|
||||
|
||||
private void launchProject(String dir) {
|
||||
try {
|
||||
new ProjectLauncher(dir)
|
||||
.launch(AutoJs.getInstance().getScriptEngineService());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
GlobalAppContext.toast(R.string.text_invalid_project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void stopScript(String viewId) {
|
||||
ScriptExecution execution = mScriptExecutions.get(viewId);
|
||||
if (execution != null) {
|
||||
@@ -104,4 +162,42 @@ public class DevPluginResponseHandler implements Handler {
|
||||
PFiles.write(file, script);
|
||||
GlobalAppContext.toast(R.string.text_script_save_successfully);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void saveProject(String name, String dir) {
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = "untitled";
|
||||
}
|
||||
name = PFiles.getNameWithoutExtension(name);
|
||||
File toDir = new File(Pref.getScriptDirPath(), name);
|
||||
Observable.fromCallable(() -> {
|
||||
copyDir(new File(dir), toDir);
|
||||
return toDir.getPath();
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(dest ->
|
||||
GlobalAppContext.toast(R.string.text_project_save_success, dest),
|
||||
err ->
|
||||
GlobalAppContext.toast(R.string.text_project_save_error, err.getMessage())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private void copyDir(File fromDir, File toDir) throws FileNotFoundException {
|
||||
toDir.mkdirs();
|
||||
File[] files = fromDir.listFiles();
|
||||
if (files == null || files.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
copyDir(file, new File(toDir, file.getName()));
|
||||
} else {
|
||||
FileOutputStream fos = new FileOutputStream(new File(toDir, file.getName()));
|
||||
PFiles.write(new FileInputStream(file), fos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,15 @@ import android.util.Pair;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.util.MapBuilder;
|
||||
|
||||
import org.autojs.autojs.BuildConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -36,6 +39,7 @@ public class DevPluginService {
|
||||
private static final int CLIENT_VERSION = 2;
|
||||
private static final String LOG_TAG = "DevPluginService";
|
||||
private static final String TYPE_HELLO = "hello";
|
||||
private static final String TYPE_BYTES_COMMAND = "bytes_command";
|
||||
private static final long HANDSHAKE_TIMEOUT = 10 * 1000;
|
||||
|
||||
public static class State {
|
||||
@@ -68,15 +72,21 @@ public class DevPluginService {
|
||||
private static final int PORT = 9317;
|
||||
private static DevPluginService sInstance = new DevPluginService();
|
||||
private final PublishSubject<State> mConnectionState = PublishSubject.create();
|
||||
private final DevPluginResponseHandler mResponseHandler = new DevPluginResponseHandler();
|
||||
private final Handler mHandshakeTimeoutHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final DevPluginResponseHandler mResponseHandler;
|
||||
private final HashMap<String, JsonWebSocket.Bytes> mBytes = new HashMap<>();
|
||||
private final HashMap<String, JsonObject> mRequiredBytesCommands = new HashMap<>();
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private volatile JsonWebSocket mSocket;
|
||||
|
||||
public static DevPluginService getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public DevPluginService() {
|
||||
File cache = new File(GlobalAppContext.get().getCacheDir(), "remote_project");
|
||||
mResponseHandler = new DevPluginResponseHandler(cache);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public boolean isConnected() {
|
||||
return mSocket != null && !mSocket.isClosed();
|
||||
@@ -134,14 +144,22 @@ public class DevPluginService {
|
||||
.build()))
|
||||
.doOnNext(socket -> {
|
||||
mSocket = socket;
|
||||
socket.data()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnComplete(() -> mConnectionState.onNext(new State(State.DISCONNECTED)))
|
||||
.subscribe(data -> onSocketData(socket, data), this::onSocketError);
|
||||
subscribeMessage(socket);
|
||||
sayHelloToServer(socket);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void subscribeMessage(JsonWebSocket socket) {
|
||||
socket.data()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnComplete(() -> mConnectionState.onNext(new State(State.DISCONNECTED)))
|
||||
.subscribe(data -> onSocketData(socket, data), this::onSocketError);
|
||||
socket.bytes()
|
||||
.doOnComplete(() -> mConnectionState.onNext(new State(State.DISCONNECTED)))
|
||||
.subscribe(data -> onSocketData(socket, data), this::onSocketError);
|
||||
}
|
||||
|
||||
@MainThread
|
||||
private void onSocketError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
@@ -158,24 +176,64 @@ public class DevPluginService {
|
||||
Log.w(LOG_TAG, "onSocketData: not json object: " + element);
|
||||
return;
|
||||
}
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
JsonElement type = obj.get("type");
|
||||
if (type != null && type.isJsonPrimitive() && type.getAsString().equals(TYPE_HELLO)) {
|
||||
onServerHello(jsonWebSocket, obj);
|
||||
return;
|
||||
try {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
JsonElement typeElement = obj.get("type");
|
||||
if (typeElement == null || !typeElement.isJsonPrimitive()) {
|
||||
return;
|
||||
}
|
||||
String type = typeElement.getAsString();
|
||||
if (type.equals(TYPE_HELLO)) {
|
||||
onServerHello(jsonWebSocket, obj);
|
||||
return;
|
||||
}
|
||||
if (TYPE_BYTES_COMMAND.equals(type)) {
|
||||
String md5 = obj.get("md5").getAsString();
|
||||
JsonWebSocket.Bytes bytes = mBytes.remove(md5);
|
||||
if (bytes != null) {
|
||||
handleBytes(obj, bytes);
|
||||
} else {
|
||||
mRequiredBytesCommands.put(md5, obj);
|
||||
}
|
||||
return;
|
||||
}
|
||||
mResponseHandler.handle(obj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mResponseHandler.handle(obj);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void handleBytes(JsonObject obj, JsonWebSocket.Bytes bytes) {
|
||||
mResponseHandler.handleBytes(obj, bytes)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(dir -> {
|
||||
obj.get("data").getAsJsonObject().add("dir", new JsonPrimitive(dir.getPath()));
|
||||
mResponseHandler.handle(obj);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private void sayHelloToServer(JsonWebSocket socket) throws IOException {
|
||||
private void onSocketData(JsonWebSocket jsonWebSocket, JsonWebSocket.Bytes bytes) {
|
||||
JsonObject command = mRequiredBytesCommands.remove(bytes.md5);
|
||||
if (command != null) {
|
||||
handleBytes(command, bytes);
|
||||
} else {
|
||||
mBytes.put(bytes.md5, bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private void sayHelloToServer(JsonWebSocket socket) {
|
||||
writeMap(socket, TYPE_HELLO, new MapBuilder<String, Object>()
|
||||
.put("device_name", Build.BRAND + " " + Build.MODEL)
|
||||
.put("client_version", CLIENT_VERSION)
|
||||
.put("app_version", BuildConfig.VERSION_NAME)
|
||||
.put("app_version_code", BuildConfig.VERSION_CODE)
|
||||
.build());
|
||||
mHandshakeTimeoutHandler.postDelayed(() -> {
|
||||
mHandler.postDelayed(() -> {
|
||||
if (mSocket != socket && !socket.isClosed()) {
|
||||
onHandshakeTimeout(socket);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,28 @@ import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
public class JsonWebSocket extends WebSocketListener {
|
||||
|
||||
public static class Bytes {
|
||||
public final String md5;
|
||||
public final ByteString byteString;
|
||||
public final long timestamp;
|
||||
|
||||
public Bytes(String md5, ByteString byteString) {
|
||||
this.md5 = md5;
|
||||
this.byteString = byteString;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String LOG_TAG = "JsonWebSocket";
|
||||
|
||||
private final WebSocket mWebSocket;
|
||||
private final JsonParser mJsonParser = new JsonParser();
|
||||
private final PublishSubject<JsonElement> mJsonElementPublishSubject = PublishSubject.create();
|
||||
private final PublishSubject<Bytes> mBytesPublishSubject = PublishSubject.create();
|
||||
private volatile boolean mClosed = false;
|
||||
|
||||
public JsonWebSocket(OkHttpClient client, Request request) {
|
||||
@@ -35,14 +49,24 @@ public class JsonWebSocket extends WebSocketListener {
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
Log.d(LOG_TAG, "onMessage: " + text);
|
||||
Log.d(LOG_TAG, "onMessage: text = " + text);
|
||||
dispatchJson(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||
Log.d(LOG_TAG, "onMessage: ByteString = " + bytes.toString());
|
||||
mBytesPublishSubject.onNext(new Bytes(bytes.md5().hex(), bytes));
|
||||
}
|
||||
|
||||
public Observable<JsonElement> data() {
|
||||
return mJsonElementPublishSubject;
|
||||
}
|
||||
|
||||
public Observable<Bytes> bytes(){
|
||||
return mBytesPublishSubject;
|
||||
}
|
||||
|
||||
public boolean write(JsonElement element) {
|
||||
String json = element.toString();
|
||||
Log.d(LOG_TAG, "write: length = " + json.length() + ", json = " + element);
|
||||
|
||||
136
app/src/main/java/org/autojs/autojs/tool/SafeJsonElement.java
Normal file
136
app/src/main/java/org/autojs/autojs/tool/SafeJsonElement.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package org.autojs.autojs.tool;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class SafeJsonElement extends JsonElement {
|
||||
private final JsonElement mJsonElement;
|
||||
|
||||
public SafeJsonElement(JsonElement jsonElement) {
|
||||
mJsonElement = jsonElement;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JsonElement deepCopy() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJsonArray() {
|
||||
return mJsonElement.isJsonArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJsonObject() {
|
||||
return mJsonElement.isJsonObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJsonPrimitive() {
|
||||
return mJsonElement.isJsonPrimitive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJsonNull() {
|
||||
return mJsonElement.isJsonNull();
|
||||
}
|
||||
|
||||
public JsonObject getAsJsonObject() {
|
||||
return mJsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public SafeJsonObject getAsSafeJsonObject() {
|
||||
try {
|
||||
return new SafeJsonObject(mJsonElement.getAsJsonObject());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonArray getAsJsonArray() {
|
||||
return mJsonElement.getAsJsonArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonPrimitive getAsJsonPrimitive() {
|
||||
return mJsonElement.getAsJsonPrimitive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonNull getAsJsonNull() {
|
||||
return mJsonElement.getAsJsonNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAsBoolean() {
|
||||
return mJsonElement.getAsBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number getAsNumber() {
|
||||
return mJsonElement.getAsNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString() {
|
||||
return mJsonElement.getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAsDouble() {
|
||||
return mJsonElement.getAsDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAsFloat() {
|
||||
return mJsonElement.getAsFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAsLong() {
|
||||
return mJsonElement.getAsLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAsInt() {
|
||||
return mJsonElement.getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getAsByte() {
|
||||
return mJsonElement.getAsByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getAsCharacter() {
|
||||
return mJsonElement.getAsCharacter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getAsBigDecimal() {
|
||||
return mJsonElement.getAsBigDecimal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getAsBigInteger() {
|
||||
return mJsonElement.getAsBigInteger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getAsShort() {
|
||||
return mJsonElement.getAsShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mJsonElement.toString();
|
||||
}
|
||||
}
|
||||
161
app/src/main/java/org/autojs/autojs/tool/SafeJsonObject.java
Normal file
161
app/src/main/java/org/autojs/autojs/tool/SafeJsonObject.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package org.autojs.autojs.tool;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SafeJsonObject extends JsonElement {
|
||||
|
||||
private final JsonObject mJsonObject;
|
||||
|
||||
public SafeJsonObject(JsonObject jsonObject) {
|
||||
mJsonObject = jsonObject;
|
||||
}
|
||||
|
||||
public JsonObject deepCopy() {
|
||||
return mJsonObject.deepCopy();
|
||||
}
|
||||
|
||||
public void add(String property, JsonElement value) {
|
||||
mJsonObject.add(property, value);
|
||||
}
|
||||
|
||||
public JsonElement remove(String property) {
|
||||
return mJsonObject.remove(property);
|
||||
}
|
||||
|
||||
public void addProperty(String property, String value) {
|
||||
mJsonObject.addProperty(property, value);
|
||||
}
|
||||
|
||||
public void addProperty(String property, Number value) {
|
||||
mJsonObject.addProperty(property, value);
|
||||
}
|
||||
|
||||
public void addProperty(String property, Boolean value) {
|
||||
mJsonObject.addProperty(property, value);
|
||||
}
|
||||
|
||||
public void addProperty(String property, Character value) {
|
||||
mJsonObject.addProperty(property, value);
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, JsonElement>> entrySet() {
|
||||
return mJsonObject.entrySet();
|
||||
}
|
||||
|
||||
public Set<String> keySet() {
|
||||
return mJsonObject.keySet();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return mJsonObject.size();
|
||||
}
|
||||
|
||||
public boolean has(String memberName) {
|
||||
return mJsonObject.has(memberName);
|
||||
}
|
||||
|
||||
public JsonElement get(String memberName) {
|
||||
return mJsonObject.get(memberName);
|
||||
}
|
||||
|
||||
public JsonPrimitive getAsJsonPrimitive(String memberName) {
|
||||
return mJsonObject.getAsJsonPrimitive(memberName);
|
||||
}
|
||||
|
||||
public JsonArray getAsJsonArray(String memberName) {
|
||||
return mJsonObject.getAsJsonArray(memberName);
|
||||
}
|
||||
|
||||
public JsonObject getAsJsonObject(String memberName) {
|
||||
return mJsonObject.getAsJsonObject(memberName);
|
||||
}
|
||||
|
||||
public boolean isJsonArray() {
|
||||
return mJsonObject.isJsonArray();
|
||||
}
|
||||
|
||||
public boolean isJsonObject() {
|
||||
return mJsonObject.isJsonObject();
|
||||
}
|
||||
|
||||
public boolean isJsonPrimitive() {
|
||||
return mJsonObject.isJsonPrimitive();
|
||||
}
|
||||
|
||||
public boolean isJsonNull() {
|
||||
return mJsonObject.isJsonNull();
|
||||
}
|
||||
|
||||
public JsonObject getAsJsonObject() {
|
||||
return mJsonObject.getAsJsonObject();
|
||||
}
|
||||
|
||||
public JsonArray getAsJsonArray() {
|
||||
return mJsonObject.getAsJsonArray();
|
||||
}
|
||||
|
||||
public JsonPrimitive getAsJsonPrimitive() {
|
||||
return mJsonObject.getAsJsonPrimitive();
|
||||
}
|
||||
|
||||
public JsonNull getAsJsonNull() {
|
||||
return mJsonObject.getAsJsonNull();
|
||||
}
|
||||
|
||||
public boolean getAsBoolean() {
|
||||
return mJsonObject.getAsBoolean();
|
||||
}
|
||||
|
||||
public Number getAsNumber() {
|
||||
return mJsonObject.getAsNumber();
|
||||
}
|
||||
|
||||
public String getAsString() {
|
||||
return mJsonObject.getAsString();
|
||||
}
|
||||
|
||||
public double getAsDouble() {
|
||||
return mJsonObject.getAsDouble();
|
||||
}
|
||||
|
||||
public float getAsFloat() {
|
||||
return mJsonObject.getAsFloat();
|
||||
}
|
||||
|
||||
public long getAsLong() {
|
||||
return mJsonObject.getAsLong();
|
||||
}
|
||||
|
||||
public int getAsInt() {
|
||||
return mJsonObject.getAsInt();
|
||||
}
|
||||
|
||||
public byte getAsByte() {
|
||||
return mJsonObject.getAsByte();
|
||||
}
|
||||
|
||||
public char getAsCharacter() {
|
||||
return mJsonObject.getAsCharacter();
|
||||
}
|
||||
|
||||
public BigDecimal getAsBigDecimal() {
|
||||
return mJsonObject.getAsBigDecimal();
|
||||
}
|
||||
|
||||
public BigInteger getAsBigInteger() {
|
||||
return mJsonObject.getAsBigInteger();
|
||||
}
|
||||
|
||||
public short getAsShort() {
|
||||
return mJsonObject.getAsShort();
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
explorerView.setOnItemOperatedListener(file -> dialog.dismiss());
|
||||
explorerView.setOnItemClickListener((view, item) -> Scripts.run(item.toScriptFile()));
|
||||
DialogUtils.showDialog(dialog);
|
||||
|
||||
}
|
||||
|
||||
@Optional
|
||||
|
||||
@@ -424,4 +424,6 @@
|
||||
<string name="error_pattern_syntax">正则表达式错误</string>
|
||||
<string name="text_invalid_package_name">非法包名</string>
|
||||
<string name="error_cannot_rename">重命名失败</string>
|
||||
<string name="text_project_save_success">项目已经保存到%s</string>
|
||||
<string name="text_project_save_error">项目保存失败 %s</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user