|
@ -1,48 +0,0 @@
|
1
|
|
package com.ai.ipu.mobile.plugin;
|
2
|
|
|
3
|
|
import org.json.JSONArray;
|
4
|
|
|
5
|
|
import android.content.Intent;
|
6
|
|
import android.os.Bundle;
|
7
|
|
import android.os.Handler;
|
8
|
|
|
9
|
|
import com.ai.ipu.basic.string.EscapeUnescape;
|
10
|
|
import com.ai.ipu.mobile.common.keyboard.KeyboardActivity;
|
11
|
|
import com.ai.ipu.mobile.common.keyboard.KeyboardConstants;
|
12
|
|
import com.ai.ipu.mobile.frame.IIpuMobile;
|
13
|
|
import com.ai.ipu.mobile.frame.plugin.Plugin;
|
14
|
|
|
15
|
|
public class MobileKeyboard extends Plugin {
|
16
|
|
|
17
|
|
private static final int KEYBORAD = 1;
|
18
|
|
String functionName = "";
|
19
|
|
|
20
|
|
public MobileKeyboard(IIpuMobile ipumobile) {
|
21
|
|
super(ipumobile);
|
22
|
|
}
|
23
|
|
|
24
|
|
public void openKeyboard(JSONArray param) throws Exception {
|
25
|
|
functionName = param.getString(0);
|
26
|
|
KeyboardConstants.handler = handler;
|
27
|
|
|
28
|
|
Intent intent = new Intent(context, KeyboardActivity.class);
|
29
|
|
startActivityForResult(intent, KEYBORAD);
|
30
|
|
}
|
31
|
|
|
32
|
|
final Handler handler = new Handler() {
|
33
|
|
public void handleMessage(android.os.Message msg) {
|
34
|
|
super.handleMessage(msg);
|
35
|
|
if (msg.what == KeyboardConstants.KEYBOARD_BTN) { // 更新UI
|
36
|
|
Bundle data = msg.getData();
|
37
|
|
String character = data.getString("character");
|
38
|
|
|
39
|
|
// 转义
|
40
|
|
String callback = "(function(msg){" + functionName
|
41
|
|
+ "(unescape(msg));})";
|
42
|
|
String ret = callback + "('" + EscapeUnescape.escape(character)
|
43
|
|
+ "')";
|
44
|
|
ipumobile.getCurrentWebView().executeJs(ret);
|
45
|
|
}
|
46
|
|
}
|
47
|
|
};
|
48
|
|
}
|