|
@ -16,18 +16,72 @@ import com.ailk.common.data.impl.DatasetList;
|
16
|
16
|
import com.wade.mobile.app.MobileUtil;
|
17
|
17
|
import com.wade.mobile.app.SimpleUpdate;
|
18
|
18
|
import com.wade.mobile.frame.IWadeMobile;
|
|
19
|
import com.wade.mobile.frame.config.ServerPageConfig;
|
19
|
20
|
import com.wade.mobile.frame.multiple.MultipleAppConfig;
|
20
|
21
|
import com.wade.mobile.frame.multiple.MultipleManager;
|
21
|
22
|
import com.wade.mobile.frame.plugin.Plugin;
|
|
23
|
import com.wade.mobile.frame.template.TemplateManager;
|
|
24
|
import com.wade.mobile.util.Constant;
|
|
25
|
import com.wade.mobile.util.FileUtil;
|
22
|
26
|
|
23
|
27
|
public class AppManagePlugin extends Plugin {
|
24
|
28
|
private Map<String, NativeAppConfig> nativeAppConfigs = new HashMap<String, NativeAppConfig>();
|
25
|
29
|
private int OPEN_IPU_APP = 1;
|
|
30
|
private int OPEN_NATIVE_APP = 1;
|
26
|
31
|
|
27
|
32
|
public AppManagePlugin(IWadeMobile wademobile) {
|
28
|
33
|
super(wademobile);
|
29
|
34
|
}
|
|
35
|
|
|
36
|
/**
|
|
37
|
* 初始化IPU应用的配置
|
|
38
|
*/
|
|
39
|
public void initAppConfig(JSONArray params) throws Exception {
|
|
40
|
String apps = params.getString(0);
|
|
41
|
if(isNull(apps)){
|
|
42
|
error("App配置信息初始化异常!");
|
|
43
|
return;
|
|
44
|
}
|
|
45
|
IDataset appDatas = new DatasetList(apps);
|
|
46
|
IData appData;
|
|
47
|
for(Object app : appDatas){
|
|
48
|
appData = (IData)app;
|
|
49
|
if("I".equals(appData.getString("appType"))){
|
|
50
|
MultipleAppConfig appConfig = new MultipleAppConfig(appData.getString("requestHost"),
|
|
51
|
appData.getString("requestPath"),
|
|
52
|
appData.getString("requestServlet"),
|
|
53
|
appData.getString("appPath"));
|
|
54
|
appConfig.putDefine("appWelcomePage", appData.getString("appWelcomePage"));
|
|
55
|
MultipleManager.putAppConfig(appData.getString("appId"), appConfig);
|
|
56
|
}else if("N".equals(appData.getString("appType"))){
|
|
57
|
nativeAppConfigs.put(appData.getString("appId"),
|
|
58
|
new NativeAppConfig(appData.getString("packageName"),
|
|
59
|
appData.getString("className"),
|
|
60
|
appData.getString("downloadUrl")));
|
|
61
|
}
|
|
62
|
}
|
|
63
|
}
|
|
64
|
|
|
65
|
/**
|
|
66
|
* 打开IPU应用
|
|
67
|
*/
|
|
68
|
public void openIpuApp(JSONArray params) throws Exception {
|
|
69
|
String appId = params.getString(0);
|
|
70
|
MultipleManager.setCurrAppId(appId);
|
|
71
|
MultipleManager.setMultiple(true);
|
|
72
|
Intent intent = new Intent(wademobile.getActivity(), SubAppActivity.class);
|
|
73
|
|
|
74
|
MultipleAppConfig appConfig = MultipleManager.getAppConfig(appId);
|
|
75
|
String appWelcomePage = appConfig.getDefine("appWelcomePage");
|
|
76
|
String welcomePage = Constant.START_FILE + FileUtil.connectFilePath(TemplateManager.getBasePath(),appWelcomePage);
|
|
77
|
|
|
78
|
intent.putExtra("WELCOME_PAGE", welcomePage);//IPU的欢迎页
|
|
79
|
startActivityForResult(intent, OPEN_IPU_APP);
|
|
80
|
}
|
30
|
81
|
|
|
82
|
/**
|
|
83
|
* 打开原生应用
|
|
84
|
*/
|
31
|
85
|
public void openNativeApp(JSONArray params) throws Exception {
|
32
|
86
|
String appId = params.getString(0);
|
33
|
87
|
NativeAppConfig appConfig = nativeAppConfigs.get(appId);
|
|
@ -46,7 +100,7 @@ public class AppManagePlugin extends Plugin {
|
46
|
100
|
intent.putExtra("STAFF_ID", ipuData.getString("STAFF_ID"));//IPU的sessionId
|
47
|
101
|
intent.putExtra("ACCOUNT", ipuData.getString("ACCOUNT"));//IPU的登陆账号
|
48
|
102
|
intent.setComponent(cn);
|
49
|
|
startActivityForResult(intent, 2);
|
|
103
|
startActivityForResult(intent, OPEN_NATIVE_APP);
|
50
|
104
|
}else{
|
51
|
105
|
String downloadUrl = appConfig.getDownloadUrl();
|
52
|
106
|
/* 如果应用不存在则需要下载,配置需要下载应用 */
|
|
@ -55,39 +109,6 @@ public class AppManagePlugin extends Plugin {
|
55
|
109
|
}
|
56
|
110
|
}
|
57
|
111
|
|
58
|
|
public void initAppConfig(JSONArray params) throws Exception {
|
59
|
|
String apps = params.getString(0);
|
60
|
|
if(isNull(apps)){
|
61
|
|
error("App配置信息初始化异常!");
|
62
|
|
return;
|
63
|
|
}
|
64
|
|
IDataset appDatas = new DatasetList(apps);
|
65
|
|
IData appData;
|
66
|
|
for(Object app : appDatas){
|
67
|
|
appData = (IData)app;
|
68
|
|
if("I".equals(appData.getString("appType"))){
|
69
|
|
MultipleManager.putAppConfig(appData.getString("appId"),
|
70
|
|
new MultipleAppConfig(appData.getString("requestHost"),
|
71
|
|
appData.getString("requestPath"),
|
72
|
|
appData.getString("requestServlet"),
|
73
|
|
appData.getString("appPath")));
|
74
|
|
}else if("N".equals(appData.getString("appType"))){
|
75
|
|
nativeAppConfigs.put(appData.getString("appId"),
|
76
|
|
new NativeAppConfig(appData.getString("packageName"),
|
77
|
|
appData.getString("className"),
|
78
|
|
appData.getString("downloadUrl")));
|
79
|
|
}
|
80
|
|
}
|
81
|
|
}
|
82
|
|
|
83
|
|
public void openIpuApp(JSONArray params) throws Exception {
|
84
|
|
String appId = params.getString(0);
|
85
|
|
MultipleManager.setCurrAppName(appId);
|
86
|
|
MultipleManager.setMultiple(true);
|
87
|
|
Intent intent = new Intent(wademobile.getActivity(), SubAppActivity.class);
|
88
|
|
startActivityForResult(intent, OPEN_IPU_APP);
|
89
|
|
}
|
90
|
|
|
91
|
112
|
@Override
|
92
|
113
|
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
93
|
114
|
// TODO Auto-generated method stub
|
|
@ -96,7 +117,6 @@ public class AppManagePlugin extends Plugin {
|
96
|
117
|
}
|
97
|
118
|
}
|
98
|
119
|
|
99
|
|
|
100
|
120
|
/**
|
101
|
121
|
* @author huangbo
|
102
|
122
|
* 平台级应用中原生应用的配置对象
|