Android add jse implement to replace jsc4a
This commit is contained in:
parent
cbcbc21737
commit
7eb8287f04
@ -33,6 +33,7 @@ allprojects {
|
||||
dependencySubstitution {
|
||||
substitute module('pub.doric:core') with project(":doric")
|
||||
substitute module('pub.doric:devkit') with project(":devkit")
|
||||
substitute module('pub.doric:jse') with project(":jsvalue")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
api 'com.github.penfeizhou:jsc4a:0.2.5'
|
||||
//api "pub.doric:jse:${rootProject.ext.Version}"
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||
implementation('com.github.penfeizhou.android.animation:glide-plugin:2.13.0') {
|
||||
exclude group: 'com.github.bumptech.glide'
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
|
||||
import com.github.pengfeizhou.jscore.Encoding;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class JavaValue extends com.github.pengfeizhou.jscore.JavaValue {
|
||||
public JavaValue() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JavaValue(double value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
public JavaValue(String value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
public JavaValue(boolean value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
public JavaValue(Encoding object) {
|
||||
super(object);
|
||||
}
|
||||
|
||||
public JavaValue(JSONObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
public JavaValue(JSONArray jsonArray) {
|
||||
super(jsonArray);
|
||||
}
|
||||
|
||||
public JavaValue(Encoding[] objects) {
|
||||
super(objects);
|
||||
}
|
||||
}
|
27
doric-android/jsvalue/build.gradle
Normal file
27
doric-android/jsvalue/build.gradle
Normal file
@ -0,0 +1,27 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '30.0.1'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new File('scripts/upload.gradle').exists()) {
|
||||
apply from: rootProject.file('scripts/upload.gradle')
|
||||
}
|
4
doric-android/jsvalue/pom.properties
Normal file
4
doric-android/jsvalue/pom.properties
Normal file
@ -0,0 +1,4 @@
|
||||
name=DoricJSE
|
||||
groupId=pub.doric
|
||||
artifactId=jse
|
||||
version=0.1.0
|
21
doric-android/jsvalue/proguard-rules.pro
vendored
Normal file
21
doric-android/jsvalue/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
6
doric-android/jsvalue/src/main/AndroidManifest.xml
Normal file
6
doric-android/jsvalue/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="pub.doric.jse">
|
||||
|
||||
|
||||
<application />
|
||||
</manifest>
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class ArchiveException extends Exception {
|
||||
public ArchiveException(String str) {
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
|
||||
public interface Decoding {
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public interface DecodingFactory<T> {
|
||||
T createInstance();
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSArray extends JSValue {
|
||||
private final JSValue[] mVal;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSBoolean extends JSValue {
|
||||
private final boolean mVal;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSExecutor {
|
||||
private JSExecutor() {
|
||||
}
|
||||
|
||||
public static JSExecutor create() {
|
||||
throw new IllegalStateException("Empty implement");
|
||||
}
|
||||
|
||||
public native void destroy();
|
||||
|
||||
public native String loadJS(String script, String source) throws JSRuntimeException;
|
||||
|
||||
public native JSDecoder evaluateJS(String script, String source, boolean hashKey) throws JSRuntimeException;
|
||||
|
||||
public native void injectGlobalJSFunction(String name, JavaFunction javaFunction);
|
||||
|
||||
public native void injectGlobalJSObject(String name, JavaValue javaValue);
|
||||
|
||||
public native JSDecoder invokeMethod(String objectName, String functionName, JavaValue[] javaValues, boolean hashKey) throws JSRuntimeException;
|
||||
|
||||
|
||||
public native void injectNativeFunction(String funcName, long funcPtr);
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
/**
|
||||
* Define undefined or null
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSNumber extends JSValue {
|
||||
private final double mVal;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
|
||||
import org.json.JSONArray;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSRuntimeException extends RuntimeException {
|
||||
public JSRuntimeException(String msg) {
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public class JSString extends JSValue {
|
||||
private final String mVal;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
|
||||
public abstract class JSValue {
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.engine.value;
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
public abstract class JavaFunction {
|
||||
public abstract JavaValue exec(JSDecoder[] args);
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.github.pengfeizhou.jscore;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class JavaValue {
|
||||
protected static final int TYPE_NULL = 0;
|
||||
protected static final int TYPE_NUMBER = 1;
|
||||
protected static final int TYPE_BOOLEAN = 2;
|
||||
protected static final int TYPE_STRING = 3;
|
||||
protected static final int TYPE_OBJECT = 4;
|
||||
protected static final int TYPE_ARRAY = 5;
|
||||
protected JavaFunction[] functions = null;
|
||||
protected String[] functionNames = null;
|
||||
protected int type;
|
||||
protected String value = "";
|
||||
|
||||
public JavaValue() {
|
||||
this.type = TYPE_NULL;
|
||||
}
|
||||
|
||||
public JavaValue(double value) {
|
||||
this.value = String.valueOf(value);
|
||||
this.type = TYPE_NUMBER;
|
||||
}
|
||||
|
||||
public JavaValue(String value) {
|
||||
this.value = String.valueOf(value);
|
||||
this.type = TYPE_STRING;
|
||||
}
|
||||
|
||||
public JavaValue(boolean value) {
|
||||
this.value = String.valueOf(value);
|
||||
this.type = TYPE_BOOLEAN;
|
||||
}
|
||||
|
||||
public JavaValue(Encoding object) {
|
||||
this.type = TYPE_OBJECT;
|
||||
this.value = object.encode().toString();
|
||||
this.functionNames = object.getFunctionNames();
|
||||
this.functions = object.getFunctions();
|
||||
}
|
||||
|
||||
public JavaValue(JSONObject json) {
|
||||
this.type = TYPE_OBJECT;
|
||||
this.value = json.toString();
|
||||
}
|
||||
|
||||
public JavaValue(JSONArray jsonArray) {
|
||||
this.type = TYPE_ARRAY;
|
||||
this.value = jsonArray.toString();
|
||||
}
|
||||
|
||||
public JavaValue(Encoding[] objects) {
|
||||
this.type = TYPE_ARRAY;
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (Encoding object : objects) {
|
||||
jsonArray.put(object.encode());
|
||||
}
|
||||
this.value = jsonArray.toString();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
include ':app', ':doric', ':devkit'
|
||||
include ':app', ':doric', ':devkit', ":jsvalue"
|
||||
|
Reference in New Issue
Block a user