Skip to content

Commit

Permalink
add android remote method call , refactor webxmlui, fix json,
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalgust committed Aug 13, 2024
1 parent ca33f4c commit 3abe6ad
Show file tree
Hide file tree
Showing 42 changed files with 1,382 additions and 1,217 deletions.
4 changes: 4 additions & 0 deletions desktop/glfw_gui/java/src/main/java/org/mini/glfm/Glfm.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,8 @@ public static int glfmOpenOtherApp(byte[] cStyleURL, byte[] cStyleMore, int dete
}


public static String glfmRemoteMethodCall(String inJsonStr) {
return null;
}

}
43 changes: 43 additions & 0 deletions extlib/xgui/src/main/java/com/ebsee/rmc/RMCDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.ebsee.rmc;

/**
*
*/
public class RMCDescriptor {
String className; // 类名 eg: "org.minijvm.activity.JvmNativeActivity"
String methodDesc; // 方法名 payV2(Ljava/lang/String;)Ljava/util/Map;
String paraJson; // 参数 eg: "[\"abc\"]"
String insJson; // 实例 eg: "{\"uid\":\"123\"}" , or null

public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public String getMethodDesc() {
return methodDesc;
}

public void setMethodDesc(String methodDesc) {
this.methodDesc = methodDesc;
}

public String getParaJson() {
return paraJson;
}

public void setParaJson(String paraJson) {
this.paraJson = paraJson;
}

public String getInsJson() {
return insJson;
}

public void setInsJson(String insJson) {
this.insJson = insJson;
}
}
43 changes: 43 additions & 0 deletions extlib/xgui/src/main/java/com/ebsee/rmc/RMCUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.ebsee.rmc;

import org.mini.glfm.Glfm;
import org.mini.json.JsonParser;
import org.mini.json.JsonPrinter;

import java.util.Map;

public class RMCUtil {

/**
* 调用glfm模块的 remoteMethodCall,远程调用android 方法
*
* @param className "org.minijvm.activity.JvmNativeActivity"
* @param methodDesc "playVideo(Ljava/lang/String;Ljava/lang/String;)J"
* @param para new Object[]{"http://abc.com/x.mov","mov"}
* @param instance null or instance of class
* @return
*/
public static Map<String, String> remoteMethodCall(String className, String methodDesc, Object[] para, Object instance) {
JsonPrinter printer = new JsonPrinter();

RMCDescriptor desc = new RMCDescriptor();
desc.setClassName(className);
desc.setMethodDesc(methodDesc);
desc.setInsJson(printer.serial(instance));
desc.setParaJson(printer.serial(para));

String s = printer.serial(desc);
//JsonParser<RMCDescriptor> jp1 = new JsonParser();
//RMCDescriptor desc1 = jp1.deserial(s, RMCDescriptor.class);

String ret = Glfm.glfmRemoteMethodCall(s);
if (ret != null) {
JsonParser<Map> parser = new JsonParser<>();
Map map = parser.deserial(ret, Map.class);
return map;
} else {
return null;
}
}

}
21 changes: 1 addition & 20 deletions extlib/xgui/src/main/java/org/mini/apploader/AppLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
*/
package org.mini.apploader;

import org.mini.explorer.XUrlHelper;
import org.mini.explorer.urlhelper.XFileUrlHelper;
import org.mini.explorer.urlhelper.XHttpUrlHelper;
import org.mini.explorer.urlhelper.XJarUrlHelper;
import org.mini.gui.*;
import org.mini.zip.Zip;

Expand Down Expand Up @@ -38,6 +34,7 @@ public class AppLoader {
static final String KEY_GUISTYLE = "guistyle";
static final String KEY_HOMEICON_X = "homeiconx";
static final String KEY_HOMEICON_Y = "homeicony";
static final String KEY_TOKEN = "TOKEN";
static Properties appinfo = new Properties();
static Properties applist = new Properties();
static Properties baseinfo = new Properties();
Expand Down Expand Up @@ -589,20 +586,4 @@ public static String getBaseInfo(String key) {
return s == null ? "" : s;
}

public static String appendUrlParam(String url) {
XUrlHelper helper = XUrlHelper.getHelper(url);
if (helper instanceof XJarUrlHelper || helper instanceof XFileUrlHelper) {
return url;
}
String token = AppLoader.getProperty("token");

return url
+ "?lang=" + AppLoader.getLangName()
+ "&ver=" + AppLoader.getBaseInfo("sver")
+ "&jar=" + System.getProperty("os.name").toLowerCase()
+ "&from=" + AppLoader.getBaseInfo("from")
+ "&cver=" + AppLoader.getBaseInfo("cver")
+ "&token=" + (token == null ? "" : token)
;
}
}
Loading

0 comments on commit 3abe6ad

Please sign in to comment.